Skip to content

Commit

Permalink
Add singleton ExecutionHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekster committed Dec 18, 2016
1 parent e41695d commit d76918e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/core/RST_NSGAIII.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package core;

import java.util.ArrayList;
import java.util.ServiceConfigurationError;
import java.util.logging.Level;
import java.util.logging.Logger;

import core.hyperplane.Hyperplane;
import core.points.ReferencePoint;
import core.points.Solution;
import history.ExecutionHistory;
import igd.IGD;
import igd.TargetFrontGenerator;
import operators.impl.crossover.SBX;
import operators.impl.crossover.noCrossover;
import operators.impl.mutation.PolynomialMutation;
import operators.impl.selection.BinaryTournament;
import preferences.Elicitator;
Expand Down Expand Up @@ -203,8 +200,4 @@ public Hyperplane getHyperplane(){
public int getGeneration(){
return generation;
}

public ExecutionHistory getHistory(){
return history;
}
}
2 changes: 1 addition & 1 deletion src/core/gui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public MainWindow() {
this.chartPanelReferencePlane = createChartReferencePlane();
this.labelIGD = new JLabel("IGD: --");
this.slider = new JSlider(JSlider.HORIZONTAL, 0, numGenerations, 0);
this.history = ExecutionHistory.getInstance();
slider.addChangeListener(new ChangeListener() {

@Override
Expand Down Expand Up @@ -519,7 +520,6 @@ private MySeries createJZY3DDataset() {
alg = new RST_NSGAIII((Problem) problemConstructor.newInstance(numObjectives), numGenerations, elicitationInterval);
alg.run();
executedGenerations = alg.getGeneration();
history = alg.getHistory();

alg.evaluateFinalResult(history.getGeneration(executedGenerations));
updateSlider();
Expand Down
5 changes: 1 addition & 4 deletions src/experiment/ExperimentRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
import java.util.ArrayList;
import java.util.HashMap;

import core.NSGAIII;
import core.Population;
import core.Problem;
import core.RST_NSGAIII;
import core.points.ReferencePoint;
import core.points.Solution;
import history.ExecutionHistory;
import problems.dtlz.DTLZ1;
import problems.dtlz.DTLZ2;
import problems.dtlz.DTLZ3;
import problems.dtlz.DTLZ4;
import solutionRankers.ChebyshevRankerBuilder;
import utils.Pair;

public class ExperimentRunner {
Expand All @@ -44,7 +41,7 @@ private static void runNSGAIIIExperiment(Problem p, int runId) {
RST_NSGAIII alg = new RST_NSGAIII(p, numGenerationsMap.get(new Pair<String, Integer>(p.getName(), p.getNumObjectives())), 20);
alg.run();

ExecutionHistory history = alg.getHistory();
ExecutionHistory history = ExecutionHistory.getInstance();
alg.evaluateFinalResult(history.getGeneration(alg.getGeneration()));
System.out.println(p.getName() + " " + p.getNumObjectives() + " " + p.getNumVariables());
System.out.println("Final min: " + history.getFinalMinDist());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ProgressMonitor;

import org.xdat.Main;
import org.xdat.UserPreferences;
import org.xdat.gui.dialogs.NSGAIIISettingsDialog;
import org.xdat.gui.menus.mainWIndow.MainNSGAIIIMenu;
import org.xdat.workerThreads.DataSheetCreationThread;
import org.xdat.workerThreads.ParallelCoordinatesChartCreationThread;

import core.NSGAIIIParameters;
import core.NSGAIIIRunnner;
Expand Down Expand Up @@ -66,7 +74,20 @@ public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Set NSGAIII Execution Parameters")) {
new NSGAIIISettingsDialog(this.mainWindow);
} else if(e.getActionCommand().equals("Run NSGAIII")){
NSGAIIIRunnner.runNSGAIII();
if (mainWindow.getChartFrameCount() == 0 || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainWindow, "This operation will close all charts.\n Are you sure you want to continue?", "Import Data", JOptionPane.OK_CANCEL_OPTION)) {
mainWindow.disposeAllChartFrames();

NSGAIIIRunnner.runNSGAIII();

ProgressMonitor progressMonitor = new ProgressMonitor(mainWindow, "", "Building Chart...", 0, 100);
progressMonitor.setProgress(0);
DataSheetCreationThread dataCreationThread = new DataSheetCreationThread(null, false, this.mainWindow, progressMonitor);
dataCreationThread.execute();
progressMonitor.setProgress(0);
ParallelCoordinatesChartCreationThread parallelCoordinatesChartCreationThread = new ParallelCoordinatesChartCreationThread(mainWindow, progressMonitor);
parallelCoordinatesChartCreationThread.execute();
}

} else {
System.out.println(e.getActionCommand());
}
Expand Down
6 changes: 5 additions & 1 deletion src/org/xdat/data/DataSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ public DataSheet(String pathToInputFile, boolean dataHasHeaders, Main mainWindow
this.delimiter = userPreferences.getDelimiter();
if (userPreferences.isTreatConsecutiveAsOne())
this.delimiter = this.delimiter + "+";
importData(pathToInputFile, dataHasHeaders, progressMonitor);
if(pathToInputFile != null){
importData(pathToInputFile, dataHasHeaders, progressMonitor);
} else{

}
boolean continueChecking = true;
for (int i = 0; i < this.parameters.size(); i++) {
if (this.parameters.get(i).isMixed() && continueChecking) {
Expand Down

0 comments on commit d76918e

Please sign in to comment.