|
@@ -59,6 +59,9 @@ public class AcoAlgorithm implements Algorithm {
|
|
|
private int rounds = 3;
|
|
|
|
|
|
private int resetCount = 0;
|
|
|
+ private boolean moreInformation = false;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
//Settings For GroupNode using and cancel
|
|
@@ -104,6 +107,7 @@ public class AcoAlgorithm implements Algorithm {
|
|
|
newFrame.pack();
|
|
|
newFrame.setVisible(true);
|
|
|
newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
+
|
|
|
}
|
|
|
public AcoAlgorithm() {
|
|
|
content.setLayout(new BorderLayout());
|
|
@@ -158,6 +162,14 @@ public class AcoAlgorithm implements Algorithm {
|
|
|
progressBar.setStringPainted(true);
|
|
|
parameterPanel.add(progressBar);
|
|
|
|
|
|
+ JCheckBox informationCheckBox = new JCheckBox("More Information");
|
|
|
+ informationCheckBox.setSelected(this.moreInformation);
|
|
|
+ informationCheckBox.setBounds(350, 60, 220, 20);
|
|
|
+ informationCheckBox.addActionListener(actionEvent -> {
|
|
|
+ moreInformation = informationCheckBox.isSelected();
|
|
|
+ });
|
|
|
+ parameterPanel.add(informationCheckBox);
|
|
|
+
|
|
|
JPanel borderPanel = new JPanel(null);
|
|
|
borderPanel.setBounds(350, 85, 185, 50);
|
|
|
borderPanel.setBorder(BorderFactory.createTitledBorder(""));
|
|
@@ -394,7 +406,7 @@ public class AcoAlgorithm implements Algorithm {
|
|
|
printElapsedTime();
|
|
|
setState(runBest.position);
|
|
|
updateVisual();
|
|
|
- println("ResetsCount:"+resetCount);
|
|
|
+ if(moreInformation)println("ResetsCount:"+resetCount);
|
|
|
println("AlgoResult:" + runBest.fitness);
|
|
|
|
|
|
|
|
@@ -422,35 +434,37 @@ public class AcoAlgorithm implements Algorithm {
|
|
|
private Individual executeAcoAlgo() {
|
|
|
Individual best = new Individual();
|
|
|
best.position = extractPositionAndAccess();
|
|
|
- println("Bit-Array_length: " + best.position.size());
|
|
|
+ if(moreInformation)println("Bit-Array_length: " + best.position.size());
|
|
|
best.fitness = evaluatePosition(best.position, false);
|
|
|
- println("Start with Fitness: " + best.fitness);
|
|
|
+ console.print("Start with: " + best.fitness);
|
|
|
+ if(moreInformation)println("");
|
|
|
int problemSize = best.position.size();
|
|
|
if(problemSize == 0) return best;
|
|
|
List<Double> pheromones = initPheromones(problemSize);
|
|
|
List<Individual> population = new ArrayList<Individual>();
|
|
|
- println("Size To Test:" + population.size());
|
|
|
+ if(moreInformation)println("Size To Test:" + population.size());
|
|
|
for(int generation = 0; generation< maxGenerations; generation++) {
|
|
|
population.clear();
|
|
|
population = constructSolutionsBiasedBy(pheromones);
|
|
|
- println("Generation" + generation + " start with Fitness: " + best.fitness);
|
|
|
+ if(moreInformation)println("Generation" + generation + " start with Fitness: " + best.fitness);
|
|
|
for(Individual i : population) {
|
|
|
i.fitness = evaluatePosition(i.position, true);
|
|
|
- println("Fitness" + i.fitness);
|
|
|
+ if(moreInformation)println("Fitness" + i.fitness);
|
|
|
if(i.fitness < best.fitness) best = i;
|
|
|
}
|
|
|
- println("________________");
|
|
|
+ if(moreInformation)println("________________");
|
|
|
vaporizeIntensifiePheromons(pheromones, best.position, problemSize);
|
|
|
double cf = calculateConvergenceFactor(pheromones, problemSize);
|
|
|
- println("ConvergenceFactor = " + cf);
|
|
|
+ if(moreInformation)println("ConvergenceFactor = " + cf);
|
|
|
if(cf > this.convergenceFactorReset) {
|
|
|
pheromones = initPheromones(problemSize);
|
|
|
resetCount++;
|
|
|
}
|
|
|
+ if(cancel)return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
- println("RoundResult:" + best.fitness);
|
|
|
+ println(" End With:" + best.fitness);
|
|
|
return best;
|
|
|
|
|
|
}
|