Ajout d'une fonction d'optimisation sur les salaires
This commit is contained in:
parent
57b45430fa
commit
d091fa4217
3 changed files with 82 additions and 24 deletions
|
@ -37,6 +37,7 @@ public class ModelInitialSchedules {
|
|||
public IntVar employeesPerWorkPeriods[];
|
||||
|
||||
public Model chocoModelInitialSchedules;
|
||||
public IntVar TotalEmployeesSalary;
|
||||
public IntVar scheduleProfit;
|
||||
|
||||
public ModelInitialSchedules(ParametersInitialSchedules myScheduleParameters) {
|
||||
|
@ -66,8 +67,8 @@ public class ModelInitialSchedules {
|
|||
private void createScheduleVariables() {
|
||||
|
||||
// Variable pour l'horaire des employes
|
||||
this.workPeriodsSchedulesOfPartTimeEmployees = chocoModelInitialSchedules.boolVarMatrix(this.maxPartTimeEmployee, this.myScheduleParameters.workPeriodsPerSchedule);
|
||||
this.workPeriodsSchedulesOfFullTimeEmployees = chocoModelInitialSchedules.boolVarMatrix(this.maxFullTimeEmployee, this.myScheduleParameters.workPeriodsPerSchedule);
|
||||
this.workPeriodsSchedulesOfPartTimeEmployees = chocoModelInitialSchedules.boolVarMatrix(this.maxPartTimeEmployee, this.myScheduleParameters.workPeriodsPerSchedule);
|
||||
|
||||
// Vecteur de toutes les variables
|
||||
/*this.allWorkPeriods = chocoModelInitialSchedules.boolVarArray((this.maxPartTimeEmployee+this.maxFullTimeEmployee)*this.myScheduleParameters.workPeriodsPerSchedule);
|
||||
|
@ -176,7 +177,7 @@ public class ModelInitialSchedules {
|
|||
this.employeesPerWorkPeriods[workPeriod]).post();
|
||||
}
|
||||
|
||||
// Contrainte pour heures consécutives des employés à temps partiel
|
||||
// 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 day = 0; day < this.myScheduleParameters.daysPerSchedule; day++) {
|
||||
|
@ -194,17 +195,75 @@ public class ModelInitialSchedules {
|
|||
/*for (int employee = 0; employee < (this.maxPartTimeEmployee-1); employee++){
|
||||
chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfPartTimeEmployees[employee],
|
||||
this.workPeriodsSchedulesOfPartTimeEmployees[employee+1]).post();
|
||||
}*/
|
||||
/*for (int employee = 0; employee < (this.maxFullTimeEmployee-1); employee++){
|
||||
}
|
||||
for (int employee = 0; employee < (this.maxFullTimeEmployee-1); employee++){
|
||||
chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfFullTimeEmployees[employee],
|
||||
this.workPeriodsSchedulesOfFullTimeEmployees[employee+1]).post();
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void createModelObjectiveFunction() {
|
||||
|
||||
// Calcul du nombre de périodes travaillées par chaque type d'employés dans l'horaire
|
||||
|
||||
IntVar[] NumberOfPartTimeEmployeesPerPeriod =
|
||||
chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.workPeriodsPerSchedule,
|
||||
0,
|
||||
this.maxPartTimeEmployee, true);
|
||||
IntVar[] NumberOfFullTimeEmployeesPerPeriod =
|
||||
chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.workPeriodsPerSchedule,
|
||||
0,
|
||||
this.maxFullTimeEmployee, true);
|
||||
|
||||
for (int workPeriod = 0; workPeriod < this.myScheduleParameters.workPeriodsPerSchedule; workPeriod++) {
|
||||
chocoModelInitialSchedules.sum(transposeWorkPeriodsSchedulesOfPartTimeEmployees[workPeriod],
|
||||
"=", NumberOfPartTimeEmployeesPerPeriod[workPeriod]).post();
|
||||
chocoModelInitialSchedules.sum(transposeWorkPeriodsSchedulesOfFullTimeEmployees[workPeriod],
|
||||
"=", NumberOfFullTimeEmployeesPerPeriod[workPeriod]).post();
|
||||
}
|
||||
|
||||
IntVar NumberOfPartTimeEmployeesPeriods =
|
||||
chocoModelInitialSchedules.intVar(
|
||||
0, this.maxPartTimeEmployee * this.myScheduleParameters.workPeriodsPerSchedule, true);
|
||||
IntVar NumberOfFullTimeEmployeesPeriods =
|
||||
chocoModelInitialSchedules.intVar(
|
||||
0, this.maxPartTimeEmployee * this.myScheduleParameters.workPeriodsPerSchedule, true);
|
||||
|
||||
chocoModelInitialSchedules.sum(NumberOfPartTimeEmployeesPerPeriod, "=", NumberOfPartTimeEmployeesPeriods).post();
|
||||
chocoModelInitialSchedules.sum(NumberOfFullTimeEmployeesPerPeriod, "=", NumberOfFullTimeEmployeesPeriods).post();
|
||||
|
||||
// Calcul du salaire versé
|
||||
IntVar PartTimeEmployeesSalary =
|
||||
chocoModelInitialSchedules.intVar(1000, this.maxPartTimeEmployee *
|
||||
this.myScheduleParameters.workPeriodsPerSchedule *
|
||||
this.myScheduleParameters.hourlyRateOfPartTimeEmployees, true);
|
||||
|
||||
IntVar FullTimeEmployeesSalary =
|
||||
chocoModelInitialSchedules.intVar(1000, this.maxFullTimeEmployee *
|
||||
this.myScheduleParameters.workPeriodsPerSchedule *
|
||||
this.myScheduleParameters.regularHourlyRateOfFullTimeEmployees, true);
|
||||
|
||||
this.TotalEmployeesSalary = chocoModelInitialSchedules.intVar(0, this.maxPartTimeEmployee *
|
||||
this.myScheduleParameters.workPeriodsPerSchedule *
|
||||
this.myScheduleParameters.hourlyRateOfPartTimeEmployees +
|
||||
this.maxFullTimeEmployee *
|
||||
this.myScheduleParameters.workPeriodsPerSchedule *
|
||||
this.myScheduleParameters.regularHourlyRateOfFullTimeEmployees, true);
|
||||
|
||||
IntVar HourlyRateOfPartTimeEmployees =
|
||||
chocoModelInitialSchedules.intVar(this.myScheduleParameters.hourlyRateOfPartTimeEmployees);
|
||||
IntVar regularHourlyRateOfFullTimeEmployees =
|
||||
chocoModelInitialSchedules.intVar(this.myScheduleParameters.regularHourlyRateOfFullTimeEmployees);
|
||||
|
||||
chocoModelInitialSchedules.arithm(NumberOfPartTimeEmployeesPeriods, "*", HourlyRateOfPartTimeEmployees, "=", PartTimeEmployeesSalary).post();
|
||||
chocoModelInitialSchedules.arithm(NumberOfFullTimeEmployeesPeriods, "*", regularHourlyRateOfFullTimeEmployees, "=", FullTimeEmployeesSalary).post();
|
||||
|
||||
chocoModelInitialSchedules.arithm(PartTimeEmployeesSalary, "+", FullTimeEmployeesSalary, "=", this.TotalEmployeesSalary).post();
|
||||
|
||||
//TODO: Inclure les frais fixes par employé
|
||||
|
||||
|
||||
// this.scheduleProfit = chocoModelInitialSchedules.intVar("TOTAL_COST", 0, 20 * N * p, true);
|
||||
// chocoModelInitialSchedules.scalar(perte , coeffs , "=", this.scheduleProfit).post();
|
||||
}
|
||||
|
|
|
@ -9,24 +9,24 @@ public class ParametersInitialSchedules {
|
|||
int daysPerSchedule;
|
||||
int workPeriodsPerSchedule;
|
||||
int totalWorkedPeriodsInSchedule;
|
||||
double hoursPerWorkPeriod;
|
||||
int hoursPerWorkPeriod;
|
||||
|
||||
double fixedCostOfPartTimeEmployeesPerSchedule;
|
||||
double hourlyRateOfPartTimeEmployees;
|
||||
double minWorkingHoursOfPartTimeEmployeesPerSchedule;
|
||||
double maxWorkingHoursOfPartTimeEmployeesPerSchedule;
|
||||
int fixedCostOfPartTimeEmployeesPerSchedule;
|
||||
int hourlyRateOfPartTimeEmployees;
|
||||
int minWorkingHoursOfPartTimeEmployeesPerSchedule;
|
||||
int maxWorkingHoursOfPartTimeEmployeesPerSchedule;
|
||||
int minWorkingPeriodsOfPartTimeEmployeesPerSchedule;
|
||||
int maxWorkingPeriodsOfPartTimeEmployeesPerSchedule;
|
||||
|
||||
double fixedCostOfFullTimeEmployeesPerSchedule;
|
||||
double regularHourlyRateOfFullTimeEmployees;
|
||||
double overtimeHourlyRateOfFullTimeEmployees;
|
||||
double workingHoursOfFullTimeEmployeesPerSchedule;
|
||||
double maxWorkingHoursOfFullTimeEmployeesPerSchedule;
|
||||
int fixedCostOfFullTimeEmployeesPerSchedule;
|
||||
int regularHourlyRateOfFullTimeEmployees;
|
||||
int overtimeHourlyRateOfFullTimeEmployees;
|
||||
int workingHoursOfFullTimeEmployeesPerSchedule;
|
||||
int maxWorkingHoursOfFullTimeEmployeesPerSchedule;
|
||||
int workingPeriodsOfFullTimeEmployeesPerSchedule;
|
||||
int maxWorkingPeriodsOfFullTimeEmployeesPerSchedule;
|
||||
|
||||
double workingHoursPaidAtRegularHourlyRatePerSchedule;
|
||||
int workingHoursPaidAtRegularHourlyRatePerSchedule;
|
||||
|
||||
public int[] requiredWorkforce;
|
||||
Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
|
||||
|
@ -48,7 +48,7 @@ public class ParametersInitialSchedules {
|
|||
this.workPeriodsPerDay = 6;
|
||||
this.shiftWorkPerDay = 3;
|
||||
this.daysPerSchedule = 14;
|
||||
this.hoursPerWorkPeriod = 4;
|
||||
this.hoursPerWorkPeriod = 24 / this.workPeriodsPerDay;
|
||||
this.workPeriodsPerSchedule = this.workPeriodsPerDay * this.daysPerSchedule;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import org.chocosolver.solver.Model;
|
||||
import org.chocosolver.solver.Solver;
|
||||
|
||||
public class MainClass {
|
||||
|
@ -21,13 +22,11 @@ public class MainClass {
|
|||
= new InitialSchedules.ModelInitialSchedules(myScheduleParameters);
|
||||
|
||||
Solver solverInitialSchedules = myModelInitialSchedules.chocoModelInitialSchedules.getSolver();
|
||||
/*solverInitialSchedules.setSearch(Search.domOverWDegSearch(myModelInitialSchedules.allWorkPeriods));
|
||||
solverInitialSchedules.limitSolution(10);
|
||||
solverInitialSchedules.findAllSolutions();*/
|
||||
solverInitialSchedules.findSolution();
|
||||
// Solution bestInitialSchedules = solverInitialSchedules.findOptimalSolution
|
||||
// (myModelInitialSchedules.scheduleProfit, Model.MINIMIZE);
|
||||
|
||||
solverInitialSchedules.showDashboard();
|
||||
/*solverInitialSchedules.setSearch(Search.domOverWDegSearch(myModelInitialSchedules.allWorkPeriods));*/
|
||||
solverInitialSchedules.limitTime(10000);
|
||||
solverInitialSchedules.findAllOptimalSolutions
|
||||
(myModelInitialSchedules.TotalEmployeesSalary, Model.MINIMIZE);
|
||||
// fonction pour reduire le nombre d'horaire dans la banque d'horaire.
|
||||
// InitialSchedules.UtilInitialSchedules.refineInitialSchedules(bestInitialSchedules);
|
||||
// On pourrait creer un petit interface pour afficher les horaires optimales et les statistiques.
|
||||
|
|
Loading…
Reference in a new issue