WIP modifications VariableDemand

This commit is contained in:
François Pelletier 2018-04-14 19:21:52 -04:00
parent 177435db08
commit ed45dbfc2c
12 changed files with 695 additions and 681 deletions

File diff suppressed because it is too large Load diff

View file

@ -70,7 +70,7 @@ public class ModelFullTimeEmployeesInitialSchedules {
transposeWorkPeriodsSchedulesOfFullTimeEmployees[workPeriod],
this.fullTimeEmployeesPerWorkPeriods[workPeriod]).post();
chocoModelInitialSchedules.arithm(this.fullTimeEmployeesPerWorkPeriods[workPeriod], "<=",
this.myScheduleParameters.requiredWorkforce[workPeriod]).post();
this.myScheduleParameters.getRequiredWorkForce(workPeriod)).post();
}

View file

@ -65,7 +65,7 @@ public class ModelPartTimeEmployeesInitialSchedules {
transposeWorkPeriodsSchedulesOfPartTimeEmployees[workPeriod],
this.partTimeEmployeesPerWorkPeriods[workPeriod]).post();
chocoModelInitialSchedules.arithm(this.partTimeEmployeesPerWorkPeriods[workPeriod], "=",
this.myScheduleParameters.requiredWorkforce[workPeriod]).post();
this.myScheduleParameters.getRequiredWorkForce(workPeriod)).post();
}
// Contrainte de bris de symétrie:

View file

@ -31,7 +31,7 @@ public class ParametersInitialSchedules {
private final int maxConsecutiveWorkingHoursOfFullTimeEmployeesPerShiftWork = 12;
private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12;
int[] requiredWorkforce;
private int[] requiredWorkforce;
int NbFullTimeSolutions;
int NbPartTimeSolutions;
Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
@ -79,7 +79,9 @@ public class ParametersInitialSchedules {
}
public void setRequiredWorkforce(int[] vector) {
this.requiredWorkforce = vector;
for(int workPeriod=0;workPeriod<vector.length;workPeriod++) {
this.requiredWorkforce[workPeriod] = vector[workPeriod];
}
}
public int getDaysPerSchedule() {

View file

@ -2,6 +2,9 @@ import AbsenceSchedules.*;
import InitialSchedules.*;
import ScheduleUtil.*;
import SchedulesRecovery.*;
import VariableDemandSchedules.BankVariableDemandSchedules;
import VariableDemandSchedules.ParametersVariableDemandSimulator;
import VariableDemandSchedules.VariableDemandSchedulesArray;
import jdistlib.rng.MersenneTwister;
import jdistlib.rng.RandomEngine;
import org.chocosolver.solver.Solution;
@ -10,6 +13,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
@SuppressWarnings("unused")
public class MainClass {
public static void main(String[] args) {
@ -24,17 +28,20 @@ public class MainClass {
List<SchedulesArray> initialSchedulesArrayList = generateInitialSchedules();
//List<BankVariableDemandSchedules> listBankVariableDemandSchedules = GenerateModifiedDemandSchedules(initialSchedulesArrayList);
List<BankAbsenceSchedules> listBankAbsenceSchedules = GenerateAbsencesSchedules(initialSchedulesArrayList);
List<BankRecoveredSchedules> bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankAbsenceSchedules);
SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost);
@SuppressWarnings("unused") SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost);
// int optimalFullTimeEmployee = bankRecoveredSchedulesOrderedByMeanCost.get(0).initialSchedulesArray.getNumberFullTimeEmployee();
// System.out.println(optimalFullTimeEmployee + " ");
// }
}
@SuppressWarnings("unused")
private static List<SchedulesArray> generateInitialSchedules() {
// Trouver les horaires des employes a temps plein possibles pour different ratio templein/temps partiel
@ -42,7 +49,7 @@ public class MainClass {
InitialSchedules.ParametersInitialSchedules myScheduleParameters = new InitialSchedules.ParametersInitialSchedules();
int minFullTimeEmployee = 2; //La solution avec 1 employes est trop lente
int minFullTimeEmployee = 3; //La solution avec 1 employes est trop lente
int maxFullTimeEmployee = 9; //9 est le max d'employes a temps plein pour la presente requiredWorkforce
@ -90,6 +97,25 @@ public class MainClass {
}
private static List<BankVariableDemandSchedules> GenerateModifiedDemandSchedules(List<SchedulesArray> initialSchedulesArrayList) {
RandomEngine r = new MersenneTwister(987654321);
List<BankVariableDemandSchedules> listBankVariableDemandSchedules = new ArrayList<>();
List<SchedulesArray> listVariableDemandSchedules = new ArrayList<>(); // to be removed
for (SchedulesArray initialSchedule : initialSchedulesArrayList) {
BankVariableDemandSchedules bankVariableDemandSimulations = new BankVariableDemandSchedules(initialSchedule);
for (int simNum = 0; simNum < ParametersVariableDemandSimulator.numberVariableDemandSimulation ; simNum++){
VariableDemandSchedulesArray variableDemandSchedule = new VariableDemandSchedulesArray(initialSchedule,r);
listVariableDemandSchedules.add(variableDemandSchedule);
bankVariableDemandSimulations.addVariableDemandSchedules(variableDemandSchedule);
}
listBankVariableDemandSchedules.add(bankVariableDemandSimulations);
}
// Pour afficher les horaires avec demande modifiée
SchedulesWindows.ShowSchedulesFrame variableDemandSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listVariableDemandSchedules,"Variable Demand Schedules");
return listBankVariableDemandSchedules;
}
private static List<BankAbsenceSchedules> GenerateAbsencesSchedules(List<SchedulesArray> initialSchedulesArrayList) {
RandomEngine r = new MersenneTwister(123456789);

View file

@ -8,6 +8,8 @@ package ScheduleUtil;
import AbsenceSchedules.AbsenceSchedulesArray;
import InitialSchedules.ParametersInitialSchedules;
import SchedulesRecovery.RecoveredSchedulesArray;
import VariableDemandSchedules.VariableDemandSchedulesArray;
/**
*
* @author frabe
@ -28,6 +30,18 @@ public class EmployeeCostCalculator {
}
return totalCost;
}
public static int getFullVariableDemandScheduleCost( VariableDemandSchedulesArray myVariableDemandSchedule, ParametersInitialSchedules myScheduleParameters) {
int totalCost = 0;
/* Coût spécifique à une augmentation de la demande */
for(int p=0;p<myScheduleParameters.getWorkPeriodsPerSchedule();p++){
totalCost += (myVariableDemandSchedule.getInitialSchedulesArrayVariableDemand().myParametersInitialSchedules.getRequiredWorkForce(p)-myScheduleParameters.getRequiredWorkForce(p))*
myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate()*1.5;
}
totalCost += getFullInitialScheduleCost(myVariableDemandSchedule.getInitialSchedulesArray(),myScheduleParameters);
return totalCost;
}
public static int getFullAbsenceScheduleCost( AbsenceSchedulesArray myAbsenceSchedule, ParametersInitialSchedules myScheduleParameters) {
int totalCost = 0;

View file

@ -55,10 +55,8 @@ public class SchedulesArray {
this.myParametersInitialSchedules = myParametersInitialSchedules;
this.myParametersInitialSchedules.setRequiredWorkforce(VariableDemandVector);
this.partTimeSchedules = pteisa;
this.fullTimeSchedules = fteisa;
this.totalScheduleCost = EmployeeCostCalculator.getFullInitialScheduleCost(this, myParametersInitialSchedules);
this.partTimeSchedules = getDeepCopyEmployeesSchedules(pteisa);
this.fullTimeSchedules = getDeepCopyEmployeesSchedules(fteisa);
}
protected boolean[][] getDeepCopyEmployeesSchedules(boolean[][] schedules) {

View file

@ -1,6 +1,5 @@
package VariableDemandSchedules;
public class ParametersVariableDemandSimulator {
public static final double lambda = 2;
public static final int numberVariableDemandSimulation = 1000;
public static final int numberVariableDemandSimulation = 1;
}

View file

@ -11,7 +11,7 @@ public class VariableDemandSchedulesArray extends SchedulesArray {
public VariableDemandSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) {
super(initialSchedulesArray);
this.initialSchedulesArray = initialSchedulesArray;
generateDemandSimulation();
generateDemandSimulation(r);
this.totalScheduleCost = EmployeeCostCalculator.getFullVariableDemandScheduleCost(this, myParametersInitialSchedules);
}
@ -19,7 +19,7 @@ public class VariableDemandSchedulesArray extends SchedulesArray {
int[] vd = new VariableDemandVector(this.myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getVariableDemandVector();
int[] adjd = new int[this.myParametersInitialSchedules.getWorkPeriodsPerSchedule()];
for (int p = 0; p < this.myParametersInitialSchedules.getWorkPeriodsPerSchedule(); p++) {
adjd[p] = this.myParametersInitialSchedules.getRequiredWorkForce(p) + vd[p];
adjd[p] = /*this.myParametersInitialSchedules.getRequiredWorkForce(p) + */vd[p];
}
this.initialSchedulesArrayVariableDemand = new SchedulesArray(
@ -33,4 +33,8 @@ public class VariableDemandSchedulesArray extends SchedulesArray {
public SchedulesArray getInitialSchedulesArrayVariableDemand() {
return initialSchedulesArrayVariableDemand;
}
public SchedulesArray getInitialSchedulesArray() {
return initialSchedulesArray;
}
}

View file

@ -1,14 +1,14 @@
package VariableDemandSchedules;
import jdistlib.Poisson;
import jdistlib.Binomial;
import jdistlib.rng.RandomEngine;
public class VariableDemandVector {
private final int[] VariableDemandVector;
private int[] VariableDemandVector;
VariableDemandVector(int length, RandomEngine r) {
VariableDemandVector = new int[length];
Poisson p1 = new Poisson(ParametersVariableDemandSimulator.lambda);
Binomial p1 = new Binomial(1,0.5);
p1.setRandomEngine(r);
for (int i = 0; i < length; i++) {
VariableDemandVector[i] = (int) p1.random();