Correction d'un bugs dans l'algo de recouvrement d'horaire.
This commit is contained in:
parent
8b75086530
commit
ca614425c1
6 changed files with 35 additions and 51 deletions
|
@ -10,7 +10,7 @@ package AbsenceSchedules;
|
|||
* @author frabe
|
||||
*/
|
||||
public interface ParametersAbsencesSimulator {
|
||||
public final double probPresence = 0.50;
|
||||
public final double probReturn = 0.99;
|
||||
public final int numberAbsenceSimulations = 5;
|
||||
public final double probPresence = 0.90;
|
||||
public final double probReturn = 0.50;
|
||||
public final int numberAbsenceSimulations = 1;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SolverInitialSchedules {
|
|||
solverInitialSchedules.setRestartOnSolutions();
|
||||
BacktrackCounter restartCriterion = new BacktrackCounter(myModelPartTimeEmployeesInitialSchedules.chocoModelInitialSchedules, 100000);
|
||||
solverInitialSchedules.setRestarts(restartCriterion, new MonotonicRestartStrategy(50000), 1000);
|
||||
solverInitialSchedules.limitSolution(2);
|
||||
solverInitialSchedules.limitSolution(1);
|
||||
solverInitialSchedules.limitTime(1000000);
|
||||
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ public class MainClass {
|
|||
|
||||
InitialSchedules.ParametersInitialSchedules myScheduleParameters = new InitialSchedules.ParametersInitialSchedules();
|
||||
|
||||
int minFullTimeEmployee = 2; //La solution avec 1 employes est trop lente
|
||||
int minFullTimeEmployee = 5; //La solution avec 1 employes est trop lente
|
||||
|
||||
int maxFullTimeEmployee = 9; //C'est le max d'employes a temps plein pour la presente requiredWorkforce
|
||||
int maxFullTimeEmployee = 5; //C'est le max d'employes a temps plein pour la presente requiredWorkforce
|
||||
|
||||
int simulationNumber = 1;
|
||||
|
||||
|
|
|
@ -42,14 +42,16 @@ public class RecoveredSchedulesArray extends SchedulesArray{
|
|||
ScheduleState currentScheduleState = new ScheduleState(currentRecoveredScheduleOfPartTimeEmployees, currentRecoveredScheduleOfFullTimeEmployees,
|
||||
remainingRecoveringAction);
|
||||
|
||||
Stack< ScheduleState > scheduleStatesNodes = new Stack<>();
|
||||
scheduleStatesNodes.push(currentScheduleState);
|
||||
List< ScheduleState > scheduleStatesNodes = new ArrayList<>();
|
||||
scheduleStatesNodes.add(currentScheduleState);
|
||||
RecoveringAction currentRecoveringAction;
|
||||
|
||||
boolean isSolutionFound;
|
||||
isSolutionFound = remainingRecoveringAction == 0;
|
||||
boolean isSolutionFound = false;
|
||||
boolean isAbsenceFound = remainingRecoveringAction != 0;
|
||||
|
||||
int numberBackTrack = 0;
|
||||
// Fouilles en profondeur en privilegiant les actions avec cout minimum. On marque les noeuds dejà visites pour avoir des fouilles differentes
|
||||
while ( !isSolutionFound ) {
|
||||
while ( !isSolutionFound && isAbsenceFound) {
|
||||
PriorityQueue<RecoveringAction> recoveringActionsOrderedByCost =
|
||||
getPossibleRecoveringActions(currentRecoveredScheduleOfPartTimeEmployees, currentRecoveredScheduleOfFullTimeEmployees,
|
||||
alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees, remainingRecoveringAction, recoveringActionCostComparator);
|
||||
|
@ -70,33 +72,39 @@ public class RecoveredSchedulesArray extends SchedulesArray{
|
|||
|
||||
ScheduleState scheduleState = new ScheduleState(recoveredScheduleOfPartTimeEmployeesAfterAction, recoveredScheduleOfFullTimeEmployeesAfterAction,
|
||||
remainingRecoveringAction - 1);
|
||||
|
||||
scheduleStatesNodes.push(scheduleState);
|
||||
} else if (scheduleStatesNodes.size() == 1) {
|
||||
//Si le sommet n'a plus d'enfants non-visite, la solution n'est pas trouvee.
|
||||
|
||||
scheduleStatesNodes.add(scheduleState);
|
||||
} else if (numberBackTrack > this.getNumberFullTimeEmployee() + this.getNumberPartTimeEmployee()) {
|
||||
//Si le nombre de retour au sommet atteint le nombre total d'employes, la solution n'est pas trouvee par cette methode, il faudrait faire une fouille complete.
|
||||
isSolutionFound = false;
|
||||
System.out.println("No solution Found");
|
||||
break;
|
||||
} else{
|
||||
// Lorsqu'on est bloque dans l'arbre de recherche, on revient au sommet de l'arbre.
|
||||
do{
|
||||
scheduleStatesNodes.pop();
|
||||
} while(scheduleStatesNodes.size() > 1);
|
||||
// Lorsqu'on est bloque dans l'arbre de recherche, on revient au sommet de l'arbre et on recommence une nouvelle fouille.
|
||||
currentScheduleState = scheduleStatesNodes.get(0);
|
||||
scheduleStatesNodes.clear();
|
||||
scheduleStatesNodes.add(currentScheduleState);
|
||||
numberBackTrack++;
|
||||
remainingRecoveringAction = currentScheduleState.remainingRecoveringAction;
|
||||
|
||||
}
|
||||
|
||||
if (remainingRecoveringAction - 1 == 0){
|
||||
isSolutionFound = true;
|
||||
}
|
||||
if (scheduleStatesNodes.size() > 0) {
|
||||
currentScheduleState = scheduleStatesNodes.peek();
|
||||
currentRecoveredScheduleOfPartTimeEmployees = currentScheduleState.currentRecoveredScheduleOfPartTimeEmployees;
|
||||
currentRecoveredScheduleOfFullTimeEmployees = currentScheduleState.currentRecoveredScheduleOfFullTimeEmployees;
|
||||
remainingRecoveringAction = currentScheduleState.remainingRecoveringAction;
|
||||
}
|
||||
|
||||
currentScheduleState = scheduleStatesNodes.get(scheduleStatesNodes.size()-1);
|
||||
currentRecoveredScheduleOfPartTimeEmployees = currentScheduleState.currentRecoveredScheduleOfPartTimeEmployees;
|
||||
currentRecoveredScheduleOfFullTimeEmployees = currentScheduleState.currentRecoveredScheduleOfFullTimeEmployees;
|
||||
remainingRecoveringAction = currentScheduleState.remainingRecoveringAction;
|
||||
|
||||
}
|
||||
|
||||
if (isSolutionFound) {
|
||||
if (isSolutionFound || !isAbsenceFound) {
|
||||
this.fullTimeSchedules = currentRecoveredScheduleOfFullTimeEmployees;
|
||||
this.partTimeSchedules = currentRecoveredScheduleOfPartTimeEmployees;
|
||||
this.totalScheduleCost = EmployeeCostCalculator.getFullRecoveredScheduleCost(this, myParametersInitialSchedules);
|
||||
|
||||
} else {
|
||||
this.totalScheduleCost = Integer.MAX_VALUE;
|
||||
}
|
||||
|
|
|
@ -13,11 +13,10 @@ public class ScheduleState {
|
|||
|
||||
boolean[][] currentRecoveredScheduleOfPartTimeEmployees;
|
||||
boolean[][] currentRecoveredScheduleOfFullTimeEmployees;
|
||||
int currentOptimisticTotalEmployeeCost;
|
||||
int remainingRecoveringAction;
|
||||
|
||||
public ScheduleState(boolean[][] currentRecoveredScheduleOfPartTimeEmployees, boolean[][] currentRecoveredScheduleOfFullTimeEmployees,
|
||||
int remainingRecoveringAction) {
|
||||
int remainingRecoveringAction) {
|
||||
this.currentRecoveredScheduleOfPartTimeEmployees = currentRecoveredScheduleOfPartTimeEmployees;
|
||||
this.currentRecoveredScheduleOfFullTimeEmployees = currentRecoveredScheduleOfFullTimeEmployees;
|
||||
this.remainingRecoveringAction = remainingRecoveringAction;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package SchedulesRecovery;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author frabe
|
||||
*/
|
||||
public class ScheduleStateComparator implements Comparator< ScheduleState > {
|
||||
public int compare(ScheduleState o1, ScheduleState o2) {
|
||||
int totalCostCmp = Integer.compare(o1.currentOptimisticTotalEmployeeCost,o2.currentOptimisticTotalEmployeeCost);
|
||||
if (totalCostCmp !=0) {
|
||||
return totalCostCmp;
|
||||
}
|
||||
int remainingActionsCmp = Integer.compare(o1.remainingRecoveringAction,o2.remainingRecoveringAction);
|
||||
return remainingActionsCmp;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue