Example #1
0
 public double penalty(
     Assignment<CurVariable, CurValue> assignment, CurStudent newStudent, CurStudent oldStudent) {
   if (oldStudent != null && oldStudent.equals(newStudent))
     return penalty(assignment, newStudent, null);
   double penalty = 0;
   for (CurCourse course : iModel.getCourses()) {
     if (course.getCourseId().equals(getCourseId())) continue;
     double target = getTargetShare(course.getCourseId());
     double share = share(assignment, course);
     double oldPenalty = Math.abs(share - target);
     if (newStudent != null && course.getStudents(assignment).contains(newStudent))
       share += newStudent.getWeight();
     if (oldStudent != null && course.getStudents(assignment).contains(oldStudent))
       share -= oldStudent.getWeight();
     double newPenalty = Math.abs(share - target);
     penalty += (newPenalty - oldPenalty) * (target == 0.0 ? 10.0 : 1.0);
   }
   return penalty;
 }
Example #2
0
 public double penalty(Assignment<CurVariable, CurValue> assignment, CurCourse course) {
   double target = getTargetShare(course.getCourseId());
   return Math.abs(share(assignment, course) - target) * (target == 0.0 ? 10.0 : 1.0);
 }
Example #3
0
 public double share(Assignment<CurVariable, CurValue> assignment, CurCourse course) {
   double share = 0;
   for (CurStudent s : getContext(assignment).getStudents())
     if (course.getStudents(assignment).contains(s)) share += s.getWeight();
   return share;
 }