本文整理汇总了Java中org.cpsolver.ifs.criteria.Criterion类的典型用法代码示例。如果您正苦于以下问题:Java Criterion类的具体用法?Java Criterion怎么用?Java Criterion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Criterion类属于org.cpsolver.ifs.criteria包,在下文中一共展示了Criterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InstructorSchedulingSuggestions
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的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: incJenrl
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
* Increment the number of joined enrollments (during student final
* sectioning)
* @param assignment current assignment
* @param student student added in between the two classes of this constraint
*/
public void incJenrl(Assignment<Lecture, Placement> assignment, Student student) {
JenrlConstraintContext context = getContext(assignment);
boolean hard = context.isOverLimit();
double jenrlWeight = student.getJenrlWeight(first(), second());
iJenrl += jenrlWeight;
Double conflictPriority = student.getConflictingPriorty(first(), second());
if (conflictPriority != null) iPriority += conflictPriority * jenrlWeight;
iStudents.add(student);
if (student.getInstructor() != null && (student.getInstructor().variables().contains(first()) ||
student.getInstructor().variables().contains(second())))
iInstructors.add(student);
for (Criterion<Lecture, Placement> criterion: getModel().getCriteria())
if (criterion instanceof StudentConflict)
((StudentConflict)criterion).incJenrl(assignment, this, jenrlWeight, conflictPriority, student);
if (!hard && context.isOverLimit() && isInConflict(assignment)) {
context.incLimit(jenrlWeight);
}
}
示例3: decJenrl
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
* Decrement the number of joined enrollments (during student final
* sectioning)
* @param assignment current assignment
* @param student student removed from between the two classes of this constraint
*/
public void decJenrl(Assignment<Lecture, Placement> assignment, Student student) {
JenrlConstraintContext context = getContext(assignment);
boolean hard = context.isOverLimit();
double jenrlWeight = student.getJenrlWeight(first(), second());
iJenrl -= jenrlWeight;
Double conflictPriority = student.getConflictingPriorty(first(), second());
if (conflictPriority != null) iPriority -= conflictPriority * jenrlWeight;
iStudents.remove(student);
iInstructors.remove(student);
for (Criterion<Lecture, Placement> criterion: getModel().getCriteria())
if (criterion instanceof StudentConflict)
((StudentConflict)criterion).incJenrl(assignment, this, -jenrlWeight, conflictPriority, student);
if (hard && !context.isOverLimit())
context.decLimit(jenrlWeight);
}
示例4: toString
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
* String representation -- returns a list of values of objective criteria
* @param assignment current assignment
* @return comma separated string of {@link TimetablingCriterion#toString(Assignment)}
*/
public String toString(Assignment<V, T> assignment) {
List<Criterion<V, T>> criteria = new ArrayList<Criterion<V,T>>(getCriteria());
Collections.sort(criteria, new Comparator<Criterion<V, T>>() {
@Override
public int compare(Criterion<V, T> c1, Criterion<V, T> c2) {
int cmp = -Double.compare(c1.getWeight(), c2.getWeight());
if (cmp != 0) return cmp;
return c1.getName().compareTo(c2.getName());
}
});
String ret = "";
for (Criterion<V, T> criterion: criteria) {
String val = criterion.toString(assignment);
if (val != null && !val.isEmpty())
ret += ", " + val;
}
return (nrUnassignedVariables(assignment) == 0 ? "" : "V:" + nrAssignedVariables(assignment) + "/" + variables().size() + ", ") + "T:" + sDoubleFormat.format(getTotalValue(assignment)) + ret;
}
示例5: toInstructorInfo
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的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;
}
示例6: updateCriterion
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
* Update value of FlexibleConstraintCriterion and number of violated FlexibleConstraints
*/
protected void updateCriterion(Assignment<Lecture, Placement> assignment) {
if (!isHard()) {
Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
if (criterion != null) {
criterion.inc(assignment, -iLastPreference);
iLastPreference = getCurrentPreference(assignment, null, null);
criterion.inc(assignment, iLastPreference);
}
}
}
示例7: MaxHalfDaysFlexibleConstraintContext
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxHalfDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
super();
iHalfDayAssignments = new Set[getNrHalfDays() * Constants.NR_DAYS];
for (int i = 0; i < iHalfDayAssignments.length; i++)
iHalfDayAssignments[i] = new HashSet<Lecture>();
for (Lecture variable: variables()) {
Placement value = assignment.getValue(variable);
if (value != null) {
for (int i = 0; i < Constants.DAY_CODES.length; i++)
if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
iHalfDayAssignments[i * getNrHalfDays() + getHalfDay(value.getTimeLocation())].add(value.variable());
}
}
if (!isHard()) {
Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
if (criterion != null) {
double pref = nrViolations(null, null);
if (pref == 0)
iLastPreference = -Math.abs(iPreference);
else
iLastPreference = Math.abs(iPreference) * pref;
criterion.inc(assignment, iLastPreference);
}
}
}
示例8: MaxDaysFlexibleConstraintContext
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxDaysFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
super();
iDayAssignments = new Set[Constants.NR_DAYS];
for (int i = 0; i < iDayAssignments.length; i++)
iDayAssignments[i] = new HashSet<Lecture>();
for (Lecture variable: variables()) {
Placement value = assignment.getValue(variable);
if (value != null) {
for (int i = 0; i < iDayAssignments.length; i++)
if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0)
iDayAssignments[i].add(value.variable());
}
}
if (!isHard()) {
Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
if (criterion != null) {
double pref = nrViolations(null, null);
if (pref == 0)
iLastPreference = -Math.abs(iPreference);
else
iLastPreference = Math.abs(iPreference) * pref;
criterion.inc(assignment, iLastPreference);
}
}
}
示例9: MaxWeeksFlexibleConstraintContext
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public MaxWeeksFlexibleConstraintContext(Assignment<Lecture, Placement> assignment) {
super();
iWeeks = ((TimetableModel)getModel()).getWeeks();
iWeekAssignments = new Set[iWeeks.size()];
for (int i = 0; i < iWeekAssignments.length; i++)
iWeekAssignments[i] = new HashSet<Lecture>();
for (Lecture variable: variables()) {
Placement value = assignment.getValue(variable);
if (value != null && isCorectDayOfWeek(value)) {
for (int i = 0; i < iWeeks.size(); i++)
if (value.getTimeLocation().shareWeeks(iWeeks.get(i)))
iWeekAssignments[i].add(value.variable());
}
}
if (!isHard()) {
Criterion<Lecture, Placement> criterion = getModel().getCriterion(FlexibleConstraintCriterion.class);
if (criterion != null) {
double pref = nrViolations(null, null);
if (pref == 0)
iLastPreference = -Math.abs(iPreference);
else
iLastPreference = Math.abs(iPreference) * pref;
criterion.inc(assignment, iLastPreference);
}
}
}
示例10: getInfo
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
super.getInfo(assignment, info);
double conf = getValue(assignment);
if (conf > 0.0) {
Criterion<Lecture, Placement> c = getModel().getCriterion(InstructorStudentHardConflict.class);
double hard = (c == null ? 0.0 : c.getValue(assignment));
info.put("Instructor student conflicts", sDoubleFormat.format(conf) + (hard > 0.0 ? " [hard: " + sDoubleFormat.format(hard) + "]" : ""));
}
}
示例11: getInfo
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
super.getInfo(assignment, info);
double conf = getValue(assignment);
if (conf > 0.0) {
Criterion<Lecture, Placement> c = getModel().getCriterion(ImportantStudentHardConflict.class);
double hard = (c == null ? 0.0 : c.getValue(assignment));
info.put("Important student conflicts", sDoubleFormat.format(conf) + (hard > 0.0 ? " [hard: " + sDoubleFormat.format(hard) + "]" : ""));
}
}
示例12: getInfo
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public void getInfo(Assignment<Lecture, Placement> assignment, Map<String, String> info) {
super.getInfo(assignment, info);
double conf = getValue(assignment);
if (conf > 0.0) {
Criterion<Lecture, Placement> c = getModel().getCriterion(IgnoredCommittedStudentConflict.class);
double committed = (c == null ? 0.0 : c.getValue(assignment));
info.put("Ignored student conflicts", sDoubleFormat.format(conf) + (committed > 0.0 ? " [committed: " + sDoubleFormat.format(committed) + "]" : ""));
}
}
示例13: getTotalValue
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public double getTotalValue(Assignment<Lecture, Placement> assignment) {
double ret = 0;
for (Criterion<Lecture, Placement> criterion: getCriteria())
ret += criterion.getWeightedValue(assignment);
return ret;
}
示例14: toDouble
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
@Override
public double toDouble(Assignment<Lecture, Placement> assignment) {
double ret = 0.0;
for (Criterion<Lecture, Placement> criterion: variable().getModel().getCriteria())
ret += criterion.getWeightedValue(assignment, this, null);
return ret;
}
示例15: currentValue
import org.cpsolver.ifs.criteria.Criterion; //导入依赖的package包/类
/**
* Use {@link Model#getTotalValue()} instead.
* @param currentSolution current solution
* @return current value
*/
@Deprecated
public double currentValue(Solution<Lecture, Placement> currentSolution) {
double ret = 0.0;
for (Criterion<Lecture, Placement> criterion: currentSolution.getModel().getCriteria())
ret += criterion.getWeightedValue();
return ret;
}