WIP Ajout des vecteurs de demande modifiée

This commit is contained in:
François Pelletier 2018-04-14 12:06:25 -04:00
parent a042006557
commit 177435db08
29 changed files with 262 additions and 164 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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<AbsenceSchedulesArray> bankAbsenceSimulation;
public final SchedulesArray initialSchedulesArray;
public final List<AbsenceSchedulesArray> bankAbsenceSimulation;
public BankAbsenceSchedules(SchedulesArray initialSchedulesArray) {
this.initialSchedulesArray = initialSchedulesArray;

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -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){

View file

@ -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();

View file

@ -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[][]{

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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++;
}

View file

@ -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];
}
}

View file

@ -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<SchedulesArray> bankRecoveredSimulation;
public List<AbsenceSchedulesArray> bankAbsenceSimulation;
public final SchedulesArray initialSchedulesArray;
public final List<SchedulesArray> bankRecoveredSimulation;
private final List<AbsenceSchedulesArray> bankAbsenceSimulation;
public double meanCostRecoveredSimulations;
public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List<AbsenceSchedulesArray> bankAbsenceSimulation) {

View file

@ -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);
}
}

View file

@ -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++;
}
}

View file

@ -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;
}

View file

@ -11,7 +11,7 @@ import java.util.Comparator;
* @author frabe
*/
public class RecoveringActionComparator implements Comparator< RecoveringAction > {
class RecoveringActionComparator implements Comparator<RecoveringAction> {
public int compare(RecoveringAction a2, RecoveringAction a1) {
return Integer.compare(a1.recoveringActionCost, a2.recoveringActionCost);
}

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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<ScheduleUtil.SchedulesArray> schedulesArrayList;
private String title;
private final List<ScheduleUtil.SchedulesArray> schedulesArrayList;
private final String title;
/**
* Creates new form ShowSchedulesFrame
**/
@ -40,20 +40,16 @@ public class ShowSchedulesFrame extends javax.swing.JFrame {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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

View file

@ -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<BankRecoveredSchedules> bankRecoveredSchedulesOrderedByMeanCost;
/**
* Creates new form ShowSchedulesFrame
*/
@ -39,22 +40,18 @@ public class ShowSolutionResultsFrame extends javax.swing.JFrame {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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

View file

@ -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<VariableDemandSchedulesArray> bankVariableDemandSimulation;
public BankVariableDemandSchedules(SchedulesArray initialSchedulesArray) {
this.initialSchedulesArray = initialSchedulesArray;
this.bankVariableDemandSimulation = new ArrayList<>();
}
public void addVariableDemandSchedules(VariableDemandSchedulesArray variableDemandSchedulesArray) {
this.bankVariableDemandSimulation.add(variableDemandSchedulesArray);
}
}

View file

@ -0,0 +1,6 @@
package VariableDemandSchedules;
public class ParametersVariableDemandSimulator {
public static final double lambda = 2;
public static final int numberVariableDemandSimulation = 1000;
}

View file

@ -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;
}
}

View file

@ -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;
}
}