Skip to content

Commit

Permalink
Student Scheduling: IFS
Browse files Browse the repository at this point in the history
- added an ability to completely disable conflicting placements (no unassignments are allowed)
- added an ability to disable conflicting placements at some point during the search (e.g., two hours before solver's timeout)
- added an ability to disable this neighbourhood at some point during the search (e.g., no IFS if less than an hour before solver's timeout)

-> this is to allow the solver some time at the end of the search to optimize the solution without making steps that are hard to undo or resolve
  • Loading branch information
tomas-muller committed Nov 20, 2020
1 parent 061b087 commit 77a46cc
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class StandardSelection implements NeighbourSelection<Request, Enrollment
protected VariableSelection<Request, Enrollment> iVariableSelection = null;
protected long iNrIterations = -1;
protected boolean iPreferPriorityStudents = true;
protected long iConflictTimeOut = -7200;
protected long iTimeOut = -3600;
protected boolean iCanConflict = true;

/**
* Constructor (variable and value selection are expected to be already
Expand All @@ -84,6 +87,13 @@ public StandardSelection(DataProperties properties, VariableSelection<Request, E
iVariableSelection = variableSelection;
iValueSelection = valueSelection;
iPreferPriorityStudents = properties.getPropertyBoolean("Sectioning.PriorityStudentsFirstSelection.AllIn", true);
iTimeOut = properties.getPropertyLong("Neighbour.StandardTimeOut", -3600);
if (iTimeOut < 0)
iTimeOut = Math.max(0, properties.getPropertyLong("Termination.TimeOut", -1l) + iTimeOut);
iConflictTimeOut = properties.getPropertyLong("Neighbour.StandardConflictTimeOut", -7200);
if (iConflictTimeOut < 0)
iConflictTimeOut = Math.max(0, properties.getPropertyLong("Termination.TimeOut", -1l) + iConflictTimeOut);
iCanConflict = properties.getPropertyBoolean("Neighbour.StandardCanConflict", true);
}

/** Initialization */
Expand All @@ -102,7 +112,13 @@ protected void init(Solver<Request, Enrollment> solver, String name) {
iNrIterations = solver.getProperties().getPropertyLong("Neighbour.StandardIterations", -1);
if (iNrIterations < 0)
iNrIterations = solver.currentSolution().getModel().nrUnassignedVariables(solver.currentSolution().getAssignment());
Progress.getInstance(solver.currentSolution().getModel()).setPhase(name, iNrIterations);
if (iTimeOut > 0 && solver.currentSolution().getTime() > iTimeOut)
iNrIterations = 0;
iCanConflict = solver.getProperties().getPropertyBoolean("Neighbour.StandardCanConflict", true);
if (iCanConflict && iConflictTimeOut > 0 && solver.currentSolution().getTime() > iConflictTimeOut)
iCanConflict = false;
if (iNrIterations > 0)
Progress.getInstance(solver.currentSolution().getModel()).setPhase((iCanConflict ? name : "No-conf " + name), iNrIterations);
}

/**
Expand All @@ -111,6 +127,7 @@ protected void init(Solver<Request, Enrollment> solver, String name) {
* @return if running MPP, do not unassign initial enrollments
*/
public boolean canUnassign(Enrollment enrollment, Enrollment conflict, Assignment<Request, Enrollment> assignment) {
if (!iCanConflict) return false;
if (conflict.getRequest().isMPP() && conflict.equals(conflict.getRequest().getInitialAssignment())) return false;
if (conflict.getRequest().getStudent().hasMinCredit()) {
float credit = conflict.getRequest().getStudent().getAssignedCredit(assignment) - conflict.getCredit();
Expand Down

0 comments on commit 77a46cc

Please sign in to comment.