|
@@ -22,16 +22,16 @@ import utility.Tuple;
|
|
public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
|
|
|
|
private int problemSize = 0;
|
|
private int problemSize = 0;
|
|
- private boolean moreInformation = true;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Method to get the current Position alias a ListOf Booleans for aktive
|
|
|
|
- * settings on the Objects on the Canvas. Also initialize the Access Hashmap to
|
|
|
|
- * swap faster positions.
|
|
|
|
- *
|
|
|
|
- * @param model
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
|
|
+ private boolean moreInformation = false;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public GreedySinglePass() {
|
|
|
|
+ super();
|
|
|
|
+ addBooleanParameter("More Information", moreInformation, booleanValue -> moreInformation = booleanValue);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
protected List<Integer> generateRandomLayerIndexList() {
|
|
protected List<Integer> generateRandomLayerIndexList() {
|
|
Model model = control.getModel();
|
|
Model model = control.getModel();
|
|
List<AbstractCanvasObject> nodes = (dGroupNode != null) ? dGroupNode.getModel().getNodes()
|
|
List<AbstractCanvasObject> nodes = (dGroupNode != null) ? dGroupNode.getModel().getNodes()
|
|
@@ -121,6 +121,7 @@ public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
bestFound.fitness = Float.MAX_VALUE;
|
|
bestFound.fitness = Float.MAX_VALUE;
|
|
Individual start = new Individual(best);
|
|
Individual start = new Individual(best);
|
|
List<Integer> radomizedForEachLayerIndexList = generateRandomLayerIndexList();
|
|
List<Integer> radomizedForEachLayerIndexList = generateRandomLayerIndexList();
|
|
|
|
+
|
|
for (Integer index : radomizedForEachLayerIndexList) {
|
|
for (Integer index : radomizedForEachLayerIndexList) {
|
|
boolean actualValue = start.position.get(index);
|
|
boolean actualValue = start.position.get(index);
|
|
start.position.set(index, !actualValue);
|
|
start.position.set(index, !actualValue);
|
|
@@ -129,6 +130,7 @@ public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
if (kicked) {
|
|
if (kicked) {
|
|
bestFound = new Individual(start);
|
|
bestFound = new Individual(start);
|
|
bestFound.fitness = fitness;
|
|
bestFound.fitness = fitness;
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
start.position.set(index, actualValue);
|
|
start.position.set(index, actualValue);
|
|
}
|
|
}
|
|
@@ -136,12 +138,13 @@ public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
if (bestFound.fitness < best.fitness) {
|
|
if (bestFound.fitness < best.fitness) {
|
|
best = bestFound;
|
|
best = bestFound;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ runList.add(bestFound.fitness);
|
|
if (cancel)
|
|
if (cancel)
|
|
return null;
|
|
return null;
|
|
println("Fitness: " + fitness + "\tFlippedIndex = " + index + "(" + problemSize + ")" + kicked);
|
|
println("Fitness: " + fitness + "\tFlippedIndex = " + index + "(" + problemSize + ")" + kicked);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ console.println("Fitness: " + bestFound.fitness);
|
|
|
|
+ this.runList = runList;
|
|
return best;
|
|
return best;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -152,9 +155,11 @@ public class GreedySinglePass extends AlgorithmFrameworkFlex {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected int getProgressBarMaxCount() {
|
|
protected int getProgressBarMaxCount() {
|
|
- return (problemSize * (problemSize + 1)) / 2;
|
|
|
|
|
|
+ List<Boolean> best = extractPositionAndAccess();
|
|
|
|
+ problemSize = best.size();
|
|
|
|
+ return problemSize * rounds;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected String algoInformationToPrint() {
|
|
protected String algoInformationToPrint() {
|
|
return "NoParameter";
|
|
return "NoParameter";
|