Skip to content

Commit

Permalink
Batch Student Scheduling: Standard Selection (IFS)
Browse files Browse the repository at this point in the history
- do not penalize unassignments by default
- added an additional parameter to disable/enable the ability to accept worsening moves for critical course requests
  Neighbour.CriticalStandardCanWorsen, defaults to false
- disabled timeout for switching of IFS (Neighbour.StandardTimeOut=0)
- updated default timeout for not allowing conflicts to last 10% of the seach (Neighbour.StandardConflictTimeOut parameter)
  - conflicts are not allowed during the last 10% of the search time
- added timeout for accepting worsening moves (Neighbour.StandardWorsenTimeOut)
  - defaults to last 30% of the time limit (worsening moves are not allowed during the last 30% of the search)
  • Loading branch information
tomas-muller committed Nov 19, 2023
1 parent edf1e54 commit bd49bca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public EnrollmentSelection(DataProperties properties) {
iWeightDeltaInitialAssignment = properties.getPropertyDouble("Value.WeightDeltaInitialAssignments", 0.0);
}
iGoodSelectionProb = properties.getPropertyDouble("Value.GoodSelectionProb", 0.00);
iWeightWeightedCoflicts = properties.getPropertyDouble("Value.WeightWeightedConflicts", 1.0);
iWeightWeightedCoflicts = properties.getPropertyDouble("Value.WeightWeightedConflicts", 0.0);
iWeightPotentialConflicts = properties.getPropertyDouble("Value.WeightPotentialConflicts", 0.0);

iRandomWalkProb = properties.getPropertyDouble("Value.RandomWalkProb", 0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.cpsolver.ifs.assignment.Assignment;
import org.cpsolver.ifs.heuristics.ValueSelection;
import org.cpsolver.ifs.heuristics.VariableSelection;
import org.cpsolver.ifs.model.SimpleNeighbour;
import org.cpsolver.ifs.solution.Solution;
import org.cpsolver.ifs.solver.Solver;
import org.cpsolver.ifs.util.DataProperties;
Expand Down Expand Up @@ -52,6 +51,7 @@ public CriticalStandardSelection(DataProperties properties, VariableSelection<Re
super(properties, variableSelection, valueSelection);
iPriority = priority;
iAllowCriticalUnassignment = properties.getPropertyBoolean("Neighbour.AllowCriticalUnassignment", iAllowCriticalUnassignment);
iCanWorsen = properties.getPropertyBoolean("Neighbour.CriticalStandardCanWorsen", false);
}

public CriticalStandardSelection(DataProperties properties, ValueSelection<Request, Enrollment> valueSelection, RequestPriority priority) {
Expand Down Expand Up @@ -83,14 +83,6 @@ public boolean canUnassign(Enrollment enrollment, Enrollment conflict, Assignmen
return true;
}

/**
* Only accept neighbors that are not worsening the solution
*/
@Override
public boolean accept(SimpleNeighbour<Request, Enrollment> n, Solution<Request, Enrollment> solution) {
return n.value(solution.getAssignment()) <= 0.0;
}

/**
* Returns the unassigned critical course requests in a random order.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.cpsolver.studentsct.heuristics.EnrollmentSelection;
import org.cpsolver.studentsct.model.Enrollment;
import org.cpsolver.studentsct.model.Request;
import org.cpsolver.studentsct.model.Request.RequestPriority;


/**
Expand Down Expand Up @@ -71,9 +72,11 @@ public class StandardSelection implements NeighbourSelection<Request, Enrollment
protected long iNrIterations = -1;
protected boolean iPreferPriorityStudents = true;
protected long iConflictTimeOut = -7200;
protected long iWorsenTimeOut = -7200;
protected long iTimeOut = -3600;
protected boolean iCanConflict = true;
protected boolean iCanWorsen = true;
protected boolean iCanWorsenCritical = false;
protected boolean iCanHigherPriorityConflict = true;

/**
Expand All @@ -92,15 +95,19 @@ public StandardSelection(DataProperties properties, VariableSelection<Request, E
iVariableSelection = variableSelection;
iValueSelection = valueSelection;
iPreferPriorityStudents = properties.getPropertyBoolean("Sectioning.PriorityStudentsFirstSelection.AllIn", true);
iTimeOut = properties.getPropertyLong("Neighbour.StandardTimeOut", -3600);
iTimeOut = properties.getPropertyLong("Neighbour.StandardTimeOut", 0);
if (iTimeOut < 0)
iTimeOut = Math.max(0, properties.getPropertyLong("Termination.TimeOut", -1l) + iTimeOut);
iConflictTimeOut = properties.getPropertyLong("Neighbour.StandardConflictTimeOut", -7200);
iConflictTimeOut = properties.getPropertyLong("Neighbour.StandardConflictTimeOut", - properties.getPropertyLong("Termination.TimeOut", 0) / 10);
if (iConflictTimeOut < 0)
iConflictTimeOut = Math.max(0, properties.getPropertyLong("Termination.TimeOut", -1l) + iConflictTimeOut);
iWorsenTimeOut = properties.getPropertyLong("Neighbour.StandardWorsenTimeOut", - 3 * properties.getPropertyLong("Termination.TimeOut", 0) / 10);
if (iWorsenTimeOut < 0)
iWorsenTimeOut = Math.max(0, properties.getPropertyLong("Termination.TimeOut", -1l) + iWorsenTimeOut);
iCanConflict = properties.getPropertyBoolean("Neighbour.StandardCanConflict", true);
iCanWorsen = properties.getPropertyBoolean("Neighbour.StandardCanWorsen", false);
iCanWorsen = properties.getPropertyBoolean("Neighbour.StandardCanWorsen", true);
iCanHigherPriorityConflict = properties.getPropertyBoolean("Neighbour.StandardCanHigherPriorityConflict", true);
iCanWorsenCritical = properties.getPropertyBoolean("Neighbour.CriticalStandardCanWorsen", false);
}

/** Initialization */
Expand All @@ -124,8 +131,14 @@ protected void init(Solver<Request, Enrollment> solver, String name) {
iCanConflict = solver.getProperties().getPropertyBoolean("Neighbour.StandardCanConflict", true);
if (iCanConflict && iConflictTimeOut > 0 && solver.currentSolution().getTime() > iConflictTimeOut)
iCanConflict = false;
if (iCanWorsen && iWorsenTimeOut > 0 && solver.currentSolution().getTime() > iWorsenTimeOut)
iCanWorsen = false;
if (!iCanConflict)
name = "No-Conf " + name;
else if (!iCanWorsen)
name = "Improving " + name;
if (iNrIterations > 0)
Progress.getInstance(solver.currentSolution().getModel()).setPhase((iCanConflict ? name : "No-conf " + name), iNrIterations);
Progress.getInstance(solver.currentSolution().getModel()).setPhase(name, iNrIterations);
}

/**
Expand Down Expand Up @@ -154,6 +167,8 @@ public boolean canUnassign(Enrollment enrollment, Enrollment conflict, Assignmen
* @return by default, any neighbors is accepted
*/
public boolean accept(SimpleNeighbour<Request, Enrollment> n, Solution<Request, Enrollment> solution) {
if (!iCanWorsenCritical && RequestPriority.Important.isCritical(n.getVariable()))
return n.value(solution.getAssignment()) <= 0.0;
if (iCanWorsen) return true;
return n.value(solution.getAssignment()) <= 0.0;
}
Expand Down

0 comments on commit bd49bca

Please sign in to comment.