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