Refactored all eva2.optimization.mocco m_ variables

This commit is contained in:
Fabian Becker 2014-01-28 22:17:13 +01:00
parent 41f58bb2f9
commit 0d07553546
28 changed files with 1172 additions and 1409 deletions

View File

@ -9,21 +9,21 @@ package eva2.gui;
*/ */
public class PropertyWeightedLPTchebycheff implements java.io.Serializable { public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
public double[] m_IdealValue; public double[] idealValue;
public double[] m_Weights; public double[] weights;
public int m_P = 0; public int m_P = 0;
public PropertyWeightedLPTchebycheff() { public PropertyWeightedLPTchebycheff() {
} }
public PropertyWeightedLPTchebycheff(PropertyWeightedLPTchebycheff e) { public PropertyWeightedLPTchebycheff(PropertyWeightedLPTchebycheff e) {
if (e.m_IdealValue != null) { if (e.idealValue != null) {
this.m_IdealValue = new double[e.m_IdealValue.length]; this.idealValue = new double[e.idealValue.length];
System.arraycopy(e.m_IdealValue, 0, this.m_IdealValue, 0, this.m_IdealValue.length); System.arraycopy(e.idealValue, 0, this.idealValue, 0, this.idealValue.length);
} }
if (e.m_Weights != null) { if (e.weights != null) {
this.m_Weights = new double[e.m_Weights.length]; this.weights = new double[e.weights.length];
System.arraycopy(e.m_Weights, 0, this.m_Weights, 0, this.m_Weights.length); System.arraycopy(e.weights, 0, this.weights, 0, this.weights.length);
} }
this.m_P = e.m_P; this.m_P = e.m_P;
} }

View File

@ -123,8 +123,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
@Override @Override
public void keyReleased(KeyEvent event) { public void keyReleased(KeyEvent event) {
double[] tmpT = m_WLPT.m_IdealValue; double[] tmpT = m_WLPT.idealValue;
double[] tmpP = m_WLPT.m_Weights; double[] tmpP = m_WLPT.weights;
for (int i = 0; i < tmpT.length; i++) { for (int i = 0; i < tmpT.length; i++) {
@ -144,8 +144,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
} }
} }
m_WLPT.m_IdealValue = tmpT; m_WLPT.idealValue = tmpT;
m_WLPT.m_Weights = tmpP; m_WLPT.weights = tmpP;
} }
}; };
@ -164,8 +164,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
* This method updates the data panel * This method updates the data panel
*/ */
private void updateDataPanel() { private void updateDataPanel() {
double[] tmpT = this.m_WLPT.m_IdealValue; double[] tmpT = this.m_WLPT.idealValue;
double[] tmpP = this.m_WLPT.m_Weights; double[] tmpP = this.m_WLPT.weights;
int obj = this.m_WLPT.m_P; int obj = this.m_WLPT.m_P;
this.m_PValue.setText("" + obj); this.m_PValue.setText("" + obj);

View File

@ -77,8 +77,8 @@ public class FunctionArea extends DArea implements Serializable {
setBackground(new Color(253, 253, 253)); // not quite white setBackground(new Color(253, 253, 253)); // not quite white
// setAutoFocus(true); // setAutoFocus(true);
scaledBorder = new ScaledBorder(); scaledBorder = new ScaledBorder();
scaledBorder.x_label = xname; // "App. " + Name + " func. calls"; scaledBorder.xLabel = xname; // "App. " + Name + " func. calls";
scaledBorder.y_label = yname; // "fitness"; scaledBorder.yLabel = yname; // "fitness";
setBorder(scaledBorder); setBorder(scaledBorder);
setAutoGrid(true); setAutoGrid(true);
setGridVisible(true); setGridVisible(true);
@ -1122,9 +1122,9 @@ public class FunctionArea extends DArea implements Serializable {
setYScale(null); setYScale(null);
ScaledBorder buffer = scaledBorder; ScaledBorder buffer = scaledBorder;
scaledBorder = new ScaledBorder(); scaledBorder = new ScaledBorder();
scaledBorder.x_label = buffer.x_label; // "App. " + Name + scaledBorder.xLabel = buffer.xLabel; // "App. " + Name +
// " func. calls"; // " func. calls";
scaledBorder.y_label = buffer.y_label; // "fitness"; scaledBorder.yLabel = buffer.yLabel; // "fitness";
scaledBorder.setStandardPattern(false); // default decimal pattern on y axis scaledBorder.setStandardPattern(false); // default decimal pattern on y axis
setBorder(scaledBorder); setBorder(scaledBorder);
} }

View File

@ -1,6 +1,5 @@
package eva2.optimization.go; package eva2.optimization.go;
import eva2.gui.JParaPanel;
import eva2.gui.PropertyDoubleArray; import eva2.gui.PropertyDoubleArray;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.optimization.mocco.*; import eva2.optimization.mocco.*;
@ -20,28 +19,24 @@ import java.awt.event.WindowEvent;
import java.io.*; import java.io.*;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 21.10.2005
* Time: 14:31:56
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOStandalone implements InterfaceStandaloneOptimization, InterfacePopulationChangedEventListener, Serializable { public class MOCCOStandalone implements InterfaceStandaloneOptimization, InterfacePopulationChangedEventListener, Serializable {
public volatile MOCCOState m_State; public volatile MOCCOState state;
private SwingWorker worker; private SwingWorker worker;
private volatile boolean m_StillWorking = false; private volatile boolean stillWorking = false;
public int m_Iteration = -1; public int iteration = -1;
public JFrame m_JFrame; private JFrame mainFrame;
//public ParetoFrontView n_ParetoFrontView; //public ParetoFrontView n_ParetoFrontView;
public boolean m_Debug = false; private boolean debug = false;
public MOCCOViewer m_View; public MOCCOViewer view;
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom; public JPanel mainPanel, parameterPanel, controlPanel, buttonPanel;
private JLabel m_CurrentState; private JLabel currentState;
private JProgressBar m_ProgressBar; private JProgressBar progressBar;
public MOCCOStandalone() { public MOCCOStandalone() {
this.m_State = new MOCCOState(); this.state = new MOCCOState();
} }
/** /**
@ -49,44 +44,43 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
* frame * frame
*/ */
public void initMOCCOFrame() { public void initMOCCOFrame() {
JParaPanel paraPanel = new JParaPanel(this, "MyGUI");
this.m_State.isVisible = true; this.state.isVisible = true;
this.m_JFrame = new JFrame(); this.mainFrame = new JFrame();
this.m_JFrame.setTitle("MOCCO - Interactive Multi-Objective Optimization"); this.mainFrame.setTitle("MOCCO - Interactive Multi-Objective Optimization");
this.m_JFrame.setSize(1200, 750); this.mainFrame.setSize(1200, 750);
this.m_JFrame.setLocation(50, 50); this.mainFrame.setLocation(50, 50);
this.m_JFrame.addWindowListener(new WindowAdapter() { this.mainFrame.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(WindowEvent ev) { public void windowClosing(WindowEvent ev) {
System.exit(0); System.exit(0);
} }
}); });
// init basic panel structure // init basic panel structure
this.m_JPanelMain = new JPanel(); this.mainPanel = new JPanel();
this.m_JPanelParameters = new JPanel(); this.parameterPanel = new JPanel();
this.m_JPanelParameters.setPreferredSize(new Dimension(500, 300)); this.parameterPanel.setPreferredSize(new Dimension(500, 300));
this.m_JPanelParameters.setMinimumSize(new Dimension(500, 300)); this.parameterPanel.setMinimumSize(new Dimension(500, 300));
this.m_JPanelControl = new JPanel(); this.controlPanel = new JPanel();
this.m_View = new MOCCOViewer(this); this.view = new MOCCOViewer(this);
this.m_JFrame.getContentPane().add(this.m_JPanelMain); this.mainFrame.getContentPane().add(this.mainPanel);
this.m_JPanelMain.setLayout(new BorderLayout()); this.mainPanel.setLayout(new BorderLayout());
this.m_JPanelMain.add(this.m_JPanelParameters, BorderLayout.WEST); this.mainPanel.add(this.parameterPanel, BorderLayout.WEST);
this.m_JPanelMain.add(this.m_View, BorderLayout.CENTER); this.mainPanel.add(this.view, BorderLayout.CENTER);
this.m_JPanelButtom = new JPanel(); this.buttonPanel = new JPanel();
this.m_JPanelButtom.setLayout(new BorderLayout()); this.buttonPanel.setLayout(new BorderLayout());
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridLayout(2, 1)); tmpP.setLayout(new GridLayout(2, 1));
this.m_CurrentState = new JLabel("Problem Initialization"); this.currentState = new JLabel("Problem Initialization");
tmpP.add(this.m_CurrentState); tmpP.add(this.currentState);
this.m_ProgressBar = new JProgressBar(); this.progressBar = new JProgressBar();
tmpP.add(this.m_ProgressBar); tmpP.add(this.progressBar);
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER); this.buttonPanel.add(tmpP, BorderLayout.CENTER);
this.m_JPanelControl.setMinimumSize(new Dimension(400, 0)); this.controlPanel.setMinimumSize(new Dimension(400, 0));
this.m_JPanelControl.setPreferredSize(new Dimension(400, 0)); this.controlPanel.setPreferredSize(new Dimension(400, 0));
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST); this.buttonPanel.add(this.controlPanel, BorderLayout.EAST);
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH); this.mainPanel.add(this.buttonPanel, BorderLayout.SOUTH);
this.m_JFrame.validate(); this.mainFrame.validate();
// everything is prepared let's start the main loop // everything is prepared let's start the main loop
this.MOCCOOptimization(); this.MOCCOOptimization();
} }
@ -95,15 +89,15 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
boolean cont = true; boolean cont = true;
InterfaceProcessElement tmpP; InterfaceProcessElement tmpP;
while (cont) { while (cont) {
this.m_Iteration++; this.iteration++;
while (m_StillWorking) { while (stillWorking) {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (java.lang.InterruptedException e) { } catch (java.lang.InterruptedException e) {
} }
} }
if (this.m_State.m_OriginalProblem == null) { if (this.state.originalProblem == null) {
this.m_State.m_OriginalProblem = new TF1Problem(); this.state.originalProblem = new TF1Problem();
tmpP = new MOCCOProblemInitialization(this); tmpP = new MOCCOProblemInitialization(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { while (!tmpP.isFinished()) {
@ -112,9 +106,9 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} catch (java.lang.InterruptedException e) { } catch (java.lang.InterruptedException e) {
} }
} }
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone(); this.state.currentProblem = (InterfaceOptimizationProblem) this.state.originalProblem.clone();
this.m_View.problemChanged(true); this.view.problemChanged(true);
this.m_JPanelParameters.removeAll(); this.parameterPanel.removeAll();
tmpP = new MOCCOInitialPopulationSize(this); tmpP = new MOCCOInitialPopulationSize(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
while (!tmpP.isFinished()) { while (!tmpP.isFinished()) {
@ -123,16 +117,16 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} catch (java.lang.InterruptedException e) { } catch (java.lang.InterruptedException e) {
} }
} }
this.m_State.m_InitialPopulationSize = Math.max(1, this.m_State.m_InitialPopulationSize); this.state.initialPopulationSize = Math.max(1, this.state.initialPopulationSize);
Population pop = new Population(); Population pop = new Population();
pop.setTargetSize(this.m_State.m_InitialPopulationSize); pop.setTargetSize(this.state.initialPopulationSize);
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone(); this.state.currentProblem = (InterfaceOptimizationProblem) this.state.originalProblem.clone();
this.m_State.m_CurrentProblem.initializePopulation(pop); this.state.currentProblem.initializePopulation(pop);
this.m_State.m_CurrentProblem.evaluate(pop); this.state.currentProblem.evaluate(pop);
this.m_State.addPopulation2History(pop); this.state.addPopulation2History(pop);
this.m_View.problemChanged(true); this.view.problemChanged(true);
} }
((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).deactivateRepresentationEdit(); ((InterfaceMultiObjectiveDeNovoProblem) this.state.currentProblem).deactivateRepresentationEdit();
this.updateStatus("Analysis/Redefinition", 33); this.updateStatus("Analysis/Redefinition", 33);
tmpP = new MOCCOProblemRedefinition(this); tmpP = new MOCCOProblemRedefinition(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
@ -142,11 +136,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} catch (java.lang.InterruptedException e) { } catch (java.lang.InterruptedException e) {
} }
} }
this.m_State.makeFitnessCache(true); this.state.makeFitnessCache(true);
this.m_State.m_CurrentProblem.initializeProblem(); this.state.currentProblem.initializeProblem();
this.m_State.makeBackup(); this.state.makeBackup();
this.m_View.problemChanged(true); this.view.problemChanged(true);
if (this.m_State.m_CurrentProblem.isMultiObjective()) { if (this.state.currentProblem.isMultiObjective()) {
this.updateStatus("MO Strategy Selection", 50); this.updateStatus("MO Strategy Selection", 50);
tmpP = new MOCCOChooseMOStrategy(this); tmpP = new MOCCOChooseMOStrategy(this);
tmpP.initProcessElementParametrization(); tmpP.initProcessElementParametrization();
@ -292,20 +286,20 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
private void checkForObjectives(String w) { private void checkForObjectives(String w) {
System.out.println("I'm currently " + w); System.out.println("I'm currently " + w);
System.out.print("Original Problem is "); System.out.print("Original Problem is ");
if (this.m_State.m_OriginalProblem.isMultiObjective()) { if (this.state.originalProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} else { } else {
System.out.println("single-objective."); System.out.println("single-objective.");
} }
System.out.print("Current Problem is "); System.out.print("Current Problem is ");
if (this.m_State.m_CurrentProblem.isMultiObjective()) { if (this.state.currentProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} else { } else {
System.out.println("single-objective."); System.out.println("single-objective.");
} }
if (this.m_State.m_BackupProblem != null) { if (this.state.backupProblem != null) {
System.out.print("Backup Problem is "); System.out.print("Backup Problem is ");
if (this.m_State.m_BackupProblem.isMultiObjective()) { if (this.state.backupProblem.isMultiObjective()) {
System.out.println("multi-objective."); System.out.println("multi-objective.");
} else { } else {
System.out.println("single-objective."); System.out.println("single-objective.");
@ -318,9 +312,9 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
private void checktForMOSO(String w) { private void checktForMOSO(String w) {
String s; String s;
System.out.println("I'm currently at " + w); System.out.println("I'm currently at " + w);
InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem) this.m_State.m_CurrentProblem).getMOSOConverter(); InterfaceMOSOConverter moso = ((AbstractMultiObjectiveOptimizationProblem) this.state.currentProblem).getMOSOConverter();
System.out.println("MOSO selected: " + moso.getName()); System.out.println("MOSO selected: " + moso.getName());
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.state.currentProblem).getProblemObjectives();
s = "Objectives: {"; s = "Objectives: {";
for (int i = 0; i < obj.length; i++) { for (int i = 0; i < obj.length; i++) {
s += obj[i].getIdentName(); s += obj[i].getIdentName();
@ -391,11 +385,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} else { } else {
String file = args[0]; String file = args[0];
go.openObject(file); go.openObject(file);
if (go.m_State == null) { if (go.state == null) {
System.out.println("No valid input state!"); System.out.println("No valid input state!");
System.exit(0); System.exit(0);
} else { } else {
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) { if (go.state.optimizer.getPopulation().getFunctionCalls() == 0) {
// start to optimize // start to optimize
go.startExperiment(); go.startExperiment();
file = file.replaceAll(".ser", ""); file = file.replaceAll(".ser", "");
@ -425,8 +419,8 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} }
return obj; return obj;
} catch (Exception ex) { } catch (Exception ex) {
if (this.m_JFrame != null) { if (this.mainFrame != null) {
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this.mainFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
} else { } else {
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage()); System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
} }
@ -443,11 +437,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
File sFile = new File(saveAs); File sFile = new File(saveAs);
try { try {
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile))); ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
oo.writeObject(this.m_State); oo.writeObject(this.state);
oo.close(); oo.close();
} catch (Exception ex) { } catch (Exception ex) {
if (this.m_JFrame != null) { if (this.mainFrame != null) {
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this.mainFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
} else { } else {
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage()); System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
} }
@ -463,19 +457,19 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
*/ */
@Override @Override
public void startExperiment() { public void startExperiment() {
if (this.m_JFrame != null) { if (this.mainFrame != null) {
} }
this.m_StillWorking = true; this.stillWorking = true;
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem); this.state.optimizer.setProblem(this.state.currentProblem);
if (this.m_Debug) { if (this.debug) {
System.out.println("" + this.m_State.m_Optimizer.getStringRepresentation()); System.out.println("" + this.state.optimizer.getStringRepresentation());
} }
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation()); this.state.currentProblem.evaluate(this.state.optimizer.getPopulation());
this.m_State.m_Optimizer.getPopulation().setFunctionCalls(0); this.state.optimizer.getPopulation().setFunctionCalls(0);
if (this.m_State.m_Optimizer.getPopulation().size() == 0) { if (this.state.optimizer.getPopulation().size() == 0) {
this.m_State.m_Optimizer.init(); this.state.optimizer.init();
} }
this.m_State.m_Optimizer.addPopulationChangedEventListener(this); this.state.optimizer.addPopulationChangedEventListener(this);
worker = new SwingWorker() { worker = new SwingWorker() {
@Override @Override
public Object construct() { public Object construct() {
@ -485,26 +479,26 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
@Override @Override
public void finished() { public void finished() {
Population[] pop = null; Population[] pop = null;
if (m_State.m_Optimizer instanceof IslandModelEA) { if (state.optimizer instanceof IslandModelEA) {
InterfaceOptimizer[] opt = ((IslandModelEA) m_State.m_Optimizer).getOptimizers(); InterfaceOptimizer[] opt = ((IslandModelEA) state.optimizer).getOptimizers();
pop = new Population[opt.length]; pop = new Population[opt.length];
for (int i = 0; i < opt.length; i++) { for (int i = 0; i < opt.length; i++) {
pop[i] = opt[i].getPopulation(); pop[i] = opt[i].getPopulation();
} }
} }
m_State.restore(); state.restore();
if (pop == null) { if (pop == null) {
m_State.addPopulation2History(m_State.m_Optimizer.getPopulation()); state.addPopulation2History(state.optimizer.getPopulation());
} else { } else {
for (int i = 0; i < pop.length; i++) { for (int i = 0; i < pop.length; i++) {
m_State.m_CurrentProblem.evaluate(pop[i]); state.currentProblem.evaluate(pop[i]);
m_State.addPopulation2History(pop[i]); state.addPopulation2History(pop[i]);
} }
} }
if (m_View != null) { if (view != null) {
m_View.problemChanged(true); view.problemChanged(true);
} }
m_StillWorking = false; stillWorking = false;
} }
}; };
worker.start(); worker.start();
@ -517,16 +511,16 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
* changing the progress bars value. * changing the progress bars value.
*/ */
void updateStatus(final String t, final int i) { void updateStatus(final String t, final int i) {
if (this.m_ProgressBar != null) { if (this.progressBar != null) {
Runnable doSetProgressBarValue = new Runnable() { Runnable doSetProgressBarValue = new Runnable() {
@Override @Override
public void run() { public void run() {
m_ProgressBar.setValue(i); progressBar.setValue(i);
} }
}; };
SwingUtilities.invokeLater(doSetProgressBarValue); SwingUtilities.invokeLater(doSetProgressBarValue);
} }
this.m_CurrentState.setText(t); this.currentState.setText(t);
} }
/** /**
@ -541,11 +535,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
if (Thread.interrupted()) { if (Thread.interrupted()) {
throw new InterruptedException(); throw new InterruptedException();
} }
while (!this.m_State.m_Terminator.isTerminated(this.m_State.m_Optimizer.getPopulation())) { while (!this.state.terminator.isTerminated(this.state.optimizer.getPopulation())) {
if (Thread.interrupted()) { if (Thread.interrupted()) {
throw new InterruptedException(); throw new InterruptedException();
} }
this.m_State.m_Optimizer.optimize(); this.state.optimizer.optimize();
} }
System.gc(); System.gc();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -574,11 +568,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
public void registerPopulationStateChanged(Object source, String name) { public void registerPopulationStateChanged(Object source, String name) {
int currentProgress; int currentProgress;
if (name.equals(Population.NEXT_GENERATION_PERFORMED)) { if (name.equals(Population.NEXT_GENERATION_PERFORMED)) {
if (this.m_State.isVisible) { if (this.state.isVisible) {
Population population = ((InterfaceOptimizer) source).getPopulation(); Population population = ((InterfaceOptimizer) source).getPopulation();
double x = 100; double x = 100;
if (this.m_State.m_Terminator instanceof EvaluationTerminator) { if (this.state.terminator instanceof EvaluationTerminator) {
double y = x / (double) ((EvaluationTerminator) this.m_State.m_Terminator).getFitnessCalls(); double y = x / (double) ((EvaluationTerminator) this.state.terminator).getFitnessCalls();
currentProgress = (int) (population.getFunctionCalls() * y); currentProgress = (int) (population.getFunctionCalls() * y);
} else { } else {
currentProgress = (int) (0); currentProgress = (int) (0);
@ -589,4 +583,8 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
} }
} }
} }
public JFrame getMainFrame() {
return this.mainFrame;
}
} }

View File

@ -1,11 +1,7 @@
package eva2.optimization.mocco; package eva2.optimization.mocco;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 24.10.2005
* Time: 14:56:28
* To change this template use File | Settings | File Templates.
*/ */
public interface InterfaceProcessElement { public interface InterfaceProcessElement {

View File

@ -24,10 +24,10 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
public final static int STRATEGY_REFP = 2; public final static int STRATEGY_REFP = 2;
public final static int STRATEGY_TBCH = 3; public final static int STRATEGY_TBCH = 3;
public final static int STRATEGY_GDF = 4; public final static int STRATEGY_GDF = 4;
public int m_Strategy = MOCCOChooseMOStrategy.STRATEGY_MOEA; public int moStrategy = MOCCOChooseMOStrategy.STRATEGY_MOEA;
public MOCCOChooseMOStrategy(MOCCOStandalone mocco) { public MOCCOChooseMOStrategy(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -35,14 +35,14 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
// The button panel // The button panel
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a multi-objective" + this.mocco.parameterPanel.add(this.makeHelpText("Please choose a multi-objective" +
" optimization strategy for the next optimization iteration. The different optimization approaches" + " optimization strategy for the next optimization iteration. The different optimization approaches" +
" not only differ in the number of soltuion alternatives generated (more soltuions typicall require" + " not only differ in the number of soltuion alternatives generated (more soltuions typicall require" +
" higher computational effort), but also in the amount of input required by the decision maker (DM)."), BorderLayout.NORTH); " higher computational effort), but also in the amount of input required by the decision maker (DM)."), BorderLayout.NORTH);
@ -87,7 +87,7 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
tmpP.add(this.makeInformationText("Geoffrion-Dyer-Feinberg Method", "Here the DM needs to select a reference solution" + tmpP.add(this.makeInformationText("Geoffrion-Dyer-Feinberg Method", "Here the DM needs to select a reference solution" +
" from the currently known solution. For this solution the DM has to specify trade-off values for each" + " from the currently known solution. For this solution the DM has to specify trade-off values for each" +
" objective. This method assumes a linear utility function by results in a simple weighted aggregation."), gbc); " objective. This method assumes a linear utility function by results in a simple weighted aggregation."), gbc);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
tmpB = new JButton(); tmpB = new JButton();
bytes = loader.getBytesFromResourceLocation("images/MOCCO/MOCCO_STEP.gif", true); bytes = loader.getBytesFromResourceLocation("images/MOCCO/MOCCO_STEP.gif", true);
@ -138,8 +138,8 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
" reference point and tries to minimze the L-metric (=Inf). To obtain multiple alternative soltuions" + " reference point and tries to minimze the L-metric (=Inf). To obtain multiple alternative soltuions" +
" a weighted L-metric is used with different weigths for a number of optimization runs."), gbc); " a weighted L-metric is used with different weigths for a number of optimization runs."), gbc);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
/** /**
@ -148,52 +148,52 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
* @return the strategy * @return the strategy
*/ */
public int getMOStrategy() { public int getMOStrategy() {
return this.m_Strategy; return this.moStrategy;
} }
ActionListener choosenMOEA = new ActionListener() { ActionListener choosenMOEA = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Strategy = STRATEGY_MOEA; moStrategy = STRATEGY_MOEA;
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener choosenSTEP = new ActionListener() { ActionListener choosenSTEP = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Strategy = STRATEGY_STEP; moStrategy = STRATEGY_STEP;
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener choosenREFP = new ActionListener() { ActionListener choosenREFP = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Strategy = STRATEGY_REFP; moStrategy = STRATEGY_REFP;
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener choosenTBCH = new ActionListener() { ActionListener choosenTBCH = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Strategy = STRATEGY_TBCH; moStrategy = STRATEGY_TBCH;
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener choosenGDF = new ActionListener() { ActionListener choosenGDF = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Strategy = STRATEGY_GDF; moStrategy = STRATEGY_GDF;
m_Finished = true; hasFinished = true;
} }
}; };
} }

View File

@ -12,20 +12,16 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 27.10.2005
* Time: 18:42:30
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfaceProcessElement, InterfaceRefPointListener { public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfaceProcessElement, InterfaceRefPointListener {
private JTextField[] m_JTextField; private JTextField[] textField;
private double[] m_ReferencePoint; private double[] referencePoint;
JPanel m_Selected; JPanel selectedPanel;
public MOCCOChooseReferencePoint(MOCCOStandalone mocco) { public MOCCOChooseReferencePoint(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -33,46 +29,46 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Continue to algorithm parametrization."); JButton tmpB = new JButton("Continue to algorithm parametrization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Choose a reference point of aspiration levels" + this.mocco.parameterPanel.add(this.makeHelpText("Choose a reference point of aspiration levels" +
" which are not necessarily attainable, but will be used as goal for the following optimzation" + " which are not necessarily attainable, but will be used as goal for the following optimzation" +
" process. For the sake of simplicity this reference point has to be selected in fitness space only!"), BorderLayout.NORTH); " process. For the sake of simplicity this reference point has to be selected in fitness space only!"), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH); tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH);
this.m_Selected = new JPanel(); this.selectedPanel = new JPanel();
tmpP.add(this.m_Selected, BorderLayout.CENTER); tmpP.add(this.selectedPanel, BorderLayout.CENTER);
this.m_Mocco.m_View.setRefPointSelectable(true); this.mocco.view.setRefPointSelectable(true);
this.m_Mocco.m_View.addRefPointSelectionListener(this); this.mocco.view.addRefPointSelectionListener(this);
this.updateSelected(); this.updateSelected();
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void updateSelected() { private void updateSelected() {
this.m_Selected.removeAll(); this.selectedPanel.removeAll();
InterfaceOptimizationObjective[] objectives = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] objectives = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
this.m_Selected.setLayout(new BorderLayout()); this.selectedPanel.setLayout(new BorderLayout());
if (this.m_Mocco.m_View.m_ReferencePoint == null) { if (this.mocco.view.referencePoint == null) {
this.m_Selected.add(new JLabel("No reference point! Wierd there should be a default value!?"), BorderLayout.NORTH); this.selectedPanel.add(new JLabel("No reference point! Wierd there should be a default value!?"), BorderLayout.NORTH);
} else { } else {
this.m_Selected.add(new JLabel("Selected Reference Point:"), BorderLayout.NORTH); this.selectedPanel.add(new JLabel("Selected Reference Point:"), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
this.m_JTextField = new JTextField[this.m_Mocco.m_View.m_ReferencePoint.length]; this.textField = new JTextField[this.mocco.view.referencePoint.length];
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
for (int i = 0; i < this.m_Mocco.m_View.m_ReferencePoint.length; i++) { for (int i = 0; i < this.mocco.view.referencePoint.length; i++) {
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = i; gbc.gridy = i;
gbc.weightx = 1; gbc.weightx = 1;
@ -80,14 +76,14 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = i; gbc.gridy = i;
gbc.weightx = 1; gbc.weightx = 1;
this.m_JTextField[i] = new JTextField("" + this.m_Mocco.m_View.m_ReferencePoint[i]); this.textField[i] = new JTextField("" + this.mocco.view.referencePoint[i]);
this.m_JTextField[i].setEditable(true); this.textField[i].setEditable(true);
this.m_JTextField[i].addActionListener(refPointEdited); this.textField[i].addActionListener(refPointEdited);
tmpP.add(this.m_JTextField[i], gbc); tmpP.add(this.textField[i], gbc);
} }
this.m_Selected.add(tmpP, BorderLayout.CENTER); this.selectedPanel.add(tmpP, BorderLayout.CENTER);
} }
this.m_Selected.validate(); this.selectedPanel.validate();
} }
/** /**
@ -96,29 +92,29 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
* @return double[] The reference point * @return double[] The reference point
*/ */
public double[] getReferencePoint() { public double[] getReferencePoint() {
return this.m_ReferencePoint; return this.referencePoint;
} }
ActionListener refPointEdited = new ActionListener() { ActionListener refPointEdited = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
for (int i = 0; i < m_JTextField.length; i++) { for (int i = 0; i < textField.length; i++) {
m_Mocco.m_View.m_ReferencePoint[i] = new Double(m_JTextField[i].getText()).doubleValue(); mocco.view.referencePoint[i] = new Double(textField[i].getText()).doubleValue();
} }
m_Mocco.m_View.problemChanged(false); mocco.view.problemChanged(false);
} }
}; };
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_ReferencePoint = m_Mocco.m_View.m_ReferencePoint; referencePoint = mocco.view.referencePoint;
m_Mocco.m_View.setRefPointSelectable(false); mocco.view.setRefPointSelectable(false);
m_Mocco.m_View.removeRefPointSelectionListeners(); mocco.view.removeRefPointSelectionListeners();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Finished = true; hasFinished = true;
} }
}; };
@ -135,7 +131,7 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
*/ */
@Override @Override
public void refPointGiven(double[] point) { public void refPointGiven(double[] point) {
this.m_ReferencePoint = point; this.referencePoint = point;
this.updateSelected(); this.updateSelected();
} }
} }

View File

@ -14,19 +14,15 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 27.10.2005
* Time: 18:42:52
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOChooseReferenceSolution extends MOCCOPhase implements InterfaceProcessElement, InterfaceRefSolutionListener { public class MOCCOChooseReferenceSolution extends MOCCOPhase implements InterfaceProcessElement, InterfaceRefSolutionListener {
AbstractEAIndividual m_ReferenceSolution = null; AbstractEAIndividual referenceSolution = null;
JPanel m_Selected; JPanel selected;
public MOCCOChooseReferenceSolution(MOCCOStandalone mocco) { public MOCCOChooseReferenceSolution(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -34,40 +30,40 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Continue to strategy parameterization."); JButton tmpB = new JButton("Continue to strategy parameterization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a reference solution " + this.mocco.parameterPanel.add(this.makeHelpText("Please choose a reference solution " +
"from the Pareto-optimal solutions (grey circles) given to the right."), BorderLayout.NORTH); "from the Pareto-optimal solutions (grey circles) given to the right."), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH); tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH);
this.m_Selected = new JPanel(); this.selected = new JPanel();
tmpP.add(this.m_Selected, BorderLayout.CENTER); tmpP.add(this.selected, BorderLayout.CENTER);
this.updateSelected(); this.updateSelected();
this.m_Mocco.m_View.setRefSolutionSelectable(true); this.mocco.view.setRefSolutionSelectable(true);
this.m_Mocco.m_View.setUniquelySelectable(true); this.mocco.view.setUniquelySelectable(true);
this.m_Mocco.m_View.addRefSolutionSelectionListener(this); this.mocco.view.addRefSolutionSelectionListener(this);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void updateSelected() { private void updateSelected() {
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
this.m_Selected.removeAll(); this.selected.removeAll();
this.m_Selected.setLayout(new BorderLayout()); this.selected.setLayout(new BorderLayout());
if (this.m_ReferenceSolution == null) { if (this.referenceSolution == null) {
this.m_Selected.add(new JLabel("Selected Individual: none"), BorderLayout.NORTH); this.selected.add(new JLabel("Selected Individual: none"), BorderLayout.NORTH);
} else { } else {
this.m_Selected.add(new JLabel("Selected Individual: " + this.m_ReferenceSolution), BorderLayout.NORTH); this.selected.add(new JLabel("Selected Individual: " + this.referenceSolution), BorderLayout.NORTH);
//double[] fitness = this.m_ReferenceSolution.getFitness(); //double[] fitness = this.referenceSolution.getFitness();
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
JTextField textA; JTextField textA;
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
@ -104,28 +100,28 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridy = i + 1; gbc.gridy = i + 1;
gbc.weightx = 1; gbc.weightx = 1;
textA = new JTextField("" + ((Double) m_ReferenceSolution.getData(obj[i].getIdentName())).doubleValue()); textA = new JTextField("" + ((Double) referenceSolution.getData(obj[i].getIdentName())).doubleValue());
textA.setEditable(false); textA.setEditable(false);
tmpP.add(textA, gbc); tmpP.add(textA, gbc);
} }
this.m_Selected.add(tmpP, BorderLayout.CENTER); this.selected.add(tmpP, BorderLayout.CENTER);
} }
this.m_Selected.validate(); this.selected.validate();
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
if (m_ReferenceSolution != null) { if (referenceSolution != null) {
m_Mocco.m_View.setRefSolutionSelectable(false); mocco.view.setRefSolutionSelectable(false);
m_Mocco.m_View.removeRefSolutionSelectionListeners(); mocco.view.removeRefSolutionSelectionListeners();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Finished = true; hasFinished = true;
} else { } else {
JOptionPane.showMessageDialog(m_Mocco.m_JFrame, JOptionPane.showMessageDialog(mocco.getMainFrame(),
"No reference solution selected. Cannot proceed!", "No reference solution selected. Cannot proceed!",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
} }
@ -133,7 +129,7 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
}; };
public AbstractEAIndividual getReferenceSolution() { public AbstractEAIndividual getReferenceSolution() {
return this.m_ReferenceSolution; return this.referenceSolution;
} }
/****************************************************************************** /******************************************************************************
* InterfaceSelectionListener * InterfaceSelectionListener
@ -147,11 +143,11 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
*/ */
@Override @Override
public void individualSelected(AbstractEAIndividual indy) { public void individualSelected(AbstractEAIndividual indy) {
Population pop = this.m_Mocco.m_State.m_ParetoFront.getMarkedIndividuals(); Population pop = this.mocco.state.paretoFront.getMarkedIndividuals();
if (pop.size() == 1) { if (pop.size() == 1) {
this.m_ReferenceSolution = (AbstractEAIndividual) pop.get(0); this.referenceSolution = (AbstractEAIndividual) pop.get(0);
} else { } else {
this.m_ReferenceSolution = null; this.referenceSolution = null;
} }
this.updateSelected(); this.updateSelected();
} }

View File

@ -8,18 +8,14 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 25.10.2005
* Time: 10:07:09
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceProcessElement {
private JTextField m_JTextField; private JTextField textField;
public MOCCOInitialPopulationSize(MOCCOStandalone mocco) { public MOCCOInitialPopulationSize(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -27,16 +23,16 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Continue to problem redefinition/analyzation."); JButton tmpB = new JButton("Continue to problem redefinition/analyzation.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a size for the " + this.mocco.parameterPanel.add(this.makeHelpText("Please choose a size for the " +
"initial set of solution alternatives necessary to start the MOCCO optimization " + "initial set of solution alternatives necessary to start the MOCCO optimization " +
"cycle."), BorderLayout.NORTH); "cycle."), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
@ -48,33 +44,33 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
tmpP.add(new JLabel("Initial Solution Set Size:"), gbc); tmpP.add(new JLabel("Initial Solution Set Size:"), gbc);
this.m_JTextField = new JTextField("" + this.m_Mocco.m_State.m_InitialPopulationSize); this.textField = new JTextField("" + this.mocco.state.initialPopulationSize);
this.m_JTextField.addActionListener(popSizeEdited); this.textField.addActionListener(popSizeEdited);
gbc.gridx = 1; gbc.gridx = 1;
tmpP.add(this.m_JTextField, gbc); tmpP.add(this.textField, gbc);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener popSizeEdited = new ActionListener() { ActionListener popSizeEdited = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
String s = m_JTextField.getText(); String s = textField.getText();
try { try {
int t = new Integer(s).intValue(); int t = new Integer(s).intValue();
m_Mocco.m_State.m_InitialPopulationSize = t; mocco.state.initialPopulationSize = t;
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {
} }

View File

@ -31,14 +31,14 @@ import java.util.ArrayList;
*/ */
public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcessElement {
private AbstractEAIndividual m_RefSolution; private AbstractEAIndividual refSolution;
private JTextField[][] m_TradeOff; private JTextField[][] tradeOffTextFields;
JPanel m_Choice; JPanel choicePanel;
private InterfaceOptimizer m_Opt; private InterfaceOptimizer optimizer;
private GeneralOptimizationEditorProperty m_EOpt; private GeneralOptimizationEditorProperty optimizationEditorProperty;
public MOCCOParameterizeGDF(MOCCOStandalone mocco) { public MOCCOParameterizeGDF(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -46,46 +46,46 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please give weights (white) for the individual objectives," + this.mocco.parameterPanel.add(this.makeHelpText("Please give weights (white) for the individual objectives," +
" or choose trade-off (gray) between individual objectives. Please note that these values are interdependent.") " or choose trade-off (gray) between individual objectives. Please note that these values are interdependent.")
, BorderLayout.NORTH); , BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
this.m_Choice = new JPanel(); this.choicePanel = new JPanel();
//this.m_Choice.setBorder(BorderFactory.createCompoundBorder( //this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
// BorderFactory.createTitledBorder("Geoffrion-Dyer-Feinberg Method:"), // BorderFactory.createTitledBorder("Geoffrion-Dyer-Feinberg Method:"),
// BorderFactory.createEmptyBorder(0, 5, 5, 5))); // BorderFactory.createEmptyBorder(0, 5, 5, 5)));
tmpP.add(this.m_Choice, BorderLayout.CENTER); tmpP.add(this.choicePanel, BorderLayout.CENTER);
this.installChoice(); this.installChoice();
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void installChoice() { private void installChoice() {
this.m_Choice.setLayout(new GridBagLayout()); this.choicePanel.setLayout(new GridBagLayout());
JPanel panelGDF = new JPanel(); JPanel panelGDF = new JPanel();
panelGDF.setBorder(BorderFactory.createCompoundBorder( panelGDF.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Parameterize Perferences:"), BorderFactory.createTitledBorder("Parameterize Perferences:"),
BorderFactory.createEmptyBorder(0, 5, 5, 5))); BorderFactory.createEmptyBorder(0, 5, 5, 5)));
panelGDF.setLayout(new GridBagLayout()); panelGDF.setLayout(new GridBagLayout());
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
this.m_TradeOff = new JTextField[obj.length][obj.length]; this.tradeOffTextFields = new JTextField[obj.length][obj.length];
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
@ -96,26 +96,26 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
gbc.weightx = 2; gbc.weightx = 2;
panelGDF.add(new JLabel("" + obj[i].getIdentName()), gbc); panelGDF.add(new JLabel("" + obj[i].getIdentName()), gbc);
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
this.m_TradeOff[i][j] = new JTextField(""); this.tradeOffTextFields[i][j] = new JTextField("");
if (i == j) { if (i == j) {
this.m_TradeOff[i][j].setBackground(Color.WHITE); this.tradeOffTextFields[i][j].setBackground(Color.WHITE);
if (obj[i].getOptimizationMode().contains("Objective")) { if (obj[i].getOptimizationMode().contains("Objective")) {
this.m_TradeOff[i][j].setEditable(true); this.tradeOffTextFields[i][j].setEditable(true);
} else { } else {
this.m_TradeOff[i][j].setEditable(false); this.tradeOffTextFields[i][j].setEditable(false);
} }
this.m_TradeOff[i][j].setText("1.0"); this.tradeOffTextFields[i][j].setText("1.0");
this.m_TradeOff[i][j].addActionListener(weightListener); this.tradeOffTextFields[i][j].addActionListener(weightListener);
} else { } else {
this.m_TradeOff[i][j].setBackground(Color.LIGHT_GRAY); this.tradeOffTextFields[i][j].setBackground(Color.LIGHT_GRAY);
this.m_TradeOff[i][j].setEditable(false); this.tradeOffTextFields[i][j].setEditable(false);
this.m_TradeOff[i][j].setText("0.5"); this.tradeOffTextFields[i][j].setText("0.5");
//this.m_TradeOff[i][j].addActionListener(tradeoffListener); //this.tradeOffTextFields[i][j].addActionListener(tradeoffListener);
} }
gbc.gridx = j + 1; gbc.gridx = j + 1;
gbc.gridy = i; gbc.gridy = i;
gbc.weightx = 1; gbc.weightx = 1;
panelGDF.add(this.m_TradeOff[i][j], gbc); panelGDF.add(this.tradeOffTextFields[i][j], gbc);
} }
} }
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
@ -123,28 +123,28 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridwidth = 2; gbc.gridwidth = 2;
gbc.gridy = 0; gbc.gridy = 0;
this.m_Choice.add(panelGDF, gbc); this.choicePanel.add(panelGDF, gbc);
// the optimizer // the optimizer
gbc.gridwidth = 1; gbc.gridwidth = 1;
this.m_EOpt = new GeneralOptimizationEditorProperty(); this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
this.m_Opt = new GeneticAlgorithm(); this.optimizer = new GeneticAlgorithm();
this.m_Opt.setProblem(this.m_Mocco.m_State.m_CurrentProblem); this.optimizer.setProblem(this.mocco.state.currentProblem);
this.m_Mocco.m_State.m_Optimizer = this.m_Opt; this.mocco.state.optimizer = this.optimizer;
this.m_EOpt.name = "Island Model EA"; this.optimizationEditorProperty.name = "Island Model EA";
try { try {
this.m_EOpt.value = this.m_Opt; this.optimizationEditorProperty.value = this.optimizer;
this.m_EOpt.editor = PropertyEditorProvider.findEditor(this.m_EOpt.value.getClass()); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
if (this.m_EOpt.editor == null) { if (this.optimizationEditorProperty.editor == null) {
this.m_EOpt.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
} }
if (this.m_EOpt.editor instanceof GenericObjectEditor) { if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_EOpt.editor).setClassType(InterfaceOptimizer.class); ((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(InterfaceOptimizer.class);
} }
this.m_EOpt.editor.setValue(this.m_EOpt.value); this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
AbstractObjectEditor.findViewFor(this.m_EOpt); AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
if (this.m_EOpt.view != null) { if (this.optimizationEditorProperty.view != null) {
this.m_EOpt.view.repaint(); this.optimizationEditorProperty.view.repaint();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Darn can't read the value..."); System.out.println("Darn can't read the value...");
@ -152,16 +152,16 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Choice.add(new JLabel("" + this.m_EOpt.name), gbc); this.choicePanel.add(new JLabel("" + this.optimizationEditorProperty.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Choice.add(this.m_EOpt.view, gbc); this.choicePanel.add(this.optimizationEditorProperty.view, gbc);
// Terminator // Terminator
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty(); GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -180,11 +180,11 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Choice.add(new JLabel("" + editor.name), gbc); this.choicePanel.add(new JLabel("" + editor.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Choice.add(editor.view, gbc); this.choicePanel.add(editor.view, gbc);
} }
@ -195,55 +195,55 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
* @param indy the reference solution * @param indy the reference solution
*/ */
public void setReferenceSolution(AbstractEAIndividual indy) { public void setReferenceSolution(AbstractEAIndividual indy) {
this.m_RefSolution = indy; this.refSolution = indy;
} }
ActionListener weightListener = new ActionListener() { ActionListener weightListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
double[] w = new double[m_TradeOff.length]; double[] w = new double[tradeOffTextFields.length];
double sum = 0; double sum = 0;
for (int i = 0; i < m_TradeOff.length; i++) { for (int i = 0; i < tradeOffTextFields.length; i++) {
w[i] = new Double(m_TradeOff[i][i].getText()).doubleValue(); w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue();
sum += w[i]; sum += w[i];
} }
if (new Double(sum).isNaN()) { if (new Double(sum).isNaN()) {
return; return;
} }
for (int i = 0; i < m_TradeOff.length; i++) { for (int i = 0; i < tradeOffTextFields.length; i++) {
for (int j = 0; j < m_TradeOff.length; j++) { for (int j = 0; j < tradeOffTextFields.length; j++) {
if (i != j) { if (i != j) {
m_TradeOff[i][j].setText("" + (w[i] / w[j])); tradeOffTextFields[i][j].setText("" + (w[i] / w[j]));
} }
} }
} }
m_Choice.validate(); choicePanel.validate();
} }
}; };
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
double[] w = new double[m_TradeOff.length]; double[] w = new double[tradeOffTextFields.length];
for (int i = 0; i < m_TradeOff.length; i++) { for (int i = 0; i < tradeOffTextFields.length; i++) {
w[i] = new Double(m_TradeOff[i][i].getText()).doubleValue(); w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue();
} }
MOSOWeightedFitness wf = new MOSOWeightedFitness(); MOSOWeightedFitness wf = new MOSOWeightedFitness();
// I've to set this before I change the parameters, because the problem sets the // I've to set this before I change the parameters, because the problem sets the
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and // output dimension based on the AbstractMultiObjectiveOptimizationProblem and
// that one has not the faintest idea about the true output dimension // that one has not the faintest idea about the true output dimension
((AbstractMultiObjectiveOptimizationProblem) m_Mocco.m_State.m_CurrentProblem).setMOSOConverter(wf); ((AbstractMultiObjectiveOptimizationProblem) mocco.state.currentProblem).setMOSOConverter(wf);
w = mapObjectives2Fitness(w); w = mapObjectives2Fitness(w);
PropertyDoubleArray da = new PropertyDoubleArray(w); PropertyDoubleArray da = new PropertyDoubleArray(w);
wf.setOutputDimension(da.getNumRows()); wf.setOutputDimension(da.getNumRows());
wf.setWeights(da); wf.setWeights(da);
m_Opt.setProblem(m_Mocco.m_State.m_CurrentProblem); optimizer.setProblem(mocco.state.currentProblem);
m_Mocco.m_State.m_Optimizer = m_Opt; mocco.state.optimizer = optimizer;
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_JPanelParameters.validate(); mocco.parameterPanel.validate();
m_Finished = true; hasFinished = true;
} }
}; };
@ -257,7 +257,7 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
*/ */
public double[] mapObjectives2Fitness(double[] d) { public double[] mapObjectives2Fitness(double[] d) {
ArrayList tmpA = new ArrayList(); ArrayList tmpA = new ArrayList();
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
System.out.println("Calling mapObjectives2Fitness"); System.out.println("Calling mapObjectives2Fitness");
System.out.println("obj.length = " + obj.length); System.out.println("obj.length = " + obj.length);
System.out.println("d.length = " + d.length); System.out.println("d.length = " + d.length);

View File

@ -18,21 +18,13 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 26.10.2005
* Time: 16:04:55
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessElement {
// private JComboBox m_OptimizerChooser;
// private InterfaceOptimizer optimizer;
public MOCCOParameterizeMO(MOCCOStandalone mocco) { public MOCCOParameterizeMO(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
// this.optimizer = (InterfaceOptimizer)this.m_Mocco.m_State.optimizer.clone(); // this.optimizer = (InterfaceOptimizer)this.mocco.state.optimizer.clone();
} }
/** /**
@ -40,43 +32,43 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.init(); this.init();
this.m_Mocco.m_JFrame.setVisible(true); this.mocco.getMainFrame().setVisible(true);
this.m_Mocco.m_JFrame.validate(); this.mocco.getMainFrame().validate();
} }
private void init() { private void init() {
if (!(this.m_Mocco.m_State.m_Optimizer instanceof MultiObjectiveEA)) { if (!(this.mocco.state.optimizer instanceof MultiObjectiveEA)) {
if (this.m_Mocco.m_State.m_Optimizer instanceof GeneticAlgorithm) { if (this.mocco.state.optimizer instanceof GeneticAlgorithm) {
JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame, JOptionPane.showMessageDialog(this.mocco.getMainFrame(),
"The current " + this.m_Mocco.m_State.m_Optimizer.getName() + "The current " + this.mocco.state.optimizer.getName() +
" is not necessarily a good multi-objective optimizer, please " + " is not necessarily a good multi-objective optimizer, please " +
"parameterize accordingly or change to MultiObjectiveEA", "parameterize accordingly or change to MultiObjectiveEA",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
} }
// JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame, // JOptionPane.showMessageDialog(this.mocco.m_JFrame,
// "The current "+this.m_Mocco.m_State.optimizer.getName() + // "The current "+this.mocco.state.optimizer.getName() +
// " is typically a single-objective optimizer. I'm defaulting to a " + // " is typically a single-objective optimizer. I'm defaulting to a " +
// "multi-objective EA instead, please parameterize accordingly.", // "multi-objective EA instead, please parameterize accordingly.",
// "Warning", JOptionPane.WARNING_MESSAGE); // "Warning", JOptionPane.WARNING_MESSAGE);
// this.m_Mocco.m_State.optimizer = new MultiObjectiveEA(); // this.mocco.state.optimizer = new MultiObjectiveEA();
} }
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
@ -87,7 +79,7 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
editor = new GeneralOptimizationEditorProperty(); editor = new GeneralOptimizationEditorProperty();
editor.name = "Optimizer"; editor.name = "Optimizer";
try { try {
editor.value = this.m_Mocco.m_State.m_Optimizer; editor.value = this.mocco.state.optimizer;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
@ -115,7 +107,7 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
editor = new GeneralOptimizationEditorProperty(); editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -139,31 +131,31 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 2; gbc.weightx = 2;
tmpP.add(editor.view, gbc); tmpP.add(editor.view, gbc);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.add(this.makeInformationText("Multi-Objective Optimiaztion", "" + this.mocco.parameterPanel.add(this.makeInformationText("Multi-Objective Optimiaztion", "" +
"Please choose an appropriate multi-objecitve optimizer."), BorderLayout.NORTH); "Please choose an appropriate multi-objecitve optimizer."), BorderLayout.NORTH);
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
//m_Mocco.m_State.optimizer = (InterfaceOptimizer)optimizer.clone(); //mocco.state.optimizer = (InterfaceOptimizer)optimizer.clone();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem); mocco.state.optimizer.setProblem(mocco.state.currentProblem);
Population pop = m_Mocco.m_State.m_Optimizer.getPopulation(); Population pop = mocco.state.optimizer.getPopulation();
pop.clear(); pop.clear();
if (pop.getArchive() != null) { if (pop.getArchive() != null) {
pop.getArchive().clear(); pop.getArchive().clear();
} }
if (m_Mocco.m_State.m_PopulationHistory.length > 0) { if (mocco.state.populationHistory.length > 0) {
pop = m_Mocco.m_State.getSelectedPopulations(); pop = mocco.state.getSelectedPopulations();
m_Mocco.m_State.m_Optimizer.initByPopulation(pop, false); mocco.state.optimizer.initByPopulation(pop, false);
if (pop.size() == 0) { if (pop.size() == 0) {
m_Mocco.m_State.m_Optimizer.init(); mocco.state.optimizer.init();
} }
} }
m_Finished = true; hasFinished = true;
} }
}; };
} }

View File

@ -27,17 +27,17 @@ import java.awt.event.ActionListener;
*/ */
public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfaceProcessElement {
private double[] m_RefPoint; private double[] refPoint;
private MOSOLpMetric m_LpMetric; private MOSOLpMetric lpMetric;
private IslandModelEA m_Island; private IslandModelEA islandModelEA;
private GeneralOptimizationEditorProperty m_EMOSO, m_EIMEA; private GeneralOptimizationEditorProperty optimizationEditorProperty, optimizationEditorProperty1;
private int m_Perturbations = 4; private int perturbations = 4;
private double m_Perturbation = 0.01; private double perturbation = 0.01;
private JTextField m_NumPer, m_SizePer; private JTextField numPerTextField, sizePerTextField;
JPanel m_Parameters; JPanel parameterPanel;
public MOCCOParameterizeRefPoint(MOCCOStandalone mocco) { public MOCCOParameterizeRefPoint(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -45,78 +45,78 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please parameterized the reference point method." + this.mocco.parameterPanel.add(this.makeHelpText("Please parameterized the reference point method." +
" Typically this methods generates a set of solutions by using k perturbations of the reference point given." + " Typically this methods generates a set of solutions by using k perturbations of the reference point given." +
" Also the choice of the optimization algorithms and migration rate for the heterogeneuos island model EA is critical." + " Also the choice of the optimization algorithms and migration rate for the heterogeneuos island model EA is critical." +
" Please note that the server settings will override k!"), BorderLayout.NORTH); " Please note that the server settings will override k!"), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
this.m_Parameters = new JPanel(); this.parameterPanel = new JPanel();
// this.m_Choice.setBorder(BorderFactory.createCompoundBorder( // this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
// BorderFactory.createTitledBorder("Step Method:"), // BorderFactory.createTitledBorder("Step Method:"),
// BorderFactory.createEmptyBorder(0, 5, 5, 5))); // BorderFactory.createEmptyBorder(0, 5, 5, 5)));
tmpP.add(this.m_Parameters, BorderLayout.CENTER); tmpP.add(this.parameterPanel, BorderLayout.CENTER);
this.installChoice(); this.installChoice();
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void installChoice() { private void installChoice() {
this.m_Parameters.setLayout(new GridBagLayout()); this.parameterPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("Choose number of Perturbations k:"), gbc); this.parameterPanel.add(new JLabel("Choose number of Perturbations k:"), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 0; gbc.gridy = 0;
gbc.weightx = 1; gbc.weightx = 1;
this.m_NumPer = new JTextField("" + this.m_Perturbations); this.numPerTextField = new JTextField("" + this.perturbations);
this.m_Parameters.add(this.m_NumPer, gbc); this.parameterPanel.add(this.numPerTextField, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("Choose amount of Perturbation:"), gbc); this.parameterPanel.add(new JLabel("Choose amount of Perturbation:"), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 1; gbc.weightx = 1;
this.m_SizePer = new JTextField("" + this.m_Perturbation); this.sizePerTextField = new JTextField("" + this.perturbation);
this.m_Parameters.add(this.m_SizePer, gbc); this.parameterPanel.add(this.sizePerTextField, gbc);
// lpmetric // lpmetric
this.m_EMOSO = new GeneralOptimizationEditorProperty(); this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
this.m_LpMetric = new MOSOLpMetric(); this.lpMetric = new MOSOLpMetric();
this.m_LpMetric.getReference().setDoubleArray(this.m_RefPoint); this.lpMetric.getReference().setDoubleArray(this.refPoint);
this.m_EMOSO.name = "Lp-Metric"; this.optimizationEditorProperty.name = "Lp-Metric";
try { try {
this.m_EMOSO.value = this.m_LpMetric; this.optimizationEditorProperty.value = this.lpMetric;
this.m_EMOSO.editor = PropertyEditorProvider.findEditor(this.m_EMOSO.value.getClass()); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
if (this.m_EMOSO.editor == null) { if (this.optimizationEditorProperty.editor == null) {
this.m_EMOSO.editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class);
} }
if (this.m_EMOSO.editor instanceof GenericObjectEditor) { if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_EMOSO.editor).setClassType(MOSOLpMetric.class); ((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(MOSOLpMetric.class);
} }
this.m_EMOSO.editor.setValue(this.m_EMOSO.value); this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
AbstractObjectEditor.findViewFor(this.m_EMOSO); AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
if (this.m_EMOSO.view != null) { if (this.optimizationEditorProperty.view != null) {
this.m_EMOSO.view.repaint(); this.optimizationEditorProperty.view.repaint();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Darn can't read the value..."); System.out.println("Darn can't read the value...");
@ -124,35 +124,35 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("" + this.m_EMOSO.name), gbc); this.parameterPanel.add(new JLabel("" + this.optimizationEditorProperty.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Parameters.add(this.m_EMOSO.view, gbc); this.parameterPanel.add(this.optimizationEditorProperty.view, gbc);
// IslandModelEA // IslandModelEA
this.m_EIMEA = new GeneralOptimizationEditorProperty(); this.optimizationEditorProperty1 = new GeneralOptimizationEditorProperty();
this.m_Island = new IslandModelEA(); this.islandModelEA = new IslandModelEA();
this.m_Island.setHeterogeneousProblems(true); this.islandModelEA.setHeterogeneousProblems(true);
this.m_Island.setLocalOnly(true); this.islandModelEA.setLocalOnly(true);
this.m_Island.setMigrationRate(2); this.islandModelEA.setMigrationRate(2);
this.m_Island.setMigrationStrategy(new SOBestMigration()); this.islandModelEA.setMigrationStrategy(new SOBestMigration());
this.m_Island.setNumberLocalCPUs(this.m_Perturbations); this.islandModelEA.setNumberLocalCPUs(this.perturbations);
this.m_Island.setProblem(this.m_Mocco.m_State.m_CurrentProblem); this.islandModelEA.setProblem(this.mocco.state.currentProblem);
this.m_Mocco.m_State.m_Optimizer = this.m_Island; this.mocco.state.optimizer = this.islandModelEA;
this.m_EIMEA.name = "Island Model EA"; this.optimizationEditorProperty1.name = "Island Model EA";
try { try {
this.m_EIMEA.value = this.m_Island; this.optimizationEditorProperty1.value = this.islandModelEA;
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(this.m_EIMEA.value.getClass()); this.optimizationEditorProperty1.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty1.value.getClass());
if (this.m_EIMEA.editor == null) { if (this.optimizationEditorProperty1.editor == null) {
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(IslandModelEA.class); this.optimizationEditorProperty1.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
} }
if (this.m_EIMEA.editor instanceof GenericObjectEditor) { if (this.optimizationEditorProperty1.editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_EIMEA.editor).setClassType(IslandModelEA.class); ((GenericObjectEditor) this.optimizationEditorProperty1.editor).setClassType(IslandModelEA.class);
} }
this.m_EIMEA.editor.setValue(this.m_EIMEA.value); this.optimizationEditorProperty1.editor.setValue(this.optimizationEditorProperty1.value);
AbstractObjectEditor.findViewFor(this.m_EIMEA); AbstractObjectEditor.findViewFor(this.optimizationEditorProperty1);
if (this.m_EIMEA.view != null) { if (this.optimizationEditorProperty1.view != null) {
this.m_EIMEA.view.repaint(); this.optimizationEditorProperty1.view.repaint();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Darn can't read the value..."); System.out.println("Darn can't read the value...");
@ -160,16 +160,16 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("" + this.m_EIMEA.name), gbc); this.parameterPanel.add(new JLabel("" + this.optimizationEditorProperty1.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Parameters.add(this.m_EIMEA.view, gbc); this.parameterPanel.add(this.optimizationEditorProperty1.view, gbc);
// Terminator // Terminator
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty(); GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -188,11 +188,11 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 4; gbc.gridy = 4;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("" + editor.name), gbc); this.parameterPanel.add(new JLabel("" + editor.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 4; gbc.gridy = 4;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Parameters.add(editor.view, gbc); this.parameterPanel.add(editor.view, gbc);
} }
/** /**
@ -202,7 +202,7 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
* @param point the reference point * @param point the reference point
*/ */
public void setReferencePoint(double[] point) { public void setReferencePoint(double[] point) {
this.m_RefPoint = point; this.refPoint = point;
} }
ActionListener satisfiedChanged = new ActionListener() { ActionListener satisfiedChanged = new ActionListener() {
@ -217,65 +217,65 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
// first read the values // first read the values
try { try {
m_Perturbations = new Integer(m_NumPer.getText()).intValue(); perturbations = new Integer(numPerTextField.getText()).intValue();
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {
System.out.println("Can't read k."); System.out.println("Can't read k.");
} }
try { try {
m_Perturbation = new Double(m_SizePer.getText()).doubleValue(); perturbation = new Double(sizePerTextField.getText()).doubleValue();
} catch (java.lang.NumberFormatException e) { } catch (java.lang.NumberFormatException e) {
System.out.println("Can't read amount of perturbation."); System.out.println("Can't read amount of perturbation.");
} }
if (m_EIMEA.value instanceof IslandModelEA) { if (optimizationEditorProperty1.value instanceof IslandModelEA) {
m_Island = (IslandModelEA) m_EIMEA.value; islandModelEA = (IslandModelEA) optimizationEditorProperty1.value;
} else { } else {
System.out.println("The selected optimizer does not allow heterogenuous multi-starts!"); System.out.println("The selected optimizer does not allow heterogenuous multi-starts!");
} }
if (m_EMOSO.value instanceof MOSOLpMetric) { if (optimizationEditorProperty.value instanceof MOSOLpMetric) {
m_LpMetric = (MOSOLpMetric) m_EMOSO.value; lpMetric = (MOSOLpMetric) optimizationEditorProperty.value;
} else { } else {
System.out.println("The selected MOSO conversion is not suited for the reference point approach!"); System.out.println("The selected MOSO conversion is not suited for the reference point approach!");
} }
// then set the values // then set the values
// if (!m_Island.getLocalOnly()) { // if (!islandModelEA.getLocalOnly()) {
// ToDo: Think of new ways to do this! // ToDo: Think of new ways to do this!
/*PropertyRemoteServers t = m_Island.getServers(); /*PropertyRemoteServers t = islandModelEA.getServers();
String[] servers = t.getServerNodes(); String[] servers = t.getServerNodes();
if (servers.length != m_Perturbations) { if (servers.length != perturbations) {
System.out.println("Warning: Number of servers overrides number of perturbations!"); System.out.println("Warning: Number of servers overrides number of perturbations!");
m_Perturbations = servers.length; perturbations = servers.length;
}*/ }*/
// } else { // } else {
// m_Island.setNumberLocalCPUs(m_Perturbations); // islandModelEA.setNumberLocalCPUs(perturbations);
// } // }
m_Mocco.m_State.m_Optimizer = m_Island; mocco.state.optimizer = islandModelEA;
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem); mocco.state.optimizer.setProblem(mocco.state.currentProblem);
m_Island.init(); islandModelEA.init();
double[] tmpD; double[] tmpD;
MOSOLpMetric[] tmpLPs = new MOSOLpMetric[m_Perturbations]; MOSOLpMetric[] tmpLPs = new MOSOLpMetric[perturbations];
for (int i = 0; i < m_Perturbations; i++) { for (int i = 0; i < perturbations; i++) {
tmpD = new double[m_RefPoint.length]; tmpD = new double[refPoint.length];
for (int j = 0; j < tmpD.length; j++) { for (int j = 0; j < tmpD.length; j++) {
if (i > 0) { if (i > 0) {
tmpD[j] = m_RefPoint[j] + RNG.gaussianDouble(m_Perturbation); tmpD[j] = refPoint[j] + RNG.gaussianDouble(perturbation);
} else { } else {
tmpD[j] = m_RefPoint[j]; tmpD[j] = refPoint[j];
} }
} }
tmpLPs[i] = (MOSOLpMetric) m_LpMetric.clone(); tmpLPs[i] = (MOSOLpMetric) lpMetric.clone();
// I've to set this before I change the parameters, because the problem sets the // I've to set this before I change the parameters, because the problem sets the
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and // output dimension based on the AbstractMultiObjectiveOptimizationProblem and
// that one has not the faintest idea about the true output dimension // that one has not the faintest idea about the true output dimension
((AbstractMultiObjectiveOptimizationProblem) m_Island.getOptimizers()[i].getProblem()).setMOSOConverter(tmpLPs[i]); ((AbstractMultiObjectiveOptimizationProblem) islandModelEA.getOptimizers()[i].getProblem()).setMOSOConverter(tmpLPs[i]);
tmpLPs[i].setOutputDimension(tmpD.length); tmpLPs[i].setOutputDimension(tmpD.length);
tmpLPs[i].getReference().setDoubleArray(tmpD); tmpLPs[i].getReference().setDoubleArray(tmpD);
} }
m_Mocco.m_View.removeReferencePoint(); mocco.view.removeReferencePoint();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_JPanelParameters.validate(); mocco.parameterPanel.validate();
m_Finished = true; hasFinished = true;
} }
}; };
} }

View File

@ -27,7 +27,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
public MOCCOParameterizeSO(MOCCOStandalone mocco) { public MOCCOParameterizeSO(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -35,37 +35,37 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.init(); this.init();
this.m_Mocco.m_JFrame.setVisible(true); this.mocco.getMainFrame().setVisible(true);
this.m_Mocco.m_JFrame.validate(); this.mocco.getMainFrame().validate();
} }
private void init() { private void init() {
if (this.m_Mocco.m_State.m_Optimizer instanceof MultiObjectiveEA) { if (this.mocco.state.optimizer instanceof MultiObjectiveEA) {
JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame, JOptionPane.showMessageDialog(this.mocco.getMainFrame(),
"The current " + this.m_Mocco.m_State.m_Optimizer.getName() + "The current " + this.mocco.state.optimizer.getName() +
" is no single-objective optimizer. I'm defaulting to " + " is no single-objective optimizer. I'm defaulting to " +
"a Genetic Algorithms, please parameterize accordingly.", "a Genetic Algorithms, please parameterize accordingly.",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
this.m_Mocco.m_State.m_Optimizer = new GeneticAlgorithm(); this.mocco.state.optimizer = new GeneticAlgorithm();
this.m_Mocco.m_State.m_Optimizer.setProblem(this.m_Mocco.m_State.m_CurrentProblem); this.mocco.state.optimizer.setProblem(this.mocco.state.currentProblem);
} }
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
@ -75,7 +75,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty(); GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
editor.name = "Optimizer"; editor.name = "Optimizer";
try { try {
editor.value = this.m_Mocco.m_State.m_Optimizer; editor.value = this.mocco.state.optimizer;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
@ -103,7 +103,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
editor = new GeneralOptimizationEditorProperty(); editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -127,8 +127,8 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 2; gbc.weightx = 2;
tmpP.add(editor.view, gbc); tmpP.add(editor.view, gbc);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.add(this.makeInformationText("Single-Objective Optimiaztion", "" + this.mocco.parameterPanel.add(this.makeInformationText("Single-Objective Optimiaztion", "" +
"Please choose an appropriate single-objecitve optimizer."), BorderLayout.NORTH); "Please choose an appropriate single-objecitve optimizer."), BorderLayout.NORTH);
} }
@ -136,9 +136,9 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Finished = true; hasFinished = true;
} }
}; };
} }

View File

@ -23,23 +23,19 @@ import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 27.10.2005
* Time: 18:42:04
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProcessElement {
private AbstractEAIndividual m_RefSolution; private AbstractEAIndividual refSolution;
private JTextField[] m_RefSol, m_Relax, m_Weight; private JTextField[] refSolTextField, relaxTextField, weightTextField;
private JCheckBox[] m_Satisfied; private JCheckBox[] satisfied;
JPanel m_Choice; JPanel choicePanel;
private InterfaceOptimizer m_Opt; private InterfaceOptimizer optimizer;
private GeneralOptimizationEditorProperty m_EOpt; private GeneralOptimizationEditorProperty optimizationEditorProperty;
public MOCCOParameterizeSTEP(MOCCOStandalone mocco) { public MOCCOParameterizeSTEP(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -47,50 +43,50 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please classify the achieved fitness values in" + this.mocco.parameterPanel.add(this.makeHelpText("Please classify the achieved fitness values in" +
" satisfying and unsatisfying results. For the satisfied objectives relaxation-level can be given" + " satisfying and unsatisfying results. For the satisfied objectives relaxation-level can be given" +
" by which this objective is allowed to worsen. For the unsatisfied objectives weights can be given" + " by which this objective is allowed to worsen. For the unsatisfied objectives weights can be given" +
" for weigthed aggregation."), BorderLayout.NORTH); " for weigthed aggregation."), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
this.m_Choice = new JPanel(); this.choicePanel = new JPanel();
//this.m_Choice.setBorder(BorderFactory.createCompoundBorder( //this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
// BorderFactory.createTitledBorder("Step Method:"), // BorderFactory.createTitledBorder("Step Method:"),
// BorderFactory.createEmptyBorder(0, 5, 5, 5))); // BorderFactory.createEmptyBorder(0, 5, 5, 5)));
tmpP.add(this.m_Choice, BorderLayout.CENTER); tmpP.add(this.choicePanel, BorderLayout.CENTER);
this.installChoice(); this.installChoice();
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void installChoice() { private void installChoice() {
this.m_Choice.setLayout(new GridBagLayout()); this.choicePanel.setLayout(new GridBagLayout());
JPanel panelSTEP = new JPanel(); JPanel panelSTEP = new JPanel();
panelSTEP.setBorder(BorderFactory.createCompoundBorder( panelSTEP.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Parameterize Perferences:"), BorderFactory.createTitledBorder("Parameterize Perferences:"),
BorderFactory.createEmptyBorder(0, 5, 5, 5))); BorderFactory.createEmptyBorder(0, 5, 5, 5)));
panelSTEP.setLayout(new GridBagLayout()); panelSTEP.setLayout(new GridBagLayout());
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
this.m_RefSol = new JTextField[obj.length]; this.refSolTextField = new JTextField[obj.length];
this.m_Relax = new JTextField[obj.length]; this.relaxTextField = new JTextField[obj.length];
this.m_Weight = new JTextField[obj.length]; this.weightTextField = new JTextField[obj.length];
this.m_Satisfied = new JCheckBox[obj.length]; this.satisfied = new JCheckBox[obj.length];
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
@ -131,58 +127,58 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
} }
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridy = i + 1; gbc.gridy = i + 1;
this.m_RefSol[i] = new JTextField("" + ((Double) m_RefSolution.getData(obj[i].getIdentName())).doubleValue()); this.refSolTextField[i] = new JTextField("" + ((Double) refSolution.getData(obj[i].getIdentName())).doubleValue());
this.m_RefSol[i].setEditable(false); this.refSolTextField[i].setEditable(false);
panelSTEP.add(this.m_RefSol[i], gbc); panelSTEP.add(this.refSolTextField[i], gbc);
gbc.gridx = 3; gbc.gridx = 3;
gbc.gridy = i + 1; gbc.gridy = i + 1;
this.m_Satisfied[i] = new JCheckBox(); this.satisfied[i] = new JCheckBox();
this.m_Satisfied[i].addActionListener(satisfiedChanged); this.satisfied[i].addActionListener(satisfiedChanged);
panelSTEP.add(this.m_Satisfied[i], gbc); panelSTEP.add(this.satisfied[i], gbc);
gbc.gridx = 4; gbc.gridx = 4;
gbc.gridy = i + 1; gbc.gridy = i + 1;
this.m_Weight[i] = new JTextField("1.0"); this.weightTextField[i] = new JTextField("1.0");
if (obj[i].getOptimizationMode().contains("Objective")) { if (obj[i].getOptimizationMode().contains("Objective")) {
this.m_Weight[i].setEditable(true); this.weightTextField[i].setEditable(true);
} else { } else {
this.m_Weight[i].setEditable(false); this.weightTextField[i].setEditable(false);
} }
//this.m_Satisfied[i].addActionListener(valueChanged); //this.satisfied[i].addActionListener(valueChanged);
panelSTEP.add(this.m_Weight[i], gbc); panelSTEP.add(this.weightTextField[i], gbc);
gbc.gridx = 5; gbc.gridx = 5;
gbc.gridy = i + 1; gbc.gridy = i + 1;
this.m_Relax[i] = new JTextField("0.0"); this.relaxTextField[i] = new JTextField("0.0");
this.m_Relax[i].setEditable(false); this.relaxTextField[i].setEditable(false);
//this.m_Satisfied[i].addActionListener(valueChanged); //this.satisfied[i].addActionListener(valueChanged);
panelSTEP.add(this.m_Relax[i], gbc); panelSTEP.add(this.relaxTextField[i], gbc);
} }
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridwidth = 2; gbc.gridwidth = 2;
gbc.gridy = 0; gbc.gridy = 0;
this.m_Choice.add(panelSTEP, gbc); this.choicePanel.add(panelSTEP, gbc);
// the optimizer // the optimizer
gbc.gridwidth = 1; gbc.gridwidth = 1;
this.m_EOpt = new GeneralOptimizationEditorProperty(); this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
this.m_Opt = new GeneticAlgorithm(); this.optimizer = new GeneticAlgorithm();
this.m_Opt.setProblem(this.m_Mocco.m_State.m_CurrentProblem); this.optimizer.setProblem(this.mocco.state.currentProblem);
this.m_Mocco.m_State.m_Optimizer = this.m_Opt; this.mocco.state.optimizer = this.optimizer;
this.m_EOpt.name = "Island Model EA"; this.optimizationEditorProperty.name = "Island Model EA";
try { try {
this.m_EOpt.value = this.m_Opt; this.optimizationEditorProperty.value = this.optimizer;
this.m_EOpt.editor = PropertyEditorProvider.findEditor(this.m_EOpt.value.getClass()); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
if (this.m_EOpt.editor == null) { if (this.optimizationEditorProperty.editor == null) {
this.m_EOpt.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
} }
if (this.m_EOpt.editor instanceof GenericObjectEditor) { if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_EOpt.editor).setClassType(InterfaceOptimizer.class); ((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(InterfaceOptimizer.class);
} }
this.m_EOpt.editor.setValue(this.m_EOpt.value); this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
AbstractObjectEditor.findViewFor(this.m_EOpt); AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
if (this.m_EOpt.view != null) { if (this.optimizationEditorProperty.view != null) {
this.m_EOpt.view.repaint(); this.optimizationEditorProperty.view.repaint();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Darn can't read the value..."); System.out.println("Darn can't read the value...");
@ -190,16 +186,16 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Choice.add(new JLabel("" + this.m_EOpt.name), gbc); this.choicePanel.add(new JLabel("" + this.optimizationEditorProperty.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Choice.add(this.m_EOpt.view, gbc); this.choicePanel.add(this.optimizationEditorProperty.view, gbc);
// Terminator // Terminator
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty(); GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -218,11 +214,11 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Choice.add(new JLabel("" + editor.name), gbc); this.choicePanel.add(new JLabel("" + editor.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Choice.add(editor.view, gbc); this.choicePanel.add(editor.view, gbc);
} }
/** /**
@ -232,28 +228,28 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
* @param indy the reference solution * @param indy the reference solution
*/ */
public void setReferenceSolution(AbstractEAIndividual indy) { public void setReferenceSolution(AbstractEAIndividual indy) {
this.m_RefSolution = indy; this.refSolution = indy;
} }
ActionListener satisfiedChanged = new ActionListener() { ActionListener satisfiedChanged = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) mocco.state.currentProblem).getProblemObjectives();
for (int i = 0; i < m_Satisfied.length; i++) { for (int i = 0; i < satisfied.length; i++) {
if (obj[i].getOptimizationMode().contains("Objective")) { if (obj[i].getOptimizationMode().contains("Objective")) {
if (m_Satisfied[i].isSelected()) { if (satisfied[i].isSelected()) {
m_Relax[i].setEditable(true); relaxTextField[i].setEditable(true);
m_Weight[i].setEditable(false); weightTextField[i].setEditable(false);
} else { } else {
m_Relax[i].setEditable(false); relaxTextField[i].setEditable(false);
m_Weight[i].setEditable(true); weightTextField[i].setEditable(true);
} }
} else { } else {
m_Relax[i].setEditable(false); relaxTextField[i].setEditable(false);
m_Weight[i].setEditable(false); weightTextField[i].setEditable(false);
} }
} }
m_Choice.validate(); choicePanel.validate();
} }
}; };
@ -261,22 +257,22 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
// first fetch the data from the choice and set constraints // first fetch the data from the choice and set constraints
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) mocco.state.currentProblem).getProblemObjectives();
double[] weights, relax; double[] weights, relax;
weights = new double[m_RefSol.length]; weights = new double[refSolTextField.length];
relax = new double[m_RefSol.length]; relax = new double[refSolTextField.length];
for (int i = 0; i < m_RefSol.length; i++) { for (int i = 0; i < refSolTextField.length; i++) {
weights[i] = new Double(m_Weight[i].getText()).doubleValue(); weights[i] = new Double(weightTextField[i].getText()).doubleValue();
relax[i] = new Double(m_Relax[i].getText()).doubleValue(); relax[i] = new Double(relaxTextField[i].getText()).doubleValue();
if ((m_Satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) { if ((satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) {
weights[i] = 0; weights[i] = 0;
if (obj[i].is2BMinimized()) { if (obj[i].is2BMinimized()) {
// check this sounds wierd => sounds correct if objectives are used above stupid! // check this sounds wierd => sounds correct if objectives are used above stupid!
relax[i] = ((Double) m_RefSolution.getData(obj[i].getIdentName())).doubleValue() relax[i] = ((Double) refSolution.getData(obj[i].getIdentName())).doubleValue()
+ Math.abs(relax[i]); + Math.abs(relax[i]);
} else { } else {
relax[i] = ((Double) m_RefSolution.getData(obj[i].getIdentName())).doubleValue() relax[i] = ((Double) refSolution.getData(obj[i].getIdentName())).doubleValue()
- Math.abs(relax[i]); - Math.abs(relax[i]);
} }
obj[i].SetConstraintGoal(relax[i]); obj[i].SetConstraintGoal(relax[i]);
@ -304,17 +300,17 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
// } // }
// } // }
MOSOWeightedFitness wf = new MOSOWeightedFitness(); MOSOWeightedFitness wf = new MOSOWeightedFitness();
((AbstractMultiObjectiveOptimizationProblem) m_Mocco.m_State.m_CurrentProblem).setMOSOConverter(wf); ((AbstractMultiObjectiveOptimizationProblem) mocco.state.currentProblem).setMOSOConverter(wf);
double[] setWeights = mapObjectives2Fitness(weights); double[] setWeights = mapObjectives2Fitness(weights);
PropertyDoubleArray da = new PropertyDoubleArray(setWeights); PropertyDoubleArray da = new PropertyDoubleArray(setWeights);
wf.setWeights(da); wf.setWeights(da);
m_Opt.setProblem(m_Mocco.m_State.m_CurrentProblem); optimizer.setProblem(mocco.state.currentProblem);
m_Mocco.m_State.m_Optimizer = m_Opt; mocco.state.optimizer = optimizer;
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_JPanelParameters.validate(); mocco.parameterPanel.validate();
m_Finished = true; hasFinished = true;
} }
}; };
@ -328,7 +324,7 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
*/ */
public double[] mapObjectives2Fitness(double[] d) { public double[] mapObjectives2Fitness(double[] d) {
ArrayList tmpA = new ArrayList(); ArrayList tmpA = new ArrayList();
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
System.out.println("Calling mapObjectives2Fitness"); System.out.println("Calling mapObjectives2Fitness");
System.out.println("obj.length = " + obj.length); System.out.println("obj.length = " + obj.length);
System.out.println("d.length = " + d.length); System.out.println("d.length = " + d.length);

View File

@ -19,24 +19,20 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 27.10.2005
* Time: 18:42:04
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements InterfaceProcessElement {
private double[] m_RefPoint; private double[] refPoint;
private IslandModelEA m_Island; private IslandModelEA islandModelEA;
private GeneralOptimizationEditorProperty m_EIMEA; private GeneralOptimizationEditorProperty optimizationEditorProperty;
private int m_Perturbations = 4; private int perturbations = 4;
private JTextField m_NumPer; private JTextField numPer;
JPanel m_Parameters; JPanel parameterPanel;
private JTextField[] m_UpperLimit, m_LowerLimit; private JTextField[] upperLimit, lowerLimit;
public MOCCOParameterizeTchebycheff(MOCCOStandalone mocco) { public MOCCOParameterizeTchebycheff(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -44,51 +40,48 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Start optimization."); JButton tmpB = new JButton("Start optimization.");
tmpB.setToolTipText("Start the adhoc online optimization."); tmpB.setToolTipText("Start the adhoc online optimization.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
tmpB = new JButton("Save task."); tmpB = new JButton("Save task.");
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization."); tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
tmpB.addActionListener(saveState2FileForOfflineOptimization); tmpB.addActionListener(saveState2FileForOfflineOptimization);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please parameterized the Tchebycheff method." + this.mocco.parameterPanel.add(this.makeHelpText("Please parameterized the Tchebycheff method." +
" Typically this methods generates a set of solutions by using k perturbations of the weights used for the weighted Tchebycheff metric." + " Typically this methods generates a set of solutions by using k perturbations of the weights used for the weighted Tchebycheff metric." +
" But also the choice of the optimization algorithms and migration rate for the heterogeneuos island model EA is critical." + " But also the choice of the optimization algorithms and migration rate for the heterogeneuos island model EA is critical." +
" Please note that any server server settings will override k!"), BorderLayout.NORTH); " Please note that any server server settings will override k!"), BorderLayout.NORTH);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new BorderLayout()); tmpP.setLayout(new BorderLayout());
this.m_Parameters = new JPanel(); this.parameterPanel = new JPanel();
// this.m_Choice.setBorder(BorderFactory.createCompoundBorder( tmpP.add(this.parameterPanel, BorderLayout.CENTER);
// BorderFactory.createTitledBorder("Step Method:"),
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
tmpP.add(this.m_Parameters, BorderLayout.CENTER);
this.installChoice(); this.installChoice();
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
this.m_Mocco.m_JPanelParameters.validate(); this.mocco.parameterPanel.validate();
this.m_Mocco.m_JPanelControl.validate(); this.mocco.controlPanel.validate();
} }
private void installChoice() { private void installChoice() {
this.m_Parameters.setLayout(new GridBagLayout()); this.parameterPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("Choose number of Perturbations k:"), gbc); this.parameterPanel.add(new JLabel("Choose number of Perturbations k:"), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 0; gbc.gridy = 0;
gbc.weightx = 1; gbc.weightx = 1;
this.m_NumPer = new JTextField("" + this.m_Perturbations); this.numPer = new JTextField("" + this.perturbations);
this.m_Parameters.add(this.m_NumPer, gbc); this.parameterPanel.add(this.numPer, gbc);
// weight constraints // weight constraints
JComponent tmpP = this.makeLimits4Weigths(); JComponent tmpP = this.makeLimits4Weigths();
tmpP.setBorder(BorderFactory.createCompoundBorder( tmpP.setBorder(BorderFactory.createCompoundBorder(
@ -98,31 +91,31 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
gbc.gridwidth = 2; gbc.gridwidth = 2;
gbc.gridy = 1; gbc.gridy = 1;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(tmpP, gbc); this.parameterPanel.add(tmpP, gbc);
// IslandModelEA // IslandModelEA
this.m_EIMEA = new GeneralOptimizationEditorProperty(); this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
this.m_Island = new IslandModelEA(); this.islandModelEA = new IslandModelEA();
this.m_Island.setHeterogeneousProblems(true); this.islandModelEA.setHeterogeneousProblems(true);
this.m_Island.setLocalOnly(true); this.islandModelEA.setLocalOnly(true);
this.m_Island.setMigrationRate(2); this.islandModelEA.setMigrationRate(2);
this.m_Island.setMigrationStrategy(new SOBestMigration()); this.islandModelEA.setMigrationStrategy(new SOBestMigration());
this.m_Island.setNumberLocalCPUs(this.m_Perturbations); this.islandModelEA.setNumberLocalCPUs(this.perturbations);
this.m_Island.setProblem(this.m_Mocco.m_State.m_CurrentProblem); this.islandModelEA.setProblem(this.mocco.state.currentProblem);
this.m_Mocco.m_State.m_Optimizer = this.m_Island; this.mocco.state.optimizer = this.islandModelEA;
this.m_EIMEA.name = "Island Model EA"; this.optimizationEditorProperty.name = "Island Model EA";
try { try {
this.m_EIMEA.value = this.m_Island; this.optimizationEditorProperty.value = this.islandModelEA;
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(this.m_EIMEA.value.getClass()); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
if (this.m_EIMEA.editor == null) { if (this.optimizationEditorProperty.editor == null) {
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(IslandModelEA.class); this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
} }
if (this.m_EIMEA.editor instanceof GenericObjectEditor) { if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_EIMEA.editor).setClassType(IslandModelEA.class); ((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(IslandModelEA.class);
} }
this.m_EIMEA.editor.setValue(this.m_EIMEA.value); this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
AbstractObjectEditor.findViewFor(this.m_EIMEA); AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
if (this.m_EIMEA.view != null) { if (this.optimizationEditorProperty.view != null) {
this.m_EIMEA.view.repaint(); this.optimizationEditorProperty.view.repaint();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Darn can't read the value..."); System.out.println("Darn can't read the value...");
@ -130,16 +123,16 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("" + this.m_EIMEA.name), gbc); this.parameterPanel.add(new JLabel("" + this.optimizationEditorProperty.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Parameters.add(this.m_EIMEA.view, gbc); this.parameterPanel.add(this.optimizationEditorProperty.view, gbc);
// Terminator // Terminator
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty(); GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
editor.name = "Terminator"; editor.name = "Terminator";
try { try {
editor.value = this.m_Mocco.m_State.m_Terminator; editor.value = this.mocco.state.terminator;
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass()); editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
if (editor.editor == null) { if (editor.editor == null) {
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class); editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
@ -158,18 +151,18 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 2; gbc.weightx = 2;
this.m_Parameters.add(new JLabel("" + editor.name), gbc); this.parameterPanel.add(new JLabel("" + editor.name), gbc);
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 3; gbc.gridy = 3;
gbc.weightx = 1; gbc.weightx = 1;
this.m_Parameters.add(editor.view, gbc); this.parameterPanel.add(editor.view, gbc);
} }
private JComponent makeLimits4Weigths() { private JComponent makeLimits4Weigths() {
JPanel result = new JPanel(); JPanel result = new JPanel();
result.setLayout(new GridBagLayout()); result.setLayout(new GridBagLayout());
this.m_UpperLimit = new JTextField[this.m_RefPoint.length]; this.upperLimit = new JTextField[this.refPoint.length];
this.m_LowerLimit = new JTextField[this.m_RefPoint.length]; this.lowerLimit = new JTextField[this.refPoint.length];
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
@ -188,7 +181,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
gbc.gridx = 3; gbc.gridx = 3;
gbc.gridy = 0; gbc.gridy = 0;
result.add(new JLabel("Upper"), gbc); result.add(new JLabel("Upper"), gbc);
for (int i = 0; i < this.m_RefPoint.length; i++) { for (int i = 0; i < this.refPoint.length; i++) {
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = i + 1; gbc.gridy = i + 1;
gbc.weightx = 1; gbc.weightx = 1;
@ -196,16 +189,16 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = i + 1; gbc.gridy = i + 1;
gbc.weightx = 2; gbc.weightx = 2;
result.add(new JLabel("" + this.m_RefPoint[i]), gbc); result.add(new JLabel("" + this.refPoint[i]), gbc);
gbc.gridx = 2; gbc.gridx = 2;
gbc.gridy = i + 1; gbc.gridy = i + 1;
gbc.weightx = 1; gbc.weightx = 1;
this.m_LowerLimit[i] = new JTextField("0.0"); this.lowerLimit[i] = new JTextField("0.0");
result.add(this.m_LowerLimit[i], gbc); result.add(this.lowerLimit[i], gbc);
gbc.gridx = 3; gbc.gridx = 3;
gbc.gridy = i + 1; gbc.gridy = i + 1;
this.m_UpperLimit[i] = new JTextField("1.0"); this.upperLimit[i] = new JTextField("1.0");
result.add(this.m_UpperLimit[i], gbc); result.add(this.upperLimit[i], gbc);
} }
return result; return result;
@ -218,7 +211,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
* @param point the reference point * @param point the reference point
*/ */
public void setReferencePoint(double[] point) { public void setReferencePoint(double[] point) {
this.m_RefPoint = point; this.refPoint = point;
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@ -226,43 +219,43 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
// first read the values // first read the values
try { try {
m_Perturbations = new Integer(m_NumPer.getText()).intValue(); perturbations = new Integer(numPer.getText()).intValue();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.out.println("Can't read k."); System.out.println("Can't read k.");
} }
if (m_EIMEA.value instanceof IslandModelEA) { if (optimizationEditorProperty.value instanceof IslandModelEA) {
m_Island = (IslandModelEA) m_EIMEA.value; islandModelEA = (IslandModelEA) optimizationEditorProperty.value;
} else { } else {
System.out.println("The selected optimizer does not allow heterogenuous multi-starts!"); System.out.println("The selected optimizer does not allow heterogenuous multi-starts!");
} }
// then set the values // then set the values
// if (!m_Island.getLocalOnly()) { // if (!islandModelEA.getLocalOnly()) {
// ToDo: Think of new ways to do this! // ToDo: Think of new ways to do this!
/* PropertyRemoteServers servs = m_Island.getServers(); /* PropertyRemoteServers servs = islandModelEA.getServers();
String[] servers = servs.getServerNodes(); String[] servers = servs.getServerNodes();
if (servers.length != m_Perturbations) { if (servers.length != perturbations) {
System.out.println("Warning: Number of servers overrides number of perturbations!"); System.out.println("Warning: Number of servers overrides number of perturbations!");
m_Perturbations = servers.length; perturbations = servers.length;
}*/ }*/
// } else { // } else {
// m_Island.setNumberLocalCPUs(m_Perturbations); // islandModelEA.setNumberLocalCPUs(perturbations);
// } // }
m_Mocco.m_State.m_Optimizer = m_Island; mocco.state.optimizer = islandModelEA;
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem); mocco.state.optimizer.setProblem(mocco.state.currentProblem);
m_Island.init(); islandModelEA.init();
double[] tmpD; double[] tmpD;
double sum = 0, l = 0, u = 1; double sum = 0, l = 0, u = 1;
MOSOWeightedLPTchebycheff[] tmpLPs = new MOSOWeightedLPTchebycheff[m_Perturbations]; MOSOWeightedLPTchebycheff[] tmpLPs = new MOSOWeightedLPTchebycheff[perturbations];
for (int i = 0; i < m_Perturbations; i++) { for (int i = 0; i < perturbations; i++) {
tmpD = new double[m_RefPoint.length]; tmpD = new double[refPoint.length];
sum = 0; sum = 0;
for (int j = 0; j < tmpD.length; j++) { for (int j = 0; j < tmpD.length; j++) {
try { try {
l = new Double(m_LowerLimit[j].getText()).doubleValue(); l = new Double(lowerLimit[j].getText()).doubleValue();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
try { try {
u = new Double(m_UpperLimit[j].getText()).doubleValue(); u = new Double(upperLimit[j].getText()).doubleValue();
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
if (l < 0) { if (l < 0) {
@ -297,17 +290,17 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
// I've to set this before I change the parameters, because the problem sets the // I've to set this before I change the parameters, because the problem sets the
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and // output dimension based on the AbstractMultiObjectiveOptimizationProblem and
// that one has not the faintest idea about the true output dimension // that one has not the faintest idea about the true output dimension
((AbstractMultiObjectiveOptimizationProblem) m_Island.getOptimizers()[i].getProblem()).setMOSOConverter(tmpLPs[i]); ((AbstractMultiObjectiveOptimizationProblem) islandModelEA.getOptimizers()[i].getProblem()).setMOSOConverter(tmpLPs[i]);
tmpLPs[i].setOutputDimension(tmpD.length); tmpLPs[i].setOutputDimension(tmpD.length);
tmpLPs[i].getIdealPWeights().m_IdealValue = m_RefPoint; tmpLPs[i].getIdealPWeights().idealValue = refPoint;
tmpLPs[i].getIdealPWeights().m_Weights = tmpD; tmpLPs[i].getIdealPWeights().weights = tmpD;
} }
m_Mocco.m_View.removeReferencePoint(); mocco.view.removeReferencePoint();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_JPanelParameters.validate(); mocco.parameterPanel.validate();
m_Finished = true; hasFinished = true;
} }
}; };
} }

View File

@ -16,8 +16,8 @@ import java.awt.event.ActionListener;
*/ */
public abstract class MOCCOPhase implements InterfaceProcessElement { public abstract class MOCCOPhase implements InterfaceProcessElement {
public MOCCOStandalone m_Mocco; public MOCCOStandalone mocco;
public volatile boolean m_Finished = false; public volatile boolean hasFinished = false;
/** /**
* This method will call the init method and will go to stall * This method will call the init method and will go to stall
@ -32,7 +32,7 @@ public abstract class MOCCOPhase implements InterfaceProcessElement {
*/ */
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return this.m_Finished; return this.hasFinished;
} }
/** /**

View File

@ -19,10 +19,10 @@ import java.awt.event.ActionListener;
*/ */
public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceProcessElement {
private JComboBox m_ProblemChooser; private JComboBox problemChooser;
public MOCCOProblemInitialization(MOCCOStandalone mocco) { public MOCCOProblemInitialization(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
} }
/** /**
@ -30,24 +30,24 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Continue to choose the initial number of solution alternatives."); JButton tmpB = new JButton("Continue to choose the initial number of solution alternatives.");
tmpB.setToolTipText("This finializes the original problem definition."); tmpB.setToolTipText("This finializes the original problem definition.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.initProblemDefinition(); this.initProblemDefinition();
this.m_Mocco.m_JFrame.setVisible(true); this.mocco.getMainFrame().setVisible(true);
this.m_Mocco.m_JFrame.validate(); this.mocco.getMainFrame().validate();
} }
private void initProblemDefinition() { private void initProblemDefinition() {
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
this.m_ProblemChooser = new JComboBox(); this.problemChooser = new JComboBox();
JComponent tmpC = new JPanel(); JComponent tmpC = new JPanel();
tmpC.setLayout(new BorderLayout()); tmpC.setLayout(new BorderLayout());
@ -57,11 +57,11 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.m_ProblemChooser.setModel(new DefaultComboBoxModel(altern)); this.problemChooser.setModel(new DefaultComboBoxModel(altern));
String objectName = (this.m_Mocco.m_State.m_OriginalProblem.getClass().getName()); String objectName = (this.mocco.state.originalProblem.getClass().getName());
this.m_ProblemChooser.getModel().setSelectedItem(objectName); this.problemChooser.getModel().setSelectedItem(objectName);
this.m_ProblemChooser.addActionListener(problemChanged); this.problemChooser.addActionListener(problemChanged);
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
@ -73,36 +73,36 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
"with the InterfaceMultiObjectiveDeNovoProblem can be optimized using the MOCCO approach."), gbc); "with the InterfaceMultiObjectiveDeNovoProblem can be optimized using the MOCCO approach."), gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 1; gbc.gridy = 1;
tmpP.add(this.m_ProblemChooser, gbc); tmpP.add(this.problemChooser, gbc);
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.NORTH); this.mocco.parameterPanel.add(tmpP, BorderLayout.NORTH);
JParaPanel paraPanel = new JParaPanel(this.m_Mocco.m_State.m_OriginalProblem, "MyGUI"); JParaPanel paraPanel = new JParaPanel(this.mocco.state.originalProblem, "MyGUI");
this.m_Mocco.m_JPanelParameters.add(paraPanel.makePanel(), BorderLayout.CENTER); this.mocco.parameterPanel.add(paraPanel.makePanel(), BorderLayout.CENTER);
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener problemChanged = new ActionListener() { ActionListener problemChanged = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
String className = (String) m_ProblemChooser.getSelectedItem(); String className = (String) problemChooser.getSelectedItem();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
Object n = null; Object n = null;
try { try {
n = (Object) Class.forName(className).newInstance(); n = (Object) Class.forName(className).newInstance();
} catch (Exception ex) { } catch (Exception ex) {
} }
m_Mocco.m_State.m_OriginalProblem = (InterfaceOptimizationProblem) n; mocco.state.originalProblem = (InterfaceOptimizationProblem) n;
initProblemDefinition(); initProblemDefinition();
m_Mocco.m_JPanelParameters.validate(); mocco.parameterPanel.validate();
} }
}; };
} }

View File

@ -19,11 +19,11 @@ import java.awt.event.ActionListener;
*/ */
public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfaceProcessElement { public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfaceProcessElement {
private InterfaceOptimizationProblem m_Problem; private InterfaceOptimizationProblem optimizationProblem;
public MOCCOProblemRedefinition(MOCCOStandalone mocco) { public MOCCOProblemRedefinition(MOCCOStandalone mocco) {
this.m_Mocco = mocco; this.mocco = mocco;
this.m_Problem = (InterfaceOptimizationProblem) this.m_Mocco.m_State.m_CurrentProblem.clone(); this.optimizationProblem = (InterfaceOptimizationProblem) this.mocco.state.currentProblem.clone();
} }
/** /**
@ -31,16 +31,16 @@ public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfacePro
*/ */
@Override @Override
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.mocco.controlPanel.removeAll();
// The button panel // The button panel
JButton tmpB = new JButton("Continue to choose the optimization strategy."); JButton tmpB = new JButton("Continue to choose the optimization strategy.");
tmpB.setToolTipText("This finializes the problem redefinition process."); tmpB.setToolTipText("This finializes the problem redefinition process.");
tmpB.addActionListener(continue2); tmpB.addActionListener(continue2);
this.m_Mocco.m_JPanelControl.add(tmpB); this.mocco.controlPanel.add(tmpB);
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.removeAll(); this.mocco.parameterPanel.removeAll();
JComponent tmpC = new JPanel(); JComponent tmpC = new JPanel();
tmpC.setLayout(new BorderLayout()); tmpC.setLayout(new BorderLayout());
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
@ -61,34 +61,34 @@ public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfacePro
tmpB = new JButton("Reevaluate Problem"); tmpB = new JButton("Reevaluate Problem");
tmpB.addActionListener(reevaluate); tmpB.addActionListener(reevaluate);
tmpP.add(tmpB, gbc); tmpP.add(tmpB, gbc);
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.mocco.parameterPanel.setLayout(new BorderLayout());
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.NORTH); this.mocco.parameterPanel.add(tmpP, BorderLayout.NORTH);
JParaPanel paraPanel = new JParaPanel(this.m_Problem, "MyGUI"); JParaPanel paraPanel = new JParaPanel(this.optimizationProblem, "MyGUI");
tmpC = (paraPanel.makePanel()); tmpC = (paraPanel.makePanel());
this.m_Mocco.m_JPanelParameters.add(tmpC, BorderLayout.CENTER); this.mocco.parameterPanel.add(tmpC, BorderLayout.CENTER);
this.m_Mocco.m_JFrame.setVisible(true); this.mocco.getMainFrame().setVisible(true);
this.m_Mocco.m_JFrame.validate(); this.mocco.getMainFrame().validate();
} }
ActionListener continue2 = new ActionListener() { ActionListener continue2 = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) m_Problem.clone(); mocco.state.currentProblem = (InterfaceOptimizationProblem) optimizationProblem.clone();
m_Mocco.m_JPanelParameters.removeAll(); mocco.parameterPanel.removeAll();
m_Mocco.m_JPanelControl.removeAll(); mocco.controlPanel.removeAll();
m_Mocco.m_JPanelControl.validate(); mocco.controlPanel.validate();
m_Finished = true; hasFinished = true;
} }
}; };
ActionListener reevaluate = new ActionListener() { ActionListener reevaluate = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
m_Mocco.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) m_Problem.clone(); mocco.state.currentProblem = (InterfaceOptimizationProblem) optimizationProblem.clone();
m_Mocco.m_State.m_CurrentProblem = m_Problem; mocco.state.currentProblem = optimizationProblem;
m_Mocco.m_State.makeFitnessCache(true); mocco.state.makeFitnessCache(true);
m_Mocco.m_View.problemChanged(true); mocco.view.problemChanged(true);
} }
}; };
} }

View File

@ -25,88 +25,88 @@ import java.util.ArrayList;
public class MOCCOState { public class MOCCOState {
public transient boolean isVisible = false; public transient boolean isVisible = false;
public InterfaceOptimizer m_Optimizer = new MultiObjectiveEA(); public InterfaceOptimizer optimizer = new MultiObjectiveEA();
public InterfaceOptimizer m_BackupOptimizer; public InterfaceOptimizer backupOptimizer;
public InterfaceTerminator m_Terminator = new EvaluationTerminator(); public InterfaceTerminator terminator = new EvaluationTerminator();
public InterfaceOptimizationProblem m_OriginalProblem = null; public InterfaceOptimizationProblem originalProblem = null;
public InterfaceOptimizationProblem m_CurrentProblem; public InterfaceOptimizationProblem currentProblem;
public InterfaceOptimizationProblem m_BackupProblem; public InterfaceOptimizationProblem backupProblem;
public int m_InitialPopulationSize = 50; public int initialPopulationSize = 50;
// the population history // the population history
public Population m_ParetoFront; public Population paretoFront;
public Population[] m_PopulationHistory = new Population[0]; public Population[] populationHistory = new Population[0];
public boolean[] m_Show; public boolean[] show;
public boolean[] m_Use; public boolean[] use;
public Color[] m_Color; public Color[] colors;
// the fitness cache for fast plotting // the fitness cache for fast plotting
public ArrayList m_FitnessCache = new ArrayList(); public ArrayList fitnessCache = new ArrayList();
public ArrayList m_ObjectiveCache = new ArrayList(); public ArrayList objectiveCache = new ArrayList();
public ArrayList m_ConstraintCache = new ArrayList(); public ArrayList constraintCache = new ArrayList();
public MOCCOState() { public MOCCOState() {
} }
public void restore() { public void restore() {
Population pop = this.m_Optimizer.getPopulation(); Population pop = this.optimizer.getPopulation();
if (this.m_BackupProblem != null) { if (this.backupProblem != null) {
this.m_CurrentProblem = this.m_BackupProblem; this.currentProblem = this.backupProblem;
this.m_BackupProblem = null; this.backupProblem = null;
} }
if (this.m_BackupOptimizer != null) { if (this.backupOptimizer != null) {
this.m_Optimizer = this.m_BackupOptimizer; this.optimizer = this.backupOptimizer;
this.m_BackupOptimizer = null; this.backupOptimizer = null;
} }
this.m_Optimizer.setPopulation(pop); this.optimizer.setPopulation(pop);
this.m_Optimizer.setProblem(this.m_CurrentProblem); this.optimizer.setProblem(this.currentProblem);
this.m_CurrentProblem.evaluate(this.m_Optimizer.getPopulation()); this.currentProblem.evaluate(this.optimizer.getPopulation());
} }
public void makeBackup() { public void makeBackup() {
this.m_BackupProblem = (InterfaceOptimizationProblem) this.m_CurrentProblem.clone(); this.backupProblem = (InterfaceOptimizationProblem) this.currentProblem.clone();
this.m_BackupOptimizer = (InterfaceOptimizer) this.m_Optimizer.clone(); this.backupOptimizer = (InterfaceOptimizer) this.optimizer.clone();
this.m_BackupOptimizer.setProblem(null); this.backupOptimizer.setProblem(null);
} }
public void addPopulation2History(Population pop) { public void addPopulation2History(Population pop) {
InterfaceOptimizationObjective[] tmpObj = null; InterfaceOptimizationObjective[] tmpObj = null;
if (this.m_Show == null) { if (this.show == null) {
this.m_Use = new boolean[1]; this.use = new boolean[1];
this.m_Use[0] = true; this.use[0] = true;
this.m_Show = new boolean[1]; this.show = new boolean[1];
this.m_Show[0] = true; this.show[0] = true;
this.m_Color = new Color[1]; this.colors = new Color[1];
this.m_Color[0] = this.getColor4Index(0); this.colors[0] = this.getColor4Index(0);
} else { } else {
boolean[] newUse = new boolean[this.m_Show.length + 1]; boolean[] newUse = new boolean[this.show.length + 1];
boolean[] newShow = new boolean[this.m_Show.length + 1]; boolean[] newShow = new boolean[this.show.length + 1];
Color[] newColor = new Color[this.m_Show.length + 1]; Color[] newColor = new Color[this.show.length + 1];
for (int i = 0; i < this.m_Show.length; i++) { for (int i = 0; i < this.show.length; i++) {
newUse[i] = this.m_Use[i]; newUse[i] = this.use[i];
newShow[i] = this.m_Show[i]; newShow[i] = this.show[i];
newColor[i] = this.m_Color[i]; newColor[i] = this.colors[i];
} }
newUse[m_Show.length] = true; newUse[show.length] = true;
newShow[m_Show.length] = true; newShow[show.length] = true;
newColor[m_Show.length] = this.getColor4Index(this.m_PopulationHistory.length); newColor[show.length] = this.getColor4Index(this.populationHistory.length);
this.m_Use = newUse; this.use = newUse;
this.m_Show = newShow; this.show = newShow;
this.m_Color = newColor; this.colors = newColor;
} }
Population[] newPop = new Population[this.m_PopulationHistory.length + 1]; Population[] newPop = new Population[this.populationHistory.length + 1];
for (int i = 0; i < this.m_PopulationHistory.length; i++) { for (int i = 0; i < this.populationHistory.length; i++) {
newPop[i] = this.m_PopulationHistory[i]; newPop[i] = this.populationHistory[i];
} }
newPop[newPop.length - 1] = (Population) pop.clone(); newPop[newPop.length - 1] = (Population) pop.clone();
newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive()); newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive());
newPop[newPop.length - 1].SetArchive(null); newPop[newPop.length - 1].SetArchive(null);
this.m_PopulationHistory = newPop; this.populationHistory = newPop;
ArrayList fitness = new ArrayList(); ArrayList fitness = new ArrayList();
ArrayList objectives = new ArrayList(); ArrayList objectives = new ArrayList();
ArrayList constraint = new ArrayList(); ArrayList constraint = new ArrayList();
if (this.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) { if (this.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_CurrentProblem).getProblemObjectives(); tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.currentProblem).getProblemObjectives();
} }
for (int j = 0; j < newPop[newPop.length - 1].size(); j++) { for (int j = 0; j < newPop[newPop.length - 1].size(); j++) {
if (tmpObj != null) { if (tmpObj != null) {
@ -119,11 +119,11 @@ public class MOCCOState {
fitness.add(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getFitness()); fitness.add(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getFitness());
constraint.add(new Double(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getConstraintViolation())); constraint.add(new Double(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getConstraintViolation()));
} }
if (this.m_ObjectiveCache != null) { if (this.objectiveCache != null) {
this.m_ObjectiveCache.add(objectives); this.objectiveCache.add(objectives);
} }
this.m_FitnessCache.add(fitness); this.fitnessCache.add(fitness);
this.m_ConstraintCache.add(constraint); this.constraintCache.add(constraint);
} }
/** /**
@ -152,9 +152,9 @@ public class MOCCOState {
public void reduce2ParetoFront(int i) { public void reduce2ParetoFront(int i) {
ArchivingAllDominating arch = new ArchivingAllDominating(); ArchivingAllDominating arch = new ArchivingAllDominating();
arch.addElementsToArchive(this.m_PopulationHistory[i]); arch.addElementsToArchive(this.populationHistory[i]);
this.m_PopulationHistory[i] = this.m_PopulationHistory[i].getArchive(); this.populationHistory[i] = this.populationHistory[i].getArchive();
this.m_PopulationHistory[i].SetArchive(null); this.populationHistory[i].SetArchive(null);
this.makeFitnessCache(false); this.makeFitnessCache(false);
} }
@ -165,12 +165,12 @@ public class MOCCOState {
*/ */
public Population getSelectedPopulations() { public Population getSelectedPopulations() {
Population result = new Population(); Population result = new Population();
for (int i = 0; i < this.m_PopulationHistory.length; i++) { for (int i = 0; i < this.populationHistory.length; i++) {
if (this.m_Use[i]) { if (this.use[i]) {
result.addPopulation(this.m_PopulationHistory[i]); result.addPopulation(this.populationHistory[i]);
} }
} }
this.m_CurrentProblem.evaluate(result); this.currentProblem.evaluate(result);
return result; return result;
} }
@ -184,65 +184,65 @@ public class MOCCOState {
InterfaceOptimizationObjective[] tmpObj = null; InterfaceOptimizationObjective[] tmpObj = null;
if (reevaluate) { if (reevaluate) {
// clear all archives, since problem dimension may have changed // clear all archives, since problem dimension may have changed
for (int i = 0; i < this.m_PopulationHistory.length; i++) { for (int i = 0; i < this.populationHistory.length; i++) {
if (this.m_PopulationHistory[i].getArchive() != null) { if (this.populationHistory[i].getArchive() != null) {
this.m_PopulationHistory[i].addPopulation(this.m_PopulationHistory[i].getArchive()); this.populationHistory[i].addPopulation(this.populationHistory[i].getArchive());
this.m_PopulationHistory[i].SetArchive(null); this.populationHistory[i].SetArchive(null);
} }
} }
Population pop = this.m_Optimizer.getPopulation(); Population pop = this.optimizer.getPopulation();
if (pop.getArchive() != null) { if (pop.getArchive() != null) {
pop.addPopulation(pop.getArchive()); pop.addPopulation(pop.getArchive());
pop.SetArchive(null); pop.SetArchive(null);
} }
this.m_CurrentProblem.evaluate(pop); this.currentProblem.evaluate(pop);
} }
this.m_FitnessCache = new ArrayList(); this.fitnessCache = new ArrayList();
this.m_ObjectiveCache = null; this.objectiveCache = null;
this.m_ConstraintCache = new ArrayList(); this.constraintCache = new ArrayList();
if (this.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) { if (this.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
this.m_ObjectiveCache = new ArrayList(); this.objectiveCache = new ArrayList();
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_CurrentProblem).getProblemObjectives(); tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.currentProblem).getProblemObjectives();
} }
this.m_ParetoFront = new Population(); this.paretoFront = new Population();
for (int i = 0; i < this.m_PopulationHistory.length; i++) { for (int i = 0; i < this.populationHistory.length; i++) {
if (reevaluate) { if (reevaluate) {
((AbstractMultiObjectiveOptimizationProblem) this.m_CurrentProblem).resetParetoFront(); ((AbstractMultiObjectiveOptimizationProblem) this.currentProblem).resetParetoFront();
this.m_CurrentProblem.evaluate(this.m_PopulationHistory[i]); this.currentProblem.evaluate(this.populationHistory[i]);
} }
this.m_ParetoFront.addPopulation(this.m_PopulationHistory[i]); this.paretoFront.addPopulation(this.populationHistory[i]);
ArrayList fitness = new ArrayList(); ArrayList fitness = new ArrayList();
ArrayList objectives = new ArrayList(); ArrayList objectives = new ArrayList();
ArrayList constraint = new ArrayList(); ArrayList constraint = new ArrayList();
for (int j = 0; j < this.m_PopulationHistory[i].size(); j++) { for (int j = 0; j < this.populationHistory[i].size(); j++) {
if (tmpObj != null) { if (tmpObj != null) {
double[] tmoF = new double[tmpObj.length]; double[] tmoF = new double[tmpObj.length];
for (int k = 0; k < tmpObj.length; k++) { for (int k = 0; k < tmpObj.length; k++) {
if (this.m_PopulationHistory[i].get(j) == null) { if (this.populationHistory[i].get(j) == null) {
System.out.println("Individual " + i + " == null!"); System.out.println("Individual " + i + " == null!");
} }
if (tmpObj[k] == null) { if (tmpObj[k] == null) {
System.out.println("Objective " + k + " == null!"); System.out.println("Objective " + k + " == null!");
} }
if (((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getData(tmpObj[k].getIdentName()) == null) { if (((AbstractEAIndividual) this.populationHistory[i].get(j)).getData(tmpObj[k].getIdentName()) == null) {
System.out.println("User Data " + k + " " + tmpObj[k].getIdentName() + " == null!"); System.out.println("User Data " + k + " " + tmpObj[k].getIdentName() + " == null!");
} }
tmoF[k] = ((Double) ((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getData(tmpObj[k].getIdentName())).doubleValue(); tmoF[k] = ((Double) ((AbstractEAIndividual) this.populationHistory[i].get(j)).getData(tmpObj[k].getIdentName())).doubleValue();
} }
objectives.add(tmoF); objectives.add(tmoF);
} }
fitness.add(((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getFitness()); fitness.add(((AbstractEAIndividual) this.populationHistory[i].get(j)).getFitness());
constraint.add(new Double(((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getConstraintViolation())); constraint.add(new Double(((AbstractEAIndividual) this.populationHistory[i].get(j)).getConstraintViolation()));
} }
if (this.m_ObjectiveCache != null) { if (this.objectiveCache != null) {
this.m_ObjectiveCache.add(objectives); this.objectiveCache.add(objectives);
} }
this.m_FitnessCache.add(fitness); this.fitnessCache.add(fitness);
this.m_ConstraintCache.add(constraint); this.constraintCache.add(constraint);
} }
ArchivingAllDominating arch = new ArchivingAllDominating(); ArchivingAllDominating arch = new ArchivingAllDominating();
arch.addElementsToArchive(this.m_ParetoFront); arch.addElementsToArchive(this.paretoFront);
this.m_ParetoFront = this.m_ParetoFront.getArchive(); this.paretoFront = this.paretoFront.getArchive();
this.m_ParetoFront.SetArchive(null); this.paretoFront.SetArchive(null);
} }
} }

View File

@ -27,45 +27,40 @@ import java.util.Date;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 04.11.2005
* Time: 11:02:47
* To change this template use File | Settings | File Templates.
*/ */
public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener, InterfaceRefPointListener { public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener, InterfaceRefPointListener {
public MOCCOStandalone m_MOCCO; public MOCCOStandalone moccoStandalone;
public MOCCOViewer m_self; public MOCCOViewer instance;
private InterfaceParetoFrontView m_View; private InterfaceParetoFrontView paretoFrontView;
private FunctionArea m_1DView; private FunctionArea functionAre;
public JSplitPane m_JSplit; public JPanel viewPanel, choicesPanel;
public JPanel m_ViewPanel, m_Choices; private InterfaceRefSolutionListener refSolutionListener;
private InterfaceRefSolutionListener m_RefSolutionListener; private InterfaceRefPointListener refPointListener;
private InterfaceRefPointListener m_RefPointListener; public double[] referencePoint = null;
public double[] m_ReferencePoint = null; public boolean selectUniqueSolution = true;
public boolean m_SelectUniqueSolution = true; public boolean refPointSelectable = false;
public boolean m_RefPointSelectable = false; public boolean refSolutionSelectable = false;
public boolean m_RefSolutionSelectable = false;
public MOCCOViewer(MOCCOStandalone t) { public MOCCOViewer(MOCCOStandalone t) {
this.m_MOCCO = t; this.moccoStandalone = t;
this.m_self = this; this.instance = this;
this.init(); this.init();
} }
public void init() { public void init() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
// the view // the view
this.m_ViewPanel = new JPanel(); this.viewPanel = new JPanel();
this.m_ViewPanel.setLayout(new BorderLayout()); this.viewPanel.setLayout(new BorderLayout());
this.m_View = new ParetoFrontView2D(this); this.paretoFrontView = new ParetoFrontView2D(this);
this.m_ViewPanel.add((JPanel) this.m_View, BorderLayout.CENTER); this.viewPanel.add((JPanel) this.paretoFrontView, BorderLayout.CENTER);
// the parameters // the parameters
this.m_Choices = new JPanel(); this.choicesPanel = new JPanel();
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
this.m_Choices.setLayout(new GridLayout(1, 2)); this.choicesPanel.setLayout(new GridLayout(1, 2));
this.m_Choices.add(tmpP); this.choicesPanel.add(tmpP);
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
@ -90,70 +85,12 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
tmpP.add(tmpC, gbc); tmpP.add(tmpC, gbc);
JButton JBSaveParetoFront = new JButton("Save Pareto Front"); JButton JBSaveParetoFront = new JButton("Save Pareto Front");
JBSaveParetoFront.addActionListener(this.saveParetoFront); JBSaveParetoFront.addActionListener(this.saveParetoFront);
this.m_Choices.add(JBSaveParetoFront); this.choicesPanel.add(JBSaveParetoFront);
// the main panel // the main panel
this.add(this.m_ViewPanel, BorderLayout.CENTER); this.add(this.viewPanel, BorderLayout.CENTER);
this.add(this.m_Choices, BorderLayout.SOUTH); this.add(this.choicesPanel, BorderLayout.SOUTH);
// the old version
// this.setLayout(new BorderLayout());
// this.m_Main = new JPanel();
// this.add(this.m_Main, BorderLayout.CENTER);
// this.m_ViewPanel = new JPanel();
// this.m_ViewPanel.setLayout(new BorderLayout());
// this.view = new ParetoFrontView2D(this);
// this.m_ViewPanel.add((JPanel)this.view, BorderLayout.CENTER);
// this.m_Parameters = new JPanel();
// this.m_Parameters.setLayout(new BorderLayout());
// this.m_Choices = new JPanel();
// this.m_Choices.setBorder(BorderFactory.createCompoundBorder(
// BorderFactory.createTitledBorder("Parameterize Visualization:"),
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
// this.m_History = new JPanel();
// JButton JBSaveParetoFront = new JButton("Save Pareto Front");
// JBSaveParetoFront.addActionListener(this.saveParetoFront);
// this.m_Parameters.add(this.m_Choices, BorderLayout.NORTH);
// this.m_Parameters.add(this.m_History, BorderLayout.CENTER);
// this.m_Parameters.add(JBSaveParetoFront, BorderLayout.SOUTH);
// this.m_JSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.m_ViewPanel, this.m_Parameters);
// this.m_JSplit.setOneTouchExpandable(true);
// this.m_Main.setLayout(new BorderLayout());
// this.m_Main.add(this.m_JSplit, BorderLayout.CENTER);
//
// this.initChoices();
// this.updateHistory();
} }
// private void initChoices() {
// JPanel tmpP = new JPanel();
// this.m_Choices.setLayout(new BorderLayout());
// this.m_ChoicesParameters = new JPanel();
// this.m_Choices.add(tmpP, BorderLayout.NORTH);
// this.m_Choices.add(this.m_ChoicesParameters, BorderLayout.CENTER);
// tmpP.setLayout(new GridBagLayout());
// GridBagConstraints gbc = new GridBagConstraints();
// gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = GridBagConstraints.BOTH;
// gbc.gridx = 0;
// gbc.gridy = 0;
// gbc.weightx = 1;
// tmpP.add(new JLabel("Choose View:"), gbc);
// String[] tmpList = new String[2];
// tmpList[0] = "2D Pareto Front";
// tmpList[1] = "Scatter Plot";
// //tmpList[2] = "Parallel Axsis";
// //tmpList[3] = "Problemspec. Viewer";
// JComboBox tmpC = new JComboBox(tmpList);
// tmpC.setSelectedIndex(0);
// tmpC.addActionListener(paretoFrontViewChanged);
// gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = GridBagConstraints.BOTH;
// gbc.gridx = 1;
// gbc.gridy = 0;
// gbc.weightx = 3;
// tmpP.add(tmpC, gbc);
// }
ActionListener paretoFrontViewChanged = new ActionListener() { ActionListener paretoFrontViewChanged = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
@ -161,35 +98,35 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
int index = tmpC.getSelectedIndex(); int index = tmpC.getSelectedIndex();
switch (index) { switch (index) {
case 0: { case 0: {
m_ViewPanel.removeAll(); viewPanel.removeAll();
m_View = new ParetoFrontView2D(m_self); paretoFrontView = new ParetoFrontView2D(instance);
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER); viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
//problemChanged(false); //problemChanged(false);
break; break;
} }
case 1: { case 1: {
m_ViewPanel.removeAll(); viewPanel.removeAll();
m_View = new ParetoFrontViewScatterPlot(m_self); paretoFrontView = new ParetoFrontViewScatterPlot(instance);
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER); viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
//problemChanged(false); //problemChanged(false);
break; break;
} }
case 2: { case 2: {
m_ViewPanel.removeAll(); viewPanel.removeAll();
m_View = new ParetoFrontViewParallelAxsis(m_self); paretoFrontView = new ParetoFrontViewParallelAxis(instance);
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER); viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
//problemChanged(false); //problemChanged(false);
break; break;
} }
case 3: { case 3: {
m_ViewPanel.removeAll(); viewPanel.removeAll();
m_View = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getParetoFrontViewer4MOCCO(m_self); paretoFrontView = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getParetoFrontViewer4MOCCO(instance);
m_ViewPanel.add((JComponent) m_View, BorderLayout.CENTER); viewPanel.add((JComponent) paretoFrontView, BorderLayout.CENTER);
//problemChanged(false); //problemChanged(false);
break; break;
} }
} }
m_ViewPanel.updateUI(); viewPanel.updateUI();
} }
}; };
@ -197,19 +134,19 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss"); SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss");
String m_StartDate = formatter.format(new Date()); String startDate = formatter.format(new Date());
BufferedWriter out = null; BufferedWriter out = null;
Population pop; Population pop;
String name = "MOCCO_" + m_StartDate + "_PF_Iteration_" + m_MOCCO.m_Iteration + ".dat", tmp; String name = "MOCCO_" + startDate + "_PF_Iteration_" + moccoStandalone.iteration + ".dat", tmp;
pop = m_MOCCO.m_State.m_ParetoFront; pop = moccoStandalone.state.paretoFront;
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("Could not open output file! Filename: " + name); System.out.println("Could not open output file! Filename: " + name);
return; return;
} }
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
tmp = ""; tmp = "";
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
tmp += obj[j].getIdentName() + "\t"; tmp += obj[j].getIdentName() + "\t";
@ -237,7 +174,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
} }
name = "MOCCO_" + m_StartDate + "_All_Iteration_" + m_MOCCO.m_Iteration + ".dat"; name = "MOCCO_" + startDate + "_All_Iteration_" + moccoStandalone.iteration + ".dat";
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -245,10 +182,10 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
return; return;
} }
pop = new Population(); pop = new Population();
for (int i = 0; i < m_MOCCO.m_State.m_PopulationHistory.length; i++) { for (int i = 0; i < moccoStandalone.state.populationHistory.length; i++) {
pop.addPopulation(m_MOCCO.m_State.m_PopulationHistory[i]); pop.addPopulation(moccoStandalone.state.populationHistory[i]);
} }
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
tmp = ""; tmp = "";
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
tmp += obj[j].getIdentName() + "\t"; tmp += obj[j].getIdentName() + "\t";
@ -276,7 +213,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
} }
name = "MOCCO_" + m_StartDate + "_Infeasible_Iteration_" + m_MOCCO.m_Iteration + ".dat"; name = "MOCCO_" + startDate + "_Infeasible_Iteration_" + moccoStandalone.iteration + ".dat";
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -284,10 +221,10 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
return; return;
} }
pop = new Population(); pop = new Population();
for (int i = 0; i < m_MOCCO.m_State.m_PopulationHistory.length; i++) { for (int i = 0; i < moccoStandalone.state.populationHistory.length; i++) {
pop.addPopulation(m_MOCCO.m_State.m_PopulationHistory[i]); pop.addPopulation(moccoStandalone.state.populationHistory[i]);
} }
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
tmp = ""; tmp = "";
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
tmp += obj[j].getIdentName() + "\t"; tmp += obj[j].getIdentName() + "\t";
@ -315,15 +252,15 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
} }
name = "MOCCO_" + m_StartDate + "_RefSolutions_Iteration_" + m_MOCCO.m_Iteration + ".dat"; name = "MOCCO_" + startDate + "_RefSolutions_Iteration_" + moccoStandalone.iteration + ".dat";
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("Could not open output file! Filename: " + name); System.out.println("Could not open output file! Filename: " + name);
return; return;
} }
pop = m_MOCCO.m_State.m_ParetoFront.getMarkedIndividuals(); pop = moccoStandalone.state.paretoFront.getMarkedIndividuals();
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
tmp = ""; tmp = "";
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
tmp += obj[j].getIdentName() + "\t"; tmp += obj[j].getIdentName() + "\t";
@ -349,15 +286,15 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
} }
name = "MOCCO_" + m_StartDate + "_RefPoint_Iteration_" + m_MOCCO.m_Iteration + ".dat"; name = "MOCCO_" + startDate + "_RefPoint_Iteration_" + moccoStandalone.iteration + ".dat";
try { try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name))); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("Could not open output file! Filename: " + name); System.out.println("Could not open output file! Filename: " + name);
return; return;
} }
pop = m_MOCCO.m_State.m_ParetoFront.getMarkedIndividuals(); pop = moccoStandalone.state.paretoFront.getMarkedIndividuals();
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
tmp = ""; tmp = "";
for (int j = 0; j < obj.length; j++) { for (int j = 0; j < obj.length; j++) {
tmp += obj[j].getIdentName() + "\t"; tmp += obj[j].getIdentName() + "\t";
@ -367,9 +304,9 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
} }
tmp = ""; tmp = "";
if (m_ReferencePoint != null) { if (referencePoint != null) {
for (int j = 0; j < m_ReferencePoint.length; j++) { for (int j = 0; j < referencePoint.length; j++) {
tmp += m_ReferencePoint[j] + "\t"; tmp += referencePoint[j] + "\t";
} }
try { try {
out.write(tmp + "\n"); out.write(tmp + "\n");
@ -384,29 +321,29 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
}; };
public void problemChanged(boolean t) { public void problemChanged(boolean t) {
this.m_MOCCO.m_State.makeFitnessCache(t); this.moccoStandalone.state.makeFitnessCache(t);
//this.updateHistory(); //this.updateHistory();
if (this.m_MOCCO.m_State.m_CurrentProblem.isMultiObjective()) { if (this.moccoStandalone.state.currentProblem.isMultiObjective()) {
if (this.m_1DView != null) { if (this.functionAre != null) {
this.m_ViewPanel.removeAll(); this.viewPanel.removeAll();
this.m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER); this.viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
} }
this.m_View.updateView(); this.paretoFrontView.updateView();
this.m_1DView = null; this.functionAre = null;
} else { } else {
// here I simply add a single-objective view.. // here I simply add a single-objective view..
if (this.m_1DView == null) { if (this.functionAre == null) {
this.m_ViewPanel.removeAll(); this.viewPanel.removeAll();
this.m_ViewPanel.setLayout(new BorderLayout()); this.viewPanel.setLayout(new BorderLayout());
this.m_1DView = new FunctionArea("?", "?"); this.functionAre = new FunctionArea("?", "?");
this.m_1DView.setPreferredSize(new Dimension(450, 450)); this.functionAre.setPreferredSize(new Dimension(450, 450));
this.m_1DView.setMinimumSize(new Dimension(450, 450)); this.functionAre.setMinimumSize(new Dimension(450, 450));
ScaledBorder areaBorder = new ScaledBorder(); ScaledBorder areaBorder = new ScaledBorder();
areaBorder.x_label = "Optimzation Step"; areaBorder.xLabel = "Optimzation Step";
areaBorder.y_label = "Fitness"; areaBorder.yLabel = "Fitness";
this.m_1DView.setBorder(areaBorder); this.functionAre.setBorder(areaBorder);
this.m_1DView.setBackground(Color.WHITE); this.functionAre.setBackground(Color.WHITE);
this.m_ViewPanel.add(this.m_1DView, BorderLayout.CENTER); this.viewPanel.add(this.functionAre, BorderLayout.CENTER);
} }
this.plot1DFitnessPlot(); this.plot1DFitnessPlot();
} }
@ -418,23 +355,22 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
*/ */
public void plot1DFitnessPlot() { public void plot1DFitnessPlot() {
double xmin = 0, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY, fitness; double xmin = 0, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY, fitness;
Population[] pops = this.m_MOCCO.m_State.m_PopulationHistory; Population[] pops = this.moccoStandalone.state.populationHistory;
if ((pops == null) || (pops.length < 1)) { if ((pops == null) || (pops.length < 1)) {
return; return;
} }
GraphPointSet mySet; GraphPointSet mySet;
DPoint myPoint; DPoint myPoint;
DPointIcon icon; DPointIcon icon;
this.m_1DView.removeAll(); this.functionAre.removeAll();
mySet = new GraphPointSet(1, this.m_1DView); mySet = new GraphPointSet(1, this.functionAre);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
mySet.setColor(Color.BLACK); mySet.setColor(Color.BLACK);
for (int i = 0; i < pops.length; i++) { for (int i = 0; i < pops.length; i++) {
fitness = pops[i].getBestEAIndividual().getFitness()[0]; fitness = pops[i].getBestEAIndividual().getFitness()[0];
myPoint = new DPoint(i + 1, fitness); myPoint = new DPoint(i + 1, fitness);
icon = new Chart2DDPointContentSelectable(); icon = new Chart2DDPointContentSelectable();
//if (this.m_MOCCOViewer.m_RefSolutionSelectable) ((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_MOCCOViewer); ((InterfaceDPointWithContent) icon).setProblem(this.moccoStandalone.state.currentProblem);
((InterfaceDPointWithContent) icon).setProblem(this.m_MOCCO.m_State.m_CurrentProblem);
((InterfaceDPointWithContent) icon).setEAIndividual(pops[i].getBestEAIndividual()); ((InterfaceDPointWithContent) icon).setEAIndividual(pops[i].getBestEAIndividual());
myPoint.setIcon(icon); myPoint.setIcon(icon);
mySet.addDPoint(myPoint); mySet.addDPoint(myPoint);
@ -445,7 +381,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
ymax = fitness; ymax = fitness;
} }
} }
mySet = new GraphPointSet(2, this.m_1DView); mySet = new GraphPointSet(2, this.functionAre);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
double yrange = ymax - ymin; double yrange = ymax - ymin;
if (yrange < 0.00001) { if (yrange < 0.00001) {
@ -453,7 +389,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
} }
mySet.addDPoint(0, ymin - 0.1 * yrange); mySet.addDPoint(0, ymin - 0.1 * yrange);
mySet.addDPoint(pops.length + 2, ymax + 0.1 * yrange); mySet.addDPoint(pops.length + 2, ymax + 0.1 * yrange);
this.m_ViewPanel.validate(); this.viewPanel.validate();
} }
@ -472,14 +408,14 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
if (indy.isMarked()) { if (indy.isMarked()) {
indy.unmark(); indy.unmark();
} else { } else {
if (this.m_SelectUniqueSolution) { if (this.selectUniqueSolution) {
this.m_MOCCO.m_State.m_ParetoFront.unmarkAllIndividuals(); this.moccoStandalone.state.paretoFront.unmarkAllIndividuals();
} }
indy.mark(); indy.mark();
} }
this.m_View.updateView(); this.paretoFrontView.updateView();
if (this.m_RefSolutionListener != null) { if (this.refSolutionListener != null) {
this.m_RefSolutionListener.individualSelected(indy); this.refSolutionListener.individualSelected(indy);
} }
} }
@ -489,7 +425,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @param t * @param t
*/ */
public void setUniquelySelectable(boolean t) { public void setUniquelySelectable(boolean t) {
this.m_SelectUniqueSolution = t; this.selectUniqueSolution = t;
} }
/** /**
@ -498,8 +434,8 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @param t * @param t
*/ */
public void setRefSolutionSelectable(boolean t) { public void setRefSolutionSelectable(boolean t) {
this.m_RefSolutionSelectable = t; this.refSolutionSelectable = t;
this.m_View.updateView(); this.paretoFrontView.updateView();
} }
/** /**
@ -509,7 +445,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @param a The selection listener * @param a The selection listener
*/ */
public void addRefSolutionSelectionListener(InterfaceRefSolutionListener a) { public void addRefSolutionSelectionListener(InterfaceRefSolutionListener a) {
this.m_RefSolutionListener = a; this.refSolutionListener = a;
} }
/** /**
@ -518,14 +454,14 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @return InterfaceSelectionListener * @return InterfaceSelectionListener
*/ */
public InterfaceRefSolutionListener getRefSolutionSelectionListener() { public InterfaceRefSolutionListener getRefSolutionSelectionListener() {
return this.m_RefSolutionListener; return this.refSolutionListener;
} }
/** /**
* This method allows to remove the selection listner to the PointIcon * This method allows to remove the selection listner to the PointIcon
*/ */
public void removeRefSolutionSelectionListeners() { public void removeRefSolutionSelectionListeners() {
this.m_RefSolutionListener = null; this.refSolutionListener = null;
} }
/*************************************************************************** /***************************************************************************
@ -539,11 +475,11 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
*/ */
@Override @Override
public void refPointGiven(double[] point) { public void refPointGiven(double[] point) {
this.m_ReferencePoint = point; this.referencePoint = point;
if (this.m_RefPointListener != null) { if (this.refPointListener != null) {
this.m_RefPointListener.refPointGiven(point); this.refPointListener.refPointGiven(point);
} }
this.m_View.updateView(); this.paretoFrontView.updateView();
} }
/** /**
@ -552,24 +488,24 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @param t * @param t
*/ */
public void setRefPointSelectable(boolean t) { public void setRefPointSelectable(boolean t) {
this.m_RefPointSelectable = t; this.refPointSelectable = t;
if (this.m_RefPointSelectable) { if (this.refPointSelectable) {
int dim = ((AbstractEAIndividual) this.m_MOCCO.m_State.m_ParetoFront.get(0)).getFitness().length; int dim = ((AbstractEAIndividual) this.moccoStandalone.state.paretoFront.get(0)).getFitness().length;
this.m_ReferencePoint = new double[dim]; this.referencePoint = new double[dim];
for (int i = 0; i < dim; i++) { for (int i = 0; i < dim; i++) {
this.m_ReferencePoint[i] = 0; this.referencePoint[i] = 0;
} }
} else { } else {
//this.m_ReferencePoint = null; //this.referencePoint = null;
} }
this.m_View.updateView(); this.paretoFrontView.updateView();
} }
/** /**
* This method removes the reference point * This method removes the reference point
*/ */
public void removeReferencePoint() { public void removeReferencePoint() {
this.m_ReferencePoint = null; this.referencePoint = null;
} }
/** /**
@ -579,7 +515,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @param a The selection listener * @param a The selection listener
*/ */
public void addRefPointSelectionListener(InterfaceRefPointListener a) { public void addRefPointSelectionListener(InterfaceRefPointListener a) {
this.m_RefPointListener = a; this.refPointListener = a;
} }
/** /**
@ -588,131 +524,14 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
* @return InterfaceSelectionListener * @return InterfaceSelectionListener
*/ */
public InterfaceRefPointListener getRefPointSelectionListener() { public InterfaceRefPointListener getRefPointSelectionListener() {
return this.m_RefPointListener; return this.refPointListener;
} }
/** /**
* This method allows to remove the selection listner to the PointIcon * This method allows to remove the selection listner to the PointIcon
*/ */
public void removeRefPointSelectionListeners() { public void removeRefPointSelectionListeners() {
this.m_RefPointListener = null; this.refPointListener = null;
this.m_View.updateView(); this.paretoFrontView.updateView();
} }
// private void updateHistory() {
// this.m_History.removeAll();
// this.m_History.setLayout(new GridBagLayout());
// this.m_JLIternations = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
// this.m_JLIterSize = new JLabel[this.m_MOCCO.m_State.m_PopulationHistory.length];
// this.m_JCUse = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
// this.m_JCShow = new JCheckBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
// this.m_JColor = new JComboBox[this.m_MOCCO.m_State.m_PopulationHistory.length];
// GridBagConstraints gbc = new GridBagConstraints();
// gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = GridBagConstraints.BOTH;
// gbc.gridx = 0;
// gbc.gridy = 0;
// gbc.weightx = 1;
// this.m_History.add(new JLabel("Iteration"), gbc);
// gbc.gridx = 1;
// gbc.gridy = 0;
// this.m_History.add(new JLabel("Size"), gbc);
// gbc.gridx = 2;
// gbc.gridy = 0;
// this.m_History.add(new JLabel("Use"), gbc);
// gbc.gridx = 3;
// gbc.gridy = 0;
// this.m_History.add(new JLabel("Show"), gbc);
// gbc.gridx = 4;
// gbc.gridy = 0;
// this.m_History.add(new JLabel("Color"), gbc);
// for (int i = 0; i < this.m_MOCCO.m_State.m_PopulationHistory.length; i++) {
// gbc.gridx = 0;
// gbc.gridy = i+1;
// this.m_History.add(new JLabel((i+0)+"."), gbc);
// gbc.gridx = 1;
// gbc.gridy = i+1;
// this.m_History.add(new JLabel(this.m_MOCCO.m_State.m_PopulationHistory[i].size()+""), gbc);
// gbc.gridx = 2;
// gbc.gridy = i+1;
// this.m_JCUse[i] = new JCheckBox();
// this.m_JCUse[i].setSelected(this.m_MOCCO.m_State.m_Use[i]);
// this.m_JCUse[i].addActionListener(useModeChanged);
// this.m_History.add(this.m_JCUse[i], gbc);
// gbc.gridx = 3;
// gbc.gridy = i+1;
// this.m_JCShow[i] = new JCheckBox();
// this.m_JCShow[i].setSelected(this.m_MOCCO.m_State.show[i]);
// this.m_JCShow[i].addActionListener(showModeChanged);
// this.m_History.add(this.m_JCShow[i], gbc);
// gbc.gridx = 4;
// gbc.gridy = i+1;
// this.m_JColor[i] = this.getComboBox(i);
// this.m_JColor[i].addActionListener(colorModeChanged);
// this.m_History.add(this.m_JColor[i], gbc);
// }
// }
//
// ActionListener useModeChanged = new ActionListener() {
// public void actionPerformed(ActionEvent event) {
// for (int i = 0; i < m_JCUse.length; i++) {
// m_MOCCO.m_State.m_Use[i] = m_JCUse[i].isSelected();
// }
// }
// };
// ActionListener showModeChanged = new ActionListener() {
// public void actionPerformed(ActionEvent event) {
// for (int i = 0; i < m_JCShow.length; i++) {
// m_MOCCO.m_State.show[i] = m_JCShow[i].isSelected();
// }
// view.updateView();
// }
// };
// ActionListener colorModeChanged = new ActionListener() {
// public void actionPerformed(ActionEvent event) {
// for (int i = 0; i < m_JColor.length; i++) {
// m_MOCCO.m_State.m_Color[i] = getColor(m_JColor[i].getSelectedIndex());
// }
// view.updateView();
// }
// };
//
// private JComboBox getComboBox(int index) {
// String[] colors = {"RED", "BLUE", "GREEN", "CYAN", "MAGENTA", "ORANGE"};
// JComboBox result;
// result = new JComboBox(colors);
// int color = 0;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.RED) color = 0;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.BLUE) color = 1;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.GREEN) color = 2;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.CYAN) color = 3;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.MAGENTA) color = 4;
// if (this.m_MOCCO.m_State.m_Color[index] == Color.ORANGE) color = 5;
// result.setSelectedIndex(color);
// return result;
// }
// public Color getColor(int i) {
// switch (i) {
// case 0 : {
// return Color.RED;
// }
// case 1 : {
// return Color.BLUE;
// }
// case 2 : {
// return Color.GREEN;
// }
// case 3 : {
// return Color.CYAN;
// }
// case 4 : {
// return Color.MAGENTA;
// }
// case 5 : {
// return Color.ORANGE;
// }
// }
// return Color.BLACK;
// }
} }

View File

@ -1,6 +1,5 @@
package eva2.optimization.mocco.paretofrontviewer; package eva2.optimization.mocco.paretofrontviewer;
import eva2.gui.plot.FunctionArea; import eva2.gui.plot.FunctionArea;
import eva2.gui.plot.GraphPointSet; import eva2.gui.plot.GraphPointSet;
import eva2.gui.plot.InterfaceDPointWithContent; import eva2.gui.plot.InterfaceDPointWithContent;
@ -16,68 +15,63 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 04.11.2005
* Time: 11:16:11
* To change this template use File | Settings | File Templates.
*/ */
public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontView, InterfaceRefPointListener { public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontView, InterfaceRefPointListener {
public MOCCOViewer m_MOCCOViewer; public MOCCOViewer moccoViewer;
private JPanel m_JPMain; private JPanel mainPanel;
private JPanel m_JPTop; private JPanel topPanel;
private JComboBox m_JCObjective1, m_JCObjective2, m_JCFitObj; private JComboBox objective1, objective2, fitObjective;
private FunctionArea m_Area; private FunctionArea functionArea;
private ScaledBorder m_AreaBorder; private ScaledBorder areaBorder;
private InterfaceRefPointListener m_RefPointListener; private InterfaceRefPointListener refPointListener;
public ParetoFrontView2D(MOCCOViewer t) { public ParetoFrontView2D(MOCCOViewer t) {
this.m_MOCCOViewer = t; this.moccoViewer = t;
this.init(); this.init();
} }
private void init() { private void init() {
this.m_JPMain = new JPanel(); this.mainPanel = new JPanel();
this.m_JPMain.setLayout(new BorderLayout()); this.mainPanel.setLayout(new BorderLayout());
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(this.m_JPMain, BorderLayout.CENTER); this.add(this.mainPanel, BorderLayout.CENTER);
this.m_Area = new FunctionArea("?", "?"); this.functionArea = new FunctionArea("?", "?");
this.m_Area.setPreferredSize(new Dimension(450, 450)); this.functionArea.setPreferredSize(new Dimension(450, 450));
this.m_Area.setMinimumSize(new Dimension(450, 450)); this.functionArea.setMinimumSize(new Dimension(450, 450));
this.m_AreaBorder = new ScaledBorder(); this.areaBorder = new ScaledBorder();
this.m_AreaBorder.x_label = "?"; this.areaBorder.xLabel = "?";
this.m_AreaBorder.y_label = "?"; this.areaBorder.yLabel = "?";
this.m_Area.setBorder(this.m_AreaBorder); this.functionArea.setBorder(this.areaBorder);
this.m_Area.setBackground(Color.WHITE); this.functionArea.setBackground(Color.WHITE);
this.m_JPMain.add(this.m_Area, BorderLayout.CENTER); this.mainPanel.add(this.functionArea, BorderLayout.CENTER);
this.m_JPTop = new JPanel(); this.topPanel = new JPanel();
this.m_JPTop.setLayout(new GridLayout(1, 5)); this.topPanel.setLayout(new GridLayout(1, 5));
String[] tmp = new String[2]; String[] tmp = new String[2];
tmp[0] = "Fitness"; tmp[0] = "Fitness";
tmp[1] = "Objective"; tmp[1] = "Objective";
this.m_JCFitObj = new JComboBox(tmp); this.fitObjective = new JComboBox(tmp);
this.m_JCFitObj.setSelectedIndex(0); this.fitObjective.setSelectedIndex(0);
this.m_JCFitObj.addActionListener(this.jcombobox2Listener); this.fitObjective.addActionListener(this.jcombobox2Listener);
this.m_JCObjective1 = new JComboBox(this.getAvailableObjectiveNames()); this.objective1 = new JComboBox(this.getAvailableObjectiveNames());
this.m_JCObjective1.setSelectedIndex(0); this.objective1.setSelectedIndex(0);
this.m_JCObjective1.addActionListener(this.jcomboboxListener); this.objective1.addActionListener(this.jcomboboxListener);
this.m_JPTop.add(this.m_JCObjective1); this.topPanel.add(this.objective1);
this.m_JPTop.add(new JLabel(" vs ")); this.topPanel.add(new JLabel(" vs "));
this.m_JCObjective2 = new JComboBox(this.getAvailableObjectiveNames()); this.objective2 = new JComboBox(this.getAvailableObjectiveNames());
try { try {
this.m_JCObjective2.setSelectedIndex(1); this.objective2.setSelectedIndex(1);
} catch (java.lang.IllegalArgumentException a) { } catch (java.lang.IllegalArgumentException a) {
// there seems to be no alternative // there seems to be no alternative
} }
this.m_JCObjective2.addActionListener(this.jcomboboxListener); this.objective2.addActionListener(this.jcomboboxListener);
this.m_JPTop.add(this.m_JCObjective2); this.topPanel.add(this.objective2);
this.m_JPTop.add(new JLabel(" using:")); this.topPanel.add(new JLabel(" using:"));
this.m_JPTop.add(this.m_JCFitObj); this.topPanel.add(this.fitObjective);
this.m_JPMain.add(this.m_JPTop, BorderLayout.NORTH); this.mainPanel.add(this.topPanel, BorderLayout.NORTH);
this.updateView(); this.updateView();
} }
@ -96,39 +90,39 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
}; };
public void updateObjectiveComboBoxes() { public void updateObjectiveComboBoxes() {
m_JCObjective1.removeActionListener(jcomboboxListener); objective1.removeActionListener(jcomboboxListener);
m_JCObjective2.removeActionListener(jcomboboxListener); objective2.removeActionListener(jcomboboxListener);
m_JCObjective1.removeAllItems(); objective1.removeAllItems();
String[] tmpS = getAvailableObjectiveNames(); String[] tmpS = getAvailableObjectiveNames();
for (int i = 0; i < tmpS.length; i++) { for (int i = 0; i < tmpS.length; i++) {
m_JCObjective1.addItem(tmpS[i]); objective1.addItem(tmpS[i]);
} }
m_JCObjective1.setSelectedIndex(0); objective1.setSelectedIndex(0);
m_JCObjective2.removeAllItems(); objective2.removeAllItems();
tmpS = getAvailableObjectiveNames(); tmpS = getAvailableObjectiveNames();
for (int i = 0; i < tmpS.length; i++) { for (int i = 0; i < tmpS.length; i++) {
m_JCObjective2.addItem(tmpS[i]); objective2.addItem(tmpS[i]);
} }
m_JCObjective2.setSelectedIndex(1); objective2.setSelectedIndex(1);
m_JCObjective1.addActionListener(jcomboboxListener); objective1.addActionListener(jcomboboxListener);
m_JCObjective2.addActionListener(jcomboboxListener); objective2.addActionListener(jcomboboxListener);
updateView(); updateView();
} }
private String[] getAvailableObjectiveNames() { private String[] getAvailableObjectiveNames() {
String[] result = null; String[] result = null;
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem == null) { if (this.moccoViewer.moccoStandalone.state.currentProblem == null) {
result = new String[1]; result = new String[1];
result[0] = "none"; result[0] = "none";
return result; return result;
} }
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) { if (this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
result = new String[tmp.length]; result = new String[tmp.length];
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
result[i] = tmp[i].getIdentName(); result[i] = tmp[i].getIdentName();
} }
if (this.m_JCFitObj.getSelectedIndex() == 0) { if (this.fitObjective.getSelectedIndex() == 0) {
// in this case constraints have to be omitted // in this case constraints have to be omitted
ArrayList tmpList = new ArrayList(); ArrayList tmpList = new ArrayList();
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
@ -154,28 +148,28 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
public void updateView() { public void updateView() {
// i assume that all the populations are evaluated // i assume that all the populations are evaluated
// all using the same problem // all using the same problem
this.m_Area.removeAll(); this.functionArea.removeAll();
// first set the names of the objectives // first set the names of the objectives
String[] tmpS = this.getAvailableObjectiveNames(); String[] tmpS = this.getAvailableObjectiveNames();
if (tmpS.length != this.m_JCObjective1.getItemCount()) { if (tmpS.length != this.objective1.getItemCount()) {
updateObjectiveComboBoxes(); updateObjectiveComboBoxes();
} }
boolean equal = true; boolean equal = true;
for (int i = 0; i < tmpS.length; i++) { for (int i = 0; i < tmpS.length; i++) {
if (!tmpS[i].equalsIgnoreCase((String) this.m_JCObjective1.getItemAt(i))) { if (!tmpS[i].equalsIgnoreCase((String) this.objective1.getItemAt(i))) {
equal = false; equal = false;
} }
} }
if (!equal) { if (!equal) {
updateObjectiveComboBoxes(); updateObjectiveComboBoxes();
} }
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) { if (this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
//InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); //InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
String[] objectives = this.getAvailableObjectiveNames(); String[] objectives = this.getAvailableObjectiveNames();
this.m_AreaBorder.x_label = "" + objectives[this.m_JCObjective1.getSelectedIndex()]; this.areaBorder.xLabel = "" + objectives[this.objective1.getSelectedIndex()];
this.m_AreaBorder.y_label = "" + objectives[this.m_JCObjective2.getSelectedIndex()]; this.areaBorder.yLabel = "" + objectives[this.objective2.getSelectedIndex()];
} }
if ((this.m_MOCCOViewer.m_MOCCO.m_State.m_ParetoFront != null) && (this.m_MOCCOViewer.m_MOCCO.m_State.m_ParetoFront.size() > 0)) { if ((this.moccoViewer.moccoStandalone.state.paretoFront != null) && (this.moccoViewer.moccoStandalone.state.paretoFront.size() > 0)) {
this.plot2DParetoFront(); this.plot2DParetoFront();
} }
this.validate(); this.validate();
@ -186,28 +180,27 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
*/ */
public void plot2DParetoFront() { public void plot2DParetoFront() {
double xmin = Double.POSITIVE_INFINITY, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY; double xmin = Double.POSITIVE_INFINITY, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY;
this.m_Area.clearAll(); this.functionArea.clearAll();
this.m_Area.setBackground(Color.WHITE); this.functionArea.setBackground(Color.WHITE);
GraphPointSet mySet; GraphPointSet mySet;
DPoint myPoint; DPoint myPoint;
double[] fitness; double[] fitness;
int indexX, indexY; int indexX, indexY;
indexX = this.m_JCObjective1.getSelectedIndex(); indexX = this.objective1.getSelectedIndex();
indexY = this.m_JCObjective2.getSelectedIndex(); indexY = this.objective2.getSelectedIndex();
// first plot the populations // first plot the populations
if (false) { if (false) {
for (int i = 0; i < this.m_MOCCOViewer.m_MOCCO.m_State.m_PopulationHistory.length; i++) { for (int i = 0; i < this.moccoViewer.moccoStandalone.state.populationHistory.length; i++) {
//System.out.println("Population " + i+" show " +this.m_MOCCOViewer.m_MOCCO.m_State.show[i]); //System.out.println("Population " + i+" show " +this.moccoViewer.moccoStandalone.state.show[i]);
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_Show[i]) { if (this.moccoViewer.moccoStandalone.state.show[i]) {
mySet = new GraphPointSet(i + 10, this.m_Area); mySet = new GraphPointSet(i + 10, this.functionArea);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
mySet.setColor(this.m_MOCCOViewer.m_MOCCO.m_State.m_Color[i]); mySet.setColor(this.moccoViewer.moccoStandalone.state.colors[i]);
//System.out.println(((ArrayList)this.m_Boss.m_FitnessCache.get(i)).size()+"/"+((ArrayList)this.m_Boss.m_ObjectiveCache.get(i)).size()); if (this.fitObjective.getSelectedIndex() == 0) {
if (this.m_JCFitObj.getSelectedIndex() == 0) { for (int j = 0; j < ((ArrayList) this.moccoViewer.moccoStandalone.state.fitnessCache.get(i)).size(); j++) {
for (int j = 0; j < ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).size(); j++) { fitness = (double[]) ((ArrayList) this.moccoViewer.moccoStandalone.state.fitnessCache.get(i)).get(j);
fitness = (double[]) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).get(j);
myPoint = new DPoint(fitness[indexX], fitness[indexY]); myPoint = new DPoint(fitness[indexX], fitness[indexY]);
if (((Double) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0) { if (((Double) ((ArrayList) this.moccoViewer.moccoStandalone.state.constraintCache.get(i)).get(j)).doubleValue() == 0) {
myPoint.setIcon(new Chart2DDPointIconCross()); myPoint.setIcon(new Chart2DDPointIconCross());
} else { } else {
myPoint.setIcon(new Chart2DDPointIconPoint()); myPoint.setIcon(new Chart2DDPointIconPoint());
@ -227,10 +220,10 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
} }
} else { } else {
for (int j = 0; j < ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).size(); j++) { for (int j = 0; j < ((ArrayList) this.moccoViewer.moccoStandalone.state.objectiveCache.get(i)).size(); j++) {
fitness = (double[]) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).get(j); fitness = (double[]) ((ArrayList) this.moccoViewer.moccoStandalone.state.objectiveCache.get(i)).get(j);
myPoint = new DPoint(fitness[indexX], fitness[indexY]); myPoint = new DPoint(fitness[indexX], fitness[indexY]);
if (((Double) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0) { if (((Double) ((ArrayList) this.moccoViewer.moccoStandalone.state.constraintCache.get(i)).get(j)).doubleValue() == 0) {
myPoint.setIcon(new Chart2DDPointIconCross()); myPoint.setIcon(new Chart2DDPointIconCross());
} else { } else {
myPoint.setIcon(new Chart2DDPointIconPoint()); myPoint.setIcon(new Chart2DDPointIconPoint());
@ -254,18 +247,18 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
} }
// now mark the ParetoFront // now mark the ParetoFront
Population pf = this.m_MOCCOViewer.m_MOCCO.m_State.m_ParetoFront; Population pf = this.moccoViewer.moccoStandalone.state.paretoFront;
if (pf.size() > 0) { if (pf.size() > 0) {
DPoint point; DPoint point;
DPointIcon icon; DPointIcon icon;
mySet = new GraphPointSet(1, this.m_Area); mySet = new GraphPointSet(1, this.functionArea);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
mySet.setColor(Color.BLACK); mySet.setColor(Color.BLACK);
for (int i = 0; i < pf.size(); i++) { for (int i = 0; i < pf.size(); i++) {
if (this.m_JCFitObj.getSelectedIndex() == 0) { if (this.fitObjective.getSelectedIndex() == 0) {
fitness = ((AbstractEAIndividual) pf.get(i)).getFitness(); fitness = ((AbstractEAIndividual) pf.get(i)).getFitness();
} else { } else {
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
fitness = new double[tmpObj.length]; fitness = new double[tmpObj.length];
for (int k = 0; k < tmpObj.length; k++) { for (int k = 0; k < tmpObj.length; k++) {
fitness[k] = ((Double) ((AbstractEAIndividual) pf.get(i)).getData(tmpObj[k].getIdentName())).doubleValue(); fitness[k] = ((Double) ((AbstractEAIndividual) pf.get(i)).getData(tmpObj[k].getIdentName())).doubleValue();
@ -273,10 +266,10 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
point = new DPoint(fitness[indexX], fitness[indexY]); point = new DPoint(fitness[indexX], fitness[indexY]);
icon = new Chart2DDPointContentSelectable(); icon = new Chart2DDPointContentSelectable();
if (this.m_MOCCOViewer.m_RefSolutionSelectable) { if (this.moccoViewer.refSolutionSelectable) {
((Chart2DDPointContentSelectable) icon).addSelectionListener(this.m_MOCCOViewer); ((Chart2DDPointContentSelectable) icon).addSelectionListener(this.moccoViewer);
} }
((InterfaceDPointWithContent) icon).setProblem(this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem); ((InterfaceDPointWithContent) icon).setProblem(this.moccoViewer.moccoStandalone.state.currentProblem);
((InterfaceDPointWithContent) icon).setEAIndividual((AbstractEAIndividual) pf.get(i)); ((InterfaceDPointWithContent) icon).setEAIndividual((AbstractEAIndividual) pf.get(i));
point.setIcon(icon); point.setIcon(icon);
mySet.addDPoint(point); mySet.addDPoint(point);
@ -295,7 +288,7 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
} }
mySet = new GraphPointSet(0, this.m_Area); mySet = new GraphPointSet(0, this.functionArea);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
double xrange = (xmax - xmin), yrange = (ymax - ymin); double xrange = (xmax - xmin), yrange = (ymax - ymin);
if ((new Double(xrange)).isNaN()) { if ((new Double(xrange)).isNaN()) {
@ -309,19 +302,19 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
// now lets prepare the contraints or goals if any... // now lets prepare the contraints or goals if any...
if ((this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) && if ((this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
(this.m_JCFitObj.getSelectedIndex() == 1)) { (this.fitObjective.getSelectedIndex() == 1)) {
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
if ((!(tmp[i].getOptimizationMode().equalsIgnoreCase("Objective"))) && if ((!(tmp[i].getOptimizationMode().equalsIgnoreCase("Objective"))) &&
((this.m_JCObjective1.getSelectedIndex() == i) || ((this.objective1.getSelectedIndex() == i) ||
(this.m_JCObjective2.getSelectedIndex() == i))) { (this.objective2.getSelectedIndex() == i))) {
double tmpD = tmp[i].getConstraintGoal(); double tmpD = tmp[i].getConstraintGoal();
if (!(new Double(tmpD)).isNaN()) { if (!(new Double(tmpD)).isNaN()) {
// draw a line indicating the constraint/goals // draw a line indicating the constraint/goals
mySet = new GraphPointSet(500 + i, this.m_Area); mySet = new GraphPointSet(500 + i, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
if (this.m_JCObjective1.getSelectedIndex() == i) { if (this.objective1.getSelectedIndex() == i) {
if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) { if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) {
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
@ -342,29 +335,29 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
} }
// lets prepare to reference point selection // lets prepare to reference point selection
if (this.m_MOCCOViewer.m_RefPointSelectable) { if (this.moccoViewer.refPointSelectable) {
this.m_Area.addRefPointSelectionListener(this); this.functionArea.addRefPointSelectionListener(this);
} else { } else {
this.m_Area.removeRefPointSelectionListeners(); this.functionArea.removeRefPointSelectionListeners();
this.removeRefPointSelectionListeners(); this.removeRefPointSelectionListeners();
} }
// lets show a reference point if given... // lets show a reference point if given...
if ((this.m_MOCCOViewer.m_ReferencePoint != null) && (this.m_JCFitObj.getSelectedIndex() == 0)) { if ((this.moccoViewer.referencePoint != null) && (this.fitObjective.getSelectedIndex() == 0)) {
mySet = new GraphPointSet(1001, this.m_Area); mySet = new GraphPointSet(1001, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
mySet.setColor(Color.RED); mySet.setColor(Color.RED);
double tmpD = this.m_MOCCOViewer.m_ReferencePoint[this.m_JCObjective1.getSelectedIndex()]; double tmpD = this.moccoViewer.referencePoint[this.objective1.getSelectedIndex()];
if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) { if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) {
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
mySet.addDPoint(tmpD, ymax + 0.1 * yrange); mySet.addDPoint(tmpD, ymax + 0.1 * yrange);
mySet.addDPoint(tmpD, ymax + 0.1 * yrange); mySet.addDPoint(tmpD, ymax + 0.1 * yrange);
} }
mySet = new GraphPointSet(1002, this.m_Area); mySet = new GraphPointSet(1002, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
mySet.setColor(Color.RED); mySet.setColor(Color.RED);
tmpD = this.m_MOCCOViewer.m_ReferencePoint[this.m_JCObjective2.getSelectedIndex()]; tmpD = this.moccoViewer.referencePoint[this.objective2.getSelectedIndex()];
if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) { if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) {
mySet.addDPoint(xmin - 0.1 * xrange, tmpD); mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
mySet.addDPoint(xmin - 0.1 * xrange, tmpD); mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
@ -387,15 +380,15 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
*/ */
@Override @Override
public void refPointGiven(double[] point) { public void refPointGiven(double[] point) {
if (this.m_JCFitObj.getSelectedIndex() == 1) { if (this.fitObjective.getSelectedIndex() == 1) {
JOptionPane.showMessageDialog(this.m_MOCCOViewer.m_MOCCO.m_JFrame, JOptionPane.showMessageDialog(this.moccoViewer.moccoStandalone.getMainFrame(),
"Reference point needs to be selected in fitness space!", "Reference point needs to be selected in fitness space!",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
} else { } else {
double[] tmpD = this.m_MOCCOViewer.m_ReferencePoint; double[] tmpD = this.moccoViewer.referencePoint;
tmpD[this.m_JCObjective1.getSelectedIndex()] = point[0]; tmpD[this.objective1.getSelectedIndex()] = point[0];
tmpD[this.m_JCObjective2.getSelectedIndex()] = point[1]; tmpD[this.objective2.getSelectedIndex()] = point[1];
this.m_MOCCOViewer.refPointGiven(tmpD); this.moccoViewer.refPointGiven(tmpD);
} }
} }
@ -406,7 +399,7 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
* @param a The selection listener * @param a The selection listener
*/ */
public void addRefPointSelectionListener(InterfaceRefPointListener a) { public void addRefPointSelectionListener(InterfaceRefPointListener a) {
this.m_RefPointListener = a; this.refPointListener = a;
} }
/** /**
@ -415,13 +408,13 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
* @return InterfaceSelectionListener * @return InterfaceSelectionListener
*/ */
public InterfaceRefPointListener getRefPointSelectionListener() { public InterfaceRefPointListener getRefPointSelectionListener() {
return this.m_RefPointListener; return this.refPointListener;
} }
/** /**
* This method allows to remove the selection listner to the PointIcon * This method allows to remove the selection listner to the PointIcon
*/ */
public void removeRefPointSelectionListeners() { public void removeRefPointSelectionListeners() {
this.m_RefPointListener = null; this.refPointListener = null;
} }
} }

View File

@ -0,0 +1,25 @@
package eva2.optimization.mocco.paretofrontviewer;
import javax.swing.*;
/**
*
*/
public class ParetoFrontViewParallelAxis extends JPanel implements InterfaceParetoFrontView {
public MOCCOViewer moccoViewer;
public ParetoFrontViewParallelAxis(MOCCOViewer t) {
this.moccoViewer = t;
}
/**
* This method notifies the Pareto front view that
* the data has changed most likely due to changes in
* the problem definition
*/
@Override
public void updateView() {
}
}

View File

@ -1,29 +0,0 @@
package eva2.optimization.mocco.paretofrontviewer;
import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 04.11.2005
* Time: 11:16:48
* To change this template use File | Settings | File Templates.
*/
public class ParetoFrontViewParallelAxsis extends JPanel implements InterfaceParetoFrontView {
public MOCCOViewer m_MOCCOViewer;
public ParetoFrontViewParallelAxsis(MOCCOViewer t) {
this.m_MOCCOViewer = t;
}
/**
* This method notifies the Pareto front view that
* the data has changed most likely due to changes in
* the problem definition
*/
@Override
public void updateView() {
}
}

View File

@ -19,101 +19,97 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by IntelliJ IDEA. *
* User: streiche
* Date: 04.11.2005
* Time: 11:16:30
* To change this template use File | Settings | File Templates.
*/ */
class SimpleView extends JComponent implements InterfaceRefPointListener { class SimpleView extends JComponent implements InterfaceRefPointListener {
private InterfaceRefPointListener m_RefPointListener; private InterfaceRefPointListener refPointListener;
private FunctionArea m_Area = null; private FunctionArea functionArea = null;
private ScaledBorder m_AreaBorder; private ScaledBorder areaBorder;
ParetoFrontViewScatterPlot m_Dad; ParetoFrontViewScatterPlot paretoFrontViewScatterPlot;
int m_Obj1, m_Obj2; int object1, object2;
JLabel m_JLabel; JLabel label;
public SimpleView(ParetoFrontViewScatterPlot dad, int obj1, int obj2) { public SimpleView(ParetoFrontViewScatterPlot dad, int obj1, int obj2) {
this.m_Dad = dad; this.paretoFrontViewScatterPlot = dad;
this.m_Obj1 = obj1; this.object1 = obj1;
this.m_Obj2 = obj2; this.object2 = obj2;
this.init(); this.init();
} }
private void init() { private void init() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
if (this.m_Obj1 == this.m_Obj2) { if (this.object1 == this.object2) {
this.m_JLabel = new JLabel("" + ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj1].getIdentName()); this.label = new JLabel("" + ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName());
this.add(this.m_JLabel, BorderLayout.CENTER); this.add(this.label, BorderLayout.CENTER);
} else { } else {
this.m_Area = new FunctionArea("?", "?"); this.functionArea = new FunctionArea("?", "?");
this.m_Area.setPreferredSize(new Dimension(200, 200)); this.functionArea.setPreferredSize(new Dimension(200, 200));
this.m_Area.setMinimumSize(new Dimension(200, 200)); this.functionArea.setMinimumSize(new Dimension(200, 200));
this.m_AreaBorder = new ScaledBorder(); this.areaBorder = new ScaledBorder();
this.m_AreaBorder.x_label = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj1].getIdentName(); this.areaBorder.xLabel = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName();
this.m_AreaBorder.y_label = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj2].getIdentName(); this.areaBorder.yLabel = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object2].getIdentName();
this.m_Area.setBorder(this.m_AreaBorder); this.functionArea.setBorder(this.areaBorder);
this.m_Area.setBackground(Color.WHITE); this.functionArea.setBackground(Color.WHITE);
this.add(this.m_Area, BorderLayout.CENTER); this.add(this.functionArea, BorderLayout.CENTER);
} }
} }
private double[] fetchPlotValueFor(AbstractEAIndividual indy) { private double[] fetchPlotValueFor(AbstractEAIndividual indy) {
double[] result = new double[2]; double[] result = new double[2];
if (this.m_Dad.m_JCFitObj.getSelectedIndex() == 0) { if (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 0) {
// now this is tricky isn't // now this is tricky isn't
// first findout whether a objective is constraint only // first findout whether a objective is constraint only
// and second since some objectives are ommited find the one fitness value that is the correct one // and second since some objectives are ommited find the one fitness value that is the correct one
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
if (tmpObj[this.m_Obj1].getOptimizationMode().equalsIgnoreCase("Constraint")) { if (tmpObj[this.object1].getOptimizationMode().equalsIgnoreCase("Constraint")) {
result[0] = 0; result[0] = 0;
} else { } else {
int index = 0; int index = 0;
for (int i = 0; i < this.m_Obj1; i++) { for (int i = 0; i < this.object1; i++) {
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) { if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) {
index++; index++;
} }
} }
// System.out.println("obj 1 is accessing fitness of " + tmpObj[this.m_Obj1].getIdentName() + " using " +index); // System.out.println("obj 1 is accessing fitness of " + tmpObj[this.object1].getIdentName() + " using " +index);
// System.out.println(" fitness.length = " + indy.getFitness().length); // System.out.println(" fitness.length = " + indy.getFitness().length);
result[0] = indy.getFitness(index); result[0] = indy.getFitness(index);
} }
if (tmpObj[this.m_Obj2].getOptimizationMode().equalsIgnoreCase("Constraint")) { if (tmpObj[this.object2].getOptimizationMode().equalsIgnoreCase("Constraint")) {
result[1] = 0; result[1] = 0;
} else { } else {
int index = 0; int index = 0;
for (int i = 0; i < this.m_Obj2; i++) { for (int i = 0; i < this.object2; i++) {
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) { if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) {
index++; index++;
} }
} }
// System.out.println("obj 2 is accessing fitness of " + tmpObj[this.m_Obj2].getIdentName() + " using " +index); // System.out.println("obj 2 is accessing fitness of " + tmpObj[this.object2].getIdentName() + " using " +index);
// System.out.println(" fitness.length = " + indy.getFitness().length); // System.out.println(" fitness.length = " + indy.getFitness().length);
result[1] = indy.getFitness(index); result[1] = indy.getFitness(index);
} }
} else { } else {
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
result[0] = ((Double) indy.getData(tmpObj[this.m_Obj1].getIdentName())).doubleValue(); result[0] = ((Double) indy.getData(tmpObj[this.object1].getIdentName())).doubleValue();
result[1] = ((Double) indy.getData(tmpObj[this.m_Obj2].getIdentName())).doubleValue(); result[1] = ((Double) indy.getData(tmpObj[this.object2].getIdentName())).doubleValue();
} }
return result; return result;
} }
public void updateView() { public void updateView() {
// InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem)this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); // InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem)this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
// System.out.println("Plotting ("+this.m_Obj1+"/"+this.m_Obj2+") of " + tmpObj.length +" objectives."); // System.out.println("Plotting ("+this.object1+"/"+this.object2+") of " + tmpObj.length +" objectives.");
// System.out.println(" ("+tmpObj[this.m_Obj1].getIdentName()+"/"+tmpObj[this.m_Obj2].getIdentName()+") which is of mode: ("+tmpObj[this.m_Obj1].getOptimizationMode()+"/"+tmpObj[this.m_Obj2].getOptimizationMode()+")"); // System.out.println(" ("+tmpObj[this.object1].getIdentName()+"/"+tmpObj[this.object2].getIdentName()+") which is of mode: ("+tmpObj[this.object1].getOptimizationMode()+"/"+tmpObj[this.object2].getOptimizationMode()+")");
if (this.m_Obj1 == this.m_Obj2) { if (this.object1 == this.object2) {
this.m_JLabel.setText("" + ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj1].getIdentName()); this.label.setText("" + ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName());
} else { } else {
// plot the objectives // plot the objectives
Population pf = this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_ParetoFront; Population pf = this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.paretoFront;
double xmin = Double.POSITIVE_INFINITY, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY; double xmin = Double.POSITIVE_INFINITY, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY;
this.m_Area.clearAll(); this.functionArea.clearAll();
this.m_Area.setBackground(Color.WHITE); this.functionArea.setBackground(Color.WHITE);
GraphPointSet mySet; GraphPointSet mySet;
DPoint myPoint; DPoint myPoint;
//double[] fitness; //double[] fitness;
@ -123,17 +119,17 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
if (pf.size() > 0) { if (pf.size() > 0) {
DPoint point; DPoint point;
DPointIcon icon; DPointIcon icon;
mySet = new GraphPointSet(1, this.m_Area); mySet = new GraphPointSet(1, this.functionArea);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
mySet.setColor(Color.BLACK); mySet.setColor(Color.BLACK);
for (int i = 0; i < pf.size(); i++) { for (int i = 0; i < pf.size(); i++) {
plotValue = this.fetchPlotValueFor((AbstractEAIndividual) pf.get(i)); plotValue = this.fetchPlotValueFor((AbstractEAIndividual) pf.get(i));
point = new DPoint(plotValue[0], plotValue[1]); point = new DPoint(plotValue[0], plotValue[1]);
icon = new Chart2DDPointContentSelectable(); icon = new Chart2DDPointContentSelectable();
if (this.m_Dad.m_MOCCOViewer.m_RefSolutionSelectable) { if (this.paretoFrontViewScatterPlot.moccoViewer.refSolutionSelectable) {
((Chart2DDPointContentSelectable) icon).addSelectionListener(this.m_Dad.m_MOCCOViewer); ((Chart2DDPointContentSelectable) icon).addSelectionListener(this.paretoFrontViewScatterPlot.moccoViewer);
} }
((InterfaceDPointWithContent) icon).setProblem(this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem); ((InterfaceDPointWithContent) icon).setProblem(this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem);
((InterfaceDPointWithContent) icon).setEAIndividual((AbstractEAIndividual) pf.get(i)); ((InterfaceDPointWithContent) icon).setEAIndividual((AbstractEAIndividual) pf.get(i));
point.setIcon(icon); point.setIcon(icon);
mySet.addDPoint(point); mySet.addDPoint(point);
@ -150,7 +146,7 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
ymax = plotValue[1]; ymax = plotValue[1];
} }
} }
mySet = new GraphPointSet(0, this.m_Area); mySet = new GraphPointSet(0, this.functionArea);
mySet.setConnectedMode(false); mySet.setConnectedMode(false);
double xrange = (xmax - xmin), yrange = (ymax - ymin); double xrange = (xmax - xmin), yrange = (ymax - ymin);
if (xrange < 0.0000001) { if (xrange < 0.0000001) {
@ -170,13 +166,13 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
} }
// now lets prepare the contraints or goals if any... // now lets prepare the contraints or goals if any...
if ((this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) && if ((this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
(this.m_Dad.m_JCFitObj.getSelectedIndex() == 1)) { (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 1)) {
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
if (tmp[this.m_Obj1].getOptimizationMode().equalsIgnoreCase("Objective")) { if (tmp[this.object1].getOptimizationMode().equalsIgnoreCase("Objective")) {
double tmpD = tmp[this.m_Obj1].getConstraintGoal(); double tmpD = tmp[this.object1].getConstraintGoal();
if (!(new Double(tmpD)).isNaN()) { if (!(new Double(tmpD)).isNaN()) {
mySet = new GraphPointSet(500 + 1, this.m_Area); mySet = new GraphPointSet(500 + 1, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) { if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) {
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
@ -186,10 +182,10 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
} }
} }
} }
if (tmp[this.m_Obj2].getOptimizationMode().equalsIgnoreCase("Objective")) { if (tmp[this.object2].getOptimizationMode().equalsIgnoreCase("Objective")) {
double tmpD = tmp[this.m_Obj2].getConstraintGoal(); double tmpD = tmp[this.object2].getConstraintGoal();
if (!(new Double(tmpD)).isNaN()) { if (!(new Double(tmpD)).isNaN()) {
mySet = new GraphPointSet(500 + 2, this.m_Area); mySet = new GraphPointSet(500 + 2, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) { if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) {
mySet.addDPoint(xmin - 0.1 * xrange, tmpD); mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
@ -201,21 +197,21 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
} }
} }
// lets show a reference point if given... // lets show a reference point if given...
if ((this.m_Dad.m_MOCCOViewer.m_ReferencePoint != null) && (this.m_Dad.m_JCFitObj.getSelectedIndex() == 0)) { if ((this.paretoFrontViewScatterPlot.moccoViewer.referencePoint != null) && (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 0)) {
mySet = new GraphPointSet(1001, this.m_Area); mySet = new GraphPointSet(1001, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
mySet.setColor(Color.RED); mySet.setColor(Color.RED);
double tmpD = this.m_Dad.m_MOCCOViewer.m_ReferencePoint[this.m_Obj1]; double tmpD = this.paretoFrontViewScatterPlot.moccoViewer.referencePoint[this.object1];
if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) { if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) {
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
mySet.addDPoint(tmpD, ymin - 0.1 * yrange); mySet.addDPoint(tmpD, ymin - 0.1 * yrange);
mySet.addDPoint(tmpD, ymax + 0.1 * yrange); mySet.addDPoint(tmpD, ymax + 0.1 * yrange);
mySet.addDPoint(tmpD, ymax + 0.1 * yrange); mySet.addDPoint(tmpD, ymax + 0.1 * yrange);
} }
mySet = new GraphPointSet(1002, this.m_Area); mySet = new GraphPointSet(1002, this.functionArea);
mySet.setConnectedMode(true); mySet.setConnectedMode(true);
mySet.setColor(Color.RED); mySet.setColor(Color.RED);
tmpD = this.m_Dad.m_MOCCOViewer.m_ReferencePoint[this.m_Obj2]; tmpD = this.paretoFrontViewScatterPlot.moccoViewer.referencePoint[this.object2];
if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) { if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) {
mySet.addDPoint(xmin - 0.1 * xrange, tmpD); mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
mySet.addDPoint(xmin - 0.1 * xrange, tmpD); mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
@ -226,12 +222,12 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
} }
// lets prepare to reference point selection // lets prepare to reference point selection
if (this.m_Dad.m_MOCCOViewer.m_RefPointSelectable) { if (this.paretoFrontViewScatterPlot.moccoViewer.refPointSelectable) {
this.m_Area.addRefPointSelectionListener(this); this.functionArea.addRefPointSelectionListener(this);
} else { } else {
this.removeRefPointSelectionListeners(); this.removeRefPointSelectionListeners();
this.m_Area.removeRefPointSelectionListeners(); this.functionArea.removeRefPointSelectionListeners();
this.m_Dad.removeRefPointSelectionListeners(); this.paretoFrontViewScatterPlot.removeRefPointSelectionListeners();
} }
@ -251,15 +247,15 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
*/ */
@Override @Override
public void refPointGiven(double[] point) { public void refPointGiven(double[] point) {
if (this.m_Dad.m_JCFitObj.getSelectedIndex() == 1) { if (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 1) {
JOptionPane.showMessageDialog(this.m_Dad.m_MOCCOViewer.m_MOCCO.m_JFrame, JOptionPane.showMessageDialog(this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.getMainFrame(),
"Reference point needs to be selected in fitness space!", "Reference point needs to be selected in fitness space!",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
} else { } else {
double[] tmpD = this.m_Dad.m_MOCCOViewer.m_ReferencePoint; double[] tmpD = this.paretoFrontViewScatterPlot.moccoViewer.referencePoint;
tmpD[this.m_Obj1] = point[0]; tmpD[this.object1] = point[0];
tmpD[this.m_Obj1] = point[1]; tmpD[this.object1] = point[1];
this.m_Dad.m_MOCCOViewer.refPointGiven(tmpD); this.paretoFrontViewScatterPlot.moccoViewer.refPointGiven(tmpD);
} }
} }
@ -270,7 +266,7 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
* @param a The selection listener * @param a The selection listener
*/ */
public void addRefPointSelectionListener(InterfaceRefPointListener a) { public void addRefPointSelectionListener(InterfaceRefPointListener a) {
this.m_RefPointListener = a; this.refPointListener = a;
} }
/** /**
@ -279,52 +275,52 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
* @return InterfaceSelectionListener * @return InterfaceSelectionListener
*/ */
public InterfaceRefPointListener getRefPointSelectionListener() { public InterfaceRefPointListener getRefPointSelectionListener() {
return this.m_RefPointListener; return this.refPointListener;
} }
/** /**
* This method allows to remove the selection listner to the PointIcon * This method allows to remove the selection listner to the PointIcon
*/ */
public void removeRefPointSelectionListeners() { public void removeRefPointSelectionListeners() {
this.m_RefPointListener = null; this.refPointListener = null;
} }
} }
public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParetoFrontView { public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParetoFrontView {
public MOCCOViewer m_MOCCOViewer; public MOCCOViewer moccoViewer;
private JPanel m_JPMain; private JPanel mainPanel;
private JPanel m_JPCenter; private JPanel centerPanel;
private JPanel m_JPTop; private JPanel topPanel;
public JComboBox m_JCFitObj; public JComboBox fitnessObjectiveComboBox;
private InterfaceRefPointListener m_RefPointListener; private InterfaceRefPointListener refPointListener;
private SimpleView[][] m_Scatter; private SimpleView[][] simpleViews;
public ParetoFrontViewScatterPlot(MOCCOViewer t) { public ParetoFrontViewScatterPlot(MOCCOViewer t) {
this.m_MOCCOViewer = t; this.moccoViewer = t;
this.init(); this.init();
} }
private void init() { private void init() {
this.m_JPMain = new JPanel(); this.mainPanel = new JPanel();
this.m_JPMain.setLayout(new BorderLayout()); this.mainPanel.setLayout(new BorderLayout());
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(this.m_JPMain, BorderLayout.CENTER); this.add(this.mainPanel, BorderLayout.CENTER);
this.m_JPCenter = new JPanel(); this.centerPanel = new JPanel();
this.m_JPMain.add(new JScrollPane(this.m_JPCenter), BorderLayout.CENTER); this.mainPanel.add(new JScrollPane(this.centerPanel), BorderLayout.CENTER);
this.m_JPTop = new JPanel(); this.topPanel = new JPanel();
this.m_JPTop.setLayout(new GridLayout(1, 2)); this.topPanel.setLayout(new GridLayout(1, 2));
String[] tmp = new String[2]; String[] tmp = new String[2];
tmp[0] = "Fitness"; tmp[0] = "Fitness";
tmp[1] = "Objective"; tmp[1] = "Objective";
this.m_JCFitObj = new JComboBox(tmp); this.fitnessObjectiveComboBox = new JComboBox(tmp);
this.m_JCFitObj.setSelectedIndex(0); this.fitnessObjectiveComboBox.setSelectedIndex(0);
this.m_JCFitObj.addActionListener(this.jcomboboxListener); this.fitnessObjectiveComboBox.addActionListener(this.jcomboboxListener);
this.m_JPTop.add(new JLabel("Showing:")); this.topPanel.add(new JLabel("Showing:"));
this.m_JPTop.add(this.m_JCFitObj); this.topPanel.add(this.fitnessObjectiveComboBox);
this.m_JPMain.add(this.m_JPTop, BorderLayout.NORTH); this.mainPanel.add(this.topPanel, BorderLayout.NORTH);
this.updateView(); this.updateView();
} }
@ -336,14 +332,14 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
}; };
private void makeScatter() { private void makeScatter() {
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
this.m_Scatter = new SimpleView[tmp.length][tmp.length]; this.simpleViews = new SimpleView[tmp.length][tmp.length];
this.m_JPCenter.removeAll(); this.centerPanel.removeAll();
this.m_JPCenter.setLayout(new GridLayout(tmp.length, tmp.length)); this.centerPanel.setLayout(new GridLayout(tmp.length, tmp.length));
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
for (int j = 0; j < tmp.length; j++) { for (int j = 0; j < tmp.length; j++) {
this.m_Scatter[i][j] = new SimpleView(this, i, j); this.simpleViews[i][j] = new SimpleView(this, i, j);
this.m_JPCenter.add(this.m_Scatter[i][j]); this.centerPanel.add(this.simpleViews[i][j]);
} }
} }
} }
@ -355,26 +351,26 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
*/ */
@Override @Override
public void updateView() { public void updateView() {
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem == null) { if (this.moccoViewer.moccoStandalone.state.currentProblem == null) {
this.m_Scatter = null; this.simpleViews = null;
this.m_JPCenter.removeAll(); this.centerPanel.removeAll();
this.m_JPCenter.add(new JLabel("no problem given")); this.centerPanel.add(new JLabel("no problem given"));
this.validate(); this.validate();
return; return;
} }
// first set the names of the objectives // first set the names of the objectives
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives(); InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
if (this.m_Scatter == null) { if (this.simpleViews == null) {
this.makeScatter(); this.makeScatter();
} }
if (this.m_Scatter.length != tmp.length) { if (this.simpleViews.length != tmp.length) {
this.makeScatter(); this.makeScatter();
} }
if (this.m_Scatter != null) { if (this.simpleViews != null) {
for (int i = 0; i < tmp.length; i++) { for (int i = 0; i < tmp.length; i++) {
for (int j = 0; j < tmp.length; j++) { for (int j = 0; j < tmp.length; j++) {
this.m_Scatter[i][j].updateView(); this.simpleViews[i][j].updateView();
} }
} }
} }
@ -394,12 +390,12 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
* @param point The selected point, most likely 2d * @param point The selected point, most likely 2d
*/ */
public void refPointGiven(double[] point) { public void refPointGiven(double[] point) {
if (this.m_JCFitObj.getSelectedIndex() == 1) { if (this.fitnessObjectiveComboBox.getSelectedIndex() == 1) {
JOptionPane.showMessageDialog(this.m_MOCCOViewer.m_MOCCO.m_JFrame, JOptionPane.showMessageDialog(this.moccoViewer.moccoStandalone.getMainFrame(),
"Reference point needs to be selected in fitness space!", "Reference point needs to be selected in fitness space!",
"Warning", JOptionPane.WARNING_MESSAGE); "Warning", JOptionPane.WARNING_MESSAGE);
} else { } else {
this.m_MOCCOViewer.refPointGiven(point); this.moccoViewer.refPointGiven(point);
} }
} }
@ -410,7 +406,7 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
* @param a The selection listener * @param a The selection listener
*/ */
public void addRefPointSelectionListener(InterfaceRefPointListener a) { public void addRefPointSelectionListener(InterfaceRefPointListener a) {
this.m_RefPointListener = a; this.refPointListener = a;
} }
/** /**
@ -419,13 +415,13 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
* @return InterfaceSelectionListener * @return InterfaceSelectionListener
*/ */
public InterfaceRefPointListener getRefPointSelectionListener() { public InterfaceRefPointListener getRefPointSelectionListener() {
return this.m_RefPointListener; return this.refPointListener;
} }
/** /**
* This method allows to remove the selection listner to the PointIcon * This method allows to remove the selection listner to the PointIcon
*/ */
public void removeRefPointSelectionListeners() { public void removeRefPointSelectionListeners() {
this.m_RefPointListener = null; this.refPointListener = null;
} }
} }

View File

@ -22,12 +22,12 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
for (int i = 0; i < tmpD.length; i++) { for (int i = 0; i < tmpD.length; i++) {
tmpD[i] = 0.0; tmpD[i] = 0.0;
} }
this.m_WLPT.m_IdealValue = tmpD; this.m_WLPT.idealValue = tmpD;
tmpD = new double[2]; tmpD = new double[2];
for (int i = 0; i < tmpD.length; i++) { for (int i = 0; i < tmpD.length; i++) {
tmpD[i] = 1.0; tmpD[i] = 1.0;
} }
this.m_WLPT.m_Weights = tmpD; this.m_WLPT.weights = tmpD;
} }
public MOSOWeightedLPTchebycheff(MOSOWeightedLPTchebycheff b) { public MOSOWeightedLPTchebycheff(MOSOWeightedLPTchebycheff b) {
@ -72,9 +72,9 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
resultFit[0] = 0; resultFit[0] = 0;
for (int i = 0; i < tmpFit.length; i++) { for (int i = 0; i < tmpFit.length; i++) {
if (this.m_WLPT.m_P == 0) { if (this.m_WLPT.m_P == 0) {
resultFit[0] = Math.max(resultFit[0], this.m_WLPT.m_Weights[i] * Math.abs(tmpFit[i] - this.m_WLPT.m_IdealValue[i])); resultFit[0] = Math.max(resultFit[0], this.m_WLPT.weights[i] * Math.abs(tmpFit[i] - this.m_WLPT.idealValue[i]));
} else { } else {
resultFit[0] += this.m_WLPT.m_Weights[i] * Math.pow(tmpFit[i] - this.m_WLPT.m_IdealValue[i], this.m_WLPT.m_P); resultFit[0] += this.m_WLPT.weights[i] * Math.pow(tmpFit[i] - this.m_WLPT.idealValue[i], this.m_WLPT.m_P);
} }
} }
if (this.m_WLPT.m_P > 0) { if (this.m_WLPT.m_P > 0) {
@ -99,12 +99,12 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
newTarget[i] = 0; newTarget[i] = 0;
newWeights[i] = 1.0; newWeights[i] = 1.0;
} }
for (int i = 0; (i < this.m_WLPT.m_IdealValue.length) && (i < newTarget.length); i++) { for (int i = 0; (i < this.m_WLPT.idealValue.length) && (i < newTarget.length); i++) {
newTarget[i] = this.m_WLPT.m_IdealValue[i]; newTarget[i] = this.m_WLPT.idealValue[i];
newWeights[i] = this.m_WLPT.m_Weights[i]; newWeights[i] = this.m_WLPT.weights[i];
} }
this.m_WLPT.m_IdealValue = newTarget; this.m_WLPT.idealValue = newTarget;
this.m_WLPT.m_Weights = newWeights; this.m_WLPT.weights = newWeights;
} }
/** /**
@ -117,7 +117,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
String result = "Lp Metric\n"; String result = "Lp Metric\n";
result += " P = " + this.m_WLPT.m_P + "\n"; result += " P = " + this.m_WLPT.m_P + "\n";
result += " Ref.Fitness = ("; result += " Ref.Fitness = (";
double[] p = this.m_WLPT.m_IdealValue; double[] p = this.m_WLPT.idealValue;
for (int i = 0; i < p.length; i++) { for (int i = 0; i < p.length; i++) {
result += p[i]; result += p[i];
if (i < (p.length - 1)) { if (i < (p.length - 1)) {
@ -126,7 +126,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
} }
result += ")\n"; result += ")\n";
result += " Weights = ("; result += " Weights = (";
p = this.m_WLPT.m_Weights; p = this.m_WLPT.weights;
for (int i = 0; i < p.length; i++) { for (int i = 0; i < p.length; i++) {
result += p[i]; result += p[i];
if (i < (p.length - 1)) { if (i < (p.length - 1)) {

View File

@ -58,13 +58,9 @@ public class F3Problem extends AbstractProblemDoubleOffset implements java.io.Se
result += "Dimension : " + this.problemDimension + "\n"; result += "Dimension : " + this.problemDimension + "\n";
result += "Noise level : " + this.getNoise() + "\n"; result += "Noise level : " + this.getNoise() + "\n";
result += "Solution representation:\n"; result += "Solution representation:\n";
//result += this.template.getSolutionRepresentationFor();
return result; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -29,8 +29,8 @@ public class TestingDArea {
area.setVisibleRectangle(0, -3, 10, 10);//plotArea.setAutoFocus(true); area.setVisibleRectangle(0, -3, 10, 10);//plotArea.setAutoFocus(true);
area.setMinRectangle(0, 0, 1, 1); area.setMinRectangle(0, 0, 1, 1);
ScaledBorder myBorder = new ScaledBorder(); ScaledBorder myBorder = new ScaledBorder();
myBorder.x_label = "x";//"App. " + Name + " func. calls"; myBorder.xLabel = "x";//"App. " + Name + " func. calls";
myBorder.y_label = "y";//"fitness"; myBorder.yLabel = "y";//"fitness";
area.setBorder(myBorder); area.setBorder(myBorder);
area.setAutoGrid(true); area.setAutoGrid(true);
area.setGridVisible(true); area.setGridVisible(true);

View File

@ -78,7 +78,7 @@ public class ScaledBorder implements Border {
/** /**
* the displayed labels * the displayed labels
*/ */
public String x_label, y_label; public String xLabel, yLabel;
/** /**
* foreground and background colors * foreground and background colors
@ -281,18 +281,18 @@ public class ScaledBorder implements Border {
inner_insets.top + cd.height + marker_length); inner_insets.top + cd.height + marker_length);
} }
if (y_label != null) { if (yLabel != null) {
Dimension yld = new Dimension(fm.getAscent() + fm.getDescent(), fm.stringWidth(y_label)); Dimension yld = new Dimension(fm.getAscent() + fm.getDescent(), fm.stringWidth(yLabel));
AffineTransform T = new AffineTransform(0, -1, 1, 0, 0, 0); AffineTransform T = new AffineTransform(0, -1, 1, 0, 0, 0);
Font old = g.getFont(), f = old.deriveFont(T); Font old = g.getFont(), f = old.deriveFont(T);
g.setFont(f); g.setFont(f);
g.drawString(y_label, y_label2border + fm.getAscent(), inner_insets.top + (cd.height + yld.height) / 2); g.drawString(yLabel, y_label2border + fm.getAscent(), inner_insets.top + (cd.height + yld.height) / 2);
g.setFont(old); g.setFont(old);
} }
if (x_label != null) { if (xLabel != null) {
g.drawString( g.drawString(
x_label, inner_insets.left + (cd.width - fm.stringWidth(x_label)) / 2, xLabel, inner_insets.left + (cd.width - fm.stringWidth(xLabel)) / 2,
d.height - outer_insets.bottom - x_label2border - fm.getDescent()); d.height - outer_insets.bottom - x_label2border - fm.getDescent());
} }
@ -630,7 +630,7 @@ public class ScaledBorder implements Border {
} }
// left: // left:
if (y_label != null) { if (yLabel != null) {
insets.left += fm.getAscent() + fm.getDescent(); insets.left += fm.getAscent() + fm.getDescent();
} }
insets.left += y_label2values * digit_width; insets.left += y_label2values * digit_width;
@ -670,7 +670,7 @@ public class ScaledBorder implements Border {
// bottom: // bottom:
insets.bottom += 1 + fontHeight + x_label2border; insets.bottom += 1 + fontHeight + x_label2border;
if (x_label != null) { if (xLabel != null) {
insets.bottom += fontHeight; insets.bottom += fontHeight;
} }