From 177435db081a85cc655a884b8acd13247dc34930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Sat, 14 Apr 2018 12:06:25 -0400 Subject: [PATCH] =?UTF-8?q?WIP=20Ajout=20des=20vecteurs=20de=20demande=20m?= =?UTF-8?q?odifi=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbsenceSchedulesArray.java | 4 +- .../AbsenceSchedules/AbsencesVector.java | 2 +- .../BankAbsenceSchedules.java | 5 +- .../ParametersAbsencesSimulator.java | 4 +- .../GenerationPossibleEmployeeSchedules.java | 30 ++++---- ...odelFullTimeEmployeesInitialSchedules.java | 6 +- ...odelPartTimeEmployeesInitialSchedules.java | 6 +- .../ParametersInitialSchedules.java | 76 ++++++++++--------- .../SolverInitialSchedules.java | 7 +- .../InitialSchedules/ValidDailySchedules.java | 16 ++-- .../ValidPartTimeEmployeeShift.java | 4 +- .../ScheduleUtil/EmployeeCostCalculator.java | 14 ++-- .../FullTimeEmployeeScheduleArray.java | 16 ++-- .../PartTimeEmployeeScheduleArray.java | 11 ++- .../ScheduleUtil/SchedulesArray.java | 45 ++++++++--- .../BankRecoveredSchedules.java | 7 +- .../BankRecoveredSchedulesComparator.java | 3 +- .../RecoveredSchedulesArray.java | 19 +++-- .../SchedulesRecovery/RecoveringAction.java | 10 +-- .../RecoveringActionComparator.java | 2 +- .../RecoveringActionFullTimeEmployee.java | 4 +- .../RecoveringActionPartTimeEmployee.java | 9 +-- .../ValidationRecoveringAction.java | 2 +- .../SchedulesWindows/ShowSchedulesFrame.java | 21 ++--- .../ShowSolutionResultsFrame.java | 20 ++--- .../BankVariableDemandSchedules.java | 20 +++++ .../ParametersVariableDemandSimulator.java | 6 ++ .../VariableDemandSchedulesArray.java | 36 +++++++++ .../VariableDemandVector.java | 21 +++++ 29 files changed, 262 insertions(+), 164 deletions(-) create mode 100644 Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java create mode 100644 Travail_de_session/VariableDemandSchedules/ParametersVariableDemandSimulator.java create mode 100644 Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java create mode 100644 Travail_de_session/VariableDemandSchedules/VariableDemandVector.java diff --git a/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java b/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java index ef1c91d..c0f216e 100644 --- a/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java +++ b/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java @@ -5,8 +5,8 @@ import ScheduleUtil.SchedulesArray; import jdistlib.rng.RandomEngine; public class AbsenceSchedulesArray extends SchedulesArray{ - - public SchedulesArray initialSchedulesArray; + + private final SchedulesArray initialSchedulesArray; public int numberOfRecoveringActionsToPerform; public AbsenceSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) { diff --git a/Travail_de_session/AbsenceSchedules/AbsencesVector.java b/Travail_de_session/AbsenceSchedules/AbsencesVector.java index bb141de..9a29ffb 100644 --- a/Travail_de_session/AbsenceSchedules/AbsencesVector.java +++ b/Travail_de_session/AbsenceSchedules/AbsencesVector.java @@ -3,7 +3,7 @@ package AbsenceSchedules; import jdistlib.Binomial; import jdistlib.rng.RandomEngine; -public class AbsencesVector { +class AbsencesVector { private final boolean[] AbsencesVector; public AbsencesVector(int length, RandomEngine r) { diff --git a/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java b/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java index bcf86bb..907c454 100644 --- a/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java +++ b/Travail_de_session/AbsenceSchedules/BankAbsenceSchedules.java @@ -6,6 +6,7 @@ package AbsenceSchedules; import ScheduleUtil.SchedulesArray; + import java.util.ArrayList; import java.util.List; @@ -14,8 +15,8 @@ import java.util.List; * @author frabe */ public class BankAbsenceSchedules { - public SchedulesArray initialSchedulesArray; - public List bankAbsenceSimulation; + public final SchedulesArray initialSchedulesArray; + public final List bankAbsenceSimulation; public BankAbsenceSchedules(SchedulesArray initialSchedulesArray) { this.initialSchedulesArray = initialSchedulesArray; diff --git a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java b/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java index c5e46a5..e0ae85c 100644 --- a/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java +++ b/Travail_de_session/AbsenceSchedules/ParametersAbsencesSimulator.java @@ -10,7 +10,7 @@ package AbsenceSchedules; * @author frabe */ public class ParametersAbsencesSimulator { - public static double probPresence = 0.99; + public static final double probPresence = 0.99; public static final double probReturn = 0.50; - public static int numberAbsenceSimulations = 1000; + public static final int numberAbsenceSimulations = 1000; } diff --git a/Travail_de_session/InitialSchedules/GenerationPossibleEmployeeSchedules.java b/Travail_de_session/InitialSchedules/GenerationPossibleEmployeeSchedules.java index 135ded1..5cc586b 100644 --- a/Travail_de_session/InitialSchedules/GenerationPossibleEmployeeSchedules.java +++ b/Travail_de_session/InitialSchedules/GenerationPossibleEmployeeSchedules.java @@ -11,13 +11,12 @@ import org.chocosolver.solver.constraints.extension.Tuples; * * @author frabe */ -public class GenerationPossibleEmployeeSchedules { +class GenerationPossibleEmployeeSchedules { public static Tuples setWorkPeriodsSchedulesOfFullTimeEmployees(int shiftWorkPerDay, int workPeriodsPerSchedule, int workPeriodPerDay, int daysPerSchedule) { ValidDailySchedules validDailyFullTimeSchedules = new ValidDailySchedules(daysPerSchedule, 10, 10, - 0, 5, 7, 12, @@ -35,28 +34,28 @@ public class GenerationPossibleEmployeeSchedules { for (int day = 0; day < daysPerSchedule; day++) { for (int shiftNumber = 0; shiftNumber < shiftWorkPerDay; shiftNumber++) { if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 0) { - workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 0] = 1; + workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay] = 1; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 1] = 1; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 3] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 4] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 1) { - workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 2] = 1; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 3] = 1; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 4] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 2) { - workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 3] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 4] = 1; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 5] = 1; } else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 0) { - workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 3] = 0; @@ -68,8 +67,7 @@ public class GenerationPossibleEmployeeSchedules { } // Creation des tuples a partir du tableau pour creer les 3 types de quart de travail (nuit, jour soir). - Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees = new Tuples(workPeriodsSchedulesOfFullTimeEmployees, true); - return enumerationWorkPeriodsSchedulesOfFullTimeEmployees; + return new Tuples(workPeriodsSchedulesOfFullTimeEmployees, true); } public static Tuples setWorkPeriodsSchedulesOfPartTimeEmployees(int workPeriodsPerSchedule, int workPeriodPerDay, int daysPerSchedule) { @@ -79,7 +77,6 @@ public class GenerationPossibleEmployeeSchedules { 0, 0, 0, - 0, 6); int NbPartTimeSolutions = validDailyPartTimeSchedules.getNbSolutions(); @@ -96,42 +93,42 @@ public class GenerationPossibleEmployeeSchedules { for (int day = 0; day < daysPerSchedule; day++) { for (int shiftNumber = 0; shiftNumber < maxShiftConfig; shiftNumber++) { if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 0) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 1; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 4] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 1) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 4] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 2) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 4] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 3) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 4] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 0; } else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 4) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 4] = 1; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 1; } else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 0) { - workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 0] = 0; + workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 1] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 2] = 0; workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 3] = 0; @@ -143,7 +140,6 @@ public class GenerationPossibleEmployeeSchedules { } // Creation des tuples a partir du tableau pour creer les 3 types de quart de travail (nuit, jour soir). - Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees = new Tuples(workPeriodsSchedulesOfPartTimeEmployees, true); - return enumerationWorkPeriodsSchedulesOfPartTimeEmployees; + return new Tuples(workPeriodsSchedulesOfPartTimeEmployees, true); } } diff --git a/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java b/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java index e0ad052..c8c9a68 100644 --- a/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ModelFullTimeEmployeesInitialSchedules.java @@ -14,16 +14,16 @@ import org.chocosolver.solver.variables.IntVar; * @author frabe */ public class ModelFullTimeEmployeesInitialSchedules { - public ParametersInitialSchedules myScheduleParameters; + public final ParametersInitialSchedules myScheduleParameters; - public int numberOfFullTimeEmployees; + public final int numberOfFullTimeEmployees; public BoolVar workPeriodsSchedulesOfFullTimeEmployees[][]; private BoolVar transposeWorkPeriodsSchedulesOfFullTimeEmployees[][]; private IntVar fullTimeEmployeesPerWorkPeriods[]; - public Model chocoModelInitialSchedules; + public final Model chocoModelInitialSchedules; public ModelFullTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters, int numberOfFullTimeEmployees) { diff --git a/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java b/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java index 5b4e1e8..a2bfd32 100644 --- a/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ModelPartTimeEmployeesInitialSchedules.java @@ -6,16 +6,16 @@ import org.chocosolver.solver.variables.IntVar; public class ModelPartTimeEmployeesInitialSchedules { - public ParametersInitialSchedules myScheduleParameters; + public final ParametersInitialSchedules myScheduleParameters; - public int maxPartTimeEmployee; + public final int maxPartTimeEmployee; public BoolVar workPeriodsSchedulesOfPartTimeEmployees[][]; private BoolVar transposeWorkPeriodsSchedulesOfPartTimeEmployees[][]; private IntVar partTimeEmployeesPerWorkPeriods[]; - public Model chocoModelInitialSchedules; + public final Model chocoModelInitialSchedules; public ModelPartTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters) { diff --git a/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java b/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java index 9b3cd54..a524771 100644 --- a/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/ParametersInitialSchedules.java @@ -6,37 +6,37 @@ import org.chocosolver.solver.constraints.extension.Tuples; public class ParametersInitialSchedules { //General Parameters - final int shiftWorkPerDay = 3; - final int daysPerSchedule = 14; - final int hoursPerWorkPeriod = 4; - final int workingHoursPaidAtRegularHourlyRatePerSchedule = 80; - final int workingHoursPaidAtRegularHourlyRatePerShiftWork = 8; + private final int shiftWorkPerDay = 3; + private final int daysPerSchedule = 14; + private final int hoursPerWorkPeriod = 4; + private final int workingHoursPaidAtRegularHourlyRatePerSchedule = 80; + private final int workingHoursPaidAtRegularHourlyRatePerShiftWork = 8; //PartTime Employees Parameters - final int fixedCostOfPartTimeEmployeesPerSchedule = 50; - final int regularHourlyRateOfPartTimeEmployees = 12; - final int overtimeHourlyRateOfPartTimeEmployees = 17; - final int minWorkingHoursOfPartTimeEmployeesPerSchedule = 32; - final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 64; - final int maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork = 12; - final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees = 12; + private final int fixedCostOfPartTimeEmployeesPerSchedule = 50; + private final int regularHourlyRateOfPartTimeEmployees = 12; + private final int overtimeHourlyRateOfPartTimeEmployees = 17; + private final int minWorkingHoursOfPartTimeEmployeesPerSchedule = 32; + private final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 64; + private final int maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork = 12; + private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees = 12; //FullTime Employees Parameters - final int fixedCostOfFullTimeEmployeesPerSchedule = 50; - final int regularHourlyRateOfFullTimeEmployees = 10; - final int overtimeHourlyRateOfFullTimeEmployees = 15; - final int workingHoursOfFullTimeEmployeesPerSchedule = 80; - final int maxWorkingHoursOfFullTimeEmployeesPerSchedule = 120; - final int maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork = 12; - final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12; + private final int fixedCostOfFullTimeEmployeesPerSchedule = 50; + private final int regularHourlyRateOfFullTimeEmployees = 10; + private final int overtimeHourlyRateOfFullTimeEmployees = 15; + private final int workingHoursOfFullTimeEmployeesPerSchedule = 80; + private final int maxWorkingHoursOfFullTimeEmployeesPerSchedule = 120; + private final int maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork = 12; + private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12; int[] requiredWorkforce; int NbFullTimeSolutions; int NbPartTimeSolutions; Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees; Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees; - Tuples ValidPartTimeEmployeeShiftTuples; + private Tuples ValidPartTimeEmployeeShiftTuples; public ParametersInitialSchedules() { @@ -77,6 +77,10 @@ public class ParametersInitialSchedules { public int getRequiredWorkForce(int workPeriod) { return this.requiredWorkforce[workPeriod]; } + + public void setRequiredWorkforce(int[] vector) { + this.requiredWorkforce = vector; + } public int getDaysPerSchedule() { return daysPerSchedule; @@ -87,7 +91,7 @@ public class ParametersInitialSchedules { } public int getWorkPeriodPerDay() { - return (int) 24/this.hoursPerWorkPeriod; + return 24 / this.hoursPerWorkPeriod; } public int getFixedCostOfPartTimeEmployeesPerSchedule() { @@ -99,64 +103,64 @@ public class ParametersInitialSchedules { } public int getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule () { - return (int) (workingHoursPaidAtRegularHourlyRatePerSchedule / this.hoursPerWorkPeriod); + return workingHoursPaidAtRegularHourlyRatePerSchedule / this.hoursPerWorkPeriod; } public int getWorkingPeriodsPaidAtRegularHourlyRatePerShiftWork () { - return (int) (workingHoursPaidAtRegularHourlyRatePerShiftWork / this.hoursPerWorkPeriod); + return workingHoursPaidAtRegularHourlyRatePerShiftWork / this.hoursPerWorkPeriod; } public int getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate () { - return (int) (regularHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod); + return regularHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod; } public int getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate () { - return (int) (regularHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod); + return regularHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod; } public int getMinimumWorkingPeriodCost () { - return (int) (regularHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod); + return regularHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod; } public int getWorkingPeriodCostOfPartTimeEmployeesPaidAtOvertimeHourlyRate () { - return (int) (overtimeHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod); + return overtimeHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod; } public int getWorkingPeriodCostOfFullTimeEmployeesPaidAtOvertimeHourlyRate () { - return (int) (overtimeHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod); + return overtimeHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod; } public int getMaxConsecutiveWorkingPeriodsOfFullTimeEmployeesPerShiftWork () { - return (int) (maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod); + return maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod; } public int getMaxConsecutiveWorkingPeriodsOfPartTimeEmployeesPerShiftWork () { - return (int) (maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod); + return maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod; } public int getMinConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployees () { - return (int) (minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees / this.hoursPerWorkPeriod); + return minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees / this.hoursPerWorkPeriod; } public int getMinConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployees () { - return (int) (minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees / this.hoursPerWorkPeriod); + return minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees / this.hoursPerWorkPeriod; } public int getMaxWorkingPeriodsOfPartTimeEmployeesPerSchedule () { - return (int) (this.maxWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod); + return this.maxWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod; } public int getMaxWorkingPeriodsOfFullTimeEmployeesPerSchedule () { - return (int) (this.maxWorkingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod); + return this.maxWorkingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod; } public int getMinWorkingPeriodsOfPartTimeEmployeesPerSchedule () { - return (int) (this.minWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod); + return this.minWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod; } public int getWorkingPeriodsOfFullTimeEmployeesPerSchedule () { - return (int) (this.workingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod); + return this.workingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod; } // A implementer plus tard si l'on veut travailler avec des fichiers texte diff --git a/Travail_de_session/InitialSchedules/SolverInitialSchedules.java b/Travail_de_session/InitialSchedules/SolverInitialSchedules.java index fefb543..c56c990 100644 --- a/Travail_de_session/InitialSchedules/SolverInitialSchedules.java +++ b/Travail_de_session/InitialSchedules/SolverInitialSchedules.java @@ -5,20 +5,21 @@ */ package InitialSchedules; -import java.util.List; import org.chocosolver.solver.Solution; import org.chocosolver.solver.Solver; import org.chocosolver.solver.exception.ContradictionException; import org.chocosolver.solver.search.limits.BacktrackCounter; import org.chocosolver.solver.search.restart.MonotonicRestartStrategy; +import java.util.List; + /** * * @author frabe */ public class SolverInitialSchedules { - - Solver solverInitialSchedules; + + private final Solver solverInitialSchedules; public SolverInitialSchedules (ModelFullTimeEmployeesInitialSchedules myModelFullTimeEmployeesInitialSchedules){ diff --git a/Travail_de_session/InitialSchedules/ValidDailySchedules.java b/Travail_de_session/InitialSchedules/ValidDailySchedules.java index d94c36d..dc942a0 100644 --- a/Travail_de_session/InitialSchedules/ValidDailySchedules.java +++ b/Travail_de_session/InitialSchedules/ValidDailySchedules.java @@ -8,12 +8,12 @@ import org.chocosolver.solver.variables.IntVar; import java.util.List; -public class ValidDailySchedules { +class ValidDailySchedules { - int[][] ValidSchedules; - private int nbSolutions; + private final int[][] ValidSchedules; + private final int nbSolutions; - ValidDailySchedules(int nbPeriodes, int nbPeriodesTravailleesMin, int nbPeriodesTravailleesMax, int p1Min, int p1Max, int p2Min, int p2Max, int nbMaxConsecutif) { + ValidDailySchedules(int nbPeriodes, int nbPeriodesTravailleesMin, int nbPeriodesTravailleesMax, int p1Max, int p2Min, int p2Max, int nbMaxConsecutif) { Model model = new Model("Horaire de " + nbPeriodes + "-periodes"); BoolVar[] horaire = new BoolVar[nbPeriodes]; @@ -21,14 +21,14 @@ public class ValidDailySchedules { horaire[p] = model.boolVar("P_" + p); } - BoolVar[] horaires1 = new BoolVar[p1Max - p1Min]; - BoolVar[] horaires2 = new BoolVar[p1Max - p1Min]; + BoolVar[] horaires1 = new BoolVar[p1Max - 0]; + BoolVar[] horaires2 = new BoolVar[p1Max - 0]; IntVar sumhoraire1 = model.intVar("SP_1", 0, nbPeriodes); IntVar sumhoraire2 = model.intVar("SP_2", 0, nbPeriodes); - for (int p = 0; p < p1Max - p1Min; p++) horaires1[p] = horaire[p1Min + p]; - for (int p = 0; p < p2Max - p2Min; p++) horaires2[p] = horaire[p2Min + p]; + System.arraycopy(horaire, 0 + 0, horaires1, 0, p1Max - 0); + System.arraycopy(horaire, p2Min + 0, horaires2, 0, p2Max - p2Min); /* Travaille entre le nombre minimum et maximum de périodes */ model.sum(horaire, ">=", nbPeriodesTravailleesMin).post(); diff --git a/Travail_de_session/InitialSchedules/ValidPartTimeEmployeeShift.java b/Travail_de_session/InitialSchedules/ValidPartTimeEmployeeShift.java index a319262..35171d2 100644 --- a/Travail_de_session/InitialSchedules/ValidPartTimeEmployeeShift.java +++ b/Travail_de_session/InitialSchedules/ValidPartTimeEmployeeShift.java @@ -2,8 +2,8 @@ package InitialSchedules; import org.chocosolver.solver.constraints.extension.Tuples; -public class ValidPartTimeEmployeeShift { - int[][] shiftsOfPartTimeEmployees; +class ValidPartTimeEmployeeShift { + private final int[][] shiftsOfPartTimeEmployees; public ValidPartTimeEmployeeShift() { this.shiftsOfPartTimeEmployees = new int[][]{ diff --git a/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java b/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java index 3995c97..c6ec7f6 100644 --- a/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java +++ b/Travail_de_session/ScheduleUtil/EmployeeCostCalculator.java @@ -76,17 +76,20 @@ public class EmployeeCostCalculator { public static int getPartTimeEmployeeCost(boolean[][] currentEmployeesSchedule, int employee, ParametersInitialSchedules myScheduleParameters) { int numberWorkingPeriod = 0; for (int workPeriod = 0 ; workPeriod < currentEmployeesSchedule.length ; workPeriod++) { - if (currentEmployeesSchedule[employee][workPeriod] == true){numberWorkingPeriod++;} + if (currentEmployeesSchedule[employee][workPeriod]) { + numberWorkingPeriod++; + } } - int totalCost = myScheduleParameters.getFixedCostOfPartTimeEmployeesPerSchedule() + + return myScheduleParameters.getFixedCostOfPartTimeEmployeesPerSchedule() + numberWorkingPeriod * myScheduleParameters.getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate(); - return totalCost; } public static int getFullTimeEmployeeCost(boolean[][] currentEmployeesSchedule, AbsenceSchedulesArray myAbsenceSchedule, int employee, ParametersInitialSchedules myScheduleParameters) { int numberWorkingPeriod = 0; for (int workPeriod = 0 ; workPeriod < currentEmployeesSchedule.length ; workPeriod++) { - if (currentEmployeesSchedule[employee][workPeriod] == true){numberWorkingPeriod++;} + if (currentEmployeesSchedule[employee][workPeriod]) { + numberWorkingPeriod++; + } } int numberAbsencePeriod = myAbsenceSchedule.getAbsencePeriodsPerFullTimeEmployees(employee); int regularHourlyRateCost; int overtimeHourlyRateCost; @@ -99,7 +102,6 @@ public class EmployeeCostCalculator { overtimeHourlyRateCost = (numberWorkingPeriod + numberAbsencePeriod - myScheduleParameters.getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule()) * myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtOvertimeHourlyRate(); } - int totalCost = myScheduleParameters.getFixedCostOfFullTimeEmployeesPerSchedule() + regularHourlyRateCost + overtimeHourlyRateCost; - return totalCost; + return myScheduleParameters.getFixedCostOfFullTimeEmployeesPerSchedule() + regularHourlyRateCost + overtimeHourlyRateCost; } } diff --git a/Travail_de_session/ScheduleUtil/FullTimeEmployeeScheduleArray.java b/Travail_de_session/ScheduleUtil/FullTimeEmployeeScheduleArray.java index e33d346..55880e0 100644 --- a/Travail_de_session/ScheduleUtil/FullTimeEmployeeScheduleArray.java +++ b/Travail_de_session/ScheduleUtil/FullTimeEmployeeScheduleArray.java @@ -5,7 +5,8 @@ */ package ScheduleUtil; -import InitialSchedules.*; +import InitialSchedules.ModelFullTimeEmployeesInitialSchedules; +import InitialSchedules.ParametersInitialSchedules; import org.chocosolver.solver.Solution; /** @@ -14,20 +15,19 @@ import org.chocosolver.solver.Solution; */ public class FullTimeEmployeeScheduleArray { public int initialScheduleSolutionNumber; - public boolean[][] fullTimeSchedules; - protected ParametersInitialSchedules myParametersInitialSchedules; + public final boolean[][] fullTimeSchedules; + final ParametersInitialSchedules myParametersInitialSchedules; public FullTimeEmployeeScheduleArray(ModelFullTimeEmployeesInitialSchedules m, Solution s) { this.myParametersInitialSchedules = m.myScheduleParameters; - Solution mySolution = s; - + this.fullTimeSchedules = new boolean[getNumberOfFullTimeEmployees(s, m)][myParametersInitialSchedules.getWorkPeriodsPerSchedule()]; int fullTimeEmployee = 0; for (int i = 0; i < m.numberOfFullTimeEmployees; i++) { if (isFullTimeEmployeeActive (i, s, m)) { for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { - this.fullTimeSchedules[fullTimeEmployee][workPeriod] = mySolution.getIntVal(m.workPeriodsSchedulesOfFullTimeEmployees[i][workPeriod]) == 1; + this.fullTimeSchedules[fullTimeEmployee][workPeriod] = s.getIntVal(m.workPeriodsSchedulesOfFullTimeEmployees[i][workPeriod]) == 1; } fullTimeEmployee++; } @@ -63,8 +63,8 @@ public class FullTimeEmployeeScheduleArray { } return employeesWorking; } - - public int getNumberFullTimeEmployee() { + + private int getNumberFullTimeEmployee() { return this.fullTimeSchedules.length; } } diff --git a/Travail_de_session/ScheduleUtil/PartTimeEmployeeScheduleArray.java b/Travail_de_session/ScheduleUtil/PartTimeEmployeeScheduleArray.java index fd5f4e7..b9f3ce9 100644 --- a/Travail_de_session/ScheduleUtil/PartTimeEmployeeScheduleArray.java +++ b/Travail_de_session/ScheduleUtil/PartTimeEmployeeScheduleArray.java @@ -5,7 +5,7 @@ */ package ScheduleUtil; -import InitialSchedules.*; +import InitialSchedules.ModelPartTimeEmployeesInitialSchedules; import InitialSchedules.ParametersInitialSchedules; import org.chocosolver.solver.Solution; @@ -15,20 +15,19 @@ import org.chocosolver.solver.Solution; */ public class PartTimeEmployeeScheduleArray { public int initialScheduleSolutionNumber; - public boolean[][] partTimeSchedules; - protected ParametersInitialSchedules myParametersInitialSchedules; + public final boolean[][] partTimeSchedules; + private final ParametersInitialSchedules myParametersInitialSchedules; public PartTimeEmployeeScheduleArray(ModelPartTimeEmployeesInitialSchedules m, Solution s) { this.myParametersInitialSchedules = m.myScheduleParameters; - Solution mySolution = s; - + this.partTimeSchedules = new boolean[getNumberOfFullTimeEmployees(s, m)][myParametersInitialSchedules.getWorkPeriodsPerSchedule()]; int partTimeEmployee = 0; for (int i = 0; i < m.maxPartTimeEmployee; i++) { if (isPartTimeEmployeeActive (i, s, m)) { for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { - this.partTimeSchedules[partTimeEmployee][workPeriod] = mySolution.getIntVal(m.workPeriodsSchedulesOfPartTimeEmployees[i][workPeriod]) == 1; + this.partTimeSchedules[partTimeEmployee][workPeriod] = s.getIntVal(m.workPeriodsSchedulesOfPartTimeEmployees[i][workPeriod]) == 1; } partTimeEmployee++; } diff --git a/Travail_de_session/ScheduleUtil/SchedulesArray.java b/Travail_de_session/ScheduleUtil/SchedulesArray.java index 905ce1a..b27a00a 100644 --- a/Travail_de_session/ScheduleUtil/SchedulesArray.java +++ b/Travail_de_session/ScheduleUtil/SchedulesArray.java @@ -5,8 +5,7 @@ */ package ScheduleUtil; -import InitialSchedules.*; -import org.chocosolver.solver.Solution; +import InitialSchedules.ParametersInitialSchedules; /** * @@ -14,11 +13,11 @@ import org.chocosolver.solver.Solution; */ //Dans cette classe, toutes les fonctions sont dedoublees. On devrait faire du polymorphisme. public class SchedulesArray { - public int initialScheduleSolutionNumber; + public final int initialScheduleSolutionNumber; public boolean[][] partTimeSchedules; public boolean[][] fullTimeSchedules; public int totalScheduleCost; - protected ParametersInitialSchedules myParametersInitialSchedules; + protected final ParametersInitialSchedules myParametersInitialSchedules; // Constructeur Copie protected SchedulesArray(SchedulesArray myScheduleArray) { @@ -39,6 +38,28 @@ public class SchedulesArray { this.totalScheduleCost = EmployeeCostCalculator.getFullInitialScheduleCost(this, myParametersInitialSchedules); } + + + /** + * This method creates a SchedulesArray with a modified required workforce vector + * + * @param myParametersInitialSchedules Parameters from initial schedule + * @param fteisa initial schedules array for full time employees + * @param pteisa initial schedules array for part time employees + * @param scheduleNumber Schedule number that comes from the initial Choco solution + * @param VariableDemandVector new required workforce vector + */ + public SchedulesArray(ParametersInitialSchedules myParametersInitialSchedules, boolean[][] fteisa, boolean[][] pteisa, int scheduleNumber, int[] VariableDemandVector) { + + this.initialScheduleSolutionNumber = scheduleNumber; + this.myParametersInitialSchedules = myParametersInitialSchedules; + this.myParametersInitialSchedules.setRequiredWorkforce(VariableDemandVector); + + this.partTimeSchedules = pteisa; + this.fullTimeSchedules = fteisa; + + this.totalScheduleCost = EmployeeCostCalculator.getFullInitialScheduleCost(this, myParametersInitialSchedules); + } protected boolean[][] getDeepCopyEmployeesSchedules(boolean[][] schedules) { int nbrEmployee = schedules.length; @@ -58,20 +79,22 @@ public class SchedulesArray { if (this.partTimeSchedules[employee][workPeriod]) {employeesWorking += 1;} } for (int employee = 0; employee < this.getNumberFullTimeEmployee(); employee++) { - if (this.fullTimeSchedules[employee][workPeriod]) {employeesWorking += 1;} + if (this.fullTimeSchedules[employee][workPeriod]) { + employeesWorking += 1; + } } return employeesWorking; } - - protected int getWorkingPeriodsPerPartTimeEmployees(int employee) { + + public int getWorkingPeriodsPerPartTimeEmployees(int employee) { int workingPeriodsPerPartTimeEmployees = 0; for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { if (this.partTimeSchedules[employee][workPeriod]) {workingPeriodsPerPartTimeEmployees += 1;} } return workingPeriodsPerPartTimeEmployees; } - - protected int getWorkingPeriodsPerFullTimeEmployees(int employee) { + + public int getWorkingPeriodsPerFullTimeEmployees(int employee) { int workingPeriodsPerFullTimeEmployees = 0; for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) { if (this.fullTimeSchedules[employee][workPeriod]) {workingPeriodsPerFullTimeEmployees += 1;} @@ -92,11 +115,11 @@ public class SchedulesArray { } public boolean isPartTimeEmployeeWorking(int employee, int workPeriod) { - return partTimeSchedules[employee][workPeriod] == true; + return partTimeSchedules[employee][workPeriod]; } public boolean isFullTimeEmployeeWorking(int employee, int workPeriod) { - return fullTimeSchedules[employee][workPeriod] == true; + return fullTimeSchedules[employee][workPeriod]; } } diff --git a/Travail_de_session/SchedulesRecovery/BankRecoveredSchedules.java b/Travail_de_session/SchedulesRecovery/BankRecoveredSchedules.java index d8f9165..642b6d3 100644 --- a/Travail_de_session/SchedulesRecovery/BankRecoveredSchedules.java +++ b/Travail_de_session/SchedulesRecovery/BankRecoveredSchedules.java @@ -7,6 +7,7 @@ package SchedulesRecovery; import AbsenceSchedules.AbsenceSchedulesArray; import ScheduleUtil.SchedulesArray; + import java.util.ArrayList; import java.util.List; @@ -15,9 +16,9 @@ import java.util.List; * @author frabe */ public class BankRecoveredSchedules { - public SchedulesArray initialSchedulesArray; - public List bankRecoveredSimulation; - public List bankAbsenceSimulation; + public final SchedulesArray initialSchedulesArray; + public final List bankRecoveredSimulation; + private final List bankAbsenceSimulation; public double meanCostRecoveredSimulations; public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List bankAbsenceSimulation) { diff --git a/Travail_de_session/SchedulesRecovery/BankRecoveredSchedulesComparator.java b/Travail_de_session/SchedulesRecovery/BankRecoveredSchedulesComparator.java index 303920c..341c387 100644 --- a/Travail_de_session/SchedulesRecovery/BankRecoveredSchedulesComparator.java +++ b/Travail_de_session/SchedulesRecovery/BankRecoveredSchedulesComparator.java @@ -17,7 +17,6 @@ public class BankRecoveredSchedulesComparator implements Comparator< BankRecover if (meanCostCmp !=0) { return meanCostCmp; } - int simNumberCmp = Integer.compare(b1.initialSchedulesArray.initialScheduleSolutionNumber, b2.initialSchedulesArray.initialScheduleSolutionNumber); - return simNumberCmp; + return Integer.compare(b1.initialSchedulesArray.initialScheduleSolutionNumber, b2.initialSchedulesArray.initialScheduleSolutionNumber); } } diff --git a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java index 66ce8c1..459d96a 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java +++ b/Travail_de_session/SchedulesRecovery/RecoveredSchedulesArray.java @@ -6,16 +6,19 @@ package SchedulesRecovery; import AbsenceSchedules.AbsenceSchedulesArray; +import ScheduleUtil.EmployeeCostCalculator; +import ScheduleUtil.SchedulesArray; + import java.util.*; -import ScheduleUtil.*; /** * * @author frabe */ +@SuppressWarnings("unchecked") public class RecoveredSchedulesArray extends SchedulesArray{ - - public AbsenceSchedulesArray absenceSchedulesArray; + + public final AbsenceSchedulesArray absenceSchedulesArray; public RecoveredSchedulesArray(AbsenceSchedulesArray absenceSchedulesArray){ super(absenceSchedulesArray); @@ -140,7 +143,7 @@ public class RecoveredSchedulesArray extends SchedulesArray{ && !alreadyRecoveredWorkPeriodByPartTimeEmployees[partTimeEmployee][remainingRecoveringAction-1]){ RecoveringActionPartTimeEmployee recoveringAction = new RecoveringActionPartTimeEmployee(partTimeEmployee, workPeriod); - recoveringAction.calculateRecoveringActionCost (currentPartTimeSchedule, absenceSchedulesArray, myParametersInitialSchedules); + recoveringAction.calculateRecoveringActionCost(currentPartTimeSchedule, myParametersInitialSchedules); recoveringActionsOrderedByCost.add(recoveringAction); } } @@ -162,13 +165,13 @@ public class RecoveredSchedulesArray extends SchedulesArray{ int workingEmployees; for (int workPeriod = 0 ; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule() ; workPeriod++) { workingEmployees = 0; - for (int partTimeEmployee = 0 ; partTimeEmployee < currentPartTimeSchedule.length ; partTimeEmployee++) { - if ( currentPartTimeSchedule[partTimeEmployee][workPeriod] ) { + for (boolean[] aCurrentPartTimeSchedule : currentPartTimeSchedule) { + if (aCurrentPartTimeSchedule[workPeriod]) { workingEmployees++; } } - for (int fullTimeEmployee = 0 ; fullTimeEmployee < currentFullTimeSchedule.length ; fullTimeEmployee++) { - if ( currentFullTimeSchedule[fullTimeEmployee][workPeriod] ) { + for (boolean[] aCurrentFullTimeSchedule : currentFullTimeSchedule) { + if (aCurrentFullTimeSchedule[workPeriod]) { workingEmployees++; } } diff --git a/Travail_de_session/SchedulesRecovery/RecoveringAction.java b/Travail_de_session/SchedulesRecovery/RecoveringAction.java index afb99d7..aa78eea 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringAction.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringAction.java @@ -9,12 +9,12 @@ package SchedulesRecovery; * * @author frabe */ -public class RecoveringAction { - public int employee; - public int workPeriod; +class RecoveringAction { + public final int employee; + public final int workPeriod; public int recoveringActionCost; - - public RecoveringAction( int employee, int workPeriod){ + + RecoveringAction(int employee, int workPeriod) { this.employee = employee; this.workPeriod = workPeriod; } diff --git a/Travail_de_session/SchedulesRecovery/RecoveringActionComparator.java b/Travail_de_session/SchedulesRecovery/RecoveringActionComparator.java index 72cf651..0d35e8c 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringActionComparator.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringActionComparator.java @@ -11,7 +11,7 @@ import java.util.Comparator; * @author frabe */ -public class RecoveringActionComparator implements Comparator< RecoveringAction > { +class RecoveringActionComparator implements Comparator { public int compare(RecoveringAction a2, RecoveringAction a1) { return Integer.compare(a1.recoveringActionCost, a2.recoveringActionCost); } diff --git a/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java b/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java index 368d8e0..8011852 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringActionFullTimeEmployee.java @@ -7,13 +7,13 @@ package SchedulesRecovery; import AbsenceSchedules.AbsenceSchedulesArray; import InitialSchedules.ParametersInitialSchedules; -import ScheduleUtil.*; +import ScheduleUtil.EmployeeCostCalculator; /** * * @author frabe */ -public class RecoveringActionFullTimeEmployee extends RecoveringAction{ +class RecoveringActionFullTimeEmployee extends RecoveringAction { public RecoveringActionFullTimeEmployee( int employee, int workPeriod){ super(employee, workPeriod); diff --git a/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java b/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java index 2779e73..3c3ea0e 100644 --- a/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java +++ b/Travail_de_session/SchedulesRecovery/RecoveringActionPartTimeEmployee.java @@ -5,21 +5,20 @@ */ package SchedulesRecovery; -import AbsenceSchedules.AbsenceSchedulesArray; import InitialSchedules.ParametersInitialSchedules; -import ScheduleUtil.*; +import ScheduleUtil.EmployeeCostCalculator; /** * * @author frabe */ -public class RecoveringActionPartTimeEmployee extends RecoveringAction{ +class RecoveringActionPartTimeEmployee extends RecoveringAction { public RecoveringActionPartTimeEmployee( int employee, int workPeriod){ super(employee, workPeriod); } - - public void calculateRecoveringActionCost ( boolean[][] currentEmployeesSchedule,AbsenceSchedulesArray absenceSchedulesArray, ParametersInitialSchedules myScheduleParameters) { + + public void calculateRecoveringActionCost(boolean[][] currentEmployeesSchedule, ParametersInitialSchedules 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 a21db5a..48b668d 100644 --- a/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java +++ b/Travail_de_session/SchedulesRecovery/ValidationRecoveringAction.java @@ -14,7 +14,7 @@ import InitialSchedules.ParametersInitialSchedules; */ // classe statique pour mettre fonction utilitaire -public class ValidationRecoveringAction { +class ValidationRecoveringAction { //Toutes les fonctions sont dedoublees. On devrait faire du polymorphisme. static boolean isPartTimeEmployeeAvailableForAbsenceRecovering(boolean[][] currentPartTimeSchedule, ParametersInitialSchedules myScheduleParameters, diff --git a/Travail_de_session/SchedulesWindows/ShowSchedulesFrame.java b/Travail_de_session/SchedulesWindows/ShowSchedulesFrame.java index 3cb143b..dd13b92 100644 --- a/Travail_de_session/SchedulesWindows/ShowSchedulesFrame.java +++ b/Travail_de_session/SchedulesWindows/ShowSchedulesFrame.java @@ -5,7 +5,7 @@ */ package SchedulesWindows; -import java.util.*; +import java.util.List; /** * @@ -13,8 +13,8 @@ import java.util.*; */ public class ShowSchedulesFrame extends javax.swing.JFrame { - private List schedulesArrayList; - private String title; + private final List schedulesArrayList; + private final String title; /** * Creates new form ShowSchedulesFrame **/ @@ -40,20 +40,16 @@ public class ShowSchedulesFrame extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - mainPanel = new javax.swing.JPanel(); + javax.swing.JPanel mainPanel = new javax.swing.JPanel(); changeScheduleNumberScrollBar = new javax.swing.JScrollBar(); - jScrollPane1 = new javax.swing.JScrollPane(); + javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); scheduleViewerArea = new javax.swing.JTextArea(); - jLabel1 = new javax.swing.JLabel(); + javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); textSolutionNumber = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - changeScheduleNumberScrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() { - public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) { - changeScheduleNumberScrollBarAdjustmentValueChanged(evt); - } - }); + changeScheduleNumberScrollBar.addAdjustmentListener(evt -> changeScheduleNumberScrollBarAdjustmentValueChanged(evt)); scheduleViewerArea.setEditable(false); scheduleViewerArea.setColumns(20); @@ -124,9 +120,6 @@ public class ShowSchedulesFrame extends javax.swing.JFrame { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollBar changeScheduleNumberScrollBar; - private javax.swing.JLabel jLabel1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JPanel mainPanel; private javax.swing.JTextArea scheduleViewerArea; private javax.swing.JLabel textSolutionNumber; // End of variables declaration//GEN-END:variables diff --git a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java index c55c8c7..c500b04 100644 --- a/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java +++ b/Travail_de_session/SchedulesWindows/ShowSolutionResultsFrame.java @@ -6,7 +6,8 @@ package SchedulesWindows; import SchedulesRecovery.BankRecoveredSchedules; -import java.util.*; + +import java.util.List; /** * @@ -14,7 +15,7 @@ import java.util.*; */ public class ShowSolutionResultsFrame extends javax.swing.JFrame { - private List< BankRecoveredSchedules > bankRecoveredSchedulesOrderedByMeanCost; + private final List bankRecoveredSchedulesOrderedByMeanCost; /** * Creates new form ShowSchedulesFrame */ @@ -39,22 +40,18 @@ public class ShowSolutionResultsFrame extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - mainPanel = new javax.swing.JPanel(); + javax.swing.JPanel mainPanel = new javax.swing.JPanel(); changeScheduleNumberScrollBar = new javax.swing.JScrollBar(); - jScrollPane1 = new javax.swing.JScrollPane(); + javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); scheduleViewerArea = new javax.swing.JTextArea(); - jLabel1 = new javax.swing.JLabel(); + javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); textSolutionNumber = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setPreferredSize(new java.awt.Dimension(1400, 600)); setSize(new java.awt.Dimension(1000, 600)); - changeScheduleNumberScrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() { - public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) { - changeScheduleNumberScrollBarAdjustmentValueChanged(evt); - } - }); + changeScheduleNumberScrollBar.addAdjustmentListener(evt -> changeScheduleNumberScrollBarAdjustmentValueChanged(evt)); scheduleViewerArea.setEditable(false); scheduleViewerArea.setColumns(20); @@ -130,9 +127,6 @@ public class ShowSolutionResultsFrame extends javax.swing.JFrame { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollBar changeScheduleNumberScrollBar; - private javax.swing.JLabel jLabel1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JPanel mainPanel; private javax.swing.JTextArea scheduleViewerArea; private javax.swing.JLabel textSolutionNumber; // End of variables declaration//GEN-END:variables diff --git a/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java b/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java new file mode 100644 index 0000000..ce808c5 --- /dev/null +++ b/Travail_de_session/VariableDemandSchedules/BankVariableDemandSchedules.java @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..9e1f5a7 --- /dev/null +++ b/Travail_de_session/VariableDemandSchedules/ParametersVariableDemandSimulator.java @@ -0,0 +1,6 @@ +package VariableDemandSchedules; + +public class ParametersVariableDemandSimulator { + public static final double lambda = 2; + public static final int numberVariableDemandSimulation = 1000; +} diff --git a/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java b/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java new file mode 100644 index 0000000..4f8c33d --- /dev/null +++ b/Travail_de_session/VariableDemandSchedules/VariableDemandSchedulesArray.java @@ -0,0 +1,36 @@ +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(); + 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; + } +} diff --git a/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java b/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java new file mode 100644 index 0000000..4617b75 --- /dev/null +++ b/Travail_de_session/VariableDemandSchedules/VariableDemandVector.java @@ -0,0 +1,21 @@ +package VariableDemandSchedules; + +import jdistlib.Poisson; +import jdistlib.rng.RandomEngine; + +public class VariableDemandVector { + private final int[] VariableDemandVector; + + VariableDemandVector(int length, RandomEngine r) { + VariableDemandVector = new int[length]; + Poisson p1 = new Poisson(ParametersVariableDemandSimulator.lambda); + p1.setRandomEngine(r); + for (int i = 0; i < length; i++) { + VariableDemandVector[i] = (int) p1.random(); + } + } + + public int[] getVariableDemandVector() { + return VariableDemandVector; + } +}