diff --git a/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java b/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java new file mode 100644 index 0000000..f35cfcf --- /dev/null +++ b/Travail_de_session/AbsenceSchedules/AbsenceSchedulesArray.java @@ -0,0 +1,41 @@ +package AbsenceSchedules; + +import InitialSchedules.InitialSchedulesArray; +import jdistlib.rng.RandomEngine; + +public class AbsenceSchedulesArray { + private int[][] PartTimeSchedules; + private int[][] FullTimeSchedules; + + public AbsenceSchedulesArray(InitialSchedulesArray I, RandomEngine r) { + + int mpte = I.getMaxPartTimeEmployee(); + int mfte = I.getMaxFullTimeEmployee(); + int[][] pts = I.getPartTimeSchedules(); + int[][] fts = I.getFullTimeSchedules(); + int wps = I.getWorkPeriodsPerSchedule(); + PartTimeSchedules = new int[mpte][wps]; + FullTimeSchedules = new int[mfte][wps]; + + for (int i = 0; i < I.getMaxPartTimeEmployee(); i++) { + int[] a = new AbsencesVector(wps, r).getAbsencesVector(); + for (int j = 0; j < wps; j++) { + this.PartTimeSchedules[i][j] = pts[i][j] * a[j]; + } + } + for (int i = 0; i < I.getMaxFullTimeEmployee(); i++) { + int[] a = new AbsencesVector(wps, r).getAbsencesVector(); + for (int j = 0; j < wps; j++) { + this.FullTimeSchedules[i][j] = fts[i][j] * a[j]; + } + } + } + + public int[][] getFullTimeSchedules() { + return FullTimeSchedules; + } + + public int[][] getPartTimeSchedules() { + return PartTimeSchedules; + } +} \ No newline at end of file diff --git a/Travail_de_session/AbsenceSchedules/AbsencesVector.java b/Travail_de_session/AbsenceSchedules/AbsencesVector.java new file mode 100644 index 0000000..7e6f8a8 --- /dev/null +++ b/Travail_de_session/AbsenceSchedules/AbsencesVector.java @@ -0,0 +1,33 @@ +package AbsenceSchedules; + +import jdistlib.Binomial; +import jdistlib.rng.RandomEngine; + +public class AbsencesVector { + private int[] AbsencesVector; + private double probAbsence = 0.02; + private double probReturn = 0.50; + + public AbsencesVector(int length, RandomEngine r) { + + int current = 1; + AbsencesVector = new int[length]; + Binomial b1 = new Binomial(1, probAbsence); + b1.setRandomEngine(r); + Binomial b2 = new Binomial(1, probReturn); + b2.setRandomEngine(r); + for (int i = 0; i < length; i++) { + if (current == 1) { + current = (int) b1.random(); + AbsencesVector[i] = current; + } else { + current = (int) b2.random(); + AbsencesVector[i] = current; + } + } + } + + public int[] getAbsencesVector() { + return AbsencesVector; + } +} diff --git a/Travail_de_session/InitialSchedules/InitialSchedulesArray.java b/Travail_de_session/InitialSchedules/InitialSchedulesArray.java index d5b6847..75adf84 100644 --- a/Travail_de_session/InitialSchedules/InitialSchedulesArray.java +++ b/Travail_de_session/InitialSchedules/InitialSchedulesArray.java @@ -4,27 +4,52 @@ import org.chocosolver.solver.Solution; public class InitialSchedulesArray { - public int[][] InitialPartTimeSchedules; - public int[][] InitialFullTimeSchedules; + private int[][] PartTimeSchedules; + private int[][] FullTimeSchedules; + private int maxPartTimeEmployee; + private int maxFullTimeEmployee; + private int workPeriodsPerSchedule; 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]); + Solution mySolution = s; + this.maxPartTimeEmployee = myModelInitialSchedules.maxPartTimeEmployee; + this.maxFullTimeEmployee = myModelInitialSchedules.maxFullTimeEmployee; + this.workPeriodsPerSchedule = myModelInitialSchedules.myScheduleParameters.workPeriodsPerSchedule; + + this.PartTimeSchedules = new int[this.maxPartTimeEmployee][this.workPeriodsPerSchedule]; + this.FullTimeSchedules = new int[this.maxFullTimeEmployee][this.workPeriodsPerSchedule]; + for (int workPeriod = 0; workPeriod < this.workPeriodsPerSchedule; workPeriod++) { + for (int employee = 0; employee < this.maxPartTimeEmployee; employee++) { + this.PartTimeSchedules[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]); + for (int workPeriod = 0; workPeriod < this.workPeriodsPerSchedule; workPeriod++) { + for (int employee = 0; employee < this.maxFullTimeEmployee; employee++) { + this.FullTimeSchedules[employee][workPeriod] = mySolution.getIntVal(myModelInitialSchedules.workPeriodsSchedulesOfFullTimeEmployees[employee][workPeriod]); } } + } + public int getMaxFullTimeEmployee() { + return maxFullTimeEmployee; + } + + public int getMaxPartTimeEmployee() { + return maxPartTimeEmployee; + } + + public int getWorkPeriodsPerSchedule() { + return workPeriodsPerSchedule; + } + + public int[][] getFullTimeSchedules() { + return FullTimeSchedules; + } + + public int[][] getPartTimeSchedules() { + return PartTimeSchedules; } } diff --git a/Travail_de_session/MainClass.java b/Travail_de_session/MainClass.java index 570d24e..94a73be 100644 --- a/Travail_de_session/MainClass.java +++ b/Travail_de_session/MainClass.java @@ -1,4 +1,7 @@ +import AbsenceSchedules.AbsenceSchedulesArray; import InitialSchedules.InitialSchedulesArray; +import jdistlib.rng.MersenneTwister; +import jdistlib.rng.RandomEngine; import org.chocosolver.solver.Solution; import org.chocosolver.solver.Solver; import org.chocosolver.solver.exception.ContradictionException; @@ -11,14 +14,17 @@ public class MainClass { public static void main(String[] args) { // Le main ne devrait contenir que les 5 fonctions correspondantes aux etapes du pipeline - generateInitialSchedule(); + List InitialSchedulesArrayList = generateInitialSchedule(); + GenerateAbsencesSchedule(InitialSchedulesArrayList); // Creer les simulation avec une autre classe. Faire un nouveau package de fonctions. // Algo de recouvrement d'absences. Faire un nouveau package de fonctions. // Trouver meilleure solution et l'afficher. } - private static void generateInitialSchedule() { + private static List generateInitialSchedule() { + + List InitialSchedulesArrayList = new ArrayList<>(); InitialSchedules.ParametersInitialSchedules myScheduleParameters = new InitialSchedules.ParametersInitialSchedules(); @@ -40,7 +46,7 @@ public class MainClass { //solverInitialSchedules.showDashboard(); /*solverInitialSchedules.setSearch(Search.domOverWDegSearch(myModelInitialSchedules.allWorkPeriods));*/ //solverInitialSchedules.setRestartOnSolutions(); /*Sans restart, toutes les horaires sont identiques*/ - solverInitialSchedules.limitSolution(100); + solverInitialSchedules.limitSolution(2); solverInitialSchedules.limitTime(10000); List myInitialSchedulesSolutions; myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions @@ -54,7 +60,6 @@ public class MainClass { // Création de l'objet banque d'horaire, qui est une liste d'objets de type InitialSchedulesArray, qui contiennent chacun deux tableaux. - List InitialSchedulesArrayList = new ArrayList<>(); for (Solution CurrentSolution : myInitialSchedulesSolutions) { InitialSchedulesArray isa = new InitialSchedules.InitialSchedulesArray(myModelInitialSchedules, CurrentSolution); @@ -68,5 +73,17 @@ public class MainClass { for (InitialSchedulesArray isa: InitialSchedulesArrayList) { System.out.println(Arrays.deepToString(isa.InitialFullTimeSchedules)); }*/ + + return InitialSchedulesArrayList; + + } + + private static void GenerateAbsencesSchedule(List InitialSchedulesArrayList) { + RandomEngine r = new MersenneTwister(123456789); + for (InitialSchedulesArray Schedule : InitialSchedulesArrayList) { + AbsenceSchedulesArray a = new AbsenceSchedulesArray(Schedule, r); + //System.out.println(Arrays.deepToString(a.getPartTimeSchedules())); + //System.out.println(Arrays.deepToString(a.getFullTimeSchedules())); + } } } diff --git a/Travail_de_session/jdistlib-0.4.5-bin.jar b/Travail_de_session/jdistlib-0.4.5-bin.jar new file mode 100644 index 0000000..3fcb3c3 Binary files /dev/null and b/Travail_de_session/jdistlib-0.4.5-bin.jar differ