本文整理汇总了Java中org.cpsolver.instructor.model.TeachingRequest类的典型用法代码示例。如果您正苦于以下问题:Java TeachingRequest类的具体用法?Java TeachingRequest怎么用?Java TeachingRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TeachingRequest类属于org.cpsolver.instructor.model包,在下文中一共展示了TeachingRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InstructorSchedulingSuggestions
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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));
}
示例2: getTeachingRequestInfo
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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();
}
}
示例3: getCurrentPreference
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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);
}
示例4: toString
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的package包/类
public String toString(TeachingRequest.Variable request) {
StringBuffer sb = new StringBuffer();
Long assId = getAssignmentId(request);
sb.append(assId == null ? "" : assId);
sb.append("," + request.getCourse().getCourseName());
Section section = request.getSections().get(0);
sb.append("," + section.getSectionName());
sb.append("," + section.getTimeName(true));
sb.append(",\"" + (section.hasRoom() ? section.getRoom() : "") + "\"");
String link = getLink(request);
sb.append("," + (link == null ? "" : link));
Map<String, Integer> levels = new HashMap<String, Integer>();
for (Preference<Attribute> p: request.getRequest().getAttributePreferences())
levels.put(p.getTarget().getAttributeName(), - p.getPreference());
sb.append(",\"" + levels + "\"");
sb.append("," + new DecimalFormat("0.0").format(request.getRequest().getLoad()));
return sb.toString();
}
示例5: toRequestInfo
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的package包/类
protected TeachingRequestInfo toRequestInfo(TeachingRequest request) {
TeachingRequestInfo info = iRequestInfos.get(request);
if (info == null) {
info = iSolver.toRequestInfo(request);
iRequestInfos.put(request, info);
}
return info;
}
示例6: InstructorSchedulingDatabaseLoader
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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();
}
示例7: toHtml
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的package包/类
protected String toHtml(org.unitime.timetable.model.TeachingRequest request) {
String sections = "";
for (TeachingClassRequest tcr: new TreeSet<TeachingClassRequest>(request.getClassRequests())) {
sections += (sections.isEmpty() ? "" : ", ") + (tcr.isAssignInstructor() ? "" : "<i>") + toHtml(tcr.getTeachingClass()) + (tcr.isAssignInstructor() ? "" : "</i>");
}
return "<a href='instructionalOfferingDetail.do?io=" + request.getOffering().getUniqueId() + "&requestId=" + request.getUniqueId() + "&op=view#instructors'>" + request.getOffering().getCourseName() + "</a> " + sections;
}
示例8: loadRequests
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的package包/类
protected void loadRequests(org.hibernate.Session hibSession) throws Exception {
List<org.unitime.timetable.model.TeachingRequest> requests = (List<org.unitime.timetable.model.TeachingRequest>)hibSession.createQuery(
"select r from TeachingRequest r inner join r.offering.courseOfferings co where co.isControl = true and co.subjectArea.department.solverGroup.uniqueId in :solverGroupId")
.setParameterList("solverGroupId", iSolverGroupId).list();
iProgress.setPhase("Loading requests...", requests.size());
for (org.unitime.timetable.model.TeachingRequest request: requests) {
iProgress.incProgress();
if (!request.isCancelled()) loadRequest(hibSession, request);
}
}
示例9: toInstructorInfo
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
示例10: computeBounds
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
示例11: getBounds
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
示例12: getValue
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
示例13: getValue
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
示例14: getValue
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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;
}
}
示例15: getInfo
import org.cpsolver.instructor.model.TeachingRequest; //导入依赖的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) + ")");
}