Ajout d'une fonction d'optimisation sur les salaires

This commit is contained in:
François Pelletier 2018-03-24 17:16:51 -04:00
parent d091fa4217
commit f431e98024
3 changed files with 71 additions and 7 deletions

View file

@ -0,0 +1,30 @@
package InitialSchedules;
import org.chocosolver.solver.Solution;
public class InitialSchedulesArray {
public int[][] InitialPartTimeSchedules;
public int[][] InitialFullTimeSchedules;
private ModelInitialSchedules myModelInitialSchedules;
private Solution mySolution;
public InitialSchedulesArray(ModelInitialSchedules m, Solution s) {
this.myModelInitialSchedules = m;
this.mySolution = s;
this.InitialPartTimeSchedules = new int[myModelInitialSchedules.maxPartTimeEmployee][myModelInitialSchedules.myScheduleParameters.workPeriodsPerSchedule];
this.InitialFullTimeSchedules = new int[myModelInitialSchedules.maxFullTimeEmployee][myModelInitialSchedules.myScheduleParameters.workPeriodsPerSchedule];
for (int workPeriod = 0; workPeriod < myModelInitialSchedules.myScheduleParameters.workPeriodsPerSchedule; workPeriod++) {
for (int employee = 0; employee < myModelInitialSchedules.maxPartTimeEmployee; employee++) {
this.InitialPartTimeSchedules[employee][workPeriod] = mySolution.getIntVal(myModelInitialSchedules.workPeriodsSchedulesOfPartTimeEmployees[employee][workPeriod]);
}
}
for (int workPeriod = 0; workPeriod < myModelInitialSchedules.myScheduleParameters.workPeriodsPerSchedule; workPeriod++) {
for (int employee = 0; employee < myModelInitialSchedules.maxFullTimeEmployee; employee++) {
this.InitialFullTimeSchedules[employee][workPeriod] = mySolution.getIntVal(myModelInitialSchedules.workPeriodsSchedulesOfFullTimeEmployees[employee][workPeriod]);
}
}
}
}

View file

@ -15,7 +15,7 @@ public class ModelInitialSchedules {
// private final int RESTART_AUCUN = 0;
// private final int RESTART_LUBY = 1;
// private final int RESTART_GEOMETRIQUE = 2;
private ParametersInitialSchedules myScheduleParameters;
public ParametersInitialSchedules myScheduleParameters;
public int maxPartTimeEmployee;
public int maxFullTimeEmployee;

View file

@ -1,5 +1,10 @@
import org.chocosolver.solver.Model;
import InitialSchedules.InitialSchedulesArray;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.exception.ContradictionException;
import java.util.ArrayList;
import java.util.List;
public class MainClass {
@ -22,17 +27,46 @@ public class MainClass {
= new InitialSchedules.ModelInitialSchedules(myScheduleParameters);
Solver solverInitialSchedules = myModelInitialSchedules.chocoModelInitialSchedules.getSolver();
solverInitialSchedules.showDashboard();
try {
solverInitialSchedules.propagate();
} catch (ContradictionException e) {
System.err.println("Caught ContradictionException: " + e.getMessage());
solverInitialSchedules.getEngine().flush();
} catch (Exception e) {
System.err.println("Caught Exception: " + e.getMessage());
}
//solverInitialSchedules.showDashboard();
/*solverInitialSchedules.setSearch(Search.domOverWDegSearch(myModelInitialSchedules.allWorkPeriods));*/
//solverInitialSchedules.setRestartOnSolutions(); /*Sans restart, toutes les horaires sont identiques*/
solverInitialSchedules.limitSolution(100);
solverInitialSchedules.limitTime(10000);
solverInitialSchedules.findAllOptimalSolutions
(myModelInitialSchedules.TotalEmployeesSalary, Model.MINIMIZE);
List<Solution> myInitialSchedulesSolutions;
myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions
(/*myModelInitialSchedules.TotalEmployeesSalary, Model.MINIMIZE*/);
// fonction pour reduire le nombre d'horaire dans la banque d'horaire.
// InitialSchedules.UtilInitialSchedules.refineInitialSchedules(bestInitialSchedules);
// InitialSchedules.UtilInitialSchedules.refineInitialSchedules(bestInitialSchedules);
// On pourrait creer un petit interface pour afficher les horaires optimales et les statistiques.
InitialSchedules.UtilInitialSchedules.printSolutionResults(myModelInitialSchedules, myScheduleParameters);
solverInitialSchedules.printStatistics();
//TODO Creer objet banque horaire
// Création de l'objet banque d'horaire, qui est une liste d'objets de type InitialSchedulesArray, qui contiennent chacun deux tableaux.
List<InitialSchedules.InitialSchedulesArray> InitialSchedulesArrayList = new ArrayList<>();
for (Solution CurrentSolution : myInitialSchedulesSolutions) {
InitialSchedulesArray isa = new InitialSchedules.InitialSchedulesArray(myModelInitialSchedules, CurrentSolution);
InitialSchedulesArrayList.add(isa);
}
// Imprimer la liste de matrices
/*for (InitialSchedulesArray isa: InitialSchedulesArrayList) {
System.out.println(Arrays.deepToString(isa.InitialPartTimeSchedules));
}
for (InitialSchedulesArray isa: InitialSchedulesArrayList) {
System.out.println(Arrays.deepToString(isa.InitialFullTimeSchedules));
}*/
}
}