From 77a46cc194a421c9a975d5c1a47c9efdf17b1f7f Mon Sep 17 00:00:00 2001 From: tomas-muller Date: Fri, 20 Nov 2020 16:30:06 +0100 Subject: [PATCH] Student Scheduling: IFS - 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 --- .../selection/StandardSelection.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/org/cpsolver/studentsct/heuristics/selection/StandardSelection.java b/src/org/cpsolver/studentsct/heuristics/selection/StandardSelection.java index fdcabd4d..b56d4c0e 100644 --- a/src/org/cpsolver/studentsct/heuristics/selection/StandardSelection.java +++ b/src/org/cpsolver/studentsct/heuristics/selection/StandardSelection.java @@ -67,6 +67,9 @@ public class StandardSelection implements NeighbourSelection 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 @@ -84,6 +87,13 @@ public StandardSelection(DataProperties properties, VariableSelection 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); } /** @@ -111,6 +127,7 @@ protected void init(Solver solver, String name) { * @return if running MPP, do not unassign initial enrollments */ public boolean canUnassign(Enrollment enrollment, Enrollment conflict, Assignment 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();