use of org.cpsolver.exam.model.ExamModel in project cpsolver by UniTime.
the class InstructorDistanceBackToBackConflicts method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
double btbDist = getBackToBackDistance();
if (btbDist < 0)
return 0;
int penalty = 0;
ExamPeriod period = value.getPeriod();
Map<ExamInstructor, Set<Exam>> prev = (period.prev() != null && period.prev().getDay() == period.getDay() ? ((ExamModel) getModel()).getInstructorsOfPeriod(assignment, period.prev()) : null);
Map<ExamInstructor, Set<Exam>> next = (period.next() != null && period.next().getDay() == period.getDay() ? ((ExamModel) getModel()).getInstructorsOfPeriod(assignment, period.next()) : null);
for (ExamInstructor s : exam.getInstructors()) {
if (prev != null) {
Set<Exam> exams = prev.get(s);
if (exams != null)
for (Exam x : exams) {
if (x.equals(exam))
continue;
if (value.getDistanceInMeters(assignment.getValue(x)) > getBackToBackDistance())
penalty++;
}
}
if (next != null) {
Set<Exam> exams = next.get(s);
if (exams != null)
for (Exam x : exams) {
if (x.equals(exam))
continue;
if (value.getDistanceInMeters(assignment.getValue(x)) > getBackToBackDistance())
penalty++;
}
}
}
/*
for (ExamInstructor s : exam.getInstructors()) {
if (period.prev() != null) {
if (period.prev().getDay() == period.getDay()) {
for (Exam x : s.getExams(assignment, period.prev())) {
if (x.equals(exam))
continue;
if (value.getDistanceInMeters(assignment.getValue(x)) > btbDist)
penalty++;
}
}
}
if (period.next() != null) {
if (period.next().getDay() == period.getDay()) {
for (Exam x : s.getExams(assignment, period.next())) {
if (x.equals(exam))
continue;
if (value.getDistanceInMeters(assignment.getValue(x)) > btbDist)
penalty++;
}
}
}
}
*/
return penalty;
}
use of org.cpsolver.exam.model.ExamModel in project cpsolver by UniTime.
the class InstructorMoreThan2ADayConflicts method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
Map<ExamInstructor, Set<Exam>> instructors = ((ExamModel) getModel()).getInstructorsOfDay(assignment, value.getPeriod());
for (ExamInstructor s : exam.getInstructors()) {
Set<Exam> exams = instructors.get(s);
if (exams == null || exams.size() < 2)
continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 2)
penalty++;
}
/*
for (ExamInstructor s : exam.getInstructors()) {
Set<Exam> exams = s.getExamsADay(assignment, value.getPeriod());
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 2)
penalty++;
}
*/
return penalty;
}
use of org.cpsolver.exam.model.ExamModel in project cpsolver by UniTime.
the class InstructorDirectConflicts method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
Map<ExamInstructor, Set<Exam>> instructors = ((ExamModel) getModel()).getInstructorsOfPeriod(assignment, value.getPeriod());
for (ExamInstructor s : exam.getInstructors()) {
Set<Exam> exams = instructors.get(s);
if (exams == null)
continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
/*
for (ExamInstructor s : exam.getInstructors()) {
Set<Exam> exams = s.getExams(assignment, value.getPeriod());
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
*/
return penalty;
}
use of org.cpsolver.exam.model.ExamModel in project cpsolver by UniTime.
the class StudentDirectConflicts method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
ExamPeriod period = value.getPeriod();
Map<ExamStudent, Set<Exam>> students = ((ExamModel) getModel()).getStudentsOfPeriod(assignment, period);
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = students.get(s);
if (exams == null)
continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
/*
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = s.getExams(assignment, period);
if (exams.isEmpty()) continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
*/
return penalty;
}
use of org.cpsolver.exam.model.ExamModel in project cpsolver by UniTime.
the class InstructorBackToBackConflicts method getValue.
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
ExamPeriod period = value.getPeriod();
Map<ExamInstructor, Set<Exam>> prev = (period.prev() != null && (isDayBreakBackToBack() || period.prev().getDay() == period.getDay()) ? ((ExamModel) getModel()).getInstructorsOfPeriod(assignment, period.prev()) : null);
Map<ExamInstructor, Set<Exam>> next = (period.next() != null && (isDayBreakBackToBack() || period.next().getDay() == period.getDay()) ? ((ExamModel) getModel()).getInstructorsOfPeriod(assignment, period.next()) : null);
for (ExamInstructor s : exam.getInstructors()) {
if (prev != null) {
Set<Exam> exams = prev.get(s);
if (exams != null) {
int nrExams = exams.size() + (exams.contains(exam) ? -1 : 0);
penalty += nrExams;
}
}
if (next != null) {
Set<Exam> exams = next.get(s);
if (exams != null) {
int nrExams = exams.size() + (exams.contains(exam) ? -1 : 0);
penalty += nrExams;
}
}
}
/*
for (ExamInstructor s : exam.getInstructors()) {
if (period.prev() != null) {
if (isDayBreakBackToBack() || period.prev().getDay() == period.getDay()) {
Set<Exam> exams = s.getExams(assignment, period.prev());
int nrExams = exams.size() + (exams.contains(exam) ? -1 : 0);
penalty += nrExams;
}
}
if (period.next() != null) {
if (isDayBreakBackToBack() || period.next().getDay() == period.getDay()) {
Set<Exam> exams = s.getExams(assignment, period.next());
int nrExams = exams.size() + (exams.contains(exam) ? -1 : 0);
penalty += nrExams;
}
}
}
*/
return penalty;
}
Aggregations