|
@@ -450,30 +450,9 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
|
|
|
protected double evaluatePosition(List<Boolean> positionToEvaluate) {
|
|
protected double evaluatePosition(List<Boolean> positionToEvaluate) {
|
|
runProgressbar.step();
|
|
runProgressbar.step();
|
|
-// long startTime = System.currentTimeMillis(), endTime;
|
|
|
|
- control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurIteration()); // execution time critical
|
|
|
|
-// endTime = System.currentTimeMillis();
|
|
|
|
-// console.print(" a:" + (endTime - startTime));
|
|
|
|
-// startTime = endTime;
|
|
|
|
setState(positionToEvaluate); // execution time critical
|
|
setState(positionToEvaluate); // execution time critical
|
|
-// endTime = System.currentTimeMillis();
|
|
|
|
-// console.print(" b:" + (endTime - startTime));
|
|
|
|
-// startTime = endTime;
|
|
|
|
- control.calculateStateOnlyForCurrentTimeStep();
|
|
|
|
-// endTime = System.currentTimeMillis();
|
|
|
|
-// console.print(" c:" + (endTime - startTime));
|
|
|
|
-// startTime = endTime;
|
|
|
|
DecoratedState actualstate = control.getSimManager().getActualDecorState();
|
|
DecoratedState actualstate = control.getSimManager().getActualDecorState();
|
|
-// endTime = System.currentTimeMillis();
|
|
|
|
-// console.print(" d:" + (endTime - startTime));
|
|
|
|
-// startTime = endTime;
|
|
|
|
double result = evaluateState(actualstate);
|
|
double result = evaluateState(actualstate);
|
|
-// endTime = System.currentTimeMillis();
|
|
|
|
-// console.print(" e:" + (endTime - startTime));
|
|
|
|
-// startTime = endTime;
|
|
|
|
-// long inUse = actualstate.getFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE).size();
|
|
|
|
-// long all = actualstate.getFlexManager().getAllFlexWrapper().size();
|
|
|
|
-// console.println(" [" + inUse + "/" + all + "]");
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -561,11 +540,11 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
runBest.fitness = Double.MAX_VALUE;
|
|
runBest.fitness = Double.MAX_VALUE;
|
|
for(int r = 0; r < rounds; r++)
|
|
for(int r = 0; r < rounds; r++)
|
|
{
|
|
{
|
|
-
|
|
|
|
startTimer();
|
|
startTimer();
|
|
Individual roundBest = executeAlgo();
|
|
Individual roundBest = executeAlgo();
|
|
if(cancel)return;
|
|
if(cancel)return;
|
|
long executionTime = printElapsedTime();
|
|
long executionTime = printElapsedTime();
|
|
|
|
+ setState(roundBest.position);
|
|
runPrinter.openStream();
|
|
runPrinter.openStream();
|
|
runPrinter.println(runList.stream().map(Object::toString).collect(Collectors.joining(", ")));
|
|
runPrinter.println(runList.stream().map(Object::toString).collect(Collectors.joining(", ")));
|
|
runPrinter.println(stringStatFromActualState());
|
|
runPrinter.println(stringStatFromActualState());
|
|
@@ -667,7 +646,6 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
if(!resetChain.isEmpty()) {
|
|
if(!resetChain.isEmpty()) {
|
|
console.println("Resetting..");
|
|
console.println("Resetting..");
|
|
setState(resetChain.getFirst());
|
|
setState(resetChain.getFirst());
|
|
- control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurIteration());
|
|
|
|
resetChain.clear();
|
|
resetChain.clear();
|
|
control.resetSimulation();
|
|
control.resetSimulation();
|
|
control.setCurIteration(0);
|
|
control.setCurIteration(0);
|
|
@@ -688,7 +666,6 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
* Sets the Model back to its original State before the LAST run.
|
|
* Sets the Model back to its original State before the LAST run.
|
|
*/
|
|
*/
|
|
private void resetState() {
|
|
private void resetState() {
|
|
- control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurIteration());
|
|
|
|
setState(resetChain.getLast());
|
|
setState(resetChain.getLast());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -698,11 +675,12 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
* @param position
|
|
* @param position
|
|
*/
|
|
*/
|
|
private void setState(List<Boolean> position) {
|
|
private void setState(List<Boolean> position) {
|
|
|
|
+ control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurIteration());
|
|
int i = 0;
|
|
int i = 0;
|
|
for(Boolean bool: position) {
|
|
for(Boolean bool: position) {
|
|
access.get(i++).setState(bool);
|
|
access.get(i++).setState(bool);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ control.calculateStateOnlyForCurrentTimeStep();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -836,7 +814,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
+ " Producer: " + percentage(amountOfSupplier, amountOfObjects)
|
|
+ " Producer: " + percentage(amountOfSupplier, amountOfObjects)
|
|
+ " Consumer: " + percentage(amountOfConsumer, amountOfObjects)
|
|
+ " Consumer: " + percentage(amountOfConsumer, amountOfObjects)
|
|
+ " Unsupplied: " + percentage(unSuppliedConsumer, amountOfConsumer)
|
|
+ " Unsupplied: " + percentage(unSuppliedConsumer, amountOfConsumer)
|
|
- + " PartiallySupplied: " + percentage(partiallySuppliedConsumer, amountOfObjects)
|
|
|
|
|
|
+ + " PartiallySupplied: " + percentage(partiallySuppliedConsumer, amountOfConsumer)
|
|
+ " with SupplyPercentage(Min: " + partiallyStat.getMin()
|
|
+ " with SupplyPercentage(Min: " + partiallyStat.getMin()
|
|
+ " Max: "+ partiallyStat.getMax()
|
|
+ " Max: "+ partiallyStat.getMax()
|
|
+ " Average: " +partiallyStat.getAverage() + ")"
|
|
+ " Average: " +partiallyStat.getAverage() + ")"
|
|
@@ -1076,6 +1054,10 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
position = c.position.stream().collect(Collectors.toList());
|
|
position = c.position.stream().collect(Collectors.toList());
|
|
fitness = c.fitness;
|
|
fitness = c.fitness;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ String positionToString() {
|
|
|
|
+ return position.stream().map(bool -> (bool?"1":"0")).collect(Collectors.joining());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
protected class ParameterStepping<T>{
|
|
protected class ParameterStepping<T>{
|