diff --git a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java b/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java index 9e9309f..6144f89 100644 --- a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java +++ b/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java @@ -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; } diff --git a/Travail_de_session/InitialSchedules/SolverInitialSchedules.java b/Travail_de_session/InitialSchedules/SolverInitialSchedules.java index b101481..fefb543 100644 --- a/Travail_de_session/InitialSchedules/SolverInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/SolverInitialSchedules.java @@ -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); } diff --git a/Travail_de_session/MainClass.java b/Travail_de_session/MainClass.java index 19da137..d5efc21 100644 --- a/Travail_de_session/MainClass.java +++ b/Travail_de_session/MainClass.java @@ -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; diff --git a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java index 575f867..6b98338 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java +++ b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java @@ -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 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; } diff --git a/Travail_de_session/SchedulesRecovery/ScheduleState.java b/Travail_de_session/SchedulesRecovery/ScheduleState.java index 3bcb8d4..c551ff0 100644 --- a/Travail_de_session/SchedulesRecovery/ScheduleState.java +++ b/Travail_de_session/SchedulesRecovery/ScheduleState.java @@ -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; diff --git a/Travail_de_session/SchedulesRecovery/ScheduleStateComparator.java b/Travail_de_session/SchedulesRecovery/ScheduleStateComparator.java deleted file mode 100644 index d810adb..0000000 --- a/Travail_de_session/SchedulesRecovery/ScheduleStateComparator.java +++ /dev/null @@ -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; - } -}