use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class StudentSwapSectioning method objective.
/**
* Student conflict weight of a solution
*/
protected double objective(Solution<Lecture, Placement> solution) {
List<StudentConflict> criteria = getStudentConflictCriteria();
if (criteria == null) {
double value = 0.0;
for (JenrlConstraint constraint : ((TimetableModel) solution.getModel()).getJenrlConstraints()) {
if (constraint.isInConflict(solution.getAssignment()))
value += constraint.jenrl();
}
return value;
}
double value = 0.0;
for (StudentConflict criterion : criteria) value += criterion.getWeightedValue(solution.getAssignment());
return value;
}
use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class Lecture method removeContstraint.
@Override
public void removeContstraint(Constraint<Lecture, Placement> constraint) {
super.removeContstraint(constraint);
if (constraint instanceof WeakeningConstraint)
iWeakeningConstraints.remove(constraint);
if (constraint instanceof FlexibleConstraint)
iFlexibleGroupConstraints.remove(constraint);
if (constraint instanceof JenrlConstraint) {
JenrlConstraint jenrl = (JenrlConstraint) constraint;
Lecture another = jenrl.another(this);
if (another != null) {
iJenrlConstraints.remove(jenrl);
another.iJenrlConstraints.remove(jenrl);
iJenrlConstraintsHash.remove(another);
another.iJenrlConstraintsHash.remove(this);
}
} else if (constraint instanceof GroupConstraint) {
iCanShareRoomGroupConstraints.remove(constraint);
iHardGroupSoftConstraints.remove(constraint);
iGroupConstraints.remove(constraint);
} else if (constraint instanceof DepartmentSpreadConstraint)
iDeptSpreadConstraint = null;
else if (constraint instanceof SpreadConstraint)
iSpreadConstraints.remove(constraint);
else if (constraint instanceof InstructorConstraint)
iInstructorConstraints.remove(constraint);
else if (constraint instanceof ClassLimitConstraint)
iClassLimitConstraint = null;
}
use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class Lecture method getInitialStudentConflicts.
/**
* Table of student conflicts caused by the initial assignment of this
* lecture in format (another lecture, number)
* @return table of student conflicts with the initial assignment of this class
*/
public Map<Lecture, Long> getInitialStudentConflicts() {
Placement value = getInitialAssignment();
if (value == null)
return null;
Map<Lecture, Long> ret = new HashMap<Lecture, Long>();
for (JenrlConstraint jenrl : jenrlConstraints()) {
Lecture another = jenrl.another(this);
if (another.getInitialAssignment() != null)
if (JenrlConstraint.isInConflict(value, another.getInitialAssignment(), getDistanceMetric(), getStudentWorkDayLimit()))
ret.put(another, jenrl.getJenrl());
}
return ret;
}
use of org.cpsolver.coursett.constraint.JenrlConstraint in project cpsolver by UniTime.
the class Lecture method addContstraint.
@Override
public void addContstraint(Constraint<Lecture, Placement> constraint) {
super.addContstraint(constraint);
if (constraint instanceof WeakeningConstraint)
iWeakeningConstraints.add(constraint);
if (constraint instanceof FlexibleConstraint)
iFlexibleGroupConstraints.add((FlexibleConstraint) constraint);
if (constraint instanceof JenrlConstraint) {
JenrlConstraint jenrl = (JenrlConstraint) constraint;
Lecture another = jenrl.another(this);
if (another != null) {
iJenrlConstraints.add(jenrl);
another.iJenrlConstraints.add(jenrl);
iJenrlConstraintsHash.put(another, (JenrlConstraint) constraint);
another.iJenrlConstraintsHash.put(this, (JenrlConstraint) constraint);
}
} else if (constraint instanceof DepartmentSpreadConstraint)
iDeptSpreadConstraint = (DepartmentSpreadConstraint) constraint;
else if (constraint instanceof SpreadConstraint)
iSpreadConstraints.add((SpreadConstraint) constraint);
else if (constraint instanceof InstructorConstraint) {
InstructorConstraint ic = (InstructorConstraint) constraint;
if (ic.getResourceId() != null && ic.getResourceId().longValue() > 0)
iInstructorConstraints.add(ic);
} else if (constraint instanceof ClassLimitConstraint)
iClassLimitConstraint = (ClassLimitConstraint) constraint;
else if (constraint instanceof GroupConstraint) {
GroupConstraint gc = (GroupConstraint) constraint;
if (gc.canShareRoom()) {
iCanShareRoomGroupConstraints.add((GroupConstraint) constraint);
} else {
iGroupConstraints.add((GroupConstraint) constraint);
if (Constants.sPreferenceProhibited.equals(Constants.preferenceLevel2preference(gc.getPreference())) || Constants.sPreferenceRequired.equals(Constants.preferenceLevel2preference(gc.getPreference())))
iHardGroupSoftConstraints.add((GroupConstraint) constraint);
}
}
}
Aggregations