Modification de la demande de travail fonctionnelle.

Correction de quelques bugs.
This commit is contained in:
Francois Berube\frabe 2018-04-16 17:47:05 -04:00
parent f439eba462
commit a0275cab5a
27 changed files with 272 additions and 318 deletions

View file

@ -14,7 +14,7 @@ import org.chocosolver.solver.variables.IntVar;
* @author frabe
*/
public class ModelFullTimeEmployeesInitialSchedules {
public final ParametersInitialSchedules myScheduleParameters;
public final ParametersSchedules myScheduleParameters;
public final int numberOfFullTimeEmployees;
@ -25,7 +25,7 @@ public class ModelFullTimeEmployeesInitialSchedules {
public final Model chocoModelInitialSchedules;
public ModelFullTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters, int numberOfFullTimeEmployees) {
public ModelFullTimeEmployeesInitialSchedules(ParametersSchedules myScheduleParameters, int numberOfFullTimeEmployees) {
this.myScheduleParameters = myScheduleParameters;
this.chocoModelInitialSchedules = new Model("Model Full Time Employees Initial Schedules");

View file

@ -6,7 +6,7 @@ import org.chocosolver.solver.variables.IntVar;
public class ModelPartTimeEmployeesInitialSchedules {
public final ParametersInitialSchedules myScheduleParameters;
public final ParametersSchedules myScheduleParameters;
public final int maxPartTimeEmployee;
@ -17,7 +17,7 @@ public class ModelPartTimeEmployeesInitialSchedules {
public final Model chocoModelInitialSchedules;
public ModelPartTimeEmployeesInitialSchedules(ParametersInitialSchedules myScheduleParameters) {
public ModelPartTimeEmployeesInitialSchedules(ParametersSchedules myScheduleParameters) {
this.myScheduleParameters = myScheduleParameters;

View file

@ -3,7 +3,7 @@ package InitialSchedules;
import ScheduleUtil.FullTimeEmployeeScheduleArray;
import org.chocosolver.solver.constraints.extension.Tuples;
public class ParametersInitialSchedules {
public class ParametersSchedules {
//General Parameters
private final int shiftWorkPerDay = 3;
@ -15,10 +15,10 @@ public class ParametersInitialSchedules {
//PartTime Employees Parameters
private final int fixedCostOfPartTimeEmployeesPerSchedule = 50;
private final int regularHourlyRateOfPartTimeEmployees = 12;
private final int overtimeHourlyRateOfPartTimeEmployees = 17;
private final int regularHourlyRateOfPartTimeEmployees = 11;
private final int overtimeHourlyRateOfPartTimeEmployees = 16;
private final int minWorkingHoursOfPartTimeEmployeesPerSchedule = 32;
private final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 64;
private final int maxWorkingHoursOfPartTimeEmployeesPerSchedule = 80;
private final int maxConsecutiveWorkingHoursOfPartTimeEmployeesPerShiftWork = 12;
private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfPartTimeEmployees = 12;
@ -32,21 +32,27 @@ public class ParametersInitialSchedules {
private final int minConsecutiveNonWorkingHoursBetweenShiftWorksOfFullTimeEmployees = 12;
private int[] requiredWorkforce;
int NbFullTimeSolutions;
int NbPartTimeSolutions;
Tuples enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
Tuples enumerationWorkPeriodsSchedulesOfPartTimeEmployees;
private Tuples ValidPartTimeEmployeeShiftTuples;
public ParametersInitialSchedules() {
public ParametersSchedules(ParametersSchedules myScheduleParameters) {
this.requiredWorkforce = new int[this.getWorkPeriodsPerSchedule()];
for (int workPeriod = 0 ; workPeriod < getWorkPeriodsPerSchedule() ; workPeriod++) {
this.requiredWorkforce[workPeriod] = myScheduleParameters.getRequiredWorkForce(workPeriod);
}
this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees = myScheduleParameters.enumerationWorkPeriodsSchedulesOfFullTimeEmployees;
this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees = myScheduleParameters.enumerationWorkPeriodsSchedulesOfPartTimeEmployees;
}
public ParametersSchedules() {
this.setRequiredWorkforce();
this.enumerationWorkPeriodsSchedulesOfFullTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfFullTimeEmployees(
shiftWorkPerDay, getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule);
this.enumerationWorkPeriodsSchedulesOfPartTimeEmployees = GenerationPossibleEmployeeSchedules.setWorkPeriodsSchedulesOfPartTimeEmployees(
getWorkPeriodsPerSchedule(), getWorkPeriodPerDay(), daysPerSchedule);
this.ValidPartTimeEmployeeShiftTuples = new ValidPartTimeEmployeeShift().makeTuples();
}
private void setRequiredWorkforce() {
@ -56,6 +62,15 @@ public class ParametersInitialSchedules {
for (int day = 0; day < this.daysPerSchedule; day++) {
System.arraycopy(dailyRequiredWorkforce, 0, this.requiredWorkforce, day * this.getWorkPeriodPerDay(), this.getWorkPeriodPerDay());
}
}
public void modifyRequiredWorkForce(int[] variableDemandVector) {
for (int workPeriod = 0 ; workPeriod < this.getWorkPeriodsPerSchedule() ; workPeriod++) {
this.requiredWorkforce[workPeriod] += variableDemandVector[workPeriod];
}
}
public void adjustRequiredWorkforce( FullTimeEmployeeScheduleArray fullTimeSchedule) {
@ -165,7 +180,4 @@ public class ParametersInitialSchedules {
return this.workingHoursOfFullTimeEmployeesPerSchedule / this.hoursPerWorkPeriod;
}
// A implementer plus tard si l'on veut travailler avec des fichiers texte
public ParametersInitialSchedules(String fileName) {}
}

View file

@ -1,10 +1,7 @@
import AbsenceSchedules.*;
import InitialSchedules.*;
import ScheduleUtil.*;
import SchedulesRecovery.*;
import VariableDemandSchedules.BankVariableDemandSchedules;
import VariableDemandSchedules.ParametersVariableDemandSimulator;
import VariableDemandSchedules.VariableDemandSchedulesArray;
import ModifiedSchedules.*;
import jdistlib.rng.MersenneTwister;
import jdistlib.rng.RandomEngine;
import org.chocosolver.solver.Solution;
@ -18,37 +15,37 @@ public class MainClass {
public static void main(String[] args) {
ParametersSchedules myScheduleParameters = new InitialSchedules.ParametersSchedules();
// for (int i = 0 ; i <= 10 ; i++) {
// ParametersAbsencesSimulator.probPresence = (double) i * 0.01 + 0.9; // Pour de 0.9 a 1.0 par increment de 0.01
// ParametersAbsencesSimulator.probPresence = 1 - (double) i * 0.01; // Pour de 0.90 a 1.0 par increment de 0.01
// System.out.print("Probabilité absence = " + (1-ParametersAbsencesSimulator.probPresence));
// for (int j = 0 ; j <= 10 ; j++) {
// ParametersVariableDemandSimulator.probIncreasedDemandbyOne = (double) j * 0.1; // Pour de 0 a 1 par increment de 0.1
// ParametersVariableDemandSimulator.probIncreasedDemandbyTwo = ParametersVariableDemandSimulator.probIncreasedDemandbyOne/5; // Pour de 0 a 0.25 par increment de 0.05
// ParametersVariableDemandSimulator.probIncreasedDemandbyThree = ParametersVariableDemandSimulator.probIncreasedDemandbyOne/25; // Pour de 0 a 0.25 par increment de 0.05
List<SchedulesArray> initialSchedulesArrayList = generateInitialSchedules(myScheduleParameters);
// Placer une sous-boucle pour faire varier la probabilite d'augmentation de la demande.
List<SchedulesArray> initialSchedulesArrayList = generateInitialSchedules();
List<BankModifiedSchedules> listBankModifiedSchedules = GenerateModifiedSchedules(initialSchedulesArrayList, myScheduleParameters);
//List<BankVariableDemandSchedules> listBankVariableDemandSchedules = GenerateModifiedDemandSchedules(initialSchedulesArrayList);
List<BankRecoveredSchedules> bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankModifiedSchedules);
List<BankAbsenceSchedules> listBankAbsenceSchedules = GenerateAbsencesSchedules(initialSchedulesArrayList);
List<BankRecoveredSchedules> bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankAbsenceSchedules);
@SuppressWarnings("unused") SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost);
SchedulesWindows.ShowSolutionResultsFrame initialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost);
// int optimalFullTimeEmployee = bankRecoveredSchedulesOrderedByMeanCost.get(0).initialSchedulesArray.getNumberFullTimeEmployee();
// System.out.println(optimalFullTimeEmployee + " ");
// System.out.print(optimalFullTimeEmployee + " ");
// }
// System.out.println(" ");
// }
}
@SuppressWarnings("unused")
private static List<SchedulesArray> generateInitialSchedules() {
private static List<SchedulesArray> generateInitialSchedules(ParametersSchedules myScheduleParameters) {
// Trouver les horaires des employes a temps plein possibles pour different ratio templein/temps partiel
List<SchedulesArray> initialSchedulesArrayList = new ArrayList<>();
InitialSchedules.ParametersInitialSchedules myScheduleParameters = new InitialSchedules.ParametersInitialSchedules();
int minFullTimeEmployee = 2; //La solution avec 1 employes est trop lente
int maxFullTimeEmployee = 9; //9 est le max d'employes a temps plein pour la presente requiredWorkforce
@ -69,7 +66,7 @@ public class MainClass {
for (Solution CurrentFullTimeEmployeesSolution : myInitialFullTimeEmployeesSchedulesSolutions) {
FullTimeEmployeeScheduleArray fullTimeSchedulesArray = new FullTimeEmployeeScheduleArray(myModelFullTimeEmployeesInitialSchedules, CurrentFullTimeEmployeesSolution);
InitialSchedules.ParametersInitialSchedules myPartTimeScheduleParameters = new InitialSchedules.ParametersInitialSchedules();
InitialSchedules.ParametersSchedules myPartTimeScheduleParameters = new InitialSchedules.ParametersSchedules();
myPartTimeScheduleParameters.adjustRequiredWorkforce(fullTimeSchedulesArray);
InitialSchedules.ModelPartTimeEmployeesInitialSchedules myModelPartTimeEmployeesInitialSchedules
@ -81,7 +78,7 @@ public class MainClass {
for (Solution CurrentPartTimeEmployeesSolution : myInitialPartTimeEmployeesSchedulesSolutions) {
PartTimeEmployeeScheduleArray partTimeSchedulesArray = new PartTimeEmployeeScheduleArray(myModelPartTimeEmployeesInitialSchedules, CurrentPartTimeEmployeesSolution);
SchedulesArray initialSchedulesArray = new SchedulesArray(fullTimeSchedulesArray, partTimeSchedulesArray, simulationNumber);
SchedulesArray initialSchedulesArray = new SchedulesArray(fullTimeSchedulesArray, partTimeSchedulesArray, myScheduleParameters, simulationNumber);
initialSchedulesArrayList.add(initialSchedulesArray);
simulationNumber++;
}
@ -97,65 +94,62 @@ 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) {
private static List<BankModifiedSchedules> GenerateModifiedSchedules(List<SchedulesArray> initialSchedulesArrayList, ParametersSchedules myScheduleParameters) {
RandomEngine r = new MersenneTwister(123456789);
List<BankAbsenceSchedules> listBankAbsenceSchedules = new ArrayList<>();
List<SchedulesArray> listAbsenceSchedules = new ArrayList<>(); // to be removed
for (SchedulesArray initialSchedule : initialSchedulesArrayList) {
BankAbsenceSchedules bankAbsenceSimulations = new BankAbsenceSchedules(initialSchedule);
for (int simNum = 0 ; simNum < ParametersAbsencesSimulator.numberAbsenceSimulations ; simNum++) {
AbsenceSchedulesArray absenceSchedule = new AbsenceSchedulesArray(initialSchedule, r);
listAbsenceSchedules.add(absenceSchedule); // to be removed
bankAbsenceSimulations.addAbsenceSchedules(absenceSchedule);
}
listBankAbsenceSchedules.add(bankAbsenceSimulations);
RandomEngine randAbsence = new MersenneTwister(123456789);
// generation de nouveaux vecteurs de demande de travail
RandomEngine randVariableDemand = new MersenneTwister(987654321);
int[][] matrixVariableDemandVector = new int[ParametersVariableDemandSimulator.numberVariableDemandSimulations][myScheduleParameters.getWorkPeriodsPerSchedule()];
for (int varDemSimNum = 0 ; varDemSimNum < ParametersVariableDemandSimulator.numberVariableDemandSimulations ; varDemSimNum++) {
matrixVariableDemandVector[varDemSimNum] = new ModifiedSchedules.VariableDemandVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randVariableDemand).getVariableDemandVector();
}
// Pour afficher les horaires avec absence
SchedulesWindows.ShowSchedulesFrame absenceSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listAbsenceSchedules, "Absence Schedules"); // to be removed
List<BankModifiedSchedules> listBankModifiedSchedules = new ArrayList<>();
List<SchedulesArray> listModifiedSchedules = new ArrayList<>(); // to be removed
for (SchedulesArray initialSchedule : initialSchedulesArrayList) {
BankModifiedSchedules bankModificationSimulations = new BankModifiedSchedules(initialSchedule);
for (int varDemSimNum = 0 ; varDemSimNum < ParametersVariableDemandSimulator.numberVariableDemandSimulations ; varDemSimNum++) {
int[] variableDemandVector = matrixVariableDemandVector[varDemSimNum];
ParametersSchedules myModifiedScheduleParameters = new InitialSchedules.ParametersSchedules(myScheduleParameters);
myModifiedScheduleParameters.modifyRequiredWorkForce(variableDemandVector);
for (int absSimNum = 0 ; absSimNum < ParametersAbsencesSimulator.numberAbsenceSimulations ; absSimNum++) {
ModifiedSchedulesArray modifiedSchedule = new ModifiedSchedulesArray(initialSchedule, myModifiedScheduleParameters, randAbsence);
listModifiedSchedules.add(modifiedSchedule); // to be removed
bankModificationSimulations.addModifiedSchedules(modifiedSchedule);
}
}
listBankModifiedSchedules.add(bankModificationSimulations);
}
return listBankAbsenceSchedules;
// Pour afficher les horaires modifies
SchedulesWindows.ShowSchedulesFrame modifiedSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listModifiedSchedules, "Modified Schedules"); // to be removed
return listBankModifiedSchedules;
}
private static List<BankRecoveredSchedules> GenerateOptimalRecoveredSchedules(List<BankAbsenceSchedules> listBankAbsenceSchedules) {
private static List<BankRecoveredSchedules> GenerateOptimalRecoveredSchedules(List<BankModifiedSchedules> listBankModifiedSchedules) {
BankRecoveredSchedulesComparator meanCostComparator = new BankRecoveredSchedulesComparator();
PriorityQueue< BankRecoveredSchedules > bankRecoveredSchedulesOrderedByMeanCost = new PriorityQueue<>(meanCostComparator);
List<SchedulesArray> listRecoveredSchedules = new ArrayList<>(); // to be removed
for (BankAbsenceSchedules bankAbsenceSchedule : listBankAbsenceSchedules) {
SchedulesArray initialSchedulesArray = bankAbsenceSchedule.initialSchedulesArray;
BankRecoveredSchedules bankRecoveredSimulations = new BankRecoveredSchedules(initialSchedulesArray, bankAbsenceSchedule.bankAbsenceSimulation);
for (BankModifiedSchedules bankModifiedSchedule : listBankModifiedSchedules) {
SchedulesArray initialSchedulesArray = bankModifiedSchedule.initialSchedulesArray;
BankRecoveredSchedules bankRecoveredSimulations = new BankRecoveredSchedules(initialSchedulesArray, bankModifiedSchedule.bankModifiedSimulation);
int totalCostRecoveredSimulations = 0;
for (AbsenceSchedulesArray absenceSchedule : bankAbsenceSchedule.bankAbsenceSimulation) {
RecoveredSchedulesArray recoveredSchedule = new RecoveredSchedulesArray(absenceSchedule);
for (ModifiedSchedulesArray modifiedSchedule : bankModifiedSchedule.bankModifiedSimulation) {
RecoveredSchedulesArray recoveredSchedule = new RecoveredSchedulesArray(modifiedSchedule);
listRecoveredSchedules.add(recoveredSchedule); // to be removed
bankRecoveredSimulations.addRecoveredSchedules(recoveredSchedule);
if (recoveredSchedule.totalScheduleCost != Integer.MAX_VALUE){
totalCostRecoveredSimulations += recoveredSchedule.totalScheduleCost;
} else {
bankRecoveredSimulations.numberUnResolvedSimulations += 1;
}
}
bankRecoveredSimulations.meanCostRecoveredSimulations = totalCostRecoveredSimulations / bankRecoveredSimulations.bankRecoveredSimulation.size();
// System.out.print(bankRecoveredSimulations.meanCostRecoveredSimulations + " ");
bankRecoveredSchedulesOrderedByMeanCost.add(bankRecoveredSimulations);
}
// Pour afficher les horaires de recouvrement

View file

@ -1,19 +1,19 @@
package AbsenceSchedules;
package ModifiedSchedules;
import jdistlib.Binomial;
import jdistlib.rng.RandomEngine;
class AbsencesVector {
private final boolean[] AbsencesVector;
public class AbsencesVector {
public boolean[] AbsencesVector;
public AbsencesVector(int length, RandomEngine r) {
public AbsencesVector(int length, RandomEngine randAbsence) {
int current = 1;
AbsencesVector = new boolean[length];
Binomial b1 = new Binomial(1, ParametersAbsencesSimulator.probPresence);
b1.setRandomEngine(r);
b1.setRandomEngine(randAbsence);
Binomial b2 = new Binomial(1, ParametersAbsencesSimulator.probReturn);
b2.setRandomEngine(r);
b2.setRandomEngine(randAbsence);
for (int i = 0; i < length; i++) {
if (current == 1) {
current = (int) b1.random();

View file

@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package AbsenceSchedules;
package ModifiedSchedules;
import ScheduleUtil.SchedulesArray;
@ -14,16 +14,16 @@ import java.util.List;
*
* @author frabe
*/
public class BankAbsenceSchedules {
public class BankModifiedSchedules {
public final SchedulesArray initialSchedulesArray;
public final List<AbsenceSchedulesArray> bankAbsenceSimulation;
public final List<ModifiedSchedulesArray> bankModifiedSimulation;
public BankAbsenceSchedules(SchedulesArray initialSchedulesArray) {
public BankModifiedSchedules(SchedulesArray initialSchedulesArray) {
this.initialSchedulesArray = initialSchedulesArray;
this.bankAbsenceSimulation = new ArrayList<>();
this.bankModifiedSimulation = new ArrayList<>();
}
public void addAbsenceSchedules(AbsenceSchedulesArray absenceSchedulesArray) {
this.bankAbsenceSimulation.add(absenceSchedulesArray);
public void addModifiedSchedules(ModifiedSchedulesArray modifiedSchedulesArray) {
this.bankModifiedSimulation.add(modifiedSchedulesArray);
}
}

View file

@ -1,44 +1,44 @@
package AbsenceSchedules;
package ModifiedSchedules;
import ScheduleUtil.EmployeeCostCalculator;
import ScheduleUtil.SchedulesArray;
import InitialSchedules.*;
import ScheduleUtil.*;
import jdistlib.rng.RandomEngine;
public class AbsenceSchedulesArray extends SchedulesArray{
public class ModifiedSchedulesArray extends SchedulesArray{
private final SchedulesArray initialSchedulesArray;
public int numberOfRecoveringActionsToPerform;
public AbsenceSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) {
public ModifiedSchedulesArray(SchedulesArray initialSchedulesArray, ParametersSchedules myModifiedScheduleParameters, RandomEngine randAbsence) {
super(initialSchedulesArray);
this.myScheduleParameters = myModifiedScheduleParameters;
this.initialSchedulesArray = initialSchedulesArray;
generateAbsenceSimulation(r);
this.totalScheduleCost = EmployeeCostCalculator.getFullAbsenceScheduleCost(this, myParametersInitialSchedules);
generateAbsenceSimulation(randAbsence);
calculateNumberOfRecoveringActionsToPerform();
this.totalScheduleCost = EmployeeCostCalculator.getFullModifiedScheduleCost(this, myScheduleParameters);
}
private void generateAbsenceSimulation(RandomEngine r) {
private void generateAbsenceSimulation(RandomEngine randAbsence) {
for (int i = 0; i < getNumberPartTimeEmployee(); i++) {
boolean[] a = new AbsencesVector(myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getAbsencesVector();
for (int j = 0; j < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); j++) {
boolean[] a = new AbsencesVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randAbsence).getAbsencesVector();
for (int j = 0; j < myScheduleParameters.getWorkPeriodsPerSchedule(); j++) {
this.partTimeSchedules[i][j] = this.initialSchedulesArray.isPartTimeEmployeeWorking(i, j) && a[j];
}
}
for (int i = 0; i < getNumberFullTimeEmployee(); i++) {
boolean[] a = new AbsencesVector(myParametersInitialSchedules.getWorkPeriodsPerSchedule(), r).getAbsencesVector();
for (int j = 0; j < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); j++) {
boolean[] a = new AbsencesVector(myScheduleParameters.getWorkPeriodsPerSchedule(), randAbsence).getAbsencesVector();
for (int j = 0; j < myScheduleParameters.getWorkPeriodsPerSchedule(); j++) {
this.fullTimeSchedules[i][j] = this.initialSchedulesArray.isFullTimeEmployeeWorking(i, j) && a[j];
}
}
calculateNumberOfRecoveringActionsToPerform();
}
public int getAbsencePeriodsPerPartTimeEmployees(int employee) {
int absencePeriodsPerPartTimeEmployees = 0;
for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) {
for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
if (this.isPartTimeEmployeeAbsent(employee, workPeriod)) {absencePeriodsPerPartTimeEmployees += 1;}
}
return absencePeriodsPerPartTimeEmployees;
@ -46,7 +46,7 @@ public class AbsenceSchedulesArray extends SchedulesArray{
public int getAbsencePeriodsPerFullTimeEmployees(int employee) {
int absencePeriodsPerFullTimeEmployees = 0;
for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) {
for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
if (this.isFullTimeEmployeeAbsent(employee, workPeriod)) {absencePeriodsPerFullTimeEmployees += 1;}
}
return absencePeriodsPerFullTimeEmployees;
@ -62,8 +62,8 @@ public class AbsenceSchedulesArray extends SchedulesArray{
private void calculateNumberOfRecoveringActionsToPerform() {
this.numberOfRecoveringActionsToPerform = 0;
for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) {
this.numberOfRecoveringActionsToPerform += this.myParametersInitialSchedules.getRequiredWorkForce(workPeriod) - this.getEmployeesWorkingPerWorkPeriod(workPeriod);
for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
this.numberOfRecoveringActionsToPerform += this.myScheduleParameters.getRequiredWorkForce(workPeriod) - this.getEmployeesWorkingPerWorkPeriod(workPeriod);
}
}

View file

@ -3,14 +3,14 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package AbsenceSchedules;
package ModifiedSchedules;
/**
*
* @author frabe
*/
public class ParametersAbsencesSimulator {
public static final double probPresence = 0.99;
public static double probPresence = 0.92;
public static final double probReturn = 0.50;
public static final int numberAbsenceSimulations = 1000;
public static final int numberAbsenceSimulations = 100;
}

View file

@ -0,0 +1,8 @@
package ModifiedSchedules;
public class ParametersVariableDemandSimulator {
public static double probIncreasedDemandbyOne = 0;
public static double probIncreasedDemandbyTwo = probIncreasedDemandbyOne / 5;
public static double probIncreasedDemandbyThree = probIncreasedDemandbyOne / 25;
public static final int numberVariableDemandSimulations = 10;
}

View file

@ -0,0 +1,33 @@
package ModifiedSchedules;
import jdistlib.Binomial;
import jdistlib.rng.RandomEngine;
public class VariableDemandVector {
public int[] variableDemandVector;
public VariableDemandVector(int length, RandomEngine randVariableDemand) {
variableDemandVector = new int[length];
Binomial p1 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyOne);
p1.setRandomEngine(randVariableDemand);
Binomial p2 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyTwo);
p2.setRandomEngine(randVariableDemand);
Binomial p3 = new Binomial(1,ParametersVariableDemandSimulator.probIncreasedDemandbyThree);
p3.setRandomEngine(randVariableDemand);
for (int i = 0; i < length; i++) {
if ((int) p3.random() == 1){
variableDemandVector[i] = 3;
} else if ((int) p2.random() == 1){
variableDemandVector[i] = 2;
} else if ((int) p1.random() == 1){
variableDemandVector[i] = 1;
} else {
variableDemandVector[i] = 0;
}
}
}
public int[] getVariableDemandVector() {
return variableDemandVector;
}
}

View file

@ -5,10 +5,9 @@
*/
package ScheduleUtil;
import AbsenceSchedules.AbsenceSchedulesArray;
import InitialSchedules.ParametersInitialSchedules;
import ModifiedSchedules.ModifiedSchedulesArray;
import InitialSchedules.ParametersSchedules;
import SchedulesRecovery.RecoveredSchedulesArray;
import VariableDemandSchedules.VariableDemandSchedulesArray;
/**
*
@ -16,7 +15,7 @@ import VariableDemandSchedules.VariableDemandSchedulesArray;
*/
public class EmployeeCostCalculator {
public static int getFullInitialScheduleCost( SchedulesArray myInitialSchedule, ParametersInitialSchedules myScheduleParameters) {
public static int getFullInitialScheduleCost( SchedulesArray myInitialSchedule, ParametersSchedules myScheduleParameters) {
int totalCost = 0;
for (int partTimeEmployee = 0 ; partTimeEmployee < myInitialSchedule.getNumberPartTimeEmployee() ; partTimeEmployee++) {
int numberWorkingPeriod = myInitialSchedule.getWorkingPeriodsPerPartTimeEmployees(partTimeEmployee);
@ -30,64 +29,58 @@ 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) {
public static int getFullModifiedScheduleCost( ModifiedSchedulesArray myModifiedSchedule, ParametersSchedules myScheduleParameters) {
int totalCost = 0;
for (int partTimeEmployee = 0 ; partTimeEmployee < myAbsenceSchedule.getNumberPartTimeEmployee() ; partTimeEmployee++) {
int numberWorkingPeriod = myAbsenceSchedule.getWorkingPeriodsPerPartTimeEmployees(partTimeEmployee);
for (int partTimeEmployee = 0 ; partTimeEmployee < myModifiedSchedule.getNumberPartTimeEmployee() ; partTimeEmployee++) {
int numberWorkingPeriod = myModifiedSchedule.getWorkingPeriodsPerPartTimeEmployees(partTimeEmployee);
totalCost += myScheduleParameters.getFixedCostOfPartTimeEmployeesPerSchedule() +
numberWorkingPeriod * myScheduleParameters.getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate();
}
for (int fullTimeEmployee = 0 ; fullTimeEmployee < myAbsenceSchedule.getNumberFullTimeEmployee() ; fullTimeEmployee++) {
int numberWorkingPeriod = myAbsenceSchedule.getWorkingPeriodsPerFullTimeEmployees(fullTimeEmployee);
int numberAbsencePeriod = myAbsenceSchedule.getAbsencePeriodsPerFullTimeEmployees(fullTimeEmployee);
for (int fullTimeEmployee = 0 ; fullTimeEmployee < myModifiedSchedule.getNumberFullTimeEmployee() ; fullTimeEmployee++) {
int numberWorkingPeriod = myModifiedSchedule.getWorkingPeriodsPerFullTimeEmployees(fullTimeEmployee);
int numberAbsencePeriod = myModifiedSchedule.getAbsencePeriodsPerFullTimeEmployees(fullTimeEmployee);
totalCost += myScheduleParameters.getFixedCostOfFullTimeEmployeesPerSchedule() +
(numberWorkingPeriod + numberAbsencePeriod) * myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate();
}
return totalCost;
}
public static int getFullRecoveredScheduleCost( RecoveredSchedulesArray myRecoveredSchedule, ParametersInitialSchedules myScheduleParameters) {
public static int getFullRecoveredScheduleCost( RecoveredSchedulesArray myRecoveredSchedule, ParametersSchedules myScheduleParameters) {
int totalCost = 0;
for (int partTimeEmployee = 0 ; partTimeEmployee < myRecoveredSchedule.getNumberPartTimeEmployee() ; partTimeEmployee++) {
int numberWorkingPeriod = myRecoveredSchedule.getWorkingPeriodsPerPartTimeEmployees(partTimeEmployee);
totalCost += myScheduleParameters.getFixedCostOfPartTimeEmployeesPerSchedule() +
numberWorkingPeriod * myScheduleParameters.getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate();
}
AbsenceSchedulesArray myAbsenceSchedule = myRecoveredSchedule.absenceSchedulesArray;
ModifiedSchedulesArray myModifiedSchedule = myRecoveredSchedule.modifiedSchedulesArray;
for (int fullTimeEmployee = 0 ; fullTimeEmployee < myRecoveredSchedule.getNumberFullTimeEmployee() ; fullTimeEmployee++) {
int numberWorkingPeriod = myRecoveredSchedule.getWorkingPeriodsPerFullTimeEmployees(fullTimeEmployee);
int numberAbsencePeriod = myAbsenceSchedule.getAbsencePeriodsPerFullTimeEmployees(fullTimeEmployee);
int numberAbsencePeriod = myModifiedSchedule.getAbsencePeriodsPerFullTimeEmployees(fullTimeEmployee);
totalCost += myScheduleParameters.getFixedCostOfFullTimeEmployeesPerSchedule();
int regularHourlyRateCost; int overtimeHourlyRateCost;
if (numberWorkingPeriod + numberAbsencePeriod <= myScheduleParameters.getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule() ) {
regularHourlyRateCost = (numberWorkingPeriod + numberAbsencePeriod) * myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate();
overtimeHourlyRateCost = 0;
} else {
regularHourlyRateCost = myScheduleParameters.getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule() *
myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate();
overtimeHourlyRateCost = (numberWorkingPeriod + numberAbsencePeriod - myScheduleParameters.getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule()) *
myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtOvertimeHourlyRate();
}
totalCost += regularHourlyRateCost + overtimeHourlyRateCost;
}
return totalCost;
}
public static int getPartTimeEmployeeCost(boolean[][] currentEmployeesSchedule, int employee, ParametersInitialSchedules myScheduleParameters) {
public static int getPartTimeEmployeeCost(boolean[][] currentEmployeesSchedule, int employee, ParametersSchedules myScheduleParameters) {
int numberWorkingPeriod = 0;
for (int workPeriod = 0 ; workPeriod < currentEmployeesSchedule.length ; workPeriod++) {
if (currentEmployeesSchedule[employee][workPeriod]) {
@ -98,14 +91,14 @@ public class EmployeeCostCalculator {
numberWorkingPeriod * myScheduleParameters.getWorkingPeriodCostOfPartTimeEmployeesPaidAtRegularHourlyRate();
}
public static int getFullTimeEmployeeCost(boolean[][] currentEmployeesSchedule, AbsenceSchedulesArray myAbsenceSchedule, int employee, ParametersInitialSchedules myScheduleParameters) {
public static int getFullTimeEmployeeCost(boolean[][] currentEmployeesSchedule, ModifiedSchedulesArray myModifiedSchedule, int employee, ParametersSchedules myScheduleParameters) {
int numberWorkingPeriod = 0;
for (int workPeriod = 0 ; workPeriod < currentEmployeesSchedule.length ; workPeriod++) {
if (currentEmployeesSchedule[employee][workPeriod]) {
numberWorkingPeriod++;
}
}
int numberAbsencePeriod = myAbsenceSchedule.getAbsencePeriodsPerFullTimeEmployees(employee);
int numberAbsencePeriod = myModifiedSchedule.getAbsencePeriodsPerFullTimeEmployees(employee);
int regularHourlyRateCost; int overtimeHourlyRateCost;
if (numberWorkingPeriod + numberAbsencePeriod <= myScheduleParameters.getWorkingPeriodsPaidAtRegularHourlyRatePerSchedule() ) {
regularHourlyRateCost = (numberWorkingPeriod + numberAbsencePeriod) * myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate();

View file

@ -6,7 +6,7 @@
package ScheduleUtil;
import InitialSchedules.ModelFullTimeEmployeesInitialSchedules;
import InitialSchedules.ParametersInitialSchedules;
import InitialSchedules.ParametersSchedules;
import org.chocosolver.solver.Solution;
/**
@ -16,7 +16,7 @@ import org.chocosolver.solver.Solution;
public class FullTimeEmployeeScheduleArray {
public int initialScheduleSolutionNumber;
public final boolean[][] fullTimeSchedules;
final ParametersInitialSchedules myParametersInitialSchedules;
final ParametersSchedules myParametersInitialSchedules;
public FullTimeEmployeeScheduleArray(ModelFullTimeEmployeesInitialSchedules m, Solution s) {
this.myParametersInitialSchedules = m.myScheduleParameters;

View file

@ -6,7 +6,7 @@
package ScheduleUtil;
import InitialSchedules.ModelPartTimeEmployeesInitialSchedules;
import InitialSchedules.ParametersInitialSchedules;
import InitialSchedules.ParametersSchedules;
import org.chocosolver.solver.Solution;
/**
@ -16,7 +16,7 @@ import org.chocosolver.solver.Solution;
public class PartTimeEmployeeScheduleArray {
public int initialScheduleSolutionNumber;
public final boolean[][] partTimeSchedules;
private final ParametersInitialSchedules myParametersInitialSchedules;
private final ParametersSchedules myParametersInitialSchedules;
public PartTimeEmployeeScheduleArray(ModelPartTimeEmployeesInitialSchedules m, Solution s) {
this.myParametersInitialSchedules = m.myScheduleParameters;

View file

@ -17,7 +17,7 @@ public class PrintSchedules {
// Cette fonction devrait etre ameliorer avec du polymorphisme car on dedouble le code pour les 2 types d'horaire.
StringBuilder sbuf = new StringBuilder();
sbuf.append(String.format("%-31s", "Schedule Day"));
for (int day = 1; day <= schedule.myParametersInitialSchedules.getDaysPerSchedule(); day++) {
for (int day = 1; day <= schedule.myScheduleParameters.getDaysPerSchedule(); day++) {
sbuf.append(String.format("%02d" + "%18s" + "%s", day, "" , "|"));
}
sbuf.append(" Worked Periods\n");
@ -32,7 +32,7 @@ public class PrintSchedules {
} else {
sbuf.append(String.format("%2d", 0));
}
if (workPeriod % schedule.myParametersInitialSchedules.getWorkPeriodPerDay()== 5 && workPeriod != 0) {
if (workPeriod % schedule.myScheduleParameters.getWorkPeriodPerDay()== 5 && workPeriod != 0) {
sbuf.append(String.format("%2s" + "%-2s", "" , "|"));
}
}
@ -50,7 +50,7 @@ public class PrintSchedules {
} else {
sbuf.append(String.format("%2d", 0));
}
if (workPeriod % schedule.myParametersInitialSchedules.getWorkPeriodPerDay()== 5 && workPeriod != 0) {
if (workPeriod % schedule.myScheduleParameters.getWorkPeriodPerDay()== 5 && workPeriod != 0) {
sbuf.append(String.format("%2s" + "%-2s", "" , "|"));
}
}
@ -61,7 +61,7 @@ public class PrintSchedules {
sbuf.append(String.format("%-24s", "Working Employees "));
for (int workPeriod = 0; workPeriod < schedule.getWorkPeriodsPerSchedule(); workPeriod++) {
sbuf.append(String.format("%2d", schedule.getEmployeesWorkingPerWorkPeriod(workPeriod)));
if (workPeriod % schedule.myParametersInitialSchedules.getWorkPeriodPerDay() == 5 && workPeriod != 0) {
if (workPeriod % schedule.myScheduleParameters.getWorkPeriodPerDay() == 5 && workPeriod != 0) {
sbuf.append(String.format("%2s" + "%-2s", "" , "|"));
}
}
@ -69,8 +69,8 @@ public class PrintSchedules {
sbuf.append(String.format("%-25s", "Required Workforce "));
for (int workPeriod = 0; workPeriod < schedule.getWorkPeriodsPerSchedule(); workPeriod++) {
sbuf.append(String.format("%2d", schedule.myParametersInitialSchedules.getRequiredWorkForce(workPeriod)));
if (workPeriod % schedule.myParametersInitialSchedules.getWorkPeriodPerDay() == 5 && workPeriod != 0) {
sbuf.append(String.format("%2d", schedule.myScheduleParameters.getRequiredWorkForce(workPeriod)));
if (workPeriod % schedule.myScheduleParameters.getWorkPeriodPerDay() == 5 && workPeriod != 0) {
sbuf.append(String.format("%2s" + "%-2s", "" , "|"));
}
}

View file

@ -5,7 +5,7 @@
*/
package ScheduleUtil;
import InitialSchedules.ParametersInitialSchedules;
import InitialSchedules.ParametersSchedules;
/**
*
@ -17,43 +17,41 @@ public class SchedulesArray {
public boolean[][] partTimeSchedules;
public boolean[][] fullTimeSchedules;
public int totalScheduleCost;
protected final ParametersInitialSchedules myParametersInitialSchedules;
public ParametersSchedules myScheduleParameters;
// Constructeur Copie
protected SchedulesArray(SchedulesArray myScheduleArray) {
this.myParametersInitialSchedules = myScheduleArray.myParametersInitialSchedules;
this.partTimeSchedules = getDeepCopyEmployeesSchedules(myScheduleArray.partTimeSchedules);
this.fullTimeSchedules = getDeepCopyEmployeesSchedules(myScheduleArray.fullTimeSchedules);
this.initialScheduleSolutionNumber = myScheduleArray.initialScheduleSolutionNumber;
this.totalScheduleCost = myScheduleArray.totalScheduleCost;
}
public SchedulesArray( FullTimeEmployeeScheduleArray fteisa, PartTimeEmployeeScheduleArray pteisa, int scheduleNumber){
public SchedulesArray( FullTimeEmployeeScheduleArray fteisa, PartTimeEmployeeScheduleArray pteisa, ParametersSchedules myScheduleParameters, int scheduleNumber){
this.initialScheduleSolutionNumber = scheduleNumber;
this.myParametersInitialSchedules = fteisa.myParametersInitialSchedules;
this.myScheduleParameters = myScheduleParameters;
this.partTimeSchedules = pteisa.partTimeSchedules;
this.fullTimeSchedules = fteisa.fullTimeSchedules;
this.totalScheduleCost = EmployeeCostCalculator.getFullInitialScheduleCost(this, myParametersInitialSchedules);
this.totalScheduleCost = EmployeeCostCalculator.getFullInitialScheduleCost(this, myScheduleParameters);
}
/**
* This method creates a SchedulesArray with a modified required workforce vector
*
* @param myParametersInitialSchedules Parameters from initial schedule
* @param myInitialParametersSchedules Parameters from initial schedule
* @param fteisa initial schedules array for full time employees
* @param pteisa initial schedules array for part time employees
* @param scheduleNumber Schedule number that comes from the initial Choco solution
* @param VariableDemandVector new required workforce vector
*/
public SchedulesArray(ParametersInitialSchedules myParametersInitialSchedules, boolean[][] fteisa, boolean[][] pteisa, int scheduleNumber, int[] VariableDemandVector) {
public SchedulesArray(ParametersSchedules myInitialParametersSchedules, boolean[][] fteisa, boolean[][] pteisa, int scheduleNumber, int[] VariableDemandVector) {
this.initialScheduleSolutionNumber = scheduleNumber;
this.myParametersInitialSchedules = myParametersInitialSchedules;
this.myParametersInitialSchedules.setRequiredWorkforce(VariableDemandVector);
this.myScheduleParameters = myInitialParametersSchedules;
this.myScheduleParameters.setRequiredWorkforce(VariableDemandVector);
this.partTimeSchedules = getDeepCopyEmployeesSchedules(pteisa);
this.fullTimeSchedules = getDeepCopyEmployeesSchedules(fteisa);
@ -86,7 +84,7 @@ public class SchedulesArray {
public int getWorkingPeriodsPerPartTimeEmployees(int employee) {
int workingPeriodsPerPartTimeEmployees = 0;
for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) {
for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
if (this.partTimeSchedules[employee][workPeriod]) {workingPeriodsPerPartTimeEmployees += 1;}
}
return workingPeriodsPerPartTimeEmployees;
@ -94,7 +92,7 @@ public class SchedulesArray {
public int getWorkingPeriodsPerFullTimeEmployees(int employee) {
int workingPeriodsPerFullTimeEmployees = 0;
for (int workPeriod = 0; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule(); workPeriod++) {
for (int workPeriod = 0; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
if (this.fullTimeSchedules[employee][workPeriod]) {workingPeriodsPerFullTimeEmployees += 1;}
}
return workingPeriodsPerFullTimeEmployees;
@ -109,7 +107,7 @@ public class SchedulesArray {
}
public int getWorkPeriodsPerSchedule() {
return myParametersInitialSchedules.getWorkPeriodsPerSchedule();
return myScheduleParameters.getWorkPeriodsPerSchedule();
}
public boolean isPartTimeEmployeeWorking(int employee, int workPeriod) {

View file

@ -5,7 +5,7 @@
*/
package SchedulesRecovery;
import AbsenceSchedules.AbsenceSchedulesArray;
import ModifiedSchedules.ModifiedSchedulesArray;
import ScheduleUtil.SchedulesArray;
import java.util.ArrayList;
@ -18,16 +18,18 @@ import java.util.List;
public class BankRecoveredSchedules {
public final SchedulesArray initialSchedulesArray;
public final List<SchedulesArray> bankRecoveredSimulation;
private final List<AbsenceSchedulesArray> bankAbsenceSimulation;
private final List<ModifiedSchedulesArray> bankModifiedSimulation;
public double meanCostRecoveredSimulations;
public int numberUnResolvedSimulations;
public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List<AbsenceSchedulesArray> bankAbsenceSimulation) {
public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List<ModifiedSchedulesArray> bankModifiedSimulation) {
this.initialSchedulesArray = initialSchedulesArray;
this.bankAbsenceSimulation = bankAbsenceSimulation;
this.bankModifiedSimulation = bankModifiedSimulation;
this.bankRecoveredSimulation = new ArrayList<>();
this.numberUnResolvedSimulations = 0;
}
public void addRecoveredSchedules(SchedulesArray absenceSchedulesArray) {
this.bankRecoveredSimulation.add(absenceSchedulesArray);
public void addRecoveredSchedules(SchedulesArray recoveredSchedulesArray) {
this.bankRecoveredSimulation.add(recoveredSchedulesArray);
}
}

View file

@ -5,7 +5,7 @@
*/
package SchedulesRecovery;
import AbsenceSchedules.AbsenceSchedulesArray;
import ModifiedSchedules.ModifiedSchedulesArray;
import ScheduleUtil.EmployeeCostCalculator;
import ScheduleUtil.SchedulesArray;
@ -18,22 +18,23 @@ import java.util.*;
@SuppressWarnings("unchecked")
public class RecoveredSchedulesArray extends SchedulesArray{
public final AbsenceSchedulesArray absenceSchedulesArray;
public final ModifiedSchedulesArray modifiedSchedulesArray;
public RecoveredSchedulesArray(AbsenceSchedulesArray absenceSchedulesArray){
super(absenceSchedulesArray);
this.absenceSchedulesArray = absenceSchedulesArray;
recoverAbsenceScheduleOptimally();
public RecoveredSchedulesArray(ModifiedSchedulesArray modifiedSchedulesArray){
super(modifiedSchedulesArray);
this.myScheduleParameters = modifiedSchedulesArray.myScheduleParameters;
this.modifiedSchedulesArray = modifiedSchedulesArray;
recoverModifiedScheduleOptimally();
}
private void recoverAbsenceScheduleOptimally() {
boolean[][] initialRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.partTimeSchedules);
boolean[][] initialRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.fullTimeSchedules);
boolean[][] currentRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.partTimeSchedules);
boolean[][] currentRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.absenceSchedulesArray.fullTimeSchedules);
private void recoverModifiedScheduleOptimally() {
boolean[][] initialRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.partTimeSchedules);
boolean[][] initialRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.fullTimeSchedules);
boolean[][] currentRecoveredScheduleOfPartTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.partTimeSchedules);
boolean[][] currentRecoveredScheduleOfFullTimeEmployees = this.getDeepCopyEmployeesSchedules(this.modifiedSchedulesArray.fullTimeSchedules);
int initialRemainingRecoveringAction = this.absenceSchedulesArray.numberOfRecoveringActionsToPerform;
int currentRemainingRecoveringAction = this.absenceSchedulesArray.numberOfRecoveringActionsToPerform;
int initialRemainingRecoveringAction = this.modifiedSchedulesArray.numberOfRecoveringActionsToPerform;
int currentRemainingRecoveringAction = this.modifiedSchedulesArray.numberOfRecoveringActionsToPerform;
boolean[][] alreadyRecoveredWorkPeriodByPartTimeEmployees = new boolean[this.getNumberPartTimeEmployee()][initialRemainingRecoveringAction];
boolean[][] alreadyRecoveredWorkPeriodByFullTimeEmployees = new boolean[this.getNumberFullTimeEmployee()][initialRemainingRecoveringAction];
@ -42,11 +43,11 @@ public class RecoveredSchedulesArray extends SchedulesArray{
RecoveringActionComparator recoveringActionCostComparator = new RecoveringActionComparator();
boolean isSolutionFound = false;
boolean isAbsenceFound = initialRemainingRecoveringAction != 0;
boolean isModificationFound = initialRemainingRecoveringAction != 0;
int numberBackTrack = 1;
// Fouilles en profondeur en privilegiant les actions avec cout minimum. On marque les noeuds dejà visites pour avoir des fouilles differentes
while ( !isSolutionFound && isAbsenceFound ) {
while ( !isSolutionFound && isModificationFound ) {
PriorityQueue<RecoveringAction> recoveringActionsOrderedByCost =
getPossibleRecoveringActions(currentRecoveredScheduleOfPartTimeEmployees, currentRecoveredScheduleOfFullTimeEmployees,
alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees, currentRemainingRecoveringAction, recoveringActionCostComparator);
@ -69,13 +70,6 @@ public class RecoveredSchedulesArray extends SchedulesArray{
currentRemainingRecoveringAction--;
} else if (numberBackTrack % (this.getNumberFullTimeEmployee() + this.getNumberPartTimeEmployee()) == 0) {
//Si le nombre de retour au sommet atteint le nombre total d'employes, on reinitialize les matrices de noeuds visites.
initializeRecoveredWorkPeriodMatrix (alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees);
} else if (numberBackTrack > 10000) {
isSolutionFound = false;
System.out.println("No solution Found");
break;
} else{
// Lorsqu'on est bloque dans l'arbre de recherche, on revient au sommet de l'arbre et on recommence une nouvelle fouille.
currentRemainingRecoveringAction = initialRemainingRecoveringAction;
@ -86,14 +80,22 @@ public class RecoveredSchedulesArray extends SchedulesArray{
if (currentRemainingRecoveringAction == 0){
isSolutionFound = true;
} else if (numberBackTrack % (this.getNumberFullTimeEmployee() + this.getNumberPartTimeEmployee()) == 0) {
//Si le nombre de retour au sommet atteint le nombre total d'employes, on reinitialize les matrices de noeuds visites.
initializeRecoveredWorkPeriodMatrix (alreadyRecoveredWorkPeriodByPartTimeEmployees, alreadyRecoveredWorkPeriodByFullTimeEmployees);
} else if (numberBackTrack > 100000) {
isSolutionFound = false;
System.out.println("No solution Found");
break;
}
}
if (isSolutionFound || !isAbsenceFound) {
if (isSolutionFound || !isModificationFound) {
this.fullTimeSchedules = currentRecoveredScheduleOfFullTimeEmployees;
this.partTimeSchedules = currentRecoveredScheduleOfPartTimeEmployees;
this.totalScheduleCost = EmployeeCostCalculator.getFullRecoveredScheduleCost(this, myParametersInitialSchedules);
this.totalScheduleCost = EmployeeCostCalculator.getFullRecoveredScheduleCost(this, myScheduleParameters);
} else {
this.totalScheduleCost = Integer.MAX_VALUE;
}
@ -136,24 +138,24 @@ public class RecoveredSchedulesArray extends SchedulesArray{
PriorityQueue<RecoveringAction> recoveringActionsOrderedByCost = new PriorityQueue<>(recoveringActionCostComparator);
int workPeriod = findWorkPeriodToRecover(currentPartTimeSchedule, currentFullTimeSchedule);
if (workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule()) {
if (workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule()) {
for (int partTimeEmployee = 0 ; partTimeEmployee < this.getNumberPartTimeEmployee() ; partTimeEmployee++ ) {
if ( ValidationRecoveringAction.isPartTimeEmployeeAvailableForAbsenceRecovering(currentPartTimeSchedule, myParametersInitialSchedules,
absenceSchedulesArray, partTimeEmployee, workPeriod)
if ( ValidationRecoveringAction.isPartTimeEmployeeAvailableForRecovering(currentPartTimeSchedule, myScheduleParameters,
modifiedSchedulesArray, partTimeEmployee, workPeriod)
&& !alreadyRecoveredWorkPeriodByPartTimeEmployees[partTimeEmployee][remainingRecoveringAction-1]){
RecoveringActionPartTimeEmployee recoveringAction =
new RecoveringActionPartTimeEmployee(partTimeEmployee, workPeriod);
recoveringAction.calculateRecoveringActionCost(currentPartTimeSchedule, myParametersInitialSchedules);
recoveringAction.calculateRecoveringActionCost(currentPartTimeSchedule, myScheduleParameters);
recoveringActionsOrderedByCost.add(recoveringAction);
}
}
for (int fullTimeEmployee = 0 ; fullTimeEmployee < this.getNumberFullTimeEmployee() ; fullTimeEmployee++ ) {
if ( ValidationRecoveringAction.isFullTimeEmployeeAvailableForAbsenceRecovering(currentFullTimeSchedule, myParametersInitialSchedules,
absenceSchedulesArray, fullTimeEmployee, workPeriod)
if ( ValidationRecoveringAction.isFullTimeEmployeeAvailableForRecovering(currentFullTimeSchedule, myScheduleParameters,
modifiedSchedulesArray, fullTimeEmployee, workPeriod)
&& !alreadyRecoveredWorkPeriodByFullTimeEmployees[fullTimeEmployee][remainingRecoveringAction-1] ){
RecoveringActionFullTimeEmployee recoveringAction =
new RecoveringActionFullTimeEmployee(fullTimeEmployee, workPeriod);
recoveringAction.calculateRecoveringActionCost (currentFullTimeSchedule, absenceSchedulesArray, myParametersInitialSchedules);
recoveringAction.calculateRecoveringActionCost (currentFullTimeSchedule, modifiedSchedulesArray, myScheduleParameters);
recoveringActionsOrderedByCost.add(recoveringAction);
}
}
@ -163,7 +165,7 @@ public class RecoveredSchedulesArray extends SchedulesArray{
private int findWorkPeriodToRecover(boolean[][] currentPartTimeSchedule, boolean[][] currentFullTimeSchedule){
int workingEmployees;
for (int workPeriod = 0 ; workPeriod < myParametersInitialSchedules.getWorkPeriodsPerSchedule() ; workPeriod++) {
for (int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++) {
workingEmployees = 0;
for (boolean[] aCurrentPartTimeSchedule : currentPartTimeSchedule) {
if (aCurrentPartTimeSchedule[workPeriod]) {
@ -175,10 +177,10 @@ public class RecoveredSchedulesArray extends SchedulesArray{
workingEmployees++;
}
}
if (workingEmployees < this.myParametersInitialSchedules.getRequiredWorkForce(workPeriod) ) {
if (workingEmployees < this.myScheduleParameters.getRequiredWorkForce(workPeriod) ) {
return workPeriod;
}
}
return myParametersInitialSchedules.getWorkPeriodsPerSchedule();
return myScheduleParameters.getWorkPeriodsPerSchedule();
}
}

View file

@ -5,8 +5,8 @@
*/
package SchedulesRecovery;
import AbsenceSchedules.AbsenceSchedulesArray;
import InitialSchedules.ParametersInitialSchedules;
import ModifiedSchedules.ModifiedSchedulesArray;
import InitialSchedules.ParametersSchedules;
import ScheduleUtil.EmployeeCostCalculator;
/**
@ -19,10 +19,10 @@ class RecoveringActionFullTimeEmployee extends RecoveringAction {
super(employee, workPeriod);
}
public void calculateRecoveringActionCost (boolean[][] currentEmployeesSchedule, AbsenceSchedulesArray absenceSchedulesArray, ParametersInitialSchedules myScheduleParameters) {
int costBeforeAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, absenceSchedulesArray, this.employee, myScheduleParameters);
public void calculateRecoveringActionCost (boolean[][] currentEmployeesSchedule, ModifiedSchedulesArray modifiedSchedulesArray, ParametersSchedules myScheduleParameters) {
int costBeforeAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, modifiedSchedulesArray, this.employee, myScheduleParameters);
currentEmployeesSchedule[this.employee][this.workPeriod] = true;
int costAfterAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, absenceSchedulesArray, this.employee, myScheduleParameters);
int costAfterAction = EmployeeCostCalculator.getFullTimeEmployeeCost(currentEmployeesSchedule, modifiedSchedulesArray, this.employee, myScheduleParameters);
currentEmployeesSchedule[this.employee][this.workPeriod] = false;
this.recoveringActionCost = costAfterAction-costBeforeAction;
}

View file

@ -5,7 +5,7 @@
*/
package SchedulesRecovery;
import InitialSchedules.ParametersInitialSchedules;
import InitialSchedules.ParametersSchedules;
import ScheduleUtil.EmployeeCostCalculator;
/**
@ -18,7 +18,7 @@ class RecoveringActionPartTimeEmployee extends RecoveringAction {
super(employee, workPeriod);
}
public void calculateRecoveringActionCost(boolean[][] currentEmployeesSchedule, ParametersInitialSchedules myScheduleParameters) {
public void calculateRecoveringActionCost(boolean[][] currentEmployeesSchedule, ParametersSchedules myScheduleParameters) {
int costBeforeAction = EmployeeCostCalculator.getPartTimeEmployeeCost(currentEmployeesSchedule, this.employee, myScheduleParameters);
currentEmployeesSchedule[this.employee][this.workPeriod] = true;
int costAfterAction = EmployeeCostCalculator.getPartTimeEmployeeCost(currentEmployeesSchedule, this.employee, myScheduleParameters);

View file

@ -5,8 +5,8 @@
*/
package SchedulesRecovery;
import AbsenceSchedules.AbsenceSchedulesArray;
import InitialSchedules.ParametersInitialSchedules;
import ModifiedSchedules.ModifiedSchedulesArray;
import InitialSchedules.ParametersSchedules;
/**
*
@ -17,19 +17,19 @@ import InitialSchedules.ParametersInitialSchedules;
class ValidationRecoveringAction {
//Toutes les fonctions sont dedoublees. On devrait faire du polymorphisme.
static boolean isPartTimeEmployeeAvailableForAbsenceRecovering(boolean[][] currentPartTimeSchedule, ParametersInitialSchedules myScheduleParameters,
AbsenceSchedulesArray myabsenceSchedule, int employee, int workPeriod){
return !currentPartTimeSchedule[employee][workPeriod] && !myabsenceSchedule.isPartTimeEmployeeAbsent(employee, workPeriod)
static boolean isPartTimeEmployeeAvailableForRecovering(boolean[][] currentPartTimeSchedule, ParametersSchedules myScheduleParameters,
ModifiedSchedulesArray myModifiedSchedule, int employee, int workPeriod){
return !currentPartTimeSchedule[employee][workPeriod] && !myModifiedSchedule.isPartTimeEmployeeAbsent(employee, workPeriod)
&& isValidPartTimeEmployeeWorkPeriod(currentPartTimeSchedule[employee], workPeriod, myScheduleParameters);
}
private static boolean isValidPartTimeEmployeeWorkPeriod(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidPartTimeEmployeeWorkPeriod(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
return isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(currentPartTimeEmployeeSchedule, myScheduleParameters) &&
isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(currentPartTimeEmployeeSchedule, workPeriod, myScheduleParameters) &&
isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(currentPartTimeEmployeeSchedule, workPeriod, myScheduleParameters);
}
private static boolean isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(boolean[] currentPartTimeEmployeeSchedule, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidWorkingPeriodsOfPartTimeEmployeePerSchedule(boolean[] currentPartTimeEmployeeSchedule, ParametersSchedules myScheduleParameters){
int employeeWorkingPeriods = 0;
for ( int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++ ) {
if (currentPartTimeEmployeeSchedule[workPeriod]){
@ -39,7 +39,7 @@ class ValidationRecoveringAction {
return employeeWorkingPeriods < myScheduleParameters.getMaxWorkingPeriodsOfPartTimeEmployeesPerSchedule();
}
private static boolean isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidConsecutiveWorkingPeriodsOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
int consecutiveWorkingPeriods = 1;
int compteurWorkPeriod = workPeriod - 1;
while ( compteurWorkPeriod >= 0 && currentPartTimeEmployeeSchedule[compteurWorkPeriod] ){
@ -54,7 +54,7 @@ class ValidationRecoveringAction {
return consecutiveWorkingPeriods <= myScheduleParameters.getMaxConsecutiveWorkingPeriodsOfPartTimeEmployeesPerShiftWork();
}
private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfPartTimeEmployee(boolean[] currentPartTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
int consecutivePreviousNonWorkingPeriods = 0;
int compteurWorkPeriod = workPeriod - 1;
while ( compteurWorkPeriod >= 0 && !currentPartTimeEmployeeSchedule[compteurWorkPeriod] ){
@ -86,20 +86,20 @@ class ValidationRecoveringAction {
return validConsecutivePreviousNonWorkingPeriods && validConsecutiveNextNonWorkingPeriods;
}
public static boolean isFullTimeEmployeeAvailableForAbsenceRecovering(boolean[][] currentFullTimeSchedule, ParametersInitialSchedules myScheduleParameters,
AbsenceSchedulesArray myabsenceSchedule, int employee, int workPeriod){
public static boolean isFullTimeEmployeeAvailableForRecovering(boolean[][] currentFullTimeSchedule, ParametersSchedules myScheduleParameters,
ModifiedSchedulesArray myModifiedSchedule, int employee, int workPeriod){
return !currentFullTimeSchedule[employee][workPeriod] && !myabsenceSchedule.isFullTimeEmployeeAbsent(employee, workPeriod)
return !currentFullTimeSchedule[employee][workPeriod] && !myModifiedSchedule.isFullTimeEmployeeAbsent(employee, workPeriod)
&& isValidFullTimeEmployeeWorkPeriod(currentFullTimeSchedule[employee], workPeriod, myScheduleParameters);
}
private static boolean isValidFullTimeEmployeeWorkPeriod(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidFullTimeEmployeeWorkPeriod(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
return isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(currentFullTimeEmployeeSchedule, myScheduleParameters) &&
isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(currentFullTimeEmployeeSchedule, workPeriod, myScheduleParameters) &&
isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(currentFullTimeEmployeeSchedule, workPeriod, myScheduleParameters);
}
private static boolean isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(boolean[] currentFullTimeEmployeeSchedule, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidWorkingPeriodsOfFullTimeEmployeePerSchedule(boolean[] currentFullTimeEmployeeSchedule, ParametersSchedules myScheduleParameters){
int employeeWorkingPeriods = 0;
for ( int workPeriod = 0 ; workPeriod < myScheduleParameters.getWorkPeriodsPerSchedule() ; workPeriod++ ) {
if (currentFullTimeEmployeeSchedule[workPeriod]){
@ -110,7 +110,7 @@ class ValidationRecoveringAction {
}
private static boolean isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidConsecutiveWorkingPeriodsOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
int consecutiveWorkingPeriods = 1;
int compteurWorkPeriod = workPeriod - 1;
while ( compteurWorkPeriod >= 0 && currentFullTimeEmployeeSchedule[compteurWorkPeriod] ){
@ -125,7 +125,7 @@ class ValidationRecoveringAction {
return consecutiveWorkingPeriods <= myScheduleParameters.getMaxConsecutiveWorkingPeriodsOfFullTimeEmployeesPerShiftWork();
}
private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersInitialSchedules myScheduleParameters){
private static boolean isValidConsecutiveNonWorkingPeriodsBetweenShiftWorksOfFullTimeEmployee(boolean[] currentFullTimeEmployeeSchedule, int workPeriod, ParametersSchedules myScheduleParameters){
int consecutivePreviousNonWorkingPeriods = 0;
int compteurWorkPeriod = workPeriod - 1;
while ( compteurWorkPeriod >= 0 && !currentFullTimeEmployeeSchedule[compteurWorkPeriod] ){

View file

@ -3,9 +3,6 @@
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1400, 600]"/>
</Property>
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1000, 600]"/>
</Property>

View file

@ -121,7 +121,8 @@ public class ShowSolutionResultsFrame extends javax.swing.JFrame {
StringBuilder sbuf = new StringBuilder();
String formattedInitialScedulesArray = ScheduleUtil.PrintSchedules.getFormattedSchedule(bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).initialSchedulesArray);
sbuf.append(formattedInitialScedulesArray);
sbuf.append(String.format("%s" + "%.2f","Mean Cost of Recovered Schedules : $", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).meanCostRecoveredSimulations));
sbuf.append(String.format("%s" + "%.2f" + "%s","Mean Cost of Recovered Schedules : $", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).meanCostRecoveredSimulations, "\n"));
sbuf.append(String.format("%s" + "%d","Number Unresolved Schedules : ", bankRecoveredSchedulesOrderedByMeanCost.get(scrollBarValue-1).numberUnResolvedSimulations));
scheduleViewerArea.setText(sbuf.toString());
}

View file

@ -1,20 +0,0 @@
package VariableDemandSchedules;
import ScheduleUtil.SchedulesArray;
import java.util.ArrayList;
import java.util.List;
public class BankVariableDemandSchedules {
public final SchedulesArray initialSchedulesArray;
public final List<VariableDemandSchedulesArray> bankVariableDemandSimulation;
public BankVariableDemandSchedules(SchedulesArray initialSchedulesArray) {
this.initialSchedulesArray = initialSchedulesArray;
this.bankVariableDemandSimulation = new ArrayList<>();
}
public void addVariableDemandSchedules(VariableDemandSchedulesArray variableDemandSchedulesArray) {
this.bankVariableDemandSimulation.add(variableDemandSchedulesArray);
}
}

View file

@ -1,5 +0,0 @@
package VariableDemandSchedules;
public class ParametersVariableDemandSimulator {
public static final int numberVariableDemandSimulation = 1;
}

View file

@ -1,40 +0,0 @@
package VariableDemandSchedules;
import ScheduleUtil.EmployeeCostCalculator;
import ScheduleUtil.SchedulesArray;
import jdistlib.rng.RandomEngine;
public class VariableDemandSchedulesArray extends SchedulesArray {
private final SchedulesArray initialSchedulesArray;
private SchedulesArray initialSchedulesArrayVariableDemand;
public VariableDemandSchedulesArray(SchedulesArray initialSchedulesArray, RandomEngine r) {
super(initialSchedulesArray);
this.initialSchedulesArray = initialSchedulesArray;
generateDemandSimulation(r);
this.totalScheduleCost = EmployeeCostCalculator.getFullVariableDemandScheduleCost(this, myParametersInitialSchedules);
}
private void generateDemandSimulation(RandomEngine r) {
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];
}
this.initialSchedulesArrayVariableDemand = new SchedulesArray(
myParametersInitialSchedules,
initialSchedulesArray.fullTimeSchedules,
initialSchedulesArray.partTimeSchedules,
initialSchedulesArray.initialScheduleSolutionNumber,
adjd);
}
public SchedulesArray getInitialSchedulesArrayVariableDemand() {
return initialSchedulesArrayVariableDemand;
}
public SchedulesArray getInitialSchedulesArray() {
return initialSchedulesArray;
}
}

View file

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