Corrections mineures dans le modèle.

Calcul et affichage des moyennes des horaires de recouvrement.
This commit is contained in:
Francois Berube\frabe 2018-04-07 15:15:44 -04:00
parent 186ae740e4
commit 8a0a2352c8
13 changed files with 352 additions and 67 deletions

View file

@ -1,5 +1,6 @@
package AbsenceSchedules;
import ScheduleUtil.EmployeeCostCalculator;
import ScheduleUtil.SchedulesArray;
import jdistlib.rng.RandomEngine;
@ -12,6 +13,7 @@ public class AbsenceSchedulesArray extends SchedulesArray{
super(initialSchedulesArray);
this.initialSchedulesArray = initialSchedulesArray;
generateAbsenceSimulation(r);
this.totalScheduleCost = EmployeeCostCalculator.getFullScheduleCost(this, myParametersInitialSchedules);
}
private void generateAbsenceSimulation(RandomEngine r) {

View file

@ -10,9 +10,9 @@ public class AbsencesVector {
int current = 1;
AbsencesVector = new boolean[length];
Binomial b1 = new Binomial(1, ParametersAbsencesGenerator.probPresence);
Binomial b1 = new Binomial(1, ParametersAbsencesSimulator.probPresence);
b1.setRandomEngine(r);
Binomial b2 = new Binomial(1, ParametersAbsencesGenerator.probReturn);
Binomial b2 = new Binomial(1, ParametersAbsencesSimulator.probReturn);
b2.setRandomEngine(r);
for (int i = 0; i < length; i++) {
if (current == 1) {

View file

@ -9,7 +9,7 @@ package AbsenceSchedules;
*
* @author frabe
*/
public interface ParametersAbsencesGenerator {
public interface ParametersAbsencesSimulator {
public final double probPresence = 0.5;
public final double probReturn = 0.99;
public final int numberAbsenceSimulations = 5;

View file

@ -29,7 +29,6 @@ public class ModelInitialSchedules {
private IntVar partTimeEmployeesPerWorkPeriods[];
private IntVar fullTimeEmployeesPerWorkPeriods[];
private IntVar employeesPerWorkPeriods[];
public Model chocoModelInitialSchedules;
public IntVar totalEmployeesCost;
@ -51,9 +50,9 @@ public class ModelInitialSchedules {
private void createEmployeesVariables() {
this.maxPartTimeEmployee = (int) Math.ceil((double) myScheduleParameters.totalWorkedPeriodsInSchedule
this.maxPartTimeEmployee = (int) Math.ceil((double) myScheduleParameters.getTotalWorkedPeriodsInSchedule()
/ myScheduleParameters.getMinWorkingPeriodsOfPartTimeEmployeesPerSchedule());
this.maxFullTimeEmployee = (int) Math.ceil((double) myScheduleParameters.totalWorkedPeriodsInSchedule
this.maxFullTimeEmployee = (int) Math.ceil((double) myScheduleParameters.getTotalWorkedPeriodsInSchedule()
/ myScheduleParameters.getWorkingPeriodsOfFullTimeEmployeesPerSchedule());
}
@ -100,8 +99,6 @@ public class ModelInitialSchedules {
// Variable pour faire le compte du nombre d'employes par periode de travail
this.partTimeEmployeesPerWorkPeriods = chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.getWorkPeriodsPerSchedule(), 0, this.maxPartTimeEmployee, true);
this.fullTimeEmployeesPerWorkPeriods = chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.getWorkPeriodsPerSchedule(), 0, this.maxFullTimeEmployee, true);
this.employeesPerWorkPeriods = chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.getWorkPeriodsPerSchedule(),
0, this.maxPartTimeEmployee + this.maxFullTimeEmployee, true);
}
@ -129,18 +126,15 @@ public class ModelInitialSchedules {
chocoModelInitialSchedules.arithm(this.partTimeEmployeesPerWorkPeriods[workPeriod], "+",
this.fullTimeEmployeesPerWorkPeriods[workPeriod], "=",
this.myScheduleParameters.requiredWorkforce[workPeriod]).post();
chocoModelInitialSchedules.arithm(this.partTimeEmployeesPerWorkPeriods[workPeriod], "+",
this.fullTimeEmployeesPerWorkPeriods[workPeriod], "=",
this.employeesPerWorkPeriods[workPeriod]).post();
}
// Contrainte de bris de symétrie:
// chaque horaire d'employé est léxicographiquement inférieure à la suivante, par type d'employé
// Ne fonctionne pas avec l'heuristique par défaut
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.maxPartTimeEmployee-1); employee++){
// chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfPartTimeEmployees[employee],
// this.workPeriodsSchedulesOfPartTimeEmployees[employee+1]).post();
// }
for (int employee = 0; employee < (this.maxFullTimeEmployee-1); employee++){
chocoModelInitialSchedules.lexLessEq(this.workPeriodsSchedulesOfFullTimeEmployees[employee],
this.workPeriodsSchedulesOfFullTimeEmployees[employee+1]).post();
@ -150,32 +144,15 @@ public class ModelInitialSchedules {
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.getWorkPeriodsPerSchedule(),
0,
this.maxPartTimeEmployee, true);
IntVar[] numberOfFullTimeEmployeesPerPeriod =
chocoModelInitialSchedules.intVarArray(this.myScheduleParameters.getWorkPeriodsPerSchedule(),
0,
this.maxFullTimeEmployee, true);
for (int workPeriod = 0; workPeriod < this.myScheduleParameters.getWorkPeriodsPerSchedule(); workPeriod++) {
chocoModelInitialSchedules.sum(transposeWorkPeriodsSchedulesOfPartTimeEmployees[workPeriod],
"=", numberOfPartTimeEmployeesPerPeriod[workPeriod]).post();
chocoModelInitialSchedules.sum(transposeWorkPeriodsSchedulesOfFullTimeEmployees[workPeriod],
"=", numberOfFullTimeEmployeesPerPeriod[workPeriod]).post();
}
IntVar numberOfPartTimeEmployeesPeriods =
IntVar numberOfPartTimeEmployeesWorkingPeriods =
chocoModelInitialSchedules.intVar(
0, this.maxPartTimeEmployee * this.myScheduleParameters.getWorkPeriodsPerSchedule(), true);
IntVar numberOfFullTimeEmployeesPeriods =
IntVar numberOfFullTimeEmployeesWorkingPeriods =
chocoModelInitialSchedules.intVar(
0, this.maxPartTimeEmployee * this.myScheduleParameters.getWorkPeriodsPerSchedule(), true);
chocoModelInitialSchedules.sum(numberOfPartTimeEmployeesPerPeriod, "=", numberOfPartTimeEmployeesPeriods).post();
chocoModelInitialSchedules.sum(numberOfFullTimeEmployeesPerPeriod, "=", numberOfFullTimeEmployeesPeriods).post();
chocoModelInitialSchedules.sum(this.partTimeEmployeesPerWorkPeriods, "=", numberOfPartTimeEmployeesWorkingPeriods).post();
chocoModelInitialSchedules.sum(this.fullTimeEmployeesPerWorkPeriods, "=", numberOfFullTimeEmployeesWorkingPeriods).post();
// Calcul du salaire versé
IntVar partTimeEmployeesSalary =
@ -193,8 +170,8 @@ public class ModelInitialSchedules {
IntVar workingPeriodCostOfFullTimeEmployees =
chocoModelInitialSchedules.intVar(this.myScheduleParameters.getWorkingPeriodCostOfFullTimeEmployeesPaidAtRegularHourlyRate());
chocoModelInitialSchedules.arithm(numberOfPartTimeEmployeesPeriods, "*", workingPeriodCostOfPartTimeEmployees, "=", partTimeEmployeesSalary).post();
chocoModelInitialSchedules.arithm(numberOfFullTimeEmployeesPeriods, "*", workingPeriodCostOfFullTimeEmployees, "=", fullTimeEmployeesSalary).post();
chocoModelInitialSchedules.arithm(numberOfPartTimeEmployeesWorkingPeriods, "*", workingPeriodCostOfPartTimeEmployees, "=", partTimeEmployeesSalary).post();
chocoModelInitialSchedules.arithm(numberOfFullTimeEmployeesWorkingPeriods, "*", workingPeriodCostOfFullTimeEmployees, "=", fullTimeEmployeesSalary).post();
// Compter le nombre d'heures travaillees par les differents employes pour determiner les employes actifs
IntVar[] workingPeriodsPerPartTimeEmployees =

View file

@ -10,7 +10,6 @@ public class ParametersInitialSchedules {
int shiftWorkPerDay;
int daysPerSchedule;
int hoursPerWorkPeriod;
int totalWorkedPeriodsInSchedule;
int hourlyRateOfPartTimeEmployees;
int fixedCostOfPartTimeEmployeesPerSchedule;
@ -81,15 +80,21 @@ public class ParametersInitialSchedules {
private void setRequiredWorkforce() {
this.requiredWorkforce = new int[this.daysPerSchedule * this.getWorkPeriodPerDay()];
this.totalWorkedPeriodsInSchedule = 0;
int[] dailyRequiredWorkforce = new int[]{2, 2, 4, 4, 3, 3};
for (int day = 0; day < this.daysPerSchedule; day++) {
for(int shift = 0; shift < this.getWorkPeriodPerDay(); shift++) {
this.requiredWorkforce[day * this.getWorkPeriodPerDay() + shift] = dailyRequiredWorkforce[shift];
this.totalWorkedPeriodsInSchedule += dailyRequiredWorkforce[shift];
}
}
}
public int getTotalWorkedPeriodsInSchedule() {
int totalWorkedPeriodsInSchedule = 0;
for (int workPeriod = 0 ; workPeriod < this.getWorkPeriodsPerSchedule() ; workPeriod++) {
totalWorkedPeriodsInSchedule += this.requiredWorkforce[workPeriod];
}
return totalWorkedPeriodsInSchedule;
}
private void setWorkPeriodsSchedulesOfFullTimeEmployees() {

View file

@ -3,7 +3,6 @@
import AbsenceSchedules.*;
import ScheduleUtil.*;
import SchedulesRecovery.*;
//import SchedulesRecovery.RecoveredSchedulesArray;
import jdistlib.rng.MersenneTwister;
import jdistlib.rng.RandomEngine;
import org.chocosolver.solver.Solution;
@ -12,6 +11,8 @@ import org.chocosolver.solver.exception.ContradictionException;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.TreeSet;
public class MainClass {
@ -24,12 +25,12 @@ public class MainClass {
List<BankAbsenceSchedules> listBankAbsenceSchedules = GenerateAbsencesSchedules(initialSchedulesArrayList);
List<BankRecoveredSchedules> recoveredSchedulesArrayList = GenerateOptimalRecoveredSchedules(listBankAbsenceSchedules);
// TODO :
// calcul des moyennes de cout de recouvrement
List<BankRecoveredSchedules> bankRecoveredSchedulesOrderedByMeanCost = GenerateOptimalRecoveredSchedules(listBankAbsenceSchedules);
// Afficher les solutions en ordre de cout de recouvrement et comparer avec solution optimale (nbr employes temps plein maximal).
SchedulesWindows.ShowSolutionResultsFrame intialSchedulesViewer = new SchedulesWindows.ShowSolutionResultsFrame(bankRecoveredSchedulesOrderedByMeanCost);
}
private static List<SchedulesArray> generateInitialSchedules() {
@ -57,20 +58,22 @@ public class MainClass {
/*solverInitialSchedules.setSearch(Search.domOverWDegSearch(myModelInitialSchedules.allWorkPeriods));*/
// solverInitialSchedules.setRestartOnSolutions(); /*Sans restart, toutes les horaires sont identiques*/
// solverInitialSchedules.limitSolution(5);
solverInitialSchedules.limitSolution(5);
//solverInitialSchedules.limitTime(10000);
List<Solution> myInitialSchedulesSolutions;
myInitialSchedulesSolutions = solverInitialSchedules.findAllOptimalSolutions
(myModelInitialSchedules.totalEmployeesCost, myModelInitialSchedules.chocoModelInitialSchedules.MINIMIZE);
// myInitialSchedulesSolutions = solverInitialSchedules.findAllOptimalSolutions
// (myModelInitialSchedules.totalEmployeesCost, myModelInitialSchedules.chocoModelInitialSchedules.MINIMIZE);
// solverInitialSchedules.findSolution();
// myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions();
myInitialSchedulesSolutions = solverInitialSchedules.findAllSolutions();
solverInitialSchedules.printStatistics();
// Création de l'objet banque d'horaire, qui est une liste d'objets de type InitialSchedulesArray, qui contiennent chacun deux tableaux.
int simulationNumber = 1;
for (Solution CurrentSolution : myInitialSchedulesSolutions) {
SchedulesArray isa = new SchedulesArray(myModelInitialSchedules, CurrentSolution);
SchedulesArray isa = new SchedulesArray(myModelInitialSchedules, CurrentSolution, simulationNumber);
initialSchedulesArrayList.add(isa);
simulationNumber++;
}
// Pour afficher les horaires initiales
@ -87,7 +90,7 @@ public class MainClass {
List<SchedulesArray> listAbsenceSchedules = new ArrayList<>(); // to be removed
for (SchedulesArray initialSchedule : initialSchedulesArrayList) {
BankAbsenceSchedules bankAbsenceSimulations = new BankAbsenceSchedules(initialSchedule);
for (int simNum = 0 ; simNum < ParametersAbsencesGenerator.numberAbsenceSimulations ; simNum++) {
for (int simNum = 0 ; simNum < ParametersAbsencesSimulator.numberAbsenceSimulations ; simNum++) {
AbsenceSchedulesArray absenceSchedule = new AbsenceSchedulesArray(initialSchedule, r);
listAbsenceSchedules.add(absenceSchedule); // to be removed
bankAbsenceSimulations.addAbsenceSchedules(absenceSchedule);
@ -103,21 +106,31 @@ public class MainClass {
private static List<BankRecoveredSchedules> GenerateOptimalRecoveredSchedules(List<BankAbsenceSchedules> listBankAbsenceSchedules) {
List<BankRecoveredSchedules> listBankRecoveredSchedules = new ArrayList<>();
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 bankRecoveredSimulation = new BankRecoveredSchedules(initialSchedulesArray, bankAbsenceSchedule.bankAbsenceSimulation);
BankRecoveredSchedules bankRecoveredSimulations = new BankRecoveredSchedules(initialSchedulesArray, bankAbsenceSchedule.bankAbsenceSimulation);
int totalCostRecoveredSimulations = 0;
for (AbsenceSchedulesArray absenceSchedule : bankAbsenceSchedule.bankAbsenceSimulation) {
RecoveredSchedulesArray recoveredSchedule = new RecoveredSchedulesArray(absenceSchedule);
listRecoveredSchedules.add(recoveredSchedule); // to be removed
bankRecoveredSimulation.addRecoveredSchedules(recoveredSchedule);
bankRecoveredSimulations.addRecoveredSchedules(recoveredSchedule);
totalCostRecoveredSimulations += recoveredSchedule.totalScheduleCost;
}
listBankRecoveredSchedules.add(bankRecoveredSimulation);
bankRecoveredSimulations.meanCostRecoveredSimulations = totalCostRecoveredSimulations / bankRecoveredSimulations.bankRecoveredSimulation.size();
bankRecoveredSchedulesOrderedByMeanCost.add(bankRecoveredSimulations);
}
// Pour afficher les horaires de recouvrement
SchedulesWindows.ShowSchedulesFrame recoveredSchedulesViewer = new SchedulesWindows.ShowSchedulesFrame(listRecoveredSchedules, "Recovered Schedules"); // to be removed
return listBankRecoveredSchedules;
List<BankRecoveredSchedules> listbankRecoveredSchedulesOrderedByMeanCost = new ArrayList<>();
while(!bankRecoveredSchedulesOrderedByMeanCost.isEmpty()){
BankRecoveredSchedules bankRecoveredSchedules = bankRecoveredSchedulesOrderedByMeanCost.poll();
listbankRecoveredSchedulesOrderedByMeanCost.add(bankRecoveredSchedules);
}
return listbankRecoveredSchedulesOrderedByMeanCost;
}
}

View file

@ -75,8 +75,8 @@ public class PrintSchedules {
}
}
sbuf.append("\n");
sbuf.append(String.format("%-5s" + "%02d","Total schedule Cost ", EmployeeCostCalculator.getFullScheduleCost(schedule, schedule.myParametersInitialSchedules)));
sbuf.append(String.format("%s" + "%.2f" ,"Total schedule Cost : $", (double) schedule.totalScheduleCost));
sbuf.append("\n");
return sbuf.toString();
}

View file

@ -14,9 +14,10 @@ import org.chocosolver.solver.Solution;
*/
//Dans cette classe, toutes les fonctions sont dedoublees. On devrait faire du polymorphisme.
public class SchedulesArray {
public int initialScheduleSolutionNumber;
public boolean[][] partTimeSchedules;
public boolean[][] fullTimeSchedules;
public int totalScheduleCost;
protected ParametersInitialSchedules myParametersInitialSchedules;
// Constructeur Copie
@ -25,13 +26,15 @@ public class SchedulesArray {
this.myParametersInitialSchedules = myScheduleArray.myParametersInitialSchedules;
this.partTimeSchedules = getDeepCopyEmployeesSchedules(myScheduleArray.partTimeSchedules);
this.fullTimeSchedules = getDeepCopyEmployeesSchedules(myScheduleArray.fullTimeSchedules);
this.initialScheduleSolutionNumber = myScheduleArray.initialScheduleSolutionNumber;
}
public SchedulesArray(ModelInitialSchedules m, Solution s) {
public SchedulesArray(ModelInitialSchedules m, Solution s, int scheduleNumber) {
this.initialScheduleSolutionNumber = scheduleNumber;
this.myParametersInitialSchedules = m.myScheduleParameters;
Solution mySolution = s;
this.partTimeSchedules = new boolean[getNumberOfPartTimeEmployees(s, m)][myParametersInitialSchedules.getWorkPeriodsPerSchedule()];
this.fullTimeSchedules = new boolean[getNumberOfFullTimeEmployees(s, m)][myParametersInitialSchedules.getWorkPeriodsPerSchedule()];
@ -55,8 +58,9 @@ public class SchedulesArray {
}
}
// Faire un assert pour voir si le cout total equivaut a celui trouve par le solveur.
this.totalScheduleCost = EmployeeCostCalculator.getFullScheduleCost(this, myParametersInitialSchedules);
assert(this.totalScheduleCost == s.getIntVal(m.totalEmployeesCost));
}
private int getNumberOfPartTimeEmployees( Solution s, ModelInitialSchedules m ) {

View file

@ -19,6 +19,7 @@ public class BankRecoveredSchedules {
public SchedulesArray initialSchedulesArray;
public List<SchedulesArray> bankRecoveredSimulation;
public List<AbsenceSchedulesArray> bankAbsenceSimulation;
public double meanCostRecoveredSimulations;
public BankRecoveredSchedules(SchedulesArray initialSchedulesArray, List<AbsenceSchedulesArray> bankAbsenceSimulation) {
this.initialSchedulesArray = initialSchedulesArray;

View file

@ -0,0 +1,23 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package SchedulesRecovery;
import java.util.Comparator;
/**
*
* @author frabe
*/
public class BankRecoveredSchedulesComparator implements Comparator< BankRecoveredSchedules > {
public int compare(BankRecoveredSchedules b1, BankRecoveredSchedules b2) {
int meanCostCmp = Double.compare(b1.meanCostRecoveredSimulations, b2.meanCostRecoveredSimulations);
if (meanCostCmp !=0) {
return meanCostCmp;
}
int simNumberCmp = Integer.compare(b1.initialSchedulesArray.initialScheduleSolutionNumber, b2.initialSchedulesArray.initialScheduleSolutionNumber);
return simNumberCmp;
}
}

View file

@ -90,9 +90,10 @@ public class RecoveredSchedulesArray extends SchedulesArray{
if (isSolutionFound) {
this.fullTimeSchedules = currentRecoveredScheduleOfFullTimeEmployees;
this.partTimeSchedules = currentRecoveredScheduleOfPartTimeEmployees;
assert(EmployeeCostCalculator.getFullScheduleCost(this, myParametersInitialSchedules) == bestScheduleCost);
System.out.println(" Solution Found ");
this.totalScheduleCost = EmployeeCostCalculator.getFullScheduleCost(this, myParametersInitialSchedules);
assert(this.totalScheduleCost == bestScheduleCost);
} else {
this.totalScheduleCost = Integer.MAX_VALUE;
System.out.println(" No Solution Found ");
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="mainPanel" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="mainPanel" pref="900" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="mainPanel">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1400, 1000]"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="changeScheduleNumberScrollBar" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" pref="115" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="textSolutionNumber" min="-2" pref="81" max="-2" attributes="0"/>
<EmptySpace min="0" pref="1166" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textSolutionNumber" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="changeScheduleNumberScrollBar" min="-2" pref="900" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="900" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JScrollBar" name="changeScheduleNumberScrollBar">
<Events>
<EventHandler event="adjustmentValueChanged" listener="java.awt.event.AdjustmentListener" parameters="java.awt.event.AdjustmentEvent" handler="changeScheduleNumberScrollBarAdjustmentValueChanged"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="scheduleViewerArea">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Solution number"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="textSolutionNumber">
<Properties>
<Property name="text" type="java.lang.String" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -0,0 +1,139 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package SchedulesWindows;
import SchedulesRecovery.BankRecoveredSchedules;
import java.util.*;
/**
*
* @author frabe
*/
public class ShowSolutionResultsFrame extends javax.swing.JFrame {
private List< BankRecoveredSchedules > bankRecoveredSchedulesOrderedByMeanCost;
/**
* Creates new form ShowSchedulesFrame
*/
public ShowSolutionResultsFrame(List< BankRecoveredSchedules > bankRecoveredSchedulesOrderedByMeanCost) {
this.bankRecoveredSchedulesOrderedByMeanCost = bankRecoveredSchedulesOrderedByMeanCost;
initComponents();
init();
}
private void init() {
setTitle("Simulation Results");
setVisible(true);
changeScheduleNumberScrollBar.setMinimum(1);
int numberOfSchedules = this.bankRecoveredSchedulesOrderedByMeanCost.size();
changeScheduleNumberScrollBar.setMaximum(numberOfSchedules);
changeScheduleNumberScrollBar.setBlockIncrement(numberOfSchedules/10);
changeScheduleNumberScrollBar.setVisibleAmount(numberOfSchedules/10);
changeScheduleNumberScrollBar.setUnitIncrement(1);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
mainPanel = new javax.swing.JPanel();
changeScheduleNumberScrollBar = new javax.swing.JScrollBar();
jScrollPane1 = new javax.swing.JScrollPane();
scheduleViewerArea = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
textSolutionNumber = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
mainPanel.setPreferredSize(new java.awt.Dimension(1400, 1000));
changeScheduleNumberScrollBar.addAdjustmentListener(new java.awt.event.AdjustmentListener() {
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
changeScheduleNumberScrollBarAdjustmentValueChanged(evt);
}
});
scheduleViewerArea.setEditable(false);
scheduleViewerArea.setColumns(20);
scheduleViewerArea.setRows(5);
jScrollPane1.setViewportView(scheduleViewerArea);
jLabel1.setText("Solution number");
textSolutionNumber.setText("0");
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(changeScheduleNumberScrollBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1))
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(textSolutionNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 1166, Short.MAX_VALUE)))
.addContainerGap())
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textSolutionNumber))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(changeScheduleNumberScrollBar, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 900, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void changeScheduleNumberScrollBarAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_changeScheduleNumberScrollBarAdjustmentValueChanged
// TODO add your handling code here:
int scrollBarValue = evt.getValue();
textSolutionNumber.setText(String.valueOf(scrollBarValue));
refreshScheduleText(scrollBarValue);
}//GEN-LAST:event_changeScheduleNumberScrollBarAdjustmentValueChanged
private void refreshScheduleText(int scrollBarValue) {
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));
scheduleViewerArea.setText(sbuf.toString());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollBar changeScheduleNumberScrollBar;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JPanel mainPanel;
private javax.swing.JTextArea scheduleViewerArea;
private javax.swing.JLabel textSolutionNumber;
// End of variables declaration//GEN-END:variables
}