Merge branch 'horairesquotidiensvalides' into 'master'
Horairesquotidiensvalides See merge request franc00018/tpIFT7020!2
This commit is contained in:
commit
6b4f6ff609
4 changed files with 268 additions and 68 deletions
|
@ -114,7 +114,7 @@ public class ModelInitialSchedules {
|
|||
0, this.maxPartTimeEmployee + this.maxFullTimeEmployee, true);
|
||||
|
||||
// Variable pour les périodes de travail par jour des travailleurs à temps partiel
|
||||
this.workPeriodsOfPartTimeEmployees = chocoModelInitialSchedules.boolVarMatrix(this.maxPartTimeEmployee * this.myScheduleParameters.daysPerSchedule
|
||||
/*this.workPeriodsOfPartTimeEmployees = chocoModelInitialSchedules.boolVarMatrix(this.maxPartTimeEmployee * this.myScheduleParameters.daysPerSchedule
|
||||
, this.myScheduleParameters.workPeriodsPerDay);
|
||||
|
||||
for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
|
@ -125,7 +125,7 @@ public class ModelInitialSchedules {
|
|||
0, this.myScheduleParameters.workPeriodsPerDay);
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void createModelConstraints() {
|
||||
|
@ -136,8 +136,14 @@ public class ModelInitialSchedules {
|
|||
this.myScheduleParameters.enumerationWorkPeriodsSchedulesOfFullTimeEmployees).post();
|
||||
}
|
||||
|
||||
// Constraintes pour compter le nombre d'heures travaillees par les differents employes
|
||||
for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
chocoModelInitialSchedules.table(this.workPeriodsSchedulesOfPartTimeEmployees[employee],
|
||||
this.myScheduleParameters.enumerationWorkPeriodsSchedulesOfPartTimeEmployees).post();
|
||||
}
|
||||
|
||||
|
||||
// Constraintes pour compter le nombre d'heures travaillees par les differents employes
|
||||
/*for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
chocoModelInitialSchedules.count(chocoModelInitialSchedules.intVar(1),
|
||||
this.workPeriodsSchedulesOfPartTimeEmployees[employee],
|
||||
this.workingPeriodsPerPartTimeEmployees[employee]).post();
|
||||
|
@ -146,7 +152,7 @@ public class ModelInitialSchedules {
|
|||
chocoModelInitialSchedules.count(chocoModelInitialSchedules.intVar(1),
|
||||
this.workPeriodsSchedulesOfFullTimeEmployees[employee],
|
||||
this.workingPeriodsPerFullTimeEmployees[employee]).post();
|
||||
}
|
||||
}*/
|
||||
|
||||
// Constraintes pour borner le nombre d'heures travaillees par les employes a temps partiel
|
||||
for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
|
@ -179,13 +185,13 @@ public class ModelInitialSchedules {
|
|||
|
||||
// Contrainte pour forcer des heures consécutives par jour pour les employés à temps partiel
|
||||
|
||||
for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
/*for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) {
|
||||
for (int day = 0; day < this.myScheduleParameters.daysPerSchedule; day++) {
|
||||
chocoModelInitialSchedules.table(
|
||||
this.workPeriodsOfPartTimeEmployees[employee * this.myScheduleParameters.daysPerSchedule + day],
|
||||
this.myScheduleParameters.ValidPartTimeEmployeeShiftTuples).post();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
@ -196,10 +202,10 @@ public class ModelInitialSchedules {
|
|||
// chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfPartTimeEmployees[employee],
|
||||
// this.workPeriodsSchedulesOfPartTimeEmployees[employee+1]).post();
|
||||
// }
|
||||
for (int employee = 0; employee < (this.maxFullTimeEmployee-1); employee++){
|
||||
chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfFullTimeEmployees[employee],
|
||||
this.workPeriodsSchedulesOfFullTimeEmployees[employee+1]).post();
|
||||
}
|
||||
// for (int employee = 0; employee < (this.maxFullTimeEmployee-1); employee++){
|
||||
// chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfFullTimeEmployees[employee],
|
||||
// this.workPeriodsSchedulesOfFullTimeEmployees[employee+1]).post();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,14 @@ import org.chocosolver.solver.constraints.extension.Tuples;
|
|||
public class ParametersInitialSchedules {
|
||||
|
||||
public int workPeriodsPerDay;
|
||||
int NbFullTimeSolutions;
|
||||
int NbPartTimeSolutions;
|
||||
int shiftWorkPerDay;
|
||||
public int daysPerSchedule;
|
||||
public int workPeriodsPerSchedule;
|
||||
int totalWorkedPeriodsInSchedule;
|
||||
int hoursPerWorkPeriod;
|
||||
int hourlyRateOfPartTimeEmployees;
|
||||
|
||||
public int fixedCostOfPartTimeEmployeesPerSchedule;
|
||||
public int regularHourlyRateOfPartTimeEmployees;
|
||||
|
@ -23,16 +26,21 @@ public class ParametersInitialSchedules {
|
|||
public int regularHourlyRateOfFullTimeEmployees;
|
||||
public int overtimeHourlyRateOfFullTimeEmployees;
|
||||
int maxWorkingHoursOfFullTimeEmployeesPerSchedule;
|
||||
int minWorkingHoursOfPartTimeEmployeesPerSchedule
|
||||
int maxWorkingHoursOfPartTimeEmployeesPerSchedule;
|
||||
int workingHoursOfFullTimeEmployeesPerSchedule;
|
||||
|
||||
int maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork;
|
||||
int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees;
|
||||
int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees;
|
||||
|
||||
int workingHoursPaidAtRegularHourlyRatePerSchedule;
|
||||
int workingHoursPaidAtRegularHourlyRatePerShiftWork;
|
||||
|
||||
private int fixedCostOfPartTimeEmployeesPerSchedule;
|
||||
|
||||
public int[] requiredWorkforce;
|
||||
Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
|
||||
|
||||
Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees;
|
||||
Tuples ValidPartTimeEmployeeShiftTuples;
|
||||
|
||||
public ParametersInitialSchedules() {
|
||||
|
@ -42,6 +50,7 @@ public class ParametersInitialSchedules {
|
|||
this.setFullTimeEmployeesParameters();
|
||||
this.setRequiredWorkforce();
|
||||
this.setWorkPeriodsSchedulesOfFullTimeEmployees();
|
||||
this.setWorkPeriodsSchedulesOfPartTimeEmployees();
|
||||
this.setValidPartTimeEmployeeShiftTuples();
|
||||
|
||||
}
|
||||
|
@ -53,7 +62,7 @@ public class ParametersInitialSchedules {
|
|||
this.hoursPerWorkPeriod = 24 / this.workPeriodsPerDay;
|
||||
this.workPeriodsPerSchedule = this.workPeriodsPerDay * this.daysPerSchedule;
|
||||
this.workingHoursPaidAtRegularHourlyRatePerSchedule = 80;
|
||||
this.workingHoursPaidAtRegularHourlyRatePerShiftWork = 8;
|
||||
this.workingHoursPaidAtRegularHourlyRatePerShiftWork = 8;
|
||||
}
|
||||
|
||||
private void setPartTimeEmployeesParameters() {
|
||||
|
@ -92,15 +101,24 @@ public class ParametersInitialSchedules {
|
|||
|
||||
private void setWorkPeriodsSchedulesOfFullTimeEmployees() {
|
||||
|
||||
ValidDailySchedules v = new ValidDailySchedules();
|
||||
ValidDailySchedules validDailyFullTimeSchedules = new ValidDailySchedules(daysPerSchedule,
|
||||
10,
|
||||
10,
|
||||
0,
|
||||
5,
|
||||
7,
|
||||
12,
|
||||
4);
|
||||
|
||||
int[][] dailySchedulesOfFullTimeEmployees = v.dailySchedulesOfFullTimeEmployees;
|
||||
NbFullTimeSolutions = validDailyFullTimeSchedules.getNbSolutions();
|
||||
|
||||
int[][] dailySchedulesOfFullTimeEmployees = validDailyFullTimeSchedules.getValidSchedules();
|
||||
|
||||
int[][] workPeriodsSchedulesOfFullTimeEmployees
|
||||
= new int[v.length() * this.shiftWorkPerDay][this.workPeriodsPerSchedule];
|
||||
= new int[NbFullTimeSolutions * this.shiftWorkPerDay][this.workPeriodsPerSchedule];
|
||||
|
||||
// Cette fonction sera a ameliorer avec des sous-fonctions, car elle n'est pas tres explicite.
|
||||
for (int scheduleNumber = 0; scheduleNumber < v.length(); scheduleNumber++) {
|
||||
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) {
|
||||
|
@ -141,6 +159,126 @@ public class ParametersInitialSchedules {
|
|||
= 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 * 5][this.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 < this.daysPerSchedule; day++) {
|
||||
for (int shiftNumber = 0; shiftNumber < maxShiftConfig; shiftNumber++) {
|
||||
System.out.println("Schedule:" + scheduleNumber + "day:" + day + "Shift:" + shiftNumber);
|
||||
if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 0) {
|
||||
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 0] = 1;
|
||||
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 == 1) {
|
||||
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] = 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 == 2) {
|
||||
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] = 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 == 3) {
|
||||
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] = 1;
|
||||
workPeriodsSchedulesOfPartTimeEmployees[scheduleNumber * maxShiftConfig + shiftNumber][day * this.workPeriodsPerDay + 5] = 0;
|
||||
} else if (dailySchedulesOfPartTimeEmployees[scheduleNumber][day] == 1 && shiftNumber == 4) {
|
||||
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] = 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.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] = 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();
|
||||
}
|
||||
|
@ -148,61 +286,61 @@ public class ParametersInitialSchedules {
|
|||
public int getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule () {
|
||||
return (int) (workingHoursPaidAtRegularHourlyRatePerSchedule / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodsPaidAtRegularHourlyRatePerShiftWork () {
|
||||
return (int) (workingHoursPaidAtRegularHourlyRatePerShiftWork / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate () {
|
||||
return (int) (regularHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate () {
|
||||
return (int) (regularHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodCostOfPartTimeEmployeesPaidAtOvertimeHourlyRate () {
|
||||
return (int) (overtimeHourlyRateOfPartTimeEmployees * this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodCostOfFullTimeEmployeesPaidAtOvertimeHourlyRate () {
|
||||
return (int) (overtimeHourlyRateOfFullTimeEmployees * this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxConsecutiveWorkingPeriodsOfFullTimeEmployeesPerShiftWork () {
|
||||
return (int) (maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxConsecutiveWorkingPeriodsOfPartTimeEmployeesPerShiftWork () {
|
||||
return (int) (maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMinConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployees () {
|
||||
return (int) (minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMinConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployees () {
|
||||
return (int) (minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxWorkingPeriodsOfPartTimeEmployeesPerSchedule () {
|
||||
return (int) (this.maxWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxWorkingPeriodsOfFullTimeEmployeesPerSchedule () {
|
||||
return (int) (this.maxWorkingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
public int getMinWorkingPeriodsOfPartTimeEmployeesPerSchedule () {
|
||||
return (int) (this.minWorkingHoursOfPartTimeEmployeesPerSchedule / this.hoursPerWorkPeriod);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getWorkingPeriodsOfFullTimeEmployeesPerSchedule () {
|
||||
return (int) (this.workingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// A implementer plus tard si l'on veut travailler avec des fichiers texte
|
||||
public ParametersInitialSchedules(String fileName) {
|
||||
|
||||
|
|
|
@ -1,34 +1,90 @@
|
|||
package InitialSchedules;
|
||||
|
||||
public class ValidDailySchedules {
|
||||
int[][] dailySchedulesOfFullTimeEmployees;
|
||||
import org.chocosolver.solver.Model;
|
||||
import org.chocosolver.solver.Solution;
|
||||
import org.chocosolver.solver.constraints.nary.automata.FA.FiniteAutomaton;
|
||||
import org.chocosolver.solver.constraints.nary.automata.FA.IAutomaton;
|
||||
import org.chocosolver.solver.variables.BoolVar;
|
||||
import org.chocosolver.solver.variables.IntVar;
|
||||
|
||||
public ValidDailySchedules() {
|
||||
this.dailySchedulesOfFullTimeEmployees = new int[][]{
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1},
|
||||
{0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1},
|
||||
{0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1},
|
||||
{0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1},
|
||||
{1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1},
|
||||
{1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1},
|
||||
{1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1},
|
||||
{1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1},
|
||||
{1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1},
|
||||
{1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1},
|
||||
{1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
|
||||
{1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
|
||||
{1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0},
|
||||
{1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0},
|
||||
{1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0},};
|
||||
import java.util.List;
|
||||
|
||||
public class ValidDailySchedules {
|
||||
|
||||
int[][] ValidSchedules;
|
||||
private int nbSolutions;
|
||||
|
||||
ValidDailySchedules(int nbPeriodes, int nbPeriodesTravailleesMin, int nbPeriodesTravailleesMax, int p1Min, int p1Max, int p2Min, int p2Max, int nbMaxConsecutif) {
|
||||
|
||||
Model model = new Model("Horaire de " + nbPeriodes + "-periodes");
|
||||
BoolVar[] horaire = new BoolVar[nbPeriodes];
|
||||
for (int p = 0; p < nbPeriodes; p++) {
|
||||
horaire[p] = model.boolVar("P_" + p);
|
||||
}
|
||||
|
||||
BoolVar[] horaires1 = new BoolVar[p1Max - p1Min];
|
||||
BoolVar[] horaires2 = new BoolVar[p1Max - p1Min];
|
||||
|
||||
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];
|
||||
|
||||
/* Travaille entre le nombre minimum et maximum de périodes */
|
||||
model.sum(horaire, ">=", nbPeriodesTravailleesMin).post();
|
||||
model.sum(horaire, "<=", nbPeriodesTravailleesMax).post();
|
||||
|
||||
/* Travaille autant dans les deux sous-périodes */
|
||||
model.sum(horaires1, "=", sumhoraire1).post();
|
||||
model.sum(horaires2, "=", sumhoraire2).post();
|
||||
model.arithm(sumhoraire1, "=", sumhoraire2).post();
|
||||
|
||||
/*Travaille une fin de semaine sur deux*/
|
||||
model.arithm(horaire[5], "=", horaire[6]).post();
|
||||
model.arithm(horaire[12], "=", horaire[13]).post();
|
||||
model.arithm(horaire[5], "!=", horaire[12]).post();
|
||||
|
||||
/*Respect du maximum consecutif*/
|
||||
IAutomaton automatonConsecutif = new FiniteAutomaton("[01]*1{" + (nbMaxConsecutif + 1) + "," + nbPeriodes + "}[01]*");
|
||||
BoolVar respecteMaxConsecutif = model.regular(horaire, automatonConsecutif).reify();
|
||||
model.arithm(respecteMaxConsecutif, "=", 0).post();
|
||||
|
||||
/* Trouver les solutions*/
|
||||
List<Solution> solutions = model.getSolver().findAllSolutions();
|
||||
|
||||
this.nbSolutions = solutions.size() + 1;
|
||||
|
||||
ValidSchedules = new int[this.nbSolutions][nbPeriodes];
|
||||
|
||||
/* Itérer sur les solutions */
|
||||
int iterSolutions = 0;
|
||||
System.out.println("Valid Full Time Schedules:");
|
||||
for (Solution solution : solutions) {
|
||||
if (solution != null) {
|
||||
System.out.print(iterSolutions + "::");
|
||||
for (int iterPeriod = 0; iterPeriod < nbPeriodes; iterPeriod++) {
|
||||
ValidSchedules[iterSolutions][iterPeriod] = solution.getIntVal(horaire[iterPeriod]);
|
||||
System.out.print(ValidSchedules[iterSolutions][iterPeriod]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
iterSolutions++;
|
||||
}
|
||||
}
|
||||
/* La solution additionnelle où le travailleur ne travaille pas*/
|
||||
System.out.print(this.nbSolutions - 1 + "::");
|
||||
for (int iterPeriod = 0; iterPeriod < nbPeriodes; iterPeriod++) {
|
||||
ValidSchedules[this.nbSolutions - 1][iterPeriod] = 0;
|
||||
System.out.print(ValidSchedules[this.nbSolutions - 1][iterPeriod]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return this.dailySchedulesOfFullTimeEmployees.length;
|
||||
public int getNbSolutions() {
|
||||
return this.nbSolutions;
|
||||
}
|
||||
|
||||
public int[][] getValidSchedules() {
|
||||
return ValidSchedules;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
//import AbsenceSchedules.AbsenceSchedulesArray;
|
||||
|
||||
import AbsenceSchedules.AbsenceSchedulesArray;
|
||||
import ScheduleUtil.SchedulesArray;
|
||||
import SchedulesRecovery.RecoveredSchedulesArray;
|
||||
import jdistlib.rng.MersenneTwister;
|
||||
import jdistlib.rng.RandomEngine;
|
||||
import org.chocosolver.solver.Model;
|
||||
import org.chocosolver.solver.Solution;
|
||||
import org.chocosolver.solver.Solver;
|
||||
import org.chocosolver.solver.exception.ContradictionException;
|
||||
import ScheduleUtil.SchedulesArray;
|
||||
import AbsenceSchedules.AbsenceSchedulesArray;
|
||||
import SchedulesRecovery.RecoveredSchedulesArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.lang.*;
|
||||
|
||||
|
||||
|
||||
|
@ -56,10 +55,11 @@ public class MainClass {
|
|||
solverInitialSchedules.limitSolution(5);
|
||||
//solverInitialSchedules.limitTime(10000);
|
||||
List<Solution> myInitialSchedulesSolutions;
|
||||
// myInitialSchedulesSolutions = solverInitialSchedules.findAllOptimalSolutions
|
||||
// (myModelInitialSchedules.TotalEmployeesSalary, Model.MINIMIZE);
|
||||
/* myInitialSchedulesSolutions = solverInitialSchedules.findAllOptimalSolutions
|
||||
(myModelInitialSchedules.TotalEmployeesSalary, Model.MINIMIZE);*/
|
||||
|
||||
myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions ();
|
||||
//solverInitialSchedules.findSolution();
|
||||
myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions();
|
||||
solverInitialSchedules.printStatistics();
|
||||
|
||||
// Création de l'objet banque d'horaire, qui est une liste d'objets de type InitialSchedulesArray, qui contiennent chacun deux tableaux.
|
||||
|
|
Loading…
Reference in a new issue