diff --git a/Rapport_de_session/Figures/Résultats.xlsx b/Rapport_de_session/Figures/Résultats.xlsx index 32a2716..d8e908b 100644 Binary files a/Rapport_de_session/Figures/Résultats.xlsx and b/Rapport_de_session/Figures/Résultats.xlsx differ diff --git a/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java b/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java index 004a8f6..97532cf 100644 --- a/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java @@ -14,7 +14,7 @@ import org.chocosolver.solver.variables.IntVar; * @author frabe */ public class ModelFullTimeEmployeesInitialSchedules { - public final ParametersInitialSchedules myScheduleParameters; + public final ParametersSchedules myScheduleParameters; public final int numberOfFullTimeEmployees; @@ -25,7 +25,7 @@ public class ModelFullTimeEmployeesInitialSchedules { public final Model chocoModelInitialSchedules; - public ModelFullTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters, int numberOfFullTimeEmployees) { + public ModelFullTimeEmployeesInitialSchedules(ParametersSchedules myScheduleParameters, int numberOfFullTimeEmployees) { this.myScheduleParameters = myScheduleParameters; this.chocoModelInitialSchedules = new Model("Model Full Time Employees Initial Schedules"); diff --git a/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java b/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java index 8d5713f..f48329f 100644 --- a/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java @@ -6,7 +6,7 @@ import org.chocosolver.solver.variables.IntVar; public class ModelPartTimeEmployeesInitialSchedules { - public final ParametersInitialSchedules myScheduleParameters; + public final ParametersSchedules myScheduleParameters; public final int maxPartTimeEmployee; @@ -17,7 +17,7 @@ public class ModelPartTimeEmployeesInitialSchedules { public final Model chocoModelInitialSchedules; - public ModelPartTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters) { + public ModelPartTimeEmployeesInitialSchedules(ParametersSchedules myScheduleParameters) { this.myScheduleParameters = myScheduleParameters; diff --git a/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java b/Travail_de_session/InitialSchedules/ParametersSchedules.java similarity index 85% rename from Travail_de_session/InitialSchedules/ParametersInitialSchedules.java rename to Travail_de_session/InitialSchedules/ParametersSchedules.java index 704753f..fe819c7 100644 --- a/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ParametersSchedules.java @@ -3,7 +3,7 @@ package InitialSchedules; import ScheduleUtil.FullTimeEmployeeScheduleArray; import org.chocosolver.solver.constraints.extension.Tuples; -public class ParametersInitialSchedules { +public class ParametersSchedules { //General Parameters private final int shiftWorkPerDay = 3; @@ -15,10 +15,10 @@ public class ParametersInitialSchedules { //PartTime Employees Parameters private final int fixedCostOfPartTimeEmployeesPerSchedule = 50; - private final int regularHourlyRateOfPartTimeEmployees = 12; - private final int overtimeHourlyRateOfPartTimeEmployees = 17; + private final int regularHourlyRateOfPartTimeEmployees = 11; + private final int overtimeHourlyRateOfPartTimeEmployees = 16; private final int minWorkingHoursOfPartTimeEmployeesPerSchedule = 32; - private final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 64; + private final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 80; private final int maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork = 12; private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees = 12; @@ -32,21 +32,27 @@ public class ParametersInitialSchedules { private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12; private int[] requiredWorkforce; - int NbFullTimeSolutions; - int NbPartTimeSolutions; Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees; Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees; - private Tuples ValidPartTimeEmployeeShiftTuples; - public ParametersInitialSchedules() { + public ParametersSchedules(ParametersSchedules myScheduleParameters) { + + this.requiredWorkforce = new int[this.getWorkPeriodsPerSchedule()]; + for (int workPeriod = 0 ; workPeriod < getWorkPeriodsPerSchedule() ; workPeriod++) { + this.requiredWorkforce[workPeriod] = myScheduleParameters.getRequiredWorkForce(workPeriod); + } + + this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees = myScheduleParameters.enumerationWorkPeriodsSchedulesOfFullTimeEmployees; + this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees = myScheduleParameters.enumerationWorkPeriodsSchedulesOfPartTimeEmployees; + } + + public ParametersSchedules() { this.setRequiredWorkforce(); this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfFullTimeEmployees( shiftWorkPerDay, getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule); this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfPartTimeEmployees( getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule); - this.ValidPartTimeEmployeeShiftTuples = new ValidPartTimeEmployeeShift().makeTuples(); - } private void setRequiredWorkforce() { @@ -56,6 +62,15 @@ public class ParametersInitialSchedules { for (int day = 0; day < this.daysPerSchedule; day++) { System.arraycopy(dailyRequiredWorkforce, 0, this.requiredWorkforce, day * this.getWorkPeriodPerDay(), this.getWorkPeriodPerDay()); } + + } + + public void modifyRequiredWorkForce(int[] variableDemandVector) { + + for (int workPeriod = 0 ; workPeriod < this.getWorkPeriodsPerSchedule() ; workPeriod++) { + this.requiredWorkforce[workPeriod] += variableDemandVector[workPeriod]; + } + } public void adjustRequiredWorkforce( FullTimeEmployeeScheduleArray fullTimeSchedule) { @@ -165,7 +180,4 @@ public class ParametersInitialSchedules { return this.workingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod; } - // A implementer plus tard si l'on veut travailler avec des fichiers texte - public ParametersInitialSchedules(String fileName) {} - } diff --git a/Travail_de_session/MainClass.java b/Travail_de_session/MainClass.java index b4e0a63..f16f703 100644 --- a/Travail_de_session/MainClass.java +++ b/Travail_de_session/MainClass.java @@ -1,10 +1,7 @@ -import AbsenceSchedules.*; import InitialSchedules.*; import ScheduleUtil.*; import SchedulesRecovery.*; -import VariableDemandSchedules.BankVariableDemandSchedules; -import VariableDemandSchedules.ParametersVariableDemandSimulator; -import VariableDemandSchedules.VariableDemandSchedulesArray; +import ModifiedSchedules.*; import jdistlib.rng.MersenneTwister; import jdistlib.rng.RandomEngine; import org.chocosolver.solver.Solution; @@ -18,37 +15,37 @@ public class MainClass { public static void main(String[] args) { + ParametersSchedules myScheduleParameters = new InitialSchedules.ParametersSchedules(); // for (int i = 0 ; i <= 10 ; i++) { -// ParametersAbsencesSimulator.probPresence = (double) i * 0.01 + 0.9; // Pour de 0.9 a 1.0 par increment de 0.01 +// ParametersAbsencesSimulator.probPresence = 1 - (double) i * 0.01; // Pour de 0.90 a 1.0 par increment de 0.01 -// System.out.print("Probabilité absence = " + (1-ParametersAbsencesSimulator.probPresence)); +// for (int j = 0 ; j <= 10 ; j++) { + +// ParametersVariableDemandSimulator.probIncreasedDemandbyOne = (double) j * 0.1; // Pour de 0 a 1 par increment de 0.1 +// ParametersVariableDemandSimulator.probIncreasedDemandbyTwo = ParametersVariableDemandSimulator.probIncreasedDemandbyOne/5; // Pour de 0 a 0.25 par increment de 0.05 +// ParametersVariableDemandSimulator.probIncreasedDemandbyThree = ParametersVariableDemandSimulator.probIncreasedDemandbyOne/25; // Pour de 0 a 0.25 par increment de 0.05 + List initialSchedulesArrayList = generateInitialSchedules(myScheduleParameters); - // Placer une sous-boucle pour faire varier la probabilite d'augmentation de la demande. - - List initialSchedulesArrayList = generateInitialSchedules(); + List listBankModifiedSchedules = GenerateModifiedSchedules(initialSchedulesArrayList, myScheduleParameters); - //List listBankVariableDemandSchedules = GenerateModifiedDemandSchedules(initialSchedulesArrayList); + List bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankModifiedSchedules); - List listBankAbsenceSchedules = GenerateAbsencesSchedules(initialSchedulesArrayList); - - List bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankAbsenceSchedules); - - @SuppressWarnings("unused") SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost); + SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost); // int optimalFullTimeEmployee = bankRecoveredSchedulesOrderedByMeanCost.get(0).initialSchedulesArray.getNumberFullTimeEmployee(); -// System.out.println(optimalFullTimeEmployee + " "); +// System.out.print(optimalFullTimeEmployee + " "); +// } +// System.out.println(" "); // } } @SuppressWarnings("unused") - private static List generateInitialSchedules() { + private static List generateInitialSchedules(ParametersSchedules myScheduleParameters) { // Trouver les horaires des employes a temps plein possibles pour different ratio templein/temps partiel List initialSchedulesArrayList = new ArrayList<>(); - InitialSchedules.ParametersInitialSchedules myScheduleParameters = new InitialSchedules.ParametersInitialSchedules(); - int minFullTimeEmployee = 2; //La solution avec 1 employes est trop lente int maxFullTimeEmployee = 9; //9 est le max d'employes a temps plein pour la presente requiredWorkforce @@ -69,7 +66,7 @@ public class MainClass { for (Solution CurrentFullTimeEmployeesSolution : myInitialFullTimeEmployeesSchedulesSolutions) { FullTimeEmployeeScheduleArray fullTimeSchedulesArray = new FullTimeEmployeeScheduleArray(myModelFullTimeEmployeesInitialSchedules, CurrentFullTimeEmployeesSolution); - InitialSchedules.ParametersInitialSchedules myPartTimeScheduleParameters = new InitialSchedules.ParametersInitialSchedules(); + InitialSchedules.ParametersSchedules myPartTimeScheduleParameters = new InitialSchedules.ParametersSchedules(); myPartTimeScheduleParameters.adjustRequiredWorkforce(fullTimeSchedulesArray); InitialSchedules.ModelPartTimeEmployeesInitialSchedules myModelPartTimeEmployeesInitialSchedules @@ -81,7 +78,7 @@ public class MainClass { for (Solution CurrentPartTimeEmployeesSolution : myInitialPartTimeEmployeesSchedulesSolutions) { PartTimeEmployeeScheduleArray partTimeSchedulesArray = new PartTimeEmployeeScheduleArray(myModelPartTimeEmployeesInitialSchedules, CurrentPartTimeEmployeesSolution); - SchedulesArray initialSchedulesArray = new SchedulesArray(fullTimeSchedulesArray, partTimeSchedulesArray, simulationNumber); + SchedulesArray initialSchedulesArray = new SchedulesArray(fullTimeSchedulesArray, partTimeSchedulesArray, myScheduleParameters, simulationNumber); initialSchedulesArrayList.add(initialSchedulesArray); simulationNumber++; } @@ -97,65 +94,62 @@ public class MainClass { } - private static List GenerateModifiedDemandSchedules(List initialSchedulesArrayList) { - RandomEngine r = new MersenneTwister(987654321); - List listBankVariableDemandSchedules = new ArrayList<>(); - List listVariableDemandSchedules = new ArrayList<>(); // to be removed - for (SchedulesArray initialSchedule : initialSchedulesArrayList) { - BankVariableDemandSchedules bankVariableDemandSimulations = new BankVariableDemandSchedules(initialSchedule); - for (int simNum = 0; simNum < ParametersVariableDemandSimulator.numberVariableDemandSimulation ; simNum++){ - VariableDemandSchedulesArray variableDemandSchedule = new VariableDemandSchedulesArray(initialSchedule,r); - listVariableDemandSchedules.add(variableDemandSchedule); - bankVariableDemandSimulations.addVariableDemandSchedules(variableDemandSchedule); - } - listBankVariableDemandSchedules.add(bankVariableDemandSimulations); - } - // Pour afficher les horaires avec demande modifiée - SchedulesWindows.ShowSchedulesFrame variableDemandSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listVariableDemandSchedules,"Variable Demand Schedules"); - - return listBankVariableDemandSchedules; - } - - private static List GenerateAbsencesSchedules(List initialSchedulesArrayList) { + private static List GenerateModifiedSchedules(List initialSchedulesArrayList, ParametersSchedules myScheduleParameters) { - RandomEngine r = new MersenneTwister(123456789); - List listBankAbsenceSchedules = new ArrayList<>(); - List listAbsenceSchedules = new ArrayList<>(); // to be removed - for (SchedulesArray initialSchedule : initialSchedulesArrayList) { - BankAbsenceSchedules bankAbsenceSimulations = new BankAbsenceSchedules(initialSchedule); - for (int simNum = 0 ; simNum < ParametersAbsencesSimulator.numberAbsenceSimulations ; simNum++) { - AbsenceSchedulesArray absenceSchedule = new AbsenceSchedulesArray(initialSchedule, r); - listAbsenceSchedules.add(absenceSchedule); // to be removed - bankAbsenceSimulations.addAbsenceSchedules(absenceSchedule); - } - listBankAbsenceSchedules.add(bankAbsenceSimulations); + RandomEngine randAbsence = new MersenneTwister(123456789); + + // generation de nouveaux vecteurs de demande de travail + RandomEngine randVariableDemand = new MersenneTwister(987654321); + int[][] matrixVariableDemandVector = new int[ParametersVariableDemandSimulator.numberVariableDemandSimulations][myScheduleParameters.getWorkPeriodsPerSchedule()]; + for (int varDemSimNum = 0 ; varDemSimNum < ParametersVariableDemandSimulator.numberVariableDemandSimulations ; varDemSimNum++) { + matrixVariableDemandVector[varDemSimNum] = new ModifiedSchedules.VariableDemandVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randVariableDemand).getVariableDemandVector(); } - // Pour afficher les horaires avec absence - SchedulesWindows.ShowSchedulesFrame absenceSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listAbsenceSchedules, "Absence Schedules"); // to be removed + List listBankModifiedSchedules = new ArrayList<>(); + List listModifiedSchedules = new ArrayList<>(); // to be removed + for (SchedulesArray initialSchedule : initialSchedulesArrayList) { + BankModifiedSchedules bankModificationSimulations = new BankModifiedSchedules(initialSchedule); + for (int varDemSimNum = 0 ; varDemSimNum < ParametersVariableDemandSimulator.numberVariableDemandSimulations ; varDemSimNum++) { + int[] variableDemandVector = matrixVariableDemandVector[varDemSimNum]; + ParametersSchedules myModifiedScheduleParameters = new InitialSchedules.ParametersSchedules(myScheduleParameters); + myModifiedScheduleParameters.modifyRequiredWorkForce(variableDemandVector); + for (int absSimNum = 0 ; absSimNum < ParametersAbsencesSimulator.numberAbsenceSimulations ; absSimNum++) { + ModifiedSchedulesArray modifiedSchedule = new ModifiedSchedulesArray(initialSchedule, myModifiedScheduleParameters, randAbsence); + listModifiedSchedules.add(modifiedSchedule); // to be removed + bankModificationSimulations.addModifiedSchedules(modifiedSchedule); + } + } + listBankModifiedSchedules.add(bankModificationSimulations); + } - return listBankAbsenceSchedules; + // Pour afficher les horaires modifies + SchedulesWindows.ShowSchedulesFrame modifiedSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listModifiedSchedules, "Modified Schedules"); // to be removed + + return listBankModifiedSchedules; } - private static List GenerateOptimalRecoveredSchedules(List listBankAbsenceSchedules) { + private static List GenerateOptimalRecoveredSchedules(List listBankModifiedSchedules) { BankRecoveredSchedulesComparator meanCostComparator = new BankRecoveredSchedulesComparator(); PriorityQueue< BankRecoveredSchedules > bankRecoveredSchedulesOrderedByMeanCost = new PriorityQueue<>(meanCostComparator); List listRecoveredSchedules = new ArrayList<>(); // to be removed - for (BankAbsenceSchedules bankAbsenceSchedule : listBankAbsenceSchedules) { - SchedulesArray initialSchedulesArray = bankAbsenceSchedule.initialSchedulesArray; - BankRecoveredSchedules bankRecoveredSimulations = new BankRecoveredSchedules(initialSchedulesArray, bankAbsenceSchedule.bankAbsenceSimulation); + for (BankModifiedSchedules bankModifiedSchedule : listBankModifiedSchedules) { + SchedulesArray initialSchedulesArray = bankModifiedSchedule.initialSchedulesArray; + BankRecoveredSchedules bankRecoveredSimulations = new BankRecoveredSchedules(initialSchedulesArray, bankModifiedSchedule.bankModifiedSimulation); int totalCostRecoveredSimulations = 0; - for (AbsenceSchedulesArray absenceSchedule : bankAbsenceSchedule.bankAbsenceSimulation) { - RecoveredSchedulesArray recoveredSchedule = new RecoveredSchedulesArray(absenceSchedule); + for (ModifiedSchedulesArray modifiedSchedule : bankModifiedSchedule.bankModifiedSimulation) { + RecoveredSchedulesArray recoveredSchedule = new RecoveredSchedulesArray(modifiedSchedule); listRecoveredSchedules.add(recoveredSchedule); // to be removed bankRecoveredSimulations.addRecoveredSchedules(recoveredSchedule); if (recoveredSchedule.totalScheduleCost != Integer.MAX_VALUE){ totalCostRecoveredSimulations += recoveredSchedule.totalScheduleCost; + } else { + bankRecoveredSimulations.numberUnResolvedSimulations += 1; } } bankRecoveredSimulations.meanCostRecoveredSimulations = totalCostRecoveredSimulations / bankRecoveredSimulations.bankRecoveredSimulation.size(); +// System.out.print(bankRecoveredSimulations.meanCostRecoveredSimulations + " "); bankRecoveredSchedulesOrderedByMeanCost.add(bankRecoveredSimulations); } // Pour afficher les horaires de recouvrement diff --git a/Travail_de_session/AbsenceSchedules/AbsencesVector.java b/Travail_de_session/ModifiedSchedules/AbsencesVector.java similarity index 74% rename from Travail_de_session/AbsenceSchedules/AbsencesVector.java rename to Travail_de_session/ModifiedSchedules/AbsencesVector.java index 9a29ffb..02389af 100644 --- a/Travail_de_session/AbsenceSchedules/AbsencesVector.java +++ b/Travail_de_session/ModifiedSchedules/AbsencesVector.java @@ -1,19 +1,19 @@ -package AbsenceSchedules; +package ModifiedSchedules; import jdistlib.Binomial; import jdistlib.rng.RandomEngine; -class AbsencesVector { - private final boolean[] AbsencesVector; +public class AbsencesVector { + public boolean[] AbsencesVector; - public AbsencesVector(int length, RandomEngine r) { + public AbsencesVector(int length, RandomEngine randAbsence) { int current = 1; AbsencesVector = new boolean[length]; Binomial b1 = new Binomial(1, ParametersAbsencesSimulator.probPresence); - b1.setRandomEngine(r); + b1.setRandomEngine(randAbsence); Binomial b2 = new Binomial(1, ParametersAbsencesSimulator.probReturn); - b2.setRandomEngine(r); + b2.setRandomEngine(randAbsence); for (int i = 0; i < length; i++) { if (current == 1) { current = (int) b1.random(); diff --git a/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java b/Travail_de_session/ModifiedSchedules/BankModifiedSchedules.java similarity index 51% rename from Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java rename to Travail_de_session/ModifiedSchedules/BankModifiedSchedules.java index 907c454..1aba902 100644 --- a/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java +++ b/Travail_de_session/ModifiedSchedules/BankModifiedSchedules.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package AbsenceSchedules; +package ModifiedSchedules; import ScheduleUtil.SchedulesArray; @@ -14,16 +14,16 @@ import java.util.List; * * @author frabe */ -public class BankAbsenceSchedules { +public class BankModifiedSchedules { public final SchedulesArray initialSchedulesArray; - public final List bankAbsenceSimulation; + public final List bankModifiedSimulation; - public BankAbsenceSchedules(SchedulesArray initialSchedulesArray) { + public BankModifiedSchedules(SchedulesArray initialSchedulesArray) { this.initialSchedulesArray = initialSchedulesArray; - this.bankAbsenceSimulation = new ArrayList<>(); + this.bankModifiedSimulation = new ArrayList<>(); } - public void addAbsenceSchedules(AbsenceSchedulesArray absenceSchedulesArray) { - this.bankAbsenceSimulation.add(absenceSchedulesArray); + public void addModifiedSchedules(ModifiedSchedulesArray modifiedSchedulesArray) { + this.bankModifiedSimulation.add(modifiedSchedulesArray); } } diff --git a/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java b/Travail_de_session/ModifiedSchedules/ModifiedSchedulesArray.java similarity index 55% rename from Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java rename to Travail_de_session/ModifiedSchedules/ModifiedSchedulesArray.java index c0f216e..b42b601 100644 --- a/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java +++ b/Travail_de_session/ModifiedSchedules/ModifiedSchedulesArray.java @@ -1,44 +1,44 @@ -package AbsenceSchedules; +package ModifiedSchedules; -import ScheduleUtil.EmployeeCostCalculator; -import ScheduleUtil.SchedulesArray; +import InitialSchedules.*; +import ScheduleUtil.*; import jdistlib.rng.RandomEngine; -public class AbsenceSchedulesArray extends SchedulesArray{ +public class ModifiedSchedulesArray extends SchedulesArray{ private final SchedulesArray initialSchedulesArray; public int numberOfRecoveringActionsToPerform; - public AbsenceSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) { + public ModifiedSchedulesArray(SchedulesArray initialSchedulesArray, ParametersSchedules myModifiedScheduleParameters, RandomEngine randAbsence) { super(initialSchedulesArray); + this.myScheduleParameters = myModifiedScheduleParameters; this.initialSchedulesArray = initialSchedulesArray; - generateAbsenceSimulation(r); - this.totalScheduleCost = EmployeeCostCalculator.getFullAbsenceScheduleCost(this, myParametersInitialSchedules); + generateAbsenceSimulation(randAbsence); + calculateNumberOfRecoveringActionsToPerform(); + this.totalScheduleCost = EmployeeCostCalculator.getFullModifiedScheduleCost(this, myScheduleParameters); } - private void generateAbsenceSimulation(RandomEngine r) { + private void generateAbsenceSimulation(RandomEngine randAbsence) { for (int i = 0; i < getNumberPartTimeEmployee(); i++) { - boolean[] a = new AbsencesVector(myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getAbsencesVector(); - for (int j = 0; j < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); j++) { + boolean[] a = new AbsencesVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randAbsence).getAbsencesVector(); + for (int j = 0; j < myScheduleParameters.getWorkPeriodsPerSchedule(); j++) { this.partTimeSchedules[i][j] = this.initialSchedulesArray.isPartTimeEmployeeWorking(i, j) && a[j]; } } for (int i = 0; i < getNumberFullTimeEmployee(); i++) { - boolean[] a = new AbsencesVector(myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getAbsencesVector(); - for (int j = 0; j < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); j++) { + boolean[] a = new AbsencesVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randAbsence).getAbsencesVector(); + for (int j = 0; j < myScheduleParameters.getWorkPeriodsPerSchedule(); j++) { this.fullTimeSchedules[i][j] = this.initialSchedulesArray.isFullTimeEmployeeWorking(i, j) && a[j]; } } - calculateNumberOfRecoveringActionsToPerform(); - } public int getAbsencePeriodsPerPartTimeEmployees(int employee) { int absencePeriodsPerPartTimeEmployees = 0; - for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { + for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) { if (this.isPartTimeEmployeeAbsent(employee, workPeriod)) {absencePeriodsPerPartTimeEmployees += 1;} } return absencePeriodsPerPartTimeEmployees; @@ -46,7 +46,7 @@ public class AbsenceSchedulesArray extends SchedulesArray{ public int getAbsencePeriodsPerFullTimeEmployees(int employee) { int absencePeriodsPerFullTimeEmployees = 0; - for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { + for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) { if (this.isFullTimeEmployeeAbsent(employee, workPeriod)) {absencePeriodsPerFullTimeEmployees += 1;} } return absencePeriodsPerFullTimeEmployees; @@ -62,8 +62,8 @@ public class AbsenceSchedulesArray extends SchedulesArray{ private void calculateNumberOfRecoveringActionsToPerform() { this.numberOfRecoveringActionsToPerform = 0; - for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { - this.numberOfRecoveringActionsToPerform += this.myParametersInitialSchedules.getRequiredWorkForce(workPeriod) - this.getEmployeesWorkingPerWorkPeriod(workPeriod); + for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) { + this.numberOfRecoveringActionsToPerform += this.myScheduleParameters.getRequiredWorkForce(workPeriod) - this.getEmployeesWorkingPerWorkPeriod(workPeriod); } } diff --git a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java b/Travail_de_session/ModifiedSchedules/ParametersAbsencesSimulator.java similarity index 68% rename from Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java rename to Travail_de_session/ModifiedSchedules/ParametersAbsencesSimulator.java index e0ae85c..879a0e0 100644 --- a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java +++ b/Travail_de_session/ModifiedSchedules/ParametersAbsencesSimulator.java @@ -3,14 +3,14 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package AbsenceSchedules; +package ModifiedSchedules; /** * * @author frabe */ public class ParametersAbsencesSimulator { - public static final double probPresence = 0.99; + public static double probPresence = 0.92; public static final double probReturn = 0.50; - public static final int numberAbsenceSimulations = 1000; + public static final int numberAbsenceSimulations = 100; } diff --git a/Travail_de_session/ModifiedSchedules/ParametersVariableDemandSimulator.java b/Travail_de_session/ModifiedSchedules/ParametersVariableDemandSimulator.java new file mode 100644 index 0000000..05835ec --- /dev/null +++ b/Travail_de_session/ModifiedSchedules/ParametersVariableDemandSimulator.java @@ -0,0 +1,8 @@ +package ModifiedSchedules; + +public class ParametersVariableDemandSimulator { + public static double probIncreasedDemandbyOne = 0; + public static double probIncreasedDemandbyTwo = probIncreasedDemandbyOne / 5; + public static double probIncreasedDemandbyThree = probIncreasedDemandbyOne / 25; + public static final int numberVariableDemandSimulations = 10; +} diff --git a/Travail_de_session/ModifiedSchedules/VariableDemandVector.java b/Travail_de_session/ModifiedSchedules/VariableDemandVector.java new file mode 100644 index 0000000..21a7a1a --- /dev/null +++ b/Travail_de_session/ModifiedSchedules/VariableDemandVector.java @@ -0,0 +1,33 @@ +package ModifiedSchedules; + +import jdistlib.Binomial; +import jdistlib.rng.RandomEngine; + +public class VariableDemandVector { + public int[] variableDemandVector; + + public VariableDemandVector(int length, RandomEngine randVariableDemand) { + variableDemandVector = new int[length]; + Binomial p1 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyOne); + p1.setRandomEngine(randVariableDemand); + Binomial p2 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyTwo); + p2.setRandomEngine(randVariableDemand); + Binomial p3 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyThree); + p3.setRandomEngine(randVariableDemand); + for (int i = 0; i < length; i++) { + if ((int) p3.random() == 1){ + variableDemandVector[i] = 3; + } else if ((int) p2.random() == 1){ + variableDemandVector[i] = 2; + } else if ((int) p1.random() == 1){ + variableDemandVector[i] = 1; + } else { + variableDemandVector[i] = 0; + } + } + } + + public int[] getVariableDemandVector() { + return variableDemandVector; + } +} diff --git a/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java b/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java index f8b34c5..66be29e 100644 --- a/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java +++ b/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java @@ -5,10 +5,9 @@ */ package ScheduleUtil; -import AbsenceSchedules.AbsenceSchedulesArray; -import InitialSchedules.ParametersInitialSchedules; +import ModifiedSchedules.ModifiedSchedulesArray; +import InitialSchedules.ParametersSchedules; import SchedulesRecovery.RecoveredSchedulesArray; -import VariableDemandSchedules.VariableDemandSchedulesArray; /** * @@ -16,7 +15,7 @@ import VariableDemandSchedules.VariableDemandSchedulesArray; */ public class EmployeeCostCalculator { - public static int getFullInitialScheduleCost( SchedulesArray myInitialSchedule, ParametersInitialSchedules myScheduleParameters) { + public static int getFullInitialScheduleCost( SchedulesArray myInitialSchedule, ParametersSchedules myScheduleParameters) { int totalCost = 0; for (int partTimeEmployee = 0 ; partTimeEmployee < myInitialSchedule.getNumberPartTimeEmployee() ; partTimeEmployee++) { int numberWorkingPeriod = myInitialSchedule.getWorkingPeriodsPerPartTimeEmployees(partTimeEmployee); @@ -30,64 +29,58 @@ public class EmployeeCostCalculator { } return totalCost; } - - public static int getFullVariableDemandScheduleCost( VariableDemandSchedulesArray myVariableDemandSchedule, ParametersInitialSchedules myScheduleParameters) { - int totalCost = 0; - - /* Coût spécifique à une augmentation de la demande */ - for(int p=0;p bankRecoveredSimulation; - private final List bankAbsenceSimulation; + private final List bankModifiedSimulation; public double meanCostRecoveredSimulations; + public int numberUnResolvedSimulations; - public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List bankAbsenceSimulation) { + public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List bankModifiedSimulation) { this.initialSchedulesArray = initialSchedulesArray; - this.bankAbsenceSimulation = bankAbsenceSimulation; + this.bankModifiedSimulation = bankModifiedSimulation; this.bankRecoveredSimulation = new ArrayList<>(); + this.numberUnResolvedSimulations = 0; } - public void addRecoveredSchedules(SchedulesArray absenceSchedulesArray) { - this.bankRecoveredSimulation.add(absenceSchedulesArray); + public void addRecoveredSchedules(SchedulesArray recoveredSchedulesArray) { + this.bankRecoveredSimulation.add(recoveredSchedulesArray); } } diff --git a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java index 459d96a..1170b89 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java +++ b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java @@ -5,7 +5,7 @@ */ package SchedulesRecovery; -import AbsenceSchedules.AbsenceSchedulesArray; +import ModifiedSchedules.ModifiedSchedulesArray; import ScheduleUtil.EmployeeCostCalculator; import ScheduleUtil.SchedulesArray; @@ -18,22 +18,23 @@ import java.util.*; @SuppressWarnings("unchecked") public class RecoveredSchedulesArray extends SchedulesArray{ - public final AbsenceSchedulesArray absenceSchedulesArray; + public final ModifiedSchedulesArray modifiedSchedulesArray; - public RecoveredSchedulesArray(AbsenceSchedulesArray absenceSchedulesArray){ - super(absenceSchedulesArray); - this.absenceSchedulesArray = absenceSchedulesArray; - recoverAbsenceScheduleOptimally(); + public RecoveredSchedulesArray(ModifiedSchedulesArray modifiedSchedulesArray){ + super(modifiedSchedulesArray); + this.myScheduleParameters = modifiedSchedulesArray.myScheduleParameters; + this.modifiedSchedulesArray = modifiedSchedulesArray; + recoverModifiedScheduleOptimally(); } - private void recoverAbsenceScheduleOptimally() { - boolean[][] initialRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.partTimeSchedules); - boolean[][] initialRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.fullTimeSchedules); - boolean[][] currentRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.partTimeSchedules); - boolean[][] currentRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.fullTimeSchedules); + private void recoverModifiedScheduleOptimally() { + boolean[][] initialRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.partTimeSchedules); + boolean[][] initialRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.fullTimeSchedules); + boolean[][] currentRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.partTimeSchedules); + boolean[][] currentRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.fullTimeSchedules); - int initialRemainingRecoveringAction = this.absenceSchedulesArray.numberOfRecoveringActionsToPerform; - int currentRemainingRecoveringAction = this.absenceSchedulesArray.numberOfRecoveringActionsToPerform; + int initialRemainingRecoveringAction = this.modifiedSchedulesArray.numberOfRecoveringActionsToPerform; + int currentRemainingRecoveringAction = this.modifiedSchedulesArray.numberOfRecoveringActionsToPerform; boolean[][] alreadyRecoveredWorkPeriodByPartTimeEmployees = new boolean[this.getNumberPartTimeEmployee()][initialRemainingRecoveringAction]; boolean[][] alreadyRecoveredWorkPeriodByFullTimeEmployees = new boolean[this.getNumberFullTimeEmployee()][initialRemainingRecoveringAction]; @@ -42,11 +43,11 @@ public class RecoveredSchedulesArray extends SchedulesArray{ RecoveringActionComparator recoveringActionCostComparator = new RecoveringActionComparator(); boolean isSolutionFound = false; - boolean isAbsenceFound = initialRemainingRecoveringAction != 0; + boolean isModificationFound = initialRemainingRecoveringAction != 0; int numberBackTrack = 1; // Fouilles en profondeur en privilegiant les actions avec cout minimum. On marque les noeuds dejà visites pour avoir des fouilles differentes - while ( !isSolutionFound && isAbsenceFound ) { + while ( !isSolutionFound && isModificationFound ) { PriorityQueue recoveringActionsOrderedByCost = getPossibleRecoveringActions(currentRecoveredScheduleOfPartTimeEmployees, currentRecoveredScheduleOfFullTimeEmployees, alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees, currentRemainingRecoveringAction, recoveringActionCostComparator); @@ -69,13 +70,6 @@ public class RecoveredSchedulesArray extends SchedulesArray{ currentRemainingRecoveringAction--; - } else if (numberBackTrack % (this.getNumberFullTimeEmployee() + this.getNumberPartTimeEmployee()) == 0) { - //Si le nombre de retour au sommet atteint le nombre total d'employes, on reinitialize les matrices de noeuds visites. - initializeRecoveredWorkPeriodMatrix (alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees); - } else if (numberBackTrack > 10000) { - 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 et on recommence une nouvelle fouille. currentRemainingRecoveringAction = initialRemainingRecoveringAction; @@ -86,14 +80,22 @@ public class RecoveredSchedulesArray extends SchedulesArray{ if (currentRemainingRecoveringAction == 0){ isSolutionFound = true; + } else if (numberBackTrack % (this.getNumberFullTimeEmployee() + this.getNumberPartTimeEmployee()) == 0) { + //Si le nombre de retour au sommet atteint le nombre total d'employes, on reinitialize les matrices de noeuds visites. + initializeRecoveredWorkPeriodMatrix (alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees); + } else if (numberBackTrack > 100000) { + isSolutionFound = false; + System.out.println("No solution Found"); + break; } - + } - if (isSolutionFound || !isAbsenceFound) { + if (isSolutionFound || !isModificationFound) { this.fullTimeSchedules = currentRecoveredScheduleOfFullTimeEmployees; this.partTimeSchedules = currentRecoveredScheduleOfPartTimeEmployees; - this.totalScheduleCost = EmployeeCostCalculator.getFullRecoveredScheduleCost(this, myParametersInitialSchedules); + this.totalScheduleCost = EmployeeCostCalculator.getFullRecoveredScheduleCost(this, myScheduleParameters); + } else { this.totalScheduleCost = Integer.MAX_VALUE; } @@ -136,24 +138,24 @@ public class RecoveredSchedulesArray extends SchedulesArray{ PriorityQueue recoveringActionsOrderedByCost = new PriorityQueue<>(recoveringActionCostComparator); int workPeriod = findWorkPeriodToRecover(currentPartTimeSchedule, currentFullTimeSchedule); - if (workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule()) { + if (workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule()) { for (int partTimeEmployee = 0 ; partTimeEmployee < this.getNumberPartTimeEmployee() ; partTimeEmployee++ ) { - if ( ValidationRecoveringAction.isPartTimeEmployeeAvailableForAbsenceRecovering(currentPartTimeSchedule, myParametersInitialSchedules, - absenceSchedulesArray, partTimeEmployee, workPeriod) + if ( ValidationRecoveringAction.isPartTimeEmployeeAvailableForRecovering(currentPartTimeSchedule, myScheduleParameters, + modifiedSchedulesArray, partTimeEmployee, workPeriod) && !alreadyRecoveredWorkPeriodByPartTimeEmployees[partTimeEmployee][remainingRecoveringAction-1]){ RecoveringActionPartTimeEmployee recoveringAction = new RecoveringActionPartTimeEmployee(partTimeEmployee, workPeriod); - recoveringAction.calculateRecoveringActionCost(currentPartTimeSchedule, myParametersInitialSchedules); + recoveringAction.calculateRecoveringActionCost(currentPartTimeSchedule, myScheduleParameters); recoveringActionsOrderedByCost.add(recoveringAction); } } for (int fullTimeEmployee = 0 ; fullTimeEmployee < this.getNumberFullTimeEmployee() ; fullTimeEmployee++ ) { - if ( ValidationRecoveringAction.isFullTimeEmployeeAvailableForAbsenceRecovering(currentFullTimeSchedule, myParametersInitialSchedules, - absenceSchedulesArray, fullTimeEmployee, workPeriod) + if ( ValidationRecoveringAction.isFullTimeEmployeeAvailableForRecovering(currentFullTimeSchedule, myScheduleParameters, + modifiedSchedulesArray, fullTimeEmployee, workPeriod) && !alreadyRecoveredWorkPeriodByFullTimeEmployees[fullTimeEmployee][remainingRecoveringAction-1] ){ RecoveringActionFullTimeEmployee recoveringAction = new RecoveringActionFullTimeEmployee(fullTimeEmployee, workPeriod); - recoveringAction.calculateRecoveringActionCost (currentFullTimeSchedule, absenceSchedulesArray, myParametersInitialSchedules); + recoveringAction.calculateRecoveringActionCost (currentFullTimeSchedule, modifiedSchedulesArray, myScheduleParameters); recoveringActionsOrderedByCost.add(recoveringAction); } } @@ -163,7 +165,7 @@ public class RecoveredSchedulesArray extends SchedulesArray{ private int findWorkPeriodToRecover(boolean[][] currentPartTimeSchedule, boolean[][] currentFullTimeSchedule){ int workingEmployees; - for (int workPeriod = 0 ; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule() ; workPeriod++) { + for (int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++) { workingEmployees = 0; for (boolean[] aCurrentPartTimeSchedule : currentPartTimeSchedule) { if (aCurrentPartTimeSchedule[workPeriod]) { @@ -175,10 +177,10 @@ public class RecoveredSchedulesArray extends SchedulesArray{ workingEmployees++; } } - if (workingEmployees < this.myParametersInitialSchedules.getRequiredWorkForce(workPeriod) ) { + if (workingEmployees < this.myScheduleParameters.getRequiredWorkForce(workPeriod) ) { return workPeriod; } } - return myParametersInitialSchedules.getWorkPeriodsPerSchedule(); + return myScheduleParameters.getWorkPeriodsPerSchedule(); } } diff --git a/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java b/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java index 8011852..fad11cc 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java @@ -5,8 +5,8 @@ */ package SchedulesRecovery; -import AbsenceSchedules.AbsenceSchedulesArray; -import InitialSchedules.ParametersInitialSchedules; +import ModifiedSchedules.ModifiedSchedulesArray; +import InitialSchedules.ParametersSchedules; import ScheduleUtil.EmployeeCostCalculator; /** @@ -19,10 +19,10 @@ class RecoveringActionFullTimeEmployee extends RecoveringAction { super(employee, workPeriod); } - public void calculateRecoveringActionCost (boolean[][] currentEmployeesSchedule, AbsenceSchedulesArray absenceSchedulesArray, ParametersInitialSchedules myScheduleParameters) { - int costBeforeAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, absenceSchedulesArray, this.employee, myScheduleParameters); + public void calculateRecoveringActionCost (boolean[][] currentEmployeesSchedule, ModifiedSchedulesArray modifiedSchedulesArray, ParametersSchedules myScheduleParameters) { + int costBeforeAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, modifiedSchedulesArray, this.employee, myScheduleParameters); currentEmployeesSchedule[this.employee][this.workPeriod] = true; - int costAfterAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, absenceSchedulesArray, this.employee, myScheduleParameters); + int costAfterAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, modifiedSchedulesArray, this.employee, myScheduleParameters); currentEmployeesSchedule[this.employee][this.workPeriod] = false; this.recoveringActionCost = costAfterAction-costBeforeAction; } diff --git a/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java b/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java index 3c3ea0e..9102f3e 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java @@ -5,7 +5,7 @@ */ package SchedulesRecovery; -import InitialSchedules.ParametersInitialSchedules; +import InitialSchedules.ParametersSchedules; import ScheduleUtil.EmployeeCostCalculator; /** @@ -18,7 +18,7 @@ class RecoveringActionPartTimeEmployee extends RecoveringAction { super(employee, workPeriod); } - public void calculateRecoveringActionCost(boolean[][] currentEmployeesSchedule, ParametersInitialSchedules myScheduleParameters) { + public void calculateRecoveringActionCost(boolean[][] currentEmployeesSchedule, ParametersSchedules myScheduleParameters) { int costBeforeAction = EmployeeCostCalculator.getPartTimeEmployeeCost(currentEmployeesSchedule, this.employee, myScheduleParameters); currentEmployeesSchedule[this.employee][this.workPeriod] = true; int costAfterAction = EmployeeCostCalculator.getPartTimeEmployeeCost(currentEmployeesSchedule, this.employee, myScheduleParameters); diff --git a/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java b/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java index 48b668d..424912b 100644 --- a/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java +++ b/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java @@ -5,8 +5,8 @@ */ package SchedulesRecovery; -import AbsenceSchedules.AbsenceSchedulesArray; -import InitialSchedules.ParametersInitialSchedules; +import ModifiedSchedules.ModifiedSchedulesArray; +import InitialSchedules.ParametersSchedules; /** * @@ -17,19 +17,19 @@ import InitialSchedules.ParametersInitialSchedules; class ValidationRecoveringAction { //Toutes les fonctions sont dedoublees. On devrait faire du polymorphisme. - static boolean isPartTimeEmployeeAvailableForAbsenceRecovering(boolean[][] currentPartTimeSchedule, ParametersInitialSchedules myScheduleParameters, - AbsenceSchedulesArray myabsenceSchedule, int employee, int workPeriod){ - return !currentPartTimeSchedule[employee][workPeriod] && !myabsenceSchedule.isPartTimeEmployeeAbsent(employee, workPeriod) + static boolean isPartTimeEmployeeAvailableForRecovering(boolean[][] currentPartTimeSchedule, ParametersSchedules myScheduleParameters, + ModifiedSchedulesArray myModifiedSchedule, int employee, int workPeriod){ + return !currentPartTimeSchedule[employee][workPeriod] && !myModifiedSchedule.isPartTimeEmployeeAbsent(employee, workPeriod) && isValidPartTimeEmployeeWorkPeriod(currentPartTimeSchedule[employee], workPeriod, myScheduleParameters); } - private static boolean isValidPartTimeEmployeeWorkPeriod(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidPartTimeEmployeeWorkPeriod(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ return isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(currentPartTimeEmployeeSchedule, myScheduleParameters) && isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(currentPartTimeEmployeeSchedule, workPeriod, myScheduleParameters) && isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(currentPartTimeEmployeeSchedule, workPeriod, myScheduleParameters); } - private static boolean isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(boolean[] currentPartTimeEmployeeSchedule, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(boolean[] currentPartTimeEmployeeSchedule, ParametersSchedules myScheduleParameters){ int employeeWorkingPeriods = 0; for ( int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++ ) { if (currentPartTimeEmployeeSchedule[workPeriod]){ @@ -39,7 +39,7 @@ class ValidationRecoveringAction { return employeeWorkingPeriods < myScheduleParameters.getMaxWorkingPeriodsOfPartTimeEmployeesPerSchedule(); } - private static boolean isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ int consecutiveWorkingPeriods = 1; int compteurWorkPeriod = workPeriod - 1; while ( compteurWorkPeriod >= 0 && currentPartTimeEmployeeSchedule[compteurWorkPeriod] ){ @@ -54,7 +54,7 @@ class ValidationRecoveringAction { return consecutiveWorkingPeriods <= myScheduleParameters.getMaxConsecutiveWorkingPeriodsOfPartTimeEmployeesPerShiftWork(); } - private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ int consecutivePreviousNonWorkingPeriods = 0; int compteurWorkPeriod = workPeriod - 1; while ( compteurWorkPeriod >= 0 && !currentPartTimeEmployeeSchedule[compteurWorkPeriod] ){ @@ -86,20 +86,20 @@ class ValidationRecoveringAction { return validConsecutivePreviousNonWorkingPeriods && validConsecutiveNextNonWorkingPeriods; } - public static boolean isFullTimeEmployeeAvailableForAbsenceRecovering(boolean[][] currentFullTimeSchedule, ParametersInitialSchedules myScheduleParameters, - AbsenceSchedulesArray myabsenceSchedule, int employee, int workPeriod){ + public static boolean isFullTimeEmployeeAvailableForRecovering(boolean[][] currentFullTimeSchedule, ParametersSchedules myScheduleParameters, + ModifiedSchedulesArray myModifiedSchedule, int employee, int workPeriod){ - return !currentFullTimeSchedule[employee][workPeriod] && !myabsenceSchedule.isFullTimeEmployeeAbsent(employee, workPeriod) + return !currentFullTimeSchedule[employee][workPeriod] && !myModifiedSchedule.isFullTimeEmployeeAbsent(employee, workPeriod) && isValidFullTimeEmployeeWorkPeriod(currentFullTimeSchedule[employee], workPeriod, myScheduleParameters); } - private static boolean isValidFullTimeEmployeeWorkPeriod(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidFullTimeEmployeeWorkPeriod(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ return isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(currentFullTimeEmployeeSchedule, myScheduleParameters) && isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(currentFullTimeEmployeeSchedule, workPeriod, myScheduleParameters) && isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(currentFullTimeEmployeeSchedule, workPeriod, myScheduleParameters); } - private static boolean isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(boolean[] currentFullTimeEmployeeSchedule, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(boolean[] currentFullTimeEmployeeSchedule, ParametersSchedules myScheduleParameters){ int employeeWorkingPeriods = 0; for ( int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++ ) { if (currentFullTimeEmployeeSchedule[workPeriod]){ @@ -110,7 +110,7 @@ class ValidationRecoveringAction { } - private static boolean isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ int consecutiveWorkingPeriods = 1; int compteurWorkPeriod = workPeriod - 1; while ( compteurWorkPeriod >= 0 && currentFullTimeEmployeeSchedule[compteurWorkPeriod] ){ @@ -125,7 +125,7 @@ class ValidationRecoveringAction { return consecutiveWorkingPeriods <= myScheduleParameters.getMaxConsecutiveWorkingPeriodsOfFullTimeEmployeesPerShiftWork(); } - private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){ + private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){ int consecutivePreviousNonWorkingPeriods = 0; int compteurWorkPeriod = workPeriod - 1; while ( compteurWorkPeriod >= 0 && !currentFullTimeEmployeeSchedule[compteurWorkPeriod] ){ diff --git a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.form b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.form index 42748e9..51a1612 100644 --- a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.form +++ b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.form @@ -3,9 +3,6 @@
- - - diff --git a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java index c500b04..6d1c726 100644 --- a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java +++ b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java @@ -121,7 +121,8 @@ public class ShowSolutionResultsFrame extends javax.swing.JFrame { StringBuilder sbuf = new StringBuilder(); String formattedInitialScedulesArray = ScheduleUtil.PrintSchedules.getFormattedSchedule(bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).initialSchedulesArray); sbuf.append(formattedInitialScedulesArray); - sbuf.append(String.format("%s" + "%.2f","Mean Cost of Recovered Schedules : $", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).meanCostRecoveredSimulations)); + sbuf.append(String.format("%s" + "%.2f" + "%s","Mean Cost of Recovered Schedules : $", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).meanCostRecoveredSimulations, "\n")); + sbuf.append(String.format("%s" + "%d","Number Unresolved Schedules : ", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).numberUnResolvedSimulations)); scheduleViewerArea.setText(sbuf.toString()); } diff --git a/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java b/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java deleted file mode 100644 index ce808c5..0000000 --- a/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java +++ /dev/null @@ -1,20 +0,0 @@ -package VariableDemandSchedules; - -import ScheduleUtil.SchedulesArray; - -import java.util.ArrayList; -import java.util.List; - -public class BankVariableDemandSchedules { - public final SchedulesArray initialSchedulesArray; - public final List bankVariableDemandSimulation; - - public BankVariableDemandSchedules(SchedulesArray initialSchedulesArray) { - this.initialSchedulesArray = initialSchedulesArray; - this.bankVariableDemandSimulation = new ArrayList<>(); - } - - public void addVariableDemandSchedules(VariableDemandSchedulesArray variableDemandSchedulesArray) { - this.bankVariableDemandSimulation.add(variableDemandSchedulesArray); - } -} diff --git a/Travail_de_session/VariableDemandSchedules/ParametersVariableDemandSimulator.java b/Travail_de_session/VariableDemandSchedules/ParametersVariableDemandSimulator.java deleted file mode 100644 index 549e4d6..0000000 --- a/Travail_de_session/VariableDemandSchedules/ParametersVariableDemandSimulator.java +++ /dev/null @@ -1,5 +0,0 @@ -package VariableDemandSchedules; - -public class ParametersVariableDemandSimulator { - public static final int numberVariableDemandSimulation = 1; -} diff --git a/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java b/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java deleted file mode 100644 index 65dc3f9..0000000 --- a/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java +++ /dev/null @@ -1,40 +0,0 @@ -package VariableDemandSchedules; - -import ScheduleUtil.EmployeeCostCalculator; -import ScheduleUtil.SchedulesArray; -import jdistlib.rng.RandomEngine; - -public class VariableDemandSchedulesArray extends SchedulesArray { - private final SchedulesArray initialSchedulesArray; - private SchedulesArray initialSchedulesArrayVariableDemand; - - public VariableDemandSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) { - super(initialSchedulesArray); - this.initialSchedulesArray = initialSchedulesArray; - generateDemandSimulation(r); - this.totalScheduleCost = EmployeeCostCalculator.getFullVariableDemandScheduleCost(this, myParametersInitialSchedules); - } - - private void generateDemandSimulation(RandomEngine r) { - int[] vd = new VariableDemandVector(this.myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getVariableDemandVector(); - int[] adjd = new int[this.myParametersInitialSchedules.getWorkPeriodsPerSchedule()]; - for (int p = 0; p < this.myParametersInitialSchedules.getWorkPeriodsPerSchedule(); p++) { - adjd[p] = /*this.myParametersInitialSchedules.getRequiredWorkForce(p) + */vd[p]; - } - - this.initialSchedulesArrayVariableDemand = new SchedulesArray( - myParametersInitialSchedules, - initialSchedulesArray.fullTimeSchedules, - initialSchedulesArray.partTimeSchedules, - initialSchedulesArray.initialScheduleSolutionNumber, - adjd); - } - - public SchedulesArray getInitialSchedulesArrayVariableDemand() { - return initialSchedulesArrayVariableDemand; - } - - public SchedulesArray getInitialSchedulesArray() { - return initialSchedulesArray; - } -} diff --git a/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java b/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java deleted file mode 100644 index f1d9a55..0000000 --- a/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java +++ /dev/null @@ -1,21 +0,0 @@ -package VariableDemandSchedules; - -import jdistlib.Binomial; -import jdistlib.rng.RandomEngine; - -public class VariableDemandVector { - private int[] VariableDemandVector; - - VariableDemandVector(int length, RandomEngine r) { - VariableDemandVector = new int[length]; - Binomial p1 = new Binomial(1,0.5); - p1.setRandomEngine(r); - for (int i = 0; i < length; i++) { - VariableDemandVector[i] = (int) p1.random(); - } - } - - public int[] getVariableDemandVector() { - return VariableDemandVector; - } -}