当前位置: 首页>>代码示例>>Java>>正文


Java StudentSectioningModel类代码示例

本文整理汇总了Java中org.cpsolver.studentsct.StudentSectioningModel的典型用法代码示例。如果您正苦于以下问题:Java StudentSectioningModel类的具体用法?Java StudentSectioningModel怎么用?Java StudentSectioningModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StudentSectioningModel类属于org.cpsolver.studentsct包,在下文中一共展示了StudentSectioningModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstructedOfferings

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public Collection<Long> getInstructedOfferings(String instructorExternalId) {
	List<Long> ret = new ArrayList<Long>();
	Set<Long> sections = new HashSet<Long>();
	for (Student student: ((StudentSectioningModel)currentSolution().getModel()).getStudents())
		if (instructorExternalId.equals(student.getExternalId()))
			for (Unavailability unavailability: student.getUnavailabilities())
				sections.add(unavailability.getId());
	offerings: for (Offering offering: ((StudentSectioningModel)currentSolution().getModel()).getOfferings()) {
		for (Config config: offering.getConfigs())
			for (Subpart subpart: config.getSubparts())
				for (Section section: subpart.getSections())
					if (sections.contains(section.getId())) {
						ret.add(offering.getId()); continue offerings;
					} else if (section.hasInstructors())
						for (Instructor instructor: section.getInstructors())
							if (instructorExternalId.equals(instructor.getExternalId())) {
								ret.add(offering.getId()); continue offerings;
							}
	}
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:23,代码来源:StudentSolver.java

示例2: assigned

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
/**
 * Called when a value is assigned to a variable. Internal number of
 * distance conflicts is updated, see
 * {@link DistanceConflict#getTotalNrConflicts(Assignment)}.
 */
@Override
public void assigned(Assignment<Request, Enrollment> assignment, Enrollment value) {
    StudentSectioningModelContext cx = ((StudentSectioningModel)getModel()).getContext(assignment);
    for (Conflict c: allConflicts(assignment, value)) {
        if (iAllConflicts.add(c))
            cx.add(assignment, c);
    }
    if (sDebug) {
        sLog.debug("A:" + value.variable() + " := " + value);
        int inc = nrConflicts(value);
        if (inc != 0) {
            sLog.debug("-- DC+" + inc + " A: " + value.variable() + " := " + value);
            for (Iterator<Conflict> i = allConflicts(assignment, value).iterator(); i.hasNext();)
                sLog.debug("  -- " + i.next());
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:23,代码来源:DistanceConflict.java

示例3: unassigned

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
/**
 * Called when a value is unassigned from a variable. Internal number of
 * distance conflicts is updated, see
 * {@link DistanceConflict#getTotalNrConflicts(Assignment)}.
 */
@Override
public void unassigned(Assignment<Request, Enrollment> assignment, Enrollment value) {
    if (value.variable().equals(iOldVariable))
        return;
    StudentSectioningModelContext cx = ((StudentSectioningModel)getModel()).getContext(assignment);
    for (Conflict c: allConflicts(assignment, value)) {
        if (iAllConflicts.remove(c))
            cx.remove(assignment, c);
    }
    if (sDebug) {
        sLog.debug("U:" + value.variable() + " := " + value);
        int dec = nrAllConflicts(assignment, value);
        if (dec != 0) {
            sLog.debug("-- DC+" + dec + " U: " + value.variable() + " := " + value);
            Set<Conflict> confs = allConflicts(assignment, value);
            for (Iterator<Conflict> i = confs.iterator(); i.hasNext();)
                sLog.debug("  -- " + i.next());
        }
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:26,代码来源:DistanceConflict.java

示例4: getBound

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
/**
 * Estimated bound for this request -- it estimates the smallest value among
 * all possible enrollments
 */
@Override
public double getBound() {
    return - getWeight() * ((StudentSectioningModel)getModel()).getStudentWeights().getBound(this);
    /*
    if (iCachedBound == null) {
        iCachedBound = new Double(-Math.pow(Enrollment.sPriorityWeight, getPriority())
                * (isAlternative() ? Enrollment.sAlterativeWeight : 1.0)
                * Math.pow(Enrollment.sInitialWeight, (getInitialAssignment() == null ? 0 : 1))
                * Math.pow(Enrollment.sSelectedWeight, (iSelectedChoices.isEmpty() ? 0 : 1))
                * Math.pow(Enrollment.sWaitlistedWeight, (iWaitlistedChoices.isEmpty() ? 0 : 1))
                *
                // Math.max(Enrollment.sMinWeight,getWeight()) *
                (getStudent().isDummy() ? Student.sDummyStudentWeight : 1.0)
                * Enrollment.normalizePenalty(getMinPenalty()));
    }
    return iCachedBound.doubleValue();
    */
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:23,代码来源:CourseRequest.java

示例5: getRoulette

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
/** Populate roulette wheel selection, if null or empty. 
 * @param solution current solution
 * @return selection
 **/
protected RouletteWheelSelection<Request> getRoulette(Solution<Request, Enrollment> solution) {
    if (iRoulette != null && iRoulette.hasMoreElements()) {
        if (iRoulette.getUsedPoints() < 0.1 * iRoulette.getTotalPoints())
            return iRoulette;
    }
    iRoulette = new RouletteWheelSelection<Request>();
    for (Request request : ((StudentSectioningModel) solution.getModel()).variables()) {
        double points = 0;
        if (solution.getAssignment().getValue(request) == null)
            points += 10;
        else {
            Enrollment enrollment = solution.getAssignment().getValue(request);
            if (enrollment.toDouble(solution.getAssignment()) > request.getBound())
                points += 1;
        }
        if (points > 0)
            iRoulette.add(request, points);
    }
    return iRoulette;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:25,代码来源:RouletteWheelRequestSelection.java

示例6: isAllowed

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
/** true, if it is allowed to assign given value 
 * @param assignment current assignment
 * @param value given value
 * @param conflicts conflicting assignments
 * @return true if it is allowed
 **/
public boolean isAllowed(Assignment<Request, Enrollment> assignment, Enrollment value, Set<Enrollment> conflicts) {
    if (value == null)
        return true;
    StudentSectioningModel model = (StudentSectioningModel) value.variable().getModel();
    if (model.getNrLastLikeRequests(false) == 0 || model.getNrRealRequests(false) == 0)
        return true;
    Request request = value.variable();
    if (request.getStudent().isDummy()) {
        if (conflicts == null)
            conflicts = value.variable().getModel().conflictValues(assignment, value);
        for (Enrollment conflict : conflicts) {
            if (!conflict.getRequest().getStudent().isDummy())
                return false;
        }
    } else {
        if (conflicts == null)
            conflicts = value.variable().getModel().conflictValues(assignment, value);
        if (conflicts.size() > (assignment.getValue(request) == null ? 1 : 0))
            return false;
    }
    return true;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:29,代码来源:EnrollmentSelection.java

示例7: getCourse

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
protected Course getCourse(StudentSectioningModel model, Long courseId, String courseName){
	for (Offering offering: model.getOfferings())
		for (Course course: offering.getCourses()) {
			if (courseId != null) {
				if (courseId.equals(course.getId())) return course;
			} else {
				if (course.getName().equalsIgnoreCase(courseName)) return course;
			}
		}
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:12,代码来源:BatchEnrollStudent.java

示例8: restureCurrentSolutionFromBackup

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
protected void restureCurrentSolutionFromBackup(Document document) {
       getProperties().setProperty("Xml.LoadBest", "true");
       getProperties().setProperty("Xml.LoadInitial", "true");
       getProperties().setProperty("Xml.LoadCurrent", "true");

       new StudentSectioningXMLLoader((StudentSectioningModel)currentSolution().getModel(), currentSolution().getAssignment()).load(document);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:9,代码来源:StudentSolver.java

示例9: findStudents

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public Collection<XStudentId> findStudents(StudentMatcher matcher) {
	if (matcher != null) matcher.setServer(this);
	List<XStudentId> ret = new ArrayList<XStudentId>();
	for (Student student: ((StudentSectioningModel)currentSolution().getModel()).getStudents()) {
		if (student.isDummy()) continue;
		XStudentId s = new XStudentId(student);
		if (!student.isDummy() && matcher.match(s))
			ret.add(s);
	}
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:StudentSolver.java

示例10: getCourse

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public XCourse getCourse(String courseName) {
	for (Offering offering: ((StudentSectioningModel)currentSolution().getModel()).getOfferings())
		for (Course course: offering.getCourses())
			if (course.getName().equalsIgnoreCase(courseName)) return getCourse(course.getId());
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:StudentSolver.java

示例11: getStudent

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public XStudent getStudent(Long studentId) {
	for (Student student: ((StudentSectioningModel)currentSolution().getModel()).getStudents())
		if (!student.isDummy() && student.getId() == studentId)
			return new XStudent(student, currentSolution().getAssignment());
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:StudentSolver.java

示例12: getOffering

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public XOffering getOffering(Long offeringId) {
	for (Offering offering: ((StudentSectioningModel)currentSolution().getModel()).getOfferings())
		if (offering.getId() == offeringId)
			return new XOffering(offering, ((StudentSectioningModel)currentSolution().getModel()).getLinkedSections());
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:StudentSolver.java

示例13: getRequests

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public Collection<XCourseRequest> getRequests(Long offeringId) {
	List<XCourseRequest> ret = new ArrayList<XCourseRequest>();
	for (Offering offering: ((StudentSectioningModel)currentSolution().getModel()).getOfferings())
		if (offering.getId() == offeringId) {
			for (Course course: offering.getCourses())
				for (CourseRequest req: course.getRequests()) {
					if (!req.getStudent().isDummy())
						ret.add(new XCourseRequest(req, currentSolution().getAssignment().getValue(req)));
				}
			break;
		}
	return ret;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:StudentSolver.java

示例14: getExpectations

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
@Override
public XExpectations getExpectations(Long offeringId) {
	for (Offering offering: ((StudentSectioningModel)currentSolution().getModel()).getOfferings())
		if (offering.getId() == offeringId)
			return new XExpectations(offering);
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:8,代码来源:StudentSolver.java

示例15: BatchStudentSectioningLoader

import org.cpsolver.studentsct.StudentSectioningModel; //导入依赖的package包/类
public BatchStudentSectioningLoader(StudentSectioningModel model, org.cpsolver.ifs.assignment.Assignment<Request, Enrollment> assignment) {
    super(model, assignment);
    iIncludeCourseDemands = model.getProperties().getPropertyBoolean("Load.IncludeCourseDemands", iIncludeCourseDemands);
    iIncludeLastLikeStudents = model.getProperties().getPropertyBoolean("Load.IncludeLastLikeStudents", iIncludeLastLikeStudents);
    iIncludeUseCommittedAssignments = model.getProperties().getPropertyBoolean("Load.IncludeUseCommittedAssignments", iIncludeUseCommittedAssignments);
    iLoadStudentInfo = model.getProperties().getPropertyBoolean("Load.LoadStudentInfo", iLoadStudentInfo);
    iMakeupAssignmentsFromRequiredPrefs = model.getProperties().getPropertyBoolean("Load.MakeupAssignmentsFromRequiredPrefs", iMakeupAssignmentsFromRequiredPrefs);
    iInitiative = model.getProperties().getProperty("Data.Initiative");
    iYear = model.getProperties().getProperty("Data.Year");
    iTerm = model.getProperties().getProperty("Data.Term");
    iInstructorNameFormat = NameFormat.fromReference(ApplicationProperty.OnlineSchedulingInstructorNameFormat.value());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:BatchStudentSectioningLoader.java


注:本文中的org.cpsolver.studentsct.StudentSectioningModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。