|
@@ -16,9 +16,11 @@ import java.util.ArrayList;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
+import java.util.function.BiFunction;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.function.DoubleConsumer;
|
|
|
import java.util.function.IntConsumer;
|
|
|
+import java.util.function.Supplier;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
@@ -94,7 +96,9 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
private RunPrinter printer = new RunPrinter(plottFileName(), true);
|
|
|
|
|
|
|
|
|
-
|
|
|
+ //Parameter
|
|
|
+ LinkedList<ParameterStepping> parameterSteppingList= new LinkedList<ParameterStepping>();
|
|
|
+ protected boolean useStepping = false;
|
|
|
|
|
|
|
|
|
|
|
@@ -106,6 +110,11 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
splitPane.setResizeWeight(0.0);
|
|
|
content.add(splitPane, BorderLayout.CENTER);
|
|
|
content.setPreferredSize(new Dimension(800,800));
|
|
|
+
|
|
|
+ //Add rounds
|
|
|
+ ParameterStepping<Integer> roundStepping = new ParameterStepping<Integer>(IntInput -> rounds = IntInput, () -> rounds, (a,b) -> Integer.sum(a, b), (a,b) -> a * b, 10, 2);
|
|
|
+ roundStepping.useThisParameter = true;
|
|
|
+ parameterSteppingList.add(roundStepping);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -352,11 +361,49 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
private void run() {
|
|
|
cancel = false;
|
|
|
control.guiDisable(true);
|
|
|
- executeAlgoWithParameter();
|
|
|
+ if(this.useStepping) {
|
|
|
+ initParameterStepping();
|
|
|
+ do {
|
|
|
+ executeAlgoWithParameter();
|
|
|
+ plott();
|
|
|
+ resetState();
|
|
|
+ }while(updateOneParameter());
|
|
|
+ }else {
|
|
|
+ executeAlgoWithParameter();
|
|
|
+
|
|
|
+ }
|
|
|
updateVisual();
|
|
|
control.guiDisable(false);
|
|
|
}
|
|
|
|
|
|
+ private void initParameterStepping() {
|
|
|
+ for(ParameterStepping param :this.parameterSteppingList) {
|
|
|
+ param.init();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private boolean updateOneParameter() {
|
|
|
+ for(ParameterStepping param :this.parameterSteppingList) {
|
|
|
+ if(param.useThisParameter && param.canUpdate()) {
|
|
|
+ param.update();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //No Param can be updated
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void executeAlgoWithParameter(){
|
|
|
runProgressbar.start();
|
|
|
int actualIteration = control.getModel().getCurIteration();
|
|
@@ -534,7 +581,6 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
|
|
|
|
|
|
private String stringStatFromActualState() {
|
|
|
- console.println(" (dGroupNode != null):" + (dGroupNode != null));
|
|
|
if(dGroupNode != null)
|
|
|
{
|
|
|
//GetActualDecoratedGroupNode
|
|
@@ -562,7 +608,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
+ "]";
|
|
|
}
|
|
|
|
|
|
- return "[No GroupMode Use == No detailed Info]";
|
|
|
+ return "[No GroupNode Use == No detailed Info]";
|
|
|
}
|
|
|
|
|
|
|
|
@@ -790,4 +836,47 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
|
|
|
fitness = c.fitness;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ protected class ParameterStepping<T>{
|
|
|
+ boolean useThisParameter = false;
|
|
|
+ String paramaterName;
|
|
|
+ private int count = 0;
|
|
|
+ int stepps;
|
|
|
+ T stepSize;
|
|
|
+ T startValue;
|
|
|
+ Consumer<T> setter;
|
|
|
+ Supplier<T> getter;
|
|
|
+ BiFunction<Integer,T,T> multyply;
|
|
|
+ BiFunction<T,T,T> add;
|
|
|
+ ParameterStepping(Consumer<T> setter, Supplier<T> getter, BiFunction<T,T,T> add, BiFunction<Integer,T,T> multyply, T stepSize, int stepps){
|
|
|
+ this.setter = setter;
|
|
|
+ this.getter = getter;
|
|
|
+ this.multyply = multyply;
|
|
|
+ this.add = add;
|
|
|
+ this.stepSize = stepSize;
|
|
|
+ this.stepps = stepps;
|
|
|
+ }
|
|
|
+
|
|
|
+ void init() {
|
|
|
+ startValue = getter.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean canUpdate() {
|
|
|
+ return count < stepps;
|
|
|
+ }
|
|
|
+
|
|
|
+ void update(){
|
|
|
+ if(canUpdate()) {
|
|
|
+ setter.accept(add.apply(startValue, multyply.apply(count + 1, stepSize)));
|
|
|
+ count ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void reset() {
|
|
|
+ setter.accept(startValue);
|
|
|
+ count = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|