Cleaning de la classe InitialParameters pour réduire la taille du fichier.

This commit is contained in:
Francois Berube\frabe 2018-04-12 00:14:28 -04:00
parent 4b24dc1901
commit 8b75086530
4 changed files with 183 additions and 251 deletions

View file

@ -10,7 +10,7 @@ package AbsenceSchedules;
* @author frabe
*/
public interface ParametersAbsencesSimulator {
public final double probPresence = 0.99;
public final double probPresence = 0.50;
public final double probReturn = 0.99;
public final int numberAbsenceSimulations = 5;
}

View file

@ -0,0 +1,149 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package InitialSchedules;
import org.chocosolver.solver.constraints.extension.Tuples;
/**
*
* @author frabe
*/
public 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,
4);
int NbFullTimeSolutions = validDailyFullTimeSchedules.getNbSolutions();
int[][] dailySchedulesOfFullTimeEmployees = validDailyFullTimeSchedules.getValidSchedules();
int[][] workPeriodsSchedulesOfFullTimeEmployees
= new int[NbFullTimeSolutions * shiftWorkPerDay][workPeriodsPerSchedule];
// Cette fonction sera a ameliorer avec des sous-fonctions, car elle n'est pas tres explicite.
for (int scheduleNumber = 0; scheduleNumber < NbFullTimeSolutions; scheduleNumber++) {
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] = 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 + 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 + 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 + 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] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * shiftWorkPerDay + shiftNumber][day * workPeriodPerDay + 5] = 0;
}
}
}
}
// 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;
}
public static Tuples setWorkPeriodsSchedulesOfPartTimeEmployees(int workPeriodsPerSchedule, int workPeriodPerDay, int daysPerSchedule) {
ValidDailySchedules validDailyPartTimeSchedules = new ValidDailySchedules(daysPerSchedule,
4,
8,
0,
0,
0,
0,
6);
int NbPartTimeSolutions = validDailyPartTimeSchedules.getNbSolutions();
int[][] dailySchedulesOfPartTimeEmployees = validDailyPartTimeSchedules.getValidSchedules();
int maxShiftConfig = 5;
int[][] workPeriodsSchedulesOfPartTimeEmployees
= new int[NbPartTimeSolutions * maxShiftConfig][workPeriodsPerSchedule];
// Cette fonction sera a ameliorer avec des sous-fonctions, car elle n'est pas tres explicite.
for (int scheduleNumber = 0; scheduleNumber < NbPartTimeSolutions; scheduleNumber++) {
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] = 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 + 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 + 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 + 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 + 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 + 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] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * workPeriodPerDay + 5] = 0;
}
}
}
}
// 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;
}
}

View file

@ -4,80 +4,51 @@ import ScheduleUtil.FullTimeEmployeeScheduleArray;
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;
//mettre les attributs prives et definir accesseurs
int NbFullTimeSolutions;
int NbPartTimeSolutions;
int shiftWorkPerDay;
int daysPerSchedule;
int hoursPerWorkPeriod;
int hourlyRateOfPartTimeEmployees;
int fixedCostOfPartTimeEmployeesPerSchedule;
int regularHourlyRateOfPartTimeEmployees;
int overtimeHourlyRateOfPartTimeEmployees;
int minWorkingHoursOfPartTimeEmployeesPerSchedule;
int maxWorkingHoursOfPartTimeEmployeesPerSchedule;
int maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork;
int minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees;
int fixedCostOfFullTimeEmployeesPerSchedule;
int regularHourlyRateOfFullTimeEmployees;
int overtimeHourlyRateOfFullTimeEmployees;
int maxWorkingHoursOfFullTimeEmployeesPerSchedule;
int workingHoursOfFullTimeEmployeesPerSchedule;
int maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork;
int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees;
int workingHoursPaidAtRegularHourlyRatePerSchedule;
int workingHoursPaidAtRegularHourlyRatePerShiftWork;
//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;
//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;
int[] requiredWorkforce;
int NbFullTimeSolutions;
int NbPartTimeSolutions;
Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees;
Tuples ValidPartTimeEmployeeShiftTuples;
public ParametersInitialSchedules() {
this.setGeneralParameters();
this.setPartTimeEmployeesParameters();
this.setFullTimeEmployeesParameters();
this.setRequiredWorkforce();
this.setWorkPeriodsSchedulesOfFullTimeEmployees();
this.setWorkPeriodsSchedulesOfPartTimeEmployees();
this.setValidPartTimeEmployeeShiftTuples();
this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfFullTimeEmployees(
shiftWorkPerDay, getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule);
this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfPartTimeEmployees(
getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule);
this.ValidPartTimeEmployeeShiftTuples = new ValidPartTimeEmployeeShift().makeTuples();
}
private void setGeneralParameters() {
this.shiftWorkPerDay = 3;
this.daysPerSchedule = 14;
this.hoursPerWorkPeriod = 4;
this.workingHoursPaidAtRegularHourlyRatePerSchedule = 80;
this.workingHoursPaidAtRegularHourlyRatePerShiftWork = 8;
}
private void setPartTimeEmployeesParameters() {
this.fixedCostOfPartTimeEmployeesPerSchedule = 50;
this.regularHourlyRateOfPartTimeEmployees = 12; // To simulate lower productivity
this.overtimeHourlyRateOfPartTimeEmployees = 17; // To simulate lower productivity
this.minWorkingHoursOfPartTimeEmployeesPerSchedule = 32;
this.maxWorkingHoursOfPartTimeEmployeesPerSchedule = 64;
this.maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork = 12;
this.minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees = 12;
}
private void setFullTimeEmployeesParameters() {
this.fixedCostOfFullTimeEmployeesPerSchedule = 50;
this.regularHourlyRateOfFullTimeEmployees = 10;
this.overtimeHourlyRateOfFullTimeEmployees = 15;
this.workingHoursOfFullTimeEmployeesPerSchedule = 80;
this.maxWorkingHoursOfFullTimeEmployeesPerSchedule = 120;
this.maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork = 12;
this.minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12;
}
private void setRequiredWorkforce() {
this.requiredWorkforce = new int[this.daysPerSchedule * this.getWorkPeriodPerDay()];
@ -103,189 +74,6 @@ public class ParametersInitialSchedules {
return totalWorkedPeriodsInSchedule;
}
private void setWorkPeriodsSchedulesOfFullTimeEmployees() {
ValidDailySchedules validDailyFullTimeSchedules = new ValidDailySchedules(daysPerSchedule,
10,
10,
0,
5,
7,
12,
4);
NbFullTimeSolutions = validDailyFullTimeSchedules.getNbSolutions();
int[][] dailySchedulesOfFullTimeEmployees = validDailyFullTimeSchedules.getValidSchedules();
int[][] workPeriodsSchedulesOfFullTimeEmployees
= new int[NbFullTimeSolutions * this.shiftWorkPerDay][this.getWorkPeriodsPerSchedule()];
// Cette fonction sera a ameliorer avec des sous-fonctions, car elle n'est pas tres explicite.
for (int scheduleNumber = 0; scheduleNumber < NbFullTimeSolutions; scheduleNumber++) {
for (int day = 0; day < this.daysPerSchedule; day++) {
for (int shiftNumber = 0; shiftNumber < this.shiftWorkPerDay; shiftNumber++) {
if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 0) {
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 1;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 1;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 1) {
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 1;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 1;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 2) {
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 1;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 1;
} else if (dailySchedulesOfFullTimeEmployees[scheduleNumber][day] == 0) {
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfFullTimeEmployees[scheduleNumber * this.shiftWorkPerDay + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
}
}
}
}
// Creation des tuples a partir du tableau pour creer les 3 types de quart de travail (nuit, jour soir).
this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees
= new Tuples(workPeriodsSchedulesOfFullTimeEmployees, true);
}
private void setWorkPeriodsSchedulesOfPartTimeEmployees() {
ValidDailySchedules validDailyPartTimeSchedules = new ValidDailySchedules(daysPerSchedule,
4,
8,
0,
0,
0,
0,
6);
NbPartTimeSolutions = validDailyPartTimeSchedules.getNbSolutions();
int[][] dailySchedulesOfPartTimeEmployees = validDailyPartTimeSchedules.getValidSchedules();
int maxShiftConfig = 5;
int[][] workPeriodsSchedulesOfPartTimeEmployees
= new int[NbPartTimeSolutions * maxShiftConfig][this.getWorkPeriodsPerSchedule()];
// Cette fonction sera a ameliorer avec des sous-fonctions, car elle n'est pas tres explicite.
for (int scheduleNumber = 0; scheduleNumber < NbPartTimeSolutions; scheduleNumber++) {
for (int day = 0; day < this.daysPerSchedule; day++) {
for (int shiftNumber = 0; shiftNumber < maxShiftConfig; shiftNumber++) {
if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 0) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 1) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 2) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 3) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 4) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 1;
/*} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 5) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 6) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 7) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 8) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 9) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 1;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 10) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 1;*/
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 0) {
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 0] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 1] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 2] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 3] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 4] = 0;
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.getWorkPeriodPerDay() + 5] = 0;
}
}
}
}
// Creation des tuples a partir du tableau pour creer les 3 types de quart de travail (nuit, jour soir).
this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees
= new Tuples(workPeriodsSchedulesOfPartTimeEmployees, true);
}
private void setValidPartTimeEmployeeShiftTuples() {
this.ValidPartTimeEmployeeShiftTuples = new ValidPartTimeEmployeeShift().makeTuples();
}
public int getRequiredWorkForce(int workPeriod) {
return this.requiredWorkforce[workPeriod];
}

View file

@ -12,13 +12,8 @@ import java.util.Comparator;
*/
public class RecoveringActionComparator implements Comparator< RecoveringAction > {
public int compare(RecoveringAction a1, RecoveringAction a2) {
int actionCostCmp = Integer.compare(a1.recoveringActionCost, a2.recoveringActionCost);
if (actionCostCmp !=0) {
return actionCostCmp;
}
int workPeriodCmp = Integer.compare(a1.employee, a2.employee);
return workPeriodCmp;
public int compare(RecoveringAction a2, RecoveringAction a1) {
return Integer.compare(a1.recoveringActionCost, a2.recoveringActionCost);
}
}