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


Java TeachingAssignment类代码示例

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


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

示例1: InstructorSchedulingSuggestions

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
public InstructorSchedulingSuggestions(InstructorSchedulingSolver solver) {
	iSolver = solver;
	iModel = (InstructorSchedulingModel)solver.currentSolution().getModel();
	iAssignment = solver.currentSolution().getAssignment();
	for (TeachingRequest.Variable variable: iModel.variables()) {
		TeachingAssignment value = iAssignment.getValue(variable);
		if (value == null) {
			iInitialUnassignments.add(variable);
		} else {
			iInitialAssignments.put(variable, value);
		}
	}
	iValue = iModel.getTotalValue(iAssignment);
	for (Criterion<TeachingRequest.Variable, TeachingAssignment> c: iModel.getCriteria())
		iValues.put(c.getName(), c.getValue(iAssignment));
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:InstructorSchedulingSuggestions.java

示例2: getTeachingRequestInfo

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public TeachingRequestInfo getTeachingRequestInfo(Long requestId) {
       Lock lock = currentSolution().getLock().readLock();
       lock.lock();
       try {
       	for (TeachingRequest request: getModel().getRequests()) {
       		if (request.getRequestId() == requestId) {
       			TeachingRequestInfo info = toRequestInfo(request);
               	for (TeachingRequest.Variable var: request.getVariables()) {
               		TeachingAssignment placement = currentSolution().getAssignment().getValue(var);
               		if (placement != null)
               			info.addInstructor(toInstructorInfo(placement));
               	}
           		return info;
           	}
           }
           return null;
       } finally {
       	lock.unlock();
       }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:InstructorSchedulingSolver.java

示例3: getCurrentPreference

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
/**
 * Current constraint preference (if soft)
 * @param assignment current assignment
 * @param value proposed change
 * @return change in the current preference value of this constraint
 */
public int getCurrentPreference(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, TeachingAssignment value) {
    if (isHard()) return 0; // no preference
    if (countAssignedVariables(assignment) + (assignment.getValue(value.variable()) == null ? 1 : 0) < 2) return 0; // not enough variables
    int nrViolatedPairsAfter = 0;
    int nrViolatedPairsBefore = 0;
    for (TeachingRequest.Variable v1 : variables()) {
        for (TeachingRequest.Variable v2 : variables()) {
            if (v1.getId() >= v2.getId()) continue;
            TeachingAssignment p1 = (v1.equals(value.variable()) ? null : assignment.getValue(v1));
            TeachingAssignment p2 = (v2.equals(value.variable()) ? null : assignment.getValue(v2));
            if (p1 != null && p2 != null && !isSatisfiedPair(assignment, p1, p2))
                nrViolatedPairsBefore ++;
            if (v1.equals(value.variable())) p1 = value;
            if (v2.equals(value.variable())) p2 = value;
            if (p1 != null && p2 != null && !isSatisfiedPair(assignment, p1, p2))
                nrViolatedPairsAfter ++;
        }
    }
    return (nrViolatedPairsAfter > 0 ? Math.abs(iPreference) * nrViolatedPairsAfter : 0) - (nrViolatedPairsBefore > 0 ? Math.abs(iPreference) * nrViolatedPairsBefore : 0);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:27,代码来源:SameInstructorConstraint.java

示例4: InstructorSchedulingDatabaseLoader

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
public InstructorSchedulingDatabaseLoader(InstructorSchedulingModel model, Assignment<TeachingRequest.Variable, TeachingAssignment> assignment) {
	super(model, assignment);
	iProgress = Progress.getInstance(model);
	iSessionId = model.getProperties().getPropertyLong("General.SessionId", (Long)null);
	for (Long id: model.getProperties().getPropertyLongArry("General.SolverGroupId", null))
		iSolverGroupId.add(id);
	iInstructorFormat = getModel().getProperties().getProperty("General.InstructorFormat", NameFormat.LAST_FIRST.reference());
	iDefaultSameCourse = getModel().getProperties().getProperty("Defaults.SameCourse", "R");
	iDefaultSameCommon = getModel().getProperties().getProperty("Defaults.SameCommon", "R");
	iShowClassSuffix = ApplicationProperty.SolverShowClassSufix.isTrue();
	iShowConfigName = ApplicationProperty.SolverShowConfiguratioName.isTrue();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:InstructorSchedulingDatabaseLoader.java

示例5: toInstructorInfo

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
protected InstructorInfo toInstructorInfo(TeachingAssignment assignment) {
	InstructorInfo info = toInstructorInfo(assignment.getInstructor());
	info.setAssignmentIndex(assignment.variable().getInstructorIndex());
	Instructor.Context context = assignment.getInstructor().getContext(currentSolution().getAssignment());
	if (context != null)
		info.setAssignedLoad(context.getLoad());
	for (Criterion<TeachingRequest.Variable, TeachingAssignment> c: assignment.variable().getModel().getCriteria()) {
		double value = c.getValue(currentSolution().getAssignment(), assignment, null);
		if (value != 0) info.setValue(c.getName(), value);
	}
	return info;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:InstructorSchedulingSolver.java

示例6: computeBounds

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
protected double[] computeBounds(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment) {
    double[] bounds = new double[] { 0.0, 0.0 };
    for (Instructor instructor: ((InstructorSchedulingModel)getModel()).getInstructors()) {
        bounds[1] += Math.abs(instructor.getBackToBackPreference());
    }
    return bounds;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:BackToBack.java

示例7: getBounds

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public double[] getBounds(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Collection<TeachingRequest.Variable> variables) {
    double[] bounds = new double[] { 0.0, 0.0 };
    for (Instructor instructor: getInstructors(assignment, variables)) {
        bounds[1] += Math.abs(instructor.getBackToBackPreference());
    }
    return bounds;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:BackToBack.java

示例8: getValue

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public double getValue(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Collection<TeachingRequest.Variable> variables) {
    double value = 0.0;
    for (Instructor instructor: getAssignedInstructors(assignment, variables))
        value += instructor.getContext(assignment).countBackToBackPreference(iDiffRoomWeight, iDiffTypeWeight);
    return value;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:8,代码来源:BackToBack.java

示例9: getValue

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public double getValue(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Collection<TeachingRequest.Variable> variables) {
    double value = 0.0;
    for (Instructor instructor: getAssignedInstructors(assignment, variables)) {
        value += instructor.getContext(assignment).countTimeOverlaps();
    }
    return value;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:TimeOverlaps.java

示例10: getValue

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public double getValue(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, TeachingAssignment value, Set<TeachingAssignment> conflicts) {
    if (iMPP && value.variable().getInitialAssignment() != null) {
        return (value.getInstructor().equals(value.variable().getInitialAssignment().getInstructor()) ? 0.0 : 1.0);
    } else {
        return 0.0;
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:OriginalInstructor.java

示例11: getInfo

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public void getInfo(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Map<String, String> info) {
    double val = getValue(assignment);
    double[] bounds = getBounds(assignment);
    if (bounds[0] <= val && val <= bounds[1] && bounds[0] < bounds[1])
        info.put(getName(), getPerc(val, bounds[0], bounds[1]) + "% (" + sDoubleFormat.format(bounds[1] - val) + ")");
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:8,代码来源:OriginalInstructor.java

示例12: getInfo

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public void getInfo(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Map<String, String> info) {
    double val = getValue(assignment);
    double[] bounds = getBounds(assignment);
    if (bounds[0] <= val && val <= bounds[1] && bounds[0] < bounds[1])
        info.put(getName(), getPerc(val, bounds[0], bounds[1]) + "% (" + sDoubleFormat.format(val) + ")");
    else if (bounds[1] <= val && val <= bounds[0] && bounds[1] < bounds[0])
        info.put(getName(), getPercRev(val, bounds[1], bounds[0]) + "% (" + sDoubleFormat.format(val) + ")");
    else if (bounds[0] != val || val != bounds[1])
        info.put(getName(), sDoubleFormat.format(val));
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:12,代码来源:InstructorSchedulingCriterion.java

示例13: getInstructors

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
/**
 * Instructor of a sub-problem
 * @param assignment current instructors
 * @param variables sub-problem
 * @return instructors that can be used by the given teaching requests
 */
public Set<Instructor> getInstructors(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Collection<TeachingRequest.Variable> variables) {
    Set<Instructor> instructors = new HashSet<Instructor>();
    for (TeachingRequest.Variable req: variables)
        for (TeachingAssignment ta: req.values(assignment))
            instructors.add(ta.getInstructor());
    return instructors;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:InstructorSchedulingCriterion.java

示例14: getAssignedInstructors

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
/**
 * Assigned instructors of a sub-problem
 * @param assignment current instructors
 * @param variables sub-problem
 * @return instructors that can be used by the given teaching requests
 */
public Set<Instructor> getAssignedInstructors(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, Collection<TeachingRequest.Variable> variables) {
    Set<Instructor> instructors = new HashSet<Instructor>();
    for (TeachingRequest.Variable req: variables) {
        TeachingAssignment ta = assignment.getValue(req);
        if (ta != null)
            instructors.add(ta.getInstructor());
    }
    return instructors;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:16,代码来源:InstructorSchedulingCriterion.java

示例15: getValue

import org.cpsolver.instructor.model.TeachingAssignment; //导入依赖的package包/类
@Override
public double getValue(Assignment<TeachingRequest.Variable, TeachingAssignment> assignment, TeachingAssignment value, Set<TeachingAssignment> conflicts) {
    Instructor.Context context = value.getInstructor().getContext(assignment);
    double penalty = 0.0;
    int pairs = 0;
    for (TeachingAssignment ta : context.getAssignments()) {
        if (ta.variable().equals(value.variable()))
            continue;
        penalty += value.variable().getRequest().getSameCoursePenalty(ta.variable().getRequest());
        pairs ++;
    }
    return (pairs == 0 ? 0.0 : penalty / pairs);
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:SameCourse.java


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