Refactored all eva2.optimization.mocco m_ variables
This commit is contained in:
parent
41f58bb2f9
commit
0d07553546
@ -9,21 +9,21 @@ package eva2.gui;
|
||||
*/
|
||||
public class PropertyWeightedLPTchebycheff implements java.io.Serializable {
|
||||
|
||||
public double[] m_IdealValue;
|
||||
public double[] m_Weights;
|
||||
public double[] idealValue;
|
||||
public double[] weights;
|
||||
public int m_P = 0;
|
||||
|
||||
public PropertyWeightedLPTchebycheff() {
|
||||
}
|
||||
|
||||
public PropertyWeightedLPTchebycheff(PropertyWeightedLPTchebycheff e) {
|
||||
if (e.m_IdealValue != null) {
|
||||
this.m_IdealValue = new double[e.m_IdealValue.length];
|
||||
System.arraycopy(e.m_IdealValue, 0, this.m_IdealValue, 0, this.m_IdealValue.length);
|
||||
if (e.idealValue != null) {
|
||||
this.idealValue = new double[e.idealValue.length];
|
||||
System.arraycopy(e.idealValue, 0, this.idealValue, 0, this.idealValue.length);
|
||||
}
|
||||
if (e.m_Weights != null) {
|
||||
this.m_Weights = new double[e.m_Weights.length];
|
||||
System.arraycopy(e.m_Weights, 0, this.m_Weights, 0, this.m_Weights.length);
|
||||
if (e.weights != null) {
|
||||
this.weights = new double[e.weights.length];
|
||||
System.arraycopy(e.weights, 0, this.weights, 0, this.weights.length);
|
||||
}
|
||||
this.m_P = e.m_P;
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
double[] tmpT = m_WLPT.m_IdealValue;
|
||||
double[] tmpP = m_WLPT.m_Weights;
|
||||
double[] tmpT = m_WLPT.idealValue;
|
||||
double[] tmpP = m_WLPT.weights;
|
||||
|
||||
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.m_Weights = tmpP;
|
||||
m_WLPT.idealValue = tmpT;
|
||||
m_WLPT.weights = tmpP;
|
||||
}
|
||||
};
|
||||
|
||||
@ -164,8 +164,8 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
* This method updates the data panel
|
||||
*/
|
||||
private void updateDataPanel() {
|
||||
double[] tmpT = this.m_WLPT.m_IdealValue;
|
||||
double[] tmpP = this.m_WLPT.m_Weights;
|
||||
double[] tmpT = this.m_WLPT.idealValue;
|
||||
double[] tmpP = this.m_WLPT.weights;
|
||||
int obj = this.m_WLPT.m_P;
|
||||
|
||||
this.m_PValue.setText("" + obj);
|
||||
|
@ -77,8 +77,8 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
setBackground(new Color(253, 253, 253)); // not quite white
|
||||
// setAutoFocus(true);
|
||||
scaledBorder = new ScaledBorder();
|
||||
scaledBorder.x_label = xname; // "App. " + Name + " func. calls";
|
||||
scaledBorder.y_label = yname; // "fitness";
|
||||
scaledBorder.xLabel = xname; // "App. " + Name + " func. calls";
|
||||
scaledBorder.yLabel = yname; // "fitness";
|
||||
setBorder(scaledBorder);
|
||||
setAutoGrid(true);
|
||||
setGridVisible(true);
|
||||
@ -1122,9 +1122,9 @@ public class FunctionArea extends DArea implements Serializable {
|
||||
setYScale(null);
|
||||
ScaledBorder buffer = scaledBorder;
|
||||
scaledBorder = new ScaledBorder();
|
||||
scaledBorder.x_label = buffer.x_label; // "App. " + Name +
|
||||
scaledBorder.xLabel = buffer.xLabel; // "App. " + Name +
|
||||
// " func. calls";
|
||||
scaledBorder.y_label = buffer.y_label; // "fitness";
|
||||
scaledBorder.yLabel = buffer.yLabel; // "fitness";
|
||||
scaledBorder.setStandardPattern(false); // default decimal pattern on y axis
|
||||
setBorder(scaledBorder);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.optimization.go;
|
||||
|
||||
import eva2.gui.JParaPanel;
|
||||
import eva2.gui.PropertyDoubleArray;
|
||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.mocco.*;
|
||||
@ -20,28 +19,24 @@ import java.awt.event.WindowEvent;
|
||||
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 volatile MOCCOState m_State;
|
||||
public volatile MOCCOState state;
|
||||
private SwingWorker worker;
|
||||
private volatile boolean m_StillWorking = false;
|
||||
public int m_Iteration = -1;
|
||||
public JFrame m_JFrame;
|
||||
private volatile boolean stillWorking = false;
|
||||
public int iteration = -1;
|
||||
private JFrame mainFrame;
|
||||
//public ParetoFrontView n_ParetoFrontView;
|
||||
public boolean m_Debug = false;
|
||||
public MOCCOViewer m_View;
|
||||
public JPanel m_JPanelMain, m_JPanelParameters, m_JPanelControl, m_JPanelButtom;
|
||||
private JLabel m_CurrentState;
|
||||
private JProgressBar m_ProgressBar;
|
||||
private boolean debug = false;
|
||||
public MOCCOViewer view;
|
||||
public JPanel mainPanel, parameterPanel, controlPanel, buttonPanel;
|
||||
private JLabel currentState;
|
||||
private JProgressBar progressBar;
|
||||
|
||||
public MOCCOStandalone() {
|
||||
this.m_State = new MOCCOState();
|
||||
this.state = new MOCCOState();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,44 +44,43 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
* frame
|
||||
*/
|
||||
public void initMOCCOFrame() {
|
||||
JParaPanel paraPanel = new JParaPanel(this, "MyGUI");
|
||||
|
||||
this.m_State.isVisible = true;
|
||||
this.m_JFrame = new JFrame();
|
||||
this.m_JFrame.setTitle("MOCCO - Interactive Multi-Objective Optimization");
|
||||
this.m_JFrame.setSize(1200, 750);
|
||||
this.m_JFrame.setLocation(50, 50);
|
||||
this.m_JFrame.addWindowListener(new WindowAdapter() {
|
||||
this.state.isVisible = true;
|
||||
this.mainFrame = new JFrame();
|
||||
this.mainFrame.setTitle("MOCCO - Interactive Multi-Objective Optimization");
|
||||
this.mainFrame.setSize(1200, 750);
|
||||
this.mainFrame.setLocation(50, 50);
|
||||
this.mainFrame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent ev) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
// init basic panel structure
|
||||
this.m_JPanelMain = new JPanel();
|
||||
this.m_JPanelParameters = new JPanel();
|
||||
this.m_JPanelParameters.setPreferredSize(new Dimension(500, 300));
|
||||
this.m_JPanelParameters.setMinimumSize(new Dimension(500, 300));
|
||||
this.m_JPanelControl = new JPanel();
|
||||
this.m_View = new MOCCOViewer(this);
|
||||
this.m_JFrame.getContentPane().add(this.m_JPanelMain);
|
||||
this.m_JPanelMain.setLayout(new BorderLayout());
|
||||
this.m_JPanelMain.add(this.m_JPanelParameters, BorderLayout.WEST);
|
||||
this.m_JPanelMain.add(this.m_View, BorderLayout.CENTER);
|
||||
this.m_JPanelButtom = new JPanel();
|
||||
this.m_JPanelButtom.setLayout(new BorderLayout());
|
||||
this.mainPanel = new JPanel();
|
||||
this.parameterPanel = new JPanel();
|
||||
this.parameterPanel.setPreferredSize(new Dimension(500, 300));
|
||||
this.parameterPanel.setMinimumSize(new Dimension(500, 300));
|
||||
this.controlPanel = new JPanel();
|
||||
this.view = new MOCCOViewer(this);
|
||||
this.mainFrame.getContentPane().add(this.mainPanel);
|
||||
this.mainPanel.setLayout(new BorderLayout());
|
||||
this.mainPanel.add(this.parameterPanel, BorderLayout.WEST);
|
||||
this.mainPanel.add(this.view, BorderLayout.CENTER);
|
||||
this.buttonPanel = new JPanel();
|
||||
this.buttonPanel.setLayout(new BorderLayout());
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new GridLayout(2, 1));
|
||||
this.m_CurrentState = new JLabel("Problem Initialization");
|
||||
tmpP.add(this.m_CurrentState);
|
||||
this.m_ProgressBar = new JProgressBar();
|
||||
tmpP.add(this.m_ProgressBar);
|
||||
this.m_JPanelButtom.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_JPanelControl.setMinimumSize(new Dimension(400, 0));
|
||||
this.m_JPanelControl.setPreferredSize(new Dimension(400, 0));
|
||||
this.m_JPanelButtom.add(this.m_JPanelControl, BorderLayout.EAST);
|
||||
this.m_JPanelMain.add(this.m_JPanelButtom, BorderLayout.SOUTH);
|
||||
this.m_JFrame.validate();
|
||||
this.currentState = new JLabel("Problem Initialization");
|
||||
tmpP.add(this.currentState);
|
||||
this.progressBar = new JProgressBar();
|
||||
tmpP.add(this.progressBar);
|
||||
this.buttonPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.controlPanel.setMinimumSize(new Dimension(400, 0));
|
||||
this.controlPanel.setPreferredSize(new Dimension(400, 0));
|
||||
this.buttonPanel.add(this.controlPanel, BorderLayout.EAST);
|
||||
this.mainPanel.add(this.buttonPanel, BorderLayout.SOUTH);
|
||||
this.mainFrame.validate();
|
||||
// everything is prepared let's start the main loop
|
||||
this.MOCCOOptimization();
|
||||
}
|
||||
@ -95,15 +89,15 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
boolean cont = true;
|
||||
InterfaceProcessElement tmpP;
|
||||
while (cont) {
|
||||
this.m_Iteration++;
|
||||
while (m_StillWorking) {
|
||||
this.iteration++;
|
||||
while (stillWorking) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
if (this.m_State.m_OriginalProblem == null) {
|
||||
this.m_State.m_OriginalProblem = new TF1Problem();
|
||||
if (this.state.originalProblem == null) {
|
||||
this.state.originalProblem = new TF1Problem();
|
||||
tmpP = new MOCCOProblemInitialization(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) {
|
||||
@ -112,9 +106,9 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone();
|
||||
this.m_View.problemChanged(true);
|
||||
this.m_JPanelParameters.removeAll();
|
||||
this.state.currentProblem = (InterfaceOptimizationProblem) this.state.originalProblem.clone();
|
||||
this.view.problemChanged(true);
|
||||
this.parameterPanel.removeAll();
|
||||
tmpP = new MOCCOInitialPopulationSize(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
while (!tmpP.isFinished()) {
|
||||
@ -123,16 +117,16 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
} 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();
|
||||
pop.setTargetSize(this.m_State.m_InitialPopulationSize);
|
||||
this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone();
|
||||
this.m_State.m_CurrentProblem.initializePopulation(pop);
|
||||
this.m_State.m_CurrentProblem.evaluate(pop);
|
||||
this.m_State.addPopulation2History(pop);
|
||||
this.m_View.problemChanged(true);
|
||||
pop.setTargetSize(this.state.initialPopulationSize);
|
||||
this.state.currentProblem = (InterfaceOptimizationProblem) this.state.originalProblem.clone();
|
||||
this.state.currentProblem.initializePopulation(pop);
|
||||
this.state.currentProblem.evaluate(pop);
|
||||
this.state.addPopulation2History(pop);
|
||||
this.view.problemChanged(true);
|
||||
}
|
||||
((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).deactivateRepresentationEdit();
|
||||
((InterfaceMultiObjectiveDeNovoProblem) this.state.currentProblem).deactivateRepresentationEdit();
|
||||
this.updateStatus("Analysis/Redefinition", 33);
|
||||
tmpP = new MOCCOProblemRedefinition(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
@ -142,11 +136,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
this.m_State.makeFitnessCache(true);
|
||||
this.m_State.m_CurrentProblem.initializeProblem();
|
||||
this.m_State.makeBackup();
|
||||
this.m_View.problemChanged(true);
|
||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||
this.state.makeFitnessCache(true);
|
||||
this.state.currentProblem.initializeProblem();
|
||||
this.state.makeBackup();
|
||||
this.view.problemChanged(true);
|
||||
if (this.state.currentProblem.isMultiObjective()) {
|
||||
this.updateStatus("MO Strategy Selection", 50);
|
||||
tmpP = new MOCCOChooseMOStrategy(this);
|
||||
tmpP.initProcessElementParametrization();
|
||||
@ -292,20 +286,20 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
private void checkForObjectives(String w) {
|
||||
System.out.println("I'm currently " + w);
|
||||
System.out.print("Original Problem is ");
|
||||
if (this.m_State.m_OriginalProblem.isMultiObjective()) {
|
||||
if (this.state.originalProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
System.out.print("Current Problem is ");
|
||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||
if (this.state.currentProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
if (this.m_State.m_BackupProblem != null) {
|
||||
if (this.state.backupProblem != null) {
|
||||
System.out.print("Backup Problem is ");
|
||||
if (this.m_State.m_BackupProblem.isMultiObjective()) {
|
||||
if (this.state.backupProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
} else {
|
||||
System.out.println("single-objective.");
|
||||
@ -318,9 +312,9 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
private void checktForMOSO(String w) {
|
||||
String s;
|
||||
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());
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.state.currentProblem).getProblemObjectives();
|
||||
s = "Objectives: {";
|
||||
for (int i = 0; i < obj.length; i++) {
|
||||
s += obj[i].getIdentName();
|
||||
@ -391,11 +385,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
} else {
|
||||
String file = args[0];
|
||||
go.openObject(file);
|
||||
if (go.m_State == null) {
|
||||
if (go.state == null) {
|
||||
System.out.println("No valid input state!");
|
||||
System.exit(0);
|
||||
} else {
|
||||
if (go.m_State.m_Optimizer.getPopulation().getFunctionCalls() == 0) {
|
||||
if (go.state.optimizer.getPopulation().getFunctionCalls() == 0) {
|
||||
// start to optimize
|
||||
go.startExperiment();
|
||||
file = file.replaceAll(".ser", "");
|
||||
@ -425,8 +419,8 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ex) {
|
||||
if (this.m_JFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||
if (this.mainFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.mainFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
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);
|
||||
try {
|
||||
ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile)));
|
||||
oo.writeObject(this.m_State);
|
||||
oo.writeObject(this.state);
|
||||
oo.close();
|
||||
} catch (Exception ex) {
|
||||
if (this.m_JFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||
if (this.mainFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.mainFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
@ -463,19 +457,19 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
*/
|
||||
@Override
|
||||
public void startExperiment() {
|
||||
if (this.m_JFrame != null) {
|
||||
if (this.mainFrame != null) {
|
||||
}
|
||||
this.m_StillWorking = true;
|
||||
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
|
||||
if (this.m_Debug) {
|
||||
System.out.println("" + this.m_State.m_Optimizer.getStringRepresentation());
|
||||
this.stillWorking = true;
|
||||
this.state.optimizer.setProblem(this.state.currentProblem);
|
||||
if (this.debug) {
|
||||
System.out.println("" + this.state.optimizer.getStringRepresentation());
|
||||
}
|
||||
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation());
|
||||
this.m_State.m_Optimizer.getPopulation().setFunctionCalls(0);
|
||||
if (this.m_State.m_Optimizer.getPopulation().size() == 0) {
|
||||
this.m_State.m_Optimizer.init();
|
||||
this.state.currentProblem.evaluate(this.state.optimizer.getPopulation());
|
||||
this.state.optimizer.getPopulation().setFunctionCalls(0);
|
||||
if (this.state.optimizer.getPopulation().size() == 0) {
|
||||
this.state.optimizer.init();
|
||||
}
|
||||
this.m_State.m_Optimizer.addPopulationChangedEventListener(this);
|
||||
this.state.optimizer.addPopulationChangedEventListener(this);
|
||||
worker = new SwingWorker() {
|
||||
@Override
|
||||
public Object construct() {
|
||||
@ -485,26 +479,26 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
@Override
|
||||
public void finished() {
|
||||
Population[] pop = null;
|
||||
if (m_State.m_Optimizer instanceof IslandModelEA) {
|
||||
InterfaceOptimizer[] opt = ((IslandModelEA) m_State.m_Optimizer).getOptimizers();
|
||||
if (state.optimizer instanceof IslandModelEA) {
|
||||
InterfaceOptimizer[] opt = ((IslandModelEA) state.optimizer).getOptimizers();
|
||||
pop = new Population[opt.length];
|
||||
for (int i = 0; i < opt.length; i++) {
|
||||
pop[i] = opt[i].getPopulation();
|
||||
}
|
||||
}
|
||||
m_State.restore();
|
||||
state.restore();
|
||||
if (pop == null) {
|
||||
m_State.addPopulation2History(m_State.m_Optimizer.getPopulation());
|
||||
state.addPopulation2History(state.optimizer.getPopulation());
|
||||
} else {
|
||||
for (int i = 0; i < pop.length; i++) {
|
||||
m_State.m_CurrentProblem.evaluate(pop[i]);
|
||||
m_State.addPopulation2History(pop[i]);
|
||||
state.currentProblem.evaluate(pop[i]);
|
||||
state.addPopulation2History(pop[i]);
|
||||
}
|
||||
}
|
||||
if (m_View != null) {
|
||||
m_View.problemChanged(true);
|
||||
if (view != null) {
|
||||
view.problemChanged(true);
|
||||
}
|
||||
m_StillWorking = false;
|
||||
stillWorking = false;
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
@ -517,16 +511,16 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
* changing the progress bars value.
|
||||
*/
|
||||
void updateStatus(final String t, final int i) {
|
||||
if (this.m_ProgressBar != null) {
|
||||
if (this.progressBar != null) {
|
||||
Runnable doSetProgressBarValue = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
m_ProgressBar.setValue(i);
|
||||
progressBar.setValue(i);
|
||||
}
|
||||
};
|
||||
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()) {
|
||||
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()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
this.m_State.m_Optimizer.optimize();
|
||||
this.state.optimizer.optimize();
|
||||
}
|
||||
System.gc();
|
||||
} catch (InterruptedException e) {
|
||||
@ -574,11 +568,11 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
int currentProgress;
|
||||
if (name.equals(Population.NEXT_GENERATION_PERFORMED)) {
|
||||
if (this.m_State.isVisible) {
|
||||
if (this.state.isVisible) {
|
||||
Population population = ((InterfaceOptimizer) source).getPopulation();
|
||||
double x = 100;
|
||||
if (this.m_State.m_Terminator instanceof EvaluationTerminator) {
|
||||
double y = x / (double) ((EvaluationTerminator) this.m_State.m_Terminator).getFitnessCalls();
|
||||
if (this.state.terminator instanceof EvaluationTerminator) {
|
||||
double y = x / (double) ((EvaluationTerminator) this.state.terminator).getFitnessCalls();
|
||||
currentProgress = (int) (population.getFunctionCalls() * y);
|
||||
} else {
|
||||
currentProgress = (int) (0);
|
||||
@ -589,4 +583,8 @@ public class MOCCOStandalone implements InterfaceStandaloneOptimization, Interfa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame getMainFrame() {
|
||||
return this.mainFrame;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
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 {
|
||||
|
||||
|
@ -24,10 +24,10 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
|
||||
public final static int STRATEGY_REFP = 2;
|
||||
public final static int STRATEGY_TBCH = 3;
|
||||
public final static int STRATEGY_GDF = 4;
|
||||
public int m_Strategy = MOCCOChooseMOStrategy.STRATEGY_MOEA;
|
||||
public int moStrategy = MOCCOChooseMOStrategy.STRATEGY_MOEA;
|
||||
|
||||
public MOCCOChooseMOStrategy(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,14 +35,14 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.mocco.controlPanel.removeAll();
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
|
||||
// The button 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" +
|
||||
" 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);
|
||||
@ -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" +
|
||||
" 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);
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
|
||||
tmpB = new JButton();
|
||||
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" +
|
||||
" a weighted L-metric is used with different weigths for a number of optimization runs."), gbc);
|
||||
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,52 +148,52 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
|
||||
* @return the strategy
|
||||
*/
|
||||
public int getMOStrategy() {
|
||||
return this.m_Strategy;
|
||||
return this.moStrategy;
|
||||
}
|
||||
|
||||
ActionListener choosenMOEA = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Strategy = STRATEGY_MOEA;
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
moStrategy = STRATEGY_MOEA;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
ActionListener choosenSTEP = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Strategy = STRATEGY_STEP;
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
moStrategy = STRATEGY_STEP;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
ActionListener choosenREFP = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Strategy = STRATEGY_REFP;
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
moStrategy = STRATEGY_REFP;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
ActionListener choosenTBCH = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Strategy = STRATEGY_TBCH;
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
moStrategy = STRATEGY_TBCH;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
ActionListener choosenGDF = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Strategy = STRATEGY_GDF;
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
moStrategy = STRATEGY_GDF;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
}
|
@ -12,20 +12,16 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
private JTextField[] m_JTextField;
|
||||
private double[] m_ReferencePoint;
|
||||
JPanel m_Selected;
|
||||
private JTextField[] textField;
|
||||
private double[] referencePoint;
|
||||
JPanel selectedPanel;
|
||||
|
||||
public MOCCOChooseReferencePoint(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,46 +29,46 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Continue to algorithm parametrization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Choose a reference point of aspiration levels" +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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" +
|
||||
" process. For the sake of simplicity this reference point has to be selected in fitness space only!"), BorderLayout.NORTH);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH);
|
||||
this.m_Selected = new JPanel();
|
||||
tmpP.add(this.m_Selected, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_View.setRefPointSelectable(true);
|
||||
this.m_Mocco.m_View.addRefPointSelectionListener(this);
|
||||
this.selectedPanel = new JPanel();
|
||||
tmpP.add(this.selectedPanel, BorderLayout.CENTER);
|
||||
this.mocco.view.setRefPointSelectable(true);
|
||||
this.mocco.view.addRefPointSelectionListener(this);
|
||||
this.updateSelected();
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void updateSelected() {
|
||||
this.m_Selected.removeAll();
|
||||
InterfaceOptimizationObjective[] objectives = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
this.m_Selected.setLayout(new BorderLayout());
|
||||
if (this.m_Mocco.m_View.m_ReferencePoint == null) {
|
||||
this.m_Selected.add(new JLabel("No reference point! Wierd there should be a default value!?"), BorderLayout.NORTH);
|
||||
this.selectedPanel.removeAll();
|
||||
InterfaceOptimizationObjective[] objectives = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
|
||||
this.selectedPanel.setLayout(new BorderLayout());
|
||||
if (this.mocco.view.referencePoint == null) {
|
||||
this.selectedPanel.add(new JLabel("No reference point! Wierd there should be a default value!?"), BorderLayout.NORTH);
|
||||
} 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();
|
||||
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());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
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.gridy = i;
|
||||
gbc.weightx = 1;
|
||||
@ -80,14 +76,14 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = i;
|
||||
gbc.weightx = 1;
|
||||
this.m_JTextField[i] = new JTextField("" + this.m_Mocco.m_View.m_ReferencePoint[i]);
|
||||
this.m_JTextField[i].setEditable(true);
|
||||
this.m_JTextField[i].addActionListener(refPointEdited);
|
||||
tmpP.add(this.m_JTextField[i], gbc);
|
||||
this.textField[i] = new JTextField("" + this.mocco.view.referencePoint[i]);
|
||||
this.textField[i].setEditable(true);
|
||||
this.textField[i].addActionListener(refPointEdited);
|
||||
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
|
||||
*/
|
||||
public double[] getReferencePoint() {
|
||||
return this.m_ReferencePoint;
|
||||
return this.referencePoint;
|
||||
}
|
||||
|
||||
ActionListener refPointEdited = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
for (int i = 0; i < m_JTextField.length; i++) {
|
||||
m_Mocco.m_View.m_ReferencePoint[i] = new Double(m_JTextField[i].getText()).doubleValue();
|
||||
for (int i = 0; i < textField.length; i++) {
|
||||
mocco.view.referencePoint[i] = new Double(textField[i].getText()).doubleValue();
|
||||
}
|
||||
m_Mocco.m_View.problemChanged(false);
|
||||
mocco.view.problemChanged(false);
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_ReferencePoint = m_Mocco.m_View.m_ReferencePoint;
|
||||
m_Mocco.m_View.setRefPointSelectable(false);
|
||||
m_Mocco.m_View.removeRefPointSelectionListeners();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Finished = true;
|
||||
referencePoint = mocco.view.referencePoint;
|
||||
mocco.view.setRefPointSelectable(false);
|
||||
mocco.view.removeRefPointSelectionListeners();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -135,7 +131,7 @@ public class MOCCOChooseReferencePoint extends MOCCOPhase implements InterfacePr
|
||||
*/
|
||||
@Override
|
||||
public void refPointGiven(double[] point) {
|
||||
this.m_ReferencePoint = point;
|
||||
this.referencePoint = point;
|
||||
this.updateSelected();
|
||||
}
|
||||
}
|
@ -14,19 +14,15 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
AbstractEAIndividual m_ReferenceSolution = null;
|
||||
JPanel m_Selected;
|
||||
AbstractEAIndividual referenceSolution = null;
|
||||
JPanel selected;
|
||||
|
||||
public MOCCOChooseReferenceSolution(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,40 +30,40 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Continue to strategy parameterization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a reference solution " +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
this.mocco.parameterPanel.add(this.makeHelpText("Please choose a reference solution " +
|
||||
"from the Pareto-optimal solutions (grey circles) given to the right."), BorderLayout.NORTH);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
tmpP.add(new JLabel("Currently selected solution:"), BorderLayout.NORTH);
|
||||
this.m_Selected = new JPanel();
|
||||
tmpP.add(this.m_Selected, BorderLayout.CENTER);
|
||||
this.selected = new JPanel();
|
||||
tmpP.add(this.selected, BorderLayout.CENTER);
|
||||
this.updateSelected();
|
||||
this.m_Mocco.m_View.setRefSolutionSelectable(true);
|
||||
this.m_Mocco.m_View.setUniquelySelectable(true);
|
||||
this.m_Mocco.m_View.addRefSolutionSelectionListener(this);
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.view.setRefSolutionSelectable(true);
|
||||
this.mocco.view.setUniquelySelectable(true);
|
||||
this.mocco.view.addRefSolutionSelectionListener(this);
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void updateSelected() {
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
this.m_Selected.removeAll();
|
||||
this.m_Selected.setLayout(new BorderLayout());
|
||||
if (this.m_ReferenceSolution == null) {
|
||||
this.m_Selected.add(new JLabel("Selected Individual: none"), BorderLayout.NORTH);
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
|
||||
this.selected.removeAll();
|
||||
this.selected.setLayout(new BorderLayout());
|
||||
if (this.referenceSolution == null) {
|
||||
this.selected.add(new JLabel("Selected Individual: none"), BorderLayout.NORTH);
|
||||
} else {
|
||||
this.m_Selected.add(new JLabel("Selected Individual: " + this.m_ReferenceSolution), BorderLayout.NORTH);
|
||||
//double[] fitness = this.m_ReferenceSolution.getFitness();
|
||||
this.selected.add(new JLabel("Selected Individual: " + this.referenceSolution), BorderLayout.NORTH);
|
||||
//double[] fitness = this.referenceSolution.getFitness();
|
||||
JPanel tmpP = new JPanel();
|
||||
JTextField textA;
|
||||
tmpP.setLayout(new GridBagLayout());
|
||||
@ -104,28 +100,28 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = i + 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);
|
||||
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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (m_ReferenceSolution != null) {
|
||||
m_Mocco.m_View.setRefSolutionSelectable(false);
|
||||
m_Mocco.m_View.removeRefSolutionSelectionListeners();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Finished = true;
|
||||
if (referenceSolution != null) {
|
||||
mocco.view.setRefSolutionSelectable(false);
|
||||
mocco.view.removeRefSolutionSelectionListeners();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
hasFinished = true;
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(m_Mocco.m_JFrame,
|
||||
JOptionPane.showMessageDialog(mocco.getMainFrame(),
|
||||
"No reference solution selected. Cannot proceed!",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
@ -133,7 +129,7 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
|
||||
};
|
||||
|
||||
public AbstractEAIndividual getReferenceSolution() {
|
||||
return this.m_ReferenceSolution;
|
||||
return this.referenceSolution;
|
||||
}
|
||||
/******************************************************************************
|
||||
* InterfaceSelectionListener
|
||||
@ -147,11 +143,11 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
|
||||
*/
|
||||
@Override
|
||||
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) {
|
||||
this.m_ReferenceSolution = (AbstractEAIndividual) pop.get(0);
|
||||
this.referenceSolution = (AbstractEAIndividual) pop.get(0);
|
||||
} else {
|
||||
this.m_ReferenceSolution = null;
|
||||
this.referenceSolution = null;
|
||||
}
|
||||
this.updateSelected();
|
||||
}
|
||||
|
@ -8,18 +8,14 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
private JTextField m_JTextField;
|
||||
private JTextField textField;
|
||||
|
||||
public MOCCOInitialPopulationSize(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,16 +23,16 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Continue to problem redefinition/analyzation.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a size for the " +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
this.mocco.parameterPanel.add(this.makeHelpText("Please choose a size for the " +
|
||||
"initial set of solution alternatives necessary to start the MOCCO optimization " +
|
||||
"cycle."), BorderLayout.NORTH);
|
||||
JPanel tmpP = new JPanel();
|
||||
@ -48,33 +44,33 @@ public class MOCCOInitialPopulationSize extends MOCCOPhase implements InterfaceP
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
tmpP.add(new JLabel("Initial Solution Set Size:"), gbc);
|
||||
this.m_JTextField = new JTextField("" + this.m_Mocco.m_State.m_InitialPopulationSize);
|
||||
this.m_JTextField.addActionListener(popSizeEdited);
|
||||
this.textField = new JTextField("" + this.mocco.state.initialPopulationSize);
|
||||
this.textField.addActionListener(popSizeEdited);
|
||||
gbc.gridx = 1;
|
||||
tmpP.add(this.m_JTextField, gbc);
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
tmpP.add(this.textField, gbc);
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener popSizeEdited = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String s = m_JTextField.getText();
|
||||
String s = textField.getText();
|
||||
try {
|
||||
int t = new Integer(s).intValue();
|
||||
m_Mocco.m_State.m_InitialPopulationSize = t;
|
||||
mocco.state.initialPopulationSize = t;
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcessElement {
|
||||
|
||||
private AbstractEAIndividual m_RefSolution;
|
||||
private JTextField[][] m_TradeOff;
|
||||
JPanel m_Choice;
|
||||
private InterfaceOptimizer m_Opt;
|
||||
private GeneralOptimizationEditorProperty m_EOpt;
|
||||
private AbstractEAIndividual refSolution;
|
||||
private JTextField[][] tradeOffTextFields;
|
||||
JPanel choicePanel;
|
||||
private InterfaceOptimizer optimizer;
|
||||
private GeneralOptimizationEditorProperty optimizationEditorProperty;
|
||||
|
||||
public MOCCOParameterizeGDF(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,46 +46,46 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please give weights (white) for the individual objectives," +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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.")
|
||||
, BorderLayout.NORTH);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
this.m_Choice = new JPanel();
|
||||
//this.m_Choice.setBorder(BorderFactory.createCompoundBorder(
|
||||
this.choicePanel = new JPanel();
|
||||
//this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
|
||||
// BorderFactory.createTitledBorder("Geoffrion-Dyer-Feinberg Method:"),
|
||||
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
tmpP.add(this.m_Choice, BorderLayout.CENTER);
|
||||
tmpP.add(this.choicePanel, BorderLayout.CENTER);
|
||||
this.installChoice();
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void installChoice() {
|
||||
this.m_Choice.setLayout(new GridBagLayout());
|
||||
this.choicePanel.setLayout(new GridBagLayout());
|
||||
JPanel panelGDF = new JPanel();
|
||||
panelGDF.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Parameterize Perferences:"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
panelGDF.setLayout(new GridBagLayout());
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
this.m_TradeOff = new JTextField[obj.length][obj.length];
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
|
||||
this.tradeOffTextFields = new JTextField[obj.length][obj.length];
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
@ -96,26 +96,26 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
gbc.weightx = 2;
|
||||
panelGDF.add(new JLabel("" + obj[i].getIdentName()), gbc);
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
this.m_TradeOff[i][j] = new JTextField("");
|
||||
this.tradeOffTextFields[i][j] = new JTextField("");
|
||||
if (i == j) {
|
||||
this.m_TradeOff[i][j].setBackground(Color.WHITE);
|
||||
this.tradeOffTextFields[i][j].setBackground(Color.WHITE);
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
this.m_TradeOff[i][j].setEditable(true);
|
||||
this.tradeOffTextFields[i][j].setEditable(true);
|
||||
} else {
|
||||
this.m_TradeOff[i][j].setEditable(false);
|
||||
this.tradeOffTextFields[i][j].setEditable(false);
|
||||
}
|
||||
this.m_TradeOff[i][j].setText("1.0");
|
||||
this.m_TradeOff[i][j].addActionListener(weightListener);
|
||||
this.tradeOffTextFields[i][j].setText("1.0");
|
||||
this.tradeOffTextFields[i][j].addActionListener(weightListener);
|
||||
} else {
|
||||
this.m_TradeOff[i][j].setBackground(Color.LIGHT_GRAY);
|
||||
this.m_TradeOff[i][j].setEditable(false);
|
||||
this.m_TradeOff[i][j].setText("0.5");
|
||||
//this.m_TradeOff[i][j].addActionListener(tradeoffListener);
|
||||
this.tradeOffTextFields[i][j].setBackground(Color.LIGHT_GRAY);
|
||||
this.tradeOffTextFields[i][j].setEditable(false);
|
||||
this.tradeOffTextFields[i][j].setText("0.5");
|
||||
//this.tradeOffTextFields[i][j].addActionListener(tradeoffListener);
|
||||
}
|
||||
gbc.gridx = j + 1;
|
||||
gbc.gridy = i;
|
||||
gbc.weightx = 1;
|
||||
panelGDF.add(this.m_TradeOff[i][j], gbc);
|
||||
panelGDF.add(this.tradeOffTextFields[i][j], gbc);
|
||||
}
|
||||
}
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
@ -123,28 +123,28 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
gbc.gridx = 0;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridy = 0;
|
||||
this.m_Choice.add(panelGDF, gbc);
|
||||
this.choicePanel.add(panelGDF, gbc);
|
||||
|
||||
// the optimizer
|
||||
gbc.gridwidth = 1;
|
||||
this.m_EOpt = new GeneralOptimizationEditorProperty();
|
||||
this.m_Opt = new GeneticAlgorithm();
|
||||
this.m_Opt.setProblem(this.m_Mocco.m_State.m_CurrentProblem);
|
||||
this.m_Mocco.m_State.m_Optimizer = this.m_Opt;
|
||||
this.m_EOpt.name = "Island Model EA";
|
||||
this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
|
||||
this.optimizer = new GeneticAlgorithm();
|
||||
this.optimizer.setProblem(this.mocco.state.currentProblem);
|
||||
this.mocco.state.optimizer = this.optimizer;
|
||||
this.optimizationEditorProperty.name = "Island Model EA";
|
||||
try {
|
||||
this.m_EOpt.value = this.m_Opt;
|
||||
this.m_EOpt.editor = PropertyEditorProvider.findEditor(this.m_EOpt.value.getClass());
|
||||
if (this.m_EOpt.editor == null) {
|
||||
this.m_EOpt.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
this.optimizationEditorProperty.value = this.optimizer;
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
|
||||
if (this.optimizationEditorProperty.editor == null) {
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (this.m_EOpt.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EOpt.editor).setClassType(InterfaceOptimizer.class);
|
||||
if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
this.m_EOpt.editor.setValue(this.m_EOpt.value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EOpt);
|
||||
if (this.m_EOpt.view != null) {
|
||||
this.m_EOpt.view.repaint();
|
||||
this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
|
||||
AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
|
||||
if (this.optimizationEditorProperty.view != null) {
|
||||
this.optimizationEditorProperty.view.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
@ -152,16 +152,16 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 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.gridy = 2;
|
||||
gbc.weightx = 1;
|
||||
this.m_Choice.add(this.m_EOpt.view, gbc);
|
||||
this.choicePanel.add(this.optimizationEditorProperty.view, gbc);
|
||||
// Terminator
|
||||
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -180,11 +180,11 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 2;
|
||||
this.m_Choice.add(new JLabel("" + editor.name), gbc);
|
||||
this.choicePanel.add(new JLabel("" + editor.name), gbc);
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 3;
|
||||
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
|
||||
*/
|
||||
public void setReferenceSolution(AbstractEAIndividual indy) {
|
||||
this.m_RefSolution = indy;
|
||||
this.refSolution = indy;
|
||||
}
|
||||
|
||||
ActionListener weightListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
double[] w = new double[m_TradeOff.length];
|
||||
double[] w = new double[tradeOffTextFields.length];
|
||||
double sum = 0;
|
||||
for (int i = 0; i < m_TradeOff.length; i++) {
|
||||
w[i] = new Double(m_TradeOff[i][i].getText()).doubleValue();
|
||||
for (int i = 0; i < tradeOffTextFields.length; i++) {
|
||||
w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue();
|
||||
sum += w[i];
|
||||
}
|
||||
if (new Double(sum).isNaN()) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < m_TradeOff.length; i++) {
|
||||
for (int j = 0; j < m_TradeOff.length; j++) {
|
||||
for (int i = 0; i < tradeOffTextFields.length; i++) {
|
||||
for (int j = 0; j < tradeOffTextFields.length; 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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
double[] w = new double[m_TradeOff.length];
|
||||
for (int i = 0; i < m_TradeOff.length; i++) {
|
||||
w[i] = new Double(m_TradeOff[i][i].getText()).doubleValue();
|
||||
double[] w = new double[tradeOffTextFields.length];
|
||||
for (int i = 0; i < tradeOffTextFields.length; i++) {
|
||||
w[i] = new Double(tradeOffTextFields[i][i].getText()).doubleValue();
|
||||
}
|
||||
MOSOWeightedFitness wf = new MOSOWeightedFitness();
|
||||
// I've to set this before I change the parameters, because the problem sets the
|
||||
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and
|
||||
// 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);
|
||||
PropertyDoubleArray da = new PropertyDoubleArray(w);
|
||||
wf.setOutputDimension(da.getNumRows());
|
||||
wf.setWeights(da);
|
||||
m_Opt.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
m_Mocco.m_State.m_Optimizer = m_Opt;
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_JPanelParameters.validate();
|
||||
m_Finished = true;
|
||||
optimizer.setProblem(mocco.state.currentProblem);
|
||||
mocco.state.optimizer = optimizer;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.parameterPanel.validate();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -257,7 +257,7 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
*/
|
||||
public double[] mapObjectives2Fitness(double[] d) {
|
||||
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("obj.length = " + obj.length);
|
||||
System.out.println("d.length = " + d.length);
|
||||
|
@ -18,21 +18,13 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
// private JComboBox m_OptimizerChooser;
|
||||
// private InterfaceOptimizer optimizer;
|
||||
|
||||
public MOCCOParameterizeMO(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
// this.optimizer = (InterfaceOptimizer)this.m_Mocco.m_State.optimizer.clone();
|
||||
this.mocco = mocco;
|
||||
// this.optimizer = (InterfaceOptimizer)this.mocco.state.optimizer.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,43 +32,43 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.init();
|
||||
|
||||
this.m_Mocco.m_JFrame.setVisible(true);
|
||||
this.m_Mocco.m_JFrame.validate();
|
||||
this.mocco.getMainFrame().setVisible(true);
|
||||
this.mocco.getMainFrame().validate();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!(this.m_Mocco.m_State.m_Optimizer instanceof MultiObjectiveEA)) {
|
||||
if (this.m_Mocco.m_State.m_Optimizer instanceof GeneticAlgorithm) {
|
||||
JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame,
|
||||
"The current " + this.m_Mocco.m_State.m_Optimizer.getName() +
|
||||
if (!(this.mocco.state.optimizer instanceof MultiObjectiveEA)) {
|
||||
if (this.mocco.state.optimizer instanceof GeneticAlgorithm) {
|
||||
JOptionPane.showMessageDialog(this.mocco.getMainFrame(),
|
||||
"The current " + this.mocco.state.optimizer.getName() +
|
||||
" is not necessarily a good multi-objective optimizer, please " +
|
||||
"parameterize accordingly or change to MultiObjectiveEA",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
// JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame,
|
||||
// "The current "+this.m_Mocco.m_State.optimizer.getName() +
|
||||
// JOptionPane.showMessageDialog(this.mocco.m_JFrame,
|
||||
// "The current "+this.mocco.state.optimizer.getName() +
|
||||
// " is typically a single-objective optimizer. I'm defaulting to a " +
|
||||
// "multi-objective EA instead, please parameterize accordingly.",
|
||||
// "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.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
@ -87,7 +79,7 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Optimizer";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Optimizer;
|
||||
editor.value = this.mocco.state.optimizer;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
@ -115,7 +107,7 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -139,31 +131,31 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
gbc.gridy = 1;
|
||||
gbc.weightx = 2;
|
||||
tmpP.add(editor.view, gbc);
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeInformationText("Multi-Objective Optimiaztion", "" +
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.add(this.makeInformationText("Multi-Objective Optimiaztion", "" +
|
||||
"Please choose an appropriate multi-objecitve optimizer."), BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
//m_Mocco.m_State.optimizer = (InterfaceOptimizer)optimizer.clone();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
Population pop = m_Mocco.m_State.m_Optimizer.getPopulation();
|
||||
//mocco.state.optimizer = (InterfaceOptimizer)optimizer.clone();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.state.optimizer.setProblem(mocco.state.currentProblem);
|
||||
Population pop = mocco.state.optimizer.getPopulation();
|
||||
pop.clear();
|
||||
if (pop.getArchive() != null) {
|
||||
pop.getArchive().clear();
|
||||
}
|
||||
if (m_Mocco.m_State.m_PopulationHistory.length > 0) {
|
||||
pop = m_Mocco.m_State.getSelectedPopulations();
|
||||
m_Mocco.m_State.m_Optimizer.initByPopulation(pop, false);
|
||||
if (mocco.state.populationHistory.length > 0) {
|
||||
pop = mocco.state.getSelectedPopulations();
|
||||
mocco.state.optimizer.initByPopulation(pop, false);
|
||||
if (pop.size() == 0) {
|
||||
m_Mocco.m_State.m_Optimizer.init();
|
||||
mocco.state.optimizer.init();
|
||||
}
|
||||
}
|
||||
m_Finished = true;
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -27,17 +27,17 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfaceProcessElement {
|
||||
|
||||
private double[] m_RefPoint;
|
||||
private MOSOLpMetric m_LpMetric;
|
||||
private IslandModelEA m_Island;
|
||||
private GeneralOptimizationEditorProperty m_EMOSO, m_EIMEA;
|
||||
private int m_Perturbations = 4;
|
||||
private double m_Perturbation = 0.01;
|
||||
private JTextField m_NumPer, m_SizePer;
|
||||
JPanel m_Parameters;
|
||||
private double[] refPoint;
|
||||
private MOSOLpMetric lpMetric;
|
||||
private IslandModelEA islandModelEA;
|
||||
private GeneralOptimizationEditorProperty optimizationEditorProperty, optimizationEditorProperty1;
|
||||
private int perturbations = 4;
|
||||
private double perturbation = 0.01;
|
||||
private JTextField numPerTextField, sizePerTextField;
|
||||
JPanel parameterPanel;
|
||||
|
||||
public MOCCOParameterizeRefPoint(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,78 +45,78 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please parameterized the reference point method." +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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." +
|
||||
" 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);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
this.m_Parameters = new JPanel();
|
||||
// this.m_Choice.setBorder(BorderFactory.createCompoundBorder(
|
||||
this.parameterPanel = new JPanel();
|
||||
// this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
|
||||
// BorderFactory.createTitledBorder("Step Method:"),
|
||||
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
tmpP.add(this.m_Parameters, BorderLayout.CENTER);
|
||||
tmpP.add(this.parameterPanel, BorderLayout.CENTER);
|
||||
this.installChoice();
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void installChoice() {
|
||||
this.m_Parameters.setLayout(new GridBagLayout());
|
||||
this.parameterPanel.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
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.gridy = 0;
|
||||
gbc.weightx = 1;
|
||||
this.m_NumPer = new JTextField("" + this.m_Perturbations);
|
||||
this.m_Parameters.add(this.m_NumPer, gbc);
|
||||
this.numPerTextField = new JTextField("" + this.perturbations);
|
||||
this.parameterPanel.add(this.numPerTextField, gbc);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
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.gridy = 1;
|
||||
gbc.weightx = 1;
|
||||
this.m_SizePer = new JTextField("" + this.m_Perturbation);
|
||||
this.m_Parameters.add(this.m_SizePer, gbc);
|
||||
this.sizePerTextField = new JTextField("" + this.perturbation);
|
||||
this.parameterPanel.add(this.sizePerTextField, gbc);
|
||||
// lpmetric
|
||||
this.m_EMOSO = new GeneralOptimizationEditorProperty();
|
||||
this.m_LpMetric = new MOSOLpMetric();
|
||||
this.m_LpMetric.getReference().setDoubleArray(this.m_RefPoint);
|
||||
this.m_EMOSO.name = "Lp-Metric";
|
||||
this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
|
||||
this.lpMetric = new MOSOLpMetric();
|
||||
this.lpMetric.getReference().setDoubleArray(this.refPoint);
|
||||
this.optimizationEditorProperty.name = "Lp-Metric";
|
||||
try {
|
||||
this.m_EMOSO.value = this.m_LpMetric;
|
||||
this.m_EMOSO.editor = PropertyEditorProvider.findEditor(this.m_EMOSO.value.getClass());
|
||||
if (this.m_EMOSO.editor == null) {
|
||||
this.m_EMOSO.editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class);
|
||||
this.optimizationEditorProperty.value = this.lpMetric;
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
|
||||
if (this.optimizationEditorProperty.editor == null) {
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class);
|
||||
}
|
||||
if (this.m_EMOSO.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EMOSO.editor).setClassType(MOSOLpMetric.class);
|
||||
if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(MOSOLpMetric.class);
|
||||
}
|
||||
this.m_EMOSO.editor.setValue(this.m_EMOSO.value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EMOSO);
|
||||
if (this.m_EMOSO.view != null) {
|
||||
this.m_EMOSO.view.repaint();
|
||||
this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
|
||||
AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
|
||||
if (this.optimizationEditorProperty.view != null) {
|
||||
this.optimizationEditorProperty.view.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
@ -124,35 +124,35 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 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.gridy = 2;
|
||||
gbc.weightx = 1;
|
||||
this.m_Parameters.add(this.m_EMOSO.view, gbc);
|
||||
this.parameterPanel.add(this.optimizationEditorProperty.view, gbc);
|
||||
// IslandModelEA
|
||||
this.m_EIMEA = new GeneralOptimizationEditorProperty();
|
||||
this.m_Island = new IslandModelEA();
|
||||
this.m_Island.setHeterogeneousProblems(true);
|
||||
this.m_Island.setLocalOnly(true);
|
||||
this.m_Island.setMigrationRate(2);
|
||||
this.m_Island.setMigrationStrategy(new SOBestMigration());
|
||||
this.m_Island.setNumberLocalCPUs(this.m_Perturbations);
|
||||
this.m_Island.setProblem(this.m_Mocco.m_State.m_CurrentProblem);
|
||||
this.m_Mocco.m_State.m_Optimizer = this.m_Island;
|
||||
this.m_EIMEA.name = "Island Model EA";
|
||||
this.optimizationEditorProperty1 = new GeneralOptimizationEditorProperty();
|
||||
this.islandModelEA = new IslandModelEA();
|
||||
this.islandModelEA.setHeterogeneousProblems(true);
|
||||
this.islandModelEA.setLocalOnly(true);
|
||||
this.islandModelEA.setMigrationRate(2);
|
||||
this.islandModelEA.setMigrationStrategy(new SOBestMigration());
|
||||
this.islandModelEA.setNumberLocalCPUs(this.perturbations);
|
||||
this.islandModelEA.setProblem(this.mocco.state.currentProblem);
|
||||
this.mocco.state.optimizer = this.islandModelEA;
|
||||
this.optimizationEditorProperty1.name = "Island Model EA";
|
||||
try {
|
||||
this.m_EIMEA.value = this.m_Island;
|
||||
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(this.m_EIMEA.value.getClass());
|
||||
if (this.m_EIMEA.editor == null) {
|
||||
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
this.optimizationEditorProperty1.value = this.islandModelEA;
|
||||
this.optimizationEditorProperty1.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty1.value.getClass());
|
||||
if (this.optimizationEditorProperty1.editor == null) {
|
||||
this.optimizationEditorProperty1.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
}
|
||||
if (this.m_EIMEA.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EIMEA.editor).setClassType(IslandModelEA.class);
|
||||
if (this.optimizationEditorProperty1.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.optimizationEditorProperty1.editor).setClassType(IslandModelEA.class);
|
||||
}
|
||||
this.m_EIMEA.editor.setValue(this.m_EIMEA.value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EIMEA);
|
||||
if (this.m_EIMEA.view != null) {
|
||||
this.m_EIMEA.view.repaint();
|
||||
this.optimizationEditorProperty1.editor.setValue(this.optimizationEditorProperty1.value);
|
||||
AbstractObjectEditor.findViewFor(this.optimizationEditorProperty1);
|
||||
if (this.optimizationEditorProperty1.view != null) {
|
||||
this.optimizationEditorProperty1.view.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
@ -160,16 +160,16 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
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.gridy = 3;
|
||||
gbc.weightx = 1;
|
||||
this.m_Parameters.add(this.m_EIMEA.view, gbc);
|
||||
this.parameterPanel.add(this.optimizationEditorProperty1.view, gbc);
|
||||
// Terminator
|
||||
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -188,11 +188,11 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 4;
|
||||
gbc.weightx = 2;
|
||||
this.m_Parameters.add(new JLabel("" + editor.name), gbc);
|
||||
this.parameterPanel.add(new JLabel("" + editor.name), gbc);
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 4;
|
||||
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
|
||||
*/
|
||||
public void setReferencePoint(double[] point) {
|
||||
this.m_RefPoint = point;
|
||||
this.refPoint = point;
|
||||
}
|
||||
|
||||
ActionListener satisfiedChanged = new ActionListener() {
|
||||
@ -217,65 +217,65 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
// first read the values
|
||||
try {
|
||||
m_Perturbations = new Integer(m_NumPer.getText()).intValue();
|
||||
perturbations = new Integer(numPerTextField.getText()).intValue();
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
System.out.println("Can't read k.");
|
||||
}
|
||||
try {
|
||||
m_Perturbation = new Double(m_SizePer.getText()).doubleValue();
|
||||
perturbation = new Double(sizePerTextField.getText()).doubleValue();
|
||||
} catch (java.lang.NumberFormatException e) {
|
||||
System.out.println("Can't read amount of perturbation.");
|
||||
}
|
||||
if (m_EIMEA.value instanceof IslandModelEA) {
|
||||
m_Island = (IslandModelEA) m_EIMEA.value;
|
||||
if (optimizationEditorProperty1.value instanceof IslandModelEA) {
|
||||
islandModelEA = (IslandModelEA) optimizationEditorProperty1.value;
|
||||
} else {
|
||||
System.out.println("The selected optimizer does not allow heterogenuous multi-starts!");
|
||||
}
|
||||
if (m_EMOSO.value instanceof MOSOLpMetric) {
|
||||
m_LpMetric = (MOSOLpMetric) m_EMOSO.value;
|
||||
if (optimizationEditorProperty.value instanceof MOSOLpMetric) {
|
||||
lpMetric = (MOSOLpMetric) optimizationEditorProperty.value;
|
||||
} else {
|
||||
System.out.println("The selected MOSO conversion is not suited for the reference point approach!");
|
||||
}
|
||||
// then set the values
|
||||
// if (!m_Island.getLocalOnly()) {
|
||||
// if (!islandModelEA.getLocalOnly()) {
|
||||
// ToDo: Think of new ways to do this!
|
||||
/*PropertyRemoteServers t = m_Island.getServers();
|
||||
/*PropertyRemoteServers t = islandModelEA.getServers();
|
||||
String[] servers = t.getServerNodes();
|
||||
if (servers.length != m_Perturbations) {
|
||||
if (servers.length != perturbations) {
|
||||
System.out.println("Warning: Number of servers overrides number of perturbations!");
|
||||
m_Perturbations = servers.length;
|
||||
perturbations = servers.length;
|
||||
}*/
|
||||
// } else {
|
||||
// m_Island.setNumberLocalCPUs(m_Perturbations);
|
||||
// islandModelEA.setNumberLocalCPUs(perturbations);
|
||||
// }
|
||||
m_Mocco.m_State.m_Optimizer = m_Island;
|
||||
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
m_Island.init();
|
||||
mocco.state.optimizer = islandModelEA;
|
||||
mocco.state.optimizer.setProblem(mocco.state.currentProblem);
|
||||
islandModelEA.init();
|
||||
double[] tmpD;
|
||||
MOSOLpMetric[] tmpLPs = new MOSOLpMetric[m_Perturbations];
|
||||
for (int i = 0; i < m_Perturbations; i++) {
|
||||
tmpD = new double[m_RefPoint.length];
|
||||
MOSOLpMetric[] tmpLPs = new MOSOLpMetric[perturbations];
|
||||
for (int i = 0; i < perturbations; i++) {
|
||||
tmpD = new double[refPoint.length];
|
||||
for (int j = 0; j < tmpD.length; j++) {
|
||||
if (i > 0) {
|
||||
tmpD[j] = m_RefPoint[j] + RNG.gaussianDouble(m_Perturbation);
|
||||
tmpD[j] = refPoint[j] + RNG.gaussianDouble(perturbation);
|
||||
} 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
|
||||
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and
|
||||
// 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].getReference().setDoubleArray(tmpD);
|
||||
}
|
||||
m_Mocco.m_View.removeReferencePoint();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_JPanelParameters.validate();
|
||||
m_Finished = true;
|
||||
mocco.view.removeReferencePoint();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.parameterPanel.validate();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
}
|
@ -27,7 +27,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
|
||||
|
||||
public MOCCOParameterizeSO(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,37 +35,37 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.init();
|
||||
|
||||
this.m_Mocco.m_JFrame.setVisible(true);
|
||||
this.m_Mocco.m_JFrame.validate();
|
||||
this.mocco.getMainFrame().setVisible(true);
|
||||
this.mocco.getMainFrame().validate();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (this.m_Mocco.m_State.m_Optimizer instanceof MultiObjectiveEA) {
|
||||
JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame,
|
||||
"The current " + this.m_Mocco.m_State.m_Optimizer.getName() +
|
||||
if (this.mocco.state.optimizer instanceof MultiObjectiveEA) {
|
||||
JOptionPane.showMessageDialog(this.mocco.getMainFrame(),
|
||||
"The current " + this.mocco.state.optimizer.getName() +
|
||||
" is no single-objective optimizer. I'm defaulting to " +
|
||||
"a Genetic Algorithms, please parameterize accordingly.",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
this.m_Mocco.m_State.m_Optimizer = new GeneticAlgorithm();
|
||||
this.m_Mocco.m_State.m_Optimizer.setProblem(this.m_Mocco.m_State.m_CurrentProblem);
|
||||
this.mocco.state.optimizer = new GeneticAlgorithm();
|
||||
this.mocco.state.optimizer.setProblem(this.mocco.state.currentProblem);
|
||||
}
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
@ -75,7 +75,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Optimizer";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Optimizer;
|
||||
editor.value = this.mocco.state.optimizer;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
@ -103,7 +103,7 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -127,8 +127,8 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
gbc.gridy = 1;
|
||||
gbc.weightx = 2;
|
||||
tmpP.add(editor.view, gbc);
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeInformationText("Single-Objective Optimiaztion", "" +
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.add(this.makeInformationText("Single-Objective Optimiaztion", "" +
|
||||
"Please choose an appropriate single-objecitve optimizer."), BorderLayout.NORTH);
|
||||
|
||||
}
|
||||
@ -136,9 +136,9 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.parameterPanel.removeAll();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -23,23 +23,19 @@ import java.awt.event.ActionListener;
|
||||
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 {
|
||||
|
||||
private AbstractEAIndividual m_RefSolution;
|
||||
private JTextField[] m_RefSol, m_Relax, m_Weight;
|
||||
private JCheckBox[] m_Satisfied;
|
||||
JPanel m_Choice;
|
||||
private InterfaceOptimizer m_Opt;
|
||||
private GeneralOptimizationEditorProperty m_EOpt;
|
||||
private AbstractEAIndividual refSolution;
|
||||
private JTextField[] refSolTextField, relaxTextField, weightTextField;
|
||||
private JCheckBox[] satisfied;
|
||||
JPanel choicePanel;
|
||||
private InterfaceOptimizer optimizer;
|
||||
private GeneralOptimizationEditorProperty optimizationEditorProperty;
|
||||
|
||||
public MOCCOParameterizeSTEP(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,50 +43,50 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please classify the achieved fitness values in" +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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" +
|
||||
" by which this objective is allowed to worsen. For the unsatisfied objectives weights can be given" +
|
||||
" for weigthed aggregation."), BorderLayout.NORTH);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
this.m_Choice = new JPanel();
|
||||
//this.m_Choice.setBorder(BorderFactory.createCompoundBorder(
|
||||
this.choicePanel = new JPanel();
|
||||
//this.choicePanel.setBorder(BorderFactory.createCompoundBorder(
|
||||
// BorderFactory.createTitledBorder("Step Method:"),
|
||||
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
tmpP.add(this.m_Choice, BorderLayout.CENTER);
|
||||
tmpP.add(this.choicePanel, BorderLayout.CENTER);
|
||||
this.installChoice();
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void installChoice() {
|
||||
this.m_Choice.setLayout(new GridBagLayout());
|
||||
this.choicePanel.setLayout(new GridBagLayout());
|
||||
JPanel panelSTEP = new JPanel();
|
||||
panelSTEP.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createTitledBorder("Parameterize Perferences:"),
|
||||
BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
panelSTEP.setLayout(new GridBagLayout());
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Mocco.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
this.m_RefSol = new JTextField[obj.length];
|
||||
this.m_Relax = new JTextField[obj.length];
|
||||
this.m_Weight = new JTextField[obj.length];
|
||||
this.m_Satisfied = new JCheckBox[obj.length];
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) this.mocco.state.currentProblem).getProblemObjectives();
|
||||
this.refSolTextField = new JTextField[obj.length];
|
||||
this.relaxTextField = new JTextField[obj.length];
|
||||
this.weightTextField = new JTextField[obj.length];
|
||||
this.satisfied = new JCheckBox[obj.length];
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
@ -131,58 +127,58 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
}
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = i + 1;
|
||||
this.m_RefSol[i] = new JTextField("" + ((Double) m_RefSolution.getData(obj[i].getIdentName())).doubleValue());
|
||||
this.m_RefSol[i].setEditable(false);
|
||||
panelSTEP.add(this.m_RefSol[i], gbc);
|
||||
this.refSolTextField[i] = new JTextField("" + ((Double) refSolution.getData(obj[i].getIdentName())).doubleValue());
|
||||
this.refSolTextField[i].setEditable(false);
|
||||
panelSTEP.add(this.refSolTextField[i], gbc);
|
||||
gbc.gridx = 3;
|
||||
gbc.gridy = i + 1;
|
||||
this.m_Satisfied[i] = new JCheckBox();
|
||||
this.m_Satisfied[i].addActionListener(satisfiedChanged);
|
||||
panelSTEP.add(this.m_Satisfied[i], gbc);
|
||||
this.satisfied[i] = new JCheckBox();
|
||||
this.satisfied[i].addActionListener(satisfiedChanged);
|
||||
panelSTEP.add(this.satisfied[i], gbc);
|
||||
gbc.gridx = 4;
|
||||
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")) {
|
||||
this.m_Weight[i].setEditable(true);
|
||||
this.weightTextField[i].setEditable(true);
|
||||
} else {
|
||||
this.m_Weight[i].setEditable(false);
|
||||
this.weightTextField[i].setEditable(false);
|
||||
}
|
||||
//this.m_Satisfied[i].addActionListener(valueChanged);
|
||||
panelSTEP.add(this.m_Weight[i], gbc);
|
||||
//this.satisfied[i].addActionListener(valueChanged);
|
||||
panelSTEP.add(this.weightTextField[i], gbc);
|
||||
gbc.gridx = 5;
|
||||
gbc.gridy = i + 1;
|
||||
this.m_Relax[i] = new JTextField("0.0");
|
||||
this.m_Relax[i].setEditable(false);
|
||||
//this.m_Satisfied[i].addActionListener(valueChanged);
|
||||
panelSTEP.add(this.m_Relax[i], gbc);
|
||||
this.relaxTextField[i] = new JTextField("0.0");
|
||||
this.relaxTextField[i].setEditable(false);
|
||||
//this.satisfied[i].addActionListener(valueChanged);
|
||||
panelSTEP.add(this.relaxTextField[i], gbc);
|
||||
}
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridy = 0;
|
||||
this.m_Choice.add(panelSTEP, gbc);
|
||||
this.choicePanel.add(panelSTEP, gbc);
|
||||
|
||||
// the optimizer
|
||||
gbc.gridwidth = 1;
|
||||
this.m_EOpt = new GeneralOptimizationEditorProperty();
|
||||
this.m_Opt = new GeneticAlgorithm();
|
||||
this.m_Opt.setProblem(this.m_Mocco.m_State.m_CurrentProblem);
|
||||
this.m_Mocco.m_State.m_Optimizer = this.m_Opt;
|
||||
this.m_EOpt.name = "Island Model EA";
|
||||
this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
|
||||
this.optimizer = new GeneticAlgorithm();
|
||||
this.optimizer.setProblem(this.mocco.state.currentProblem);
|
||||
this.mocco.state.optimizer = this.optimizer;
|
||||
this.optimizationEditorProperty.name = "Island Model EA";
|
||||
try {
|
||||
this.m_EOpt.value = this.m_Opt;
|
||||
this.m_EOpt.editor = PropertyEditorProvider.findEditor(this.m_EOpt.value.getClass());
|
||||
if (this.m_EOpt.editor == null) {
|
||||
this.m_EOpt.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
this.optimizationEditorProperty.value = this.optimizer;
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
|
||||
if (this.optimizationEditorProperty.editor == null) {
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (this.m_EOpt.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EOpt.editor).setClassType(InterfaceOptimizer.class);
|
||||
if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
this.m_EOpt.editor.setValue(this.m_EOpt.value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EOpt);
|
||||
if (this.m_EOpt.view != null) {
|
||||
this.m_EOpt.view.repaint();
|
||||
this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
|
||||
AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
|
||||
if (this.optimizationEditorProperty.view != null) {
|
||||
this.optimizationEditorProperty.view.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
@ -190,16 +186,16 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 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.gridy = 2;
|
||||
gbc.weightx = 1;
|
||||
this.m_Choice.add(this.m_EOpt.view, gbc);
|
||||
this.choicePanel.add(this.optimizationEditorProperty.view, gbc);
|
||||
// Terminator
|
||||
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -218,11 +214,11 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 2;
|
||||
this.m_Choice.add(new JLabel("" + editor.name), gbc);
|
||||
this.choicePanel.add(new JLabel("" + editor.name), gbc);
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 3;
|
||||
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
|
||||
*/
|
||||
public void setReferenceSolution(AbstractEAIndividual indy) {
|
||||
this.m_RefSolution = indy;
|
||||
this.refSolution = indy;
|
||||
}
|
||||
|
||||
ActionListener satisfiedChanged = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) m_Mocco.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
for (int i = 0; i < m_Satisfied.length; i++) {
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) mocco.state.currentProblem).getProblemObjectives();
|
||||
for (int i = 0; i < satisfied.length; i++) {
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
if (m_Satisfied[i].isSelected()) {
|
||||
m_Relax[i].setEditable(true);
|
||||
m_Weight[i].setEditable(false);
|
||||
if (satisfied[i].isSelected()) {
|
||||
relaxTextField[i].setEditable(true);
|
||||
weightTextField[i].setEditable(false);
|
||||
} else {
|
||||
m_Relax[i].setEditable(false);
|
||||
m_Weight[i].setEditable(true);
|
||||
relaxTextField[i].setEditable(false);
|
||||
weightTextField[i].setEditable(true);
|
||||
}
|
||||
} else {
|
||||
m_Relax[i].setEditable(false);
|
||||
m_Weight[i].setEditable(false);
|
||||
relaxTextField[i].setEditable(false);
|
||||
weightTextField[i].setEditable(false);
|
||||
}
|
||||
}
|
||||
m_Choice.validate();
|
||||
choicePanel.validate();
|
||||
}
|
||||
};
|
||||
|
||||
@ -261,22 +257,22 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
// 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;
|
||||
weights = new double[m_RefSol.length];
|
||||
relax = new double[m_RefSol.length];
|
||||
for (int i = 0; i < m_RefSol.length; i++) {
|
||||
weights[i] = new Double(m_Weight[i].getText()).doubleValue();
|
||||
relax[i] = new Double(m_Relax[i].getText()).doubleValue();
|
||||
if ((m_Satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) {
|
||||
weights = new double[refSolTextField.length];
|
||||
relax = new double[refSolTextField.length];
|
||||
for (int i = 0; i < refSolTextField.length; i++) {
|
||||
weights[i] = new Double(weightTextField[i].getText()).doubleValue();
|
||||
relax[i] = new Double(relaxTextField[i].getText()).doubleValue();
|
||||
if ((satisfied[i].isSelected()) && (obj[i].getOptimizationMode().contains("Objective"))) {
|
||||
weights[i] = 0;
|
||||
if (obj[i].is2BMinimized()) {
|
||||
// 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]);
|
||||
} else {
|
||||
relax[i] = ((Double) m_RefSolution.getData(obj[i].getIdentName())).doubleValue()
|
||||
relax[i] = ((Double) refSolution.getData(obj[i].getIdentName())).doubleValue()
|
||||
- Math.abs(relax[i]);
|
||||
}
|
||||
obj[i].SetConstraintGoal(relax[i]);
|
||||
@ -304,17 +300,17 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
// }
|
||||
// }
|
||||
MOSOWeightedFitness wf = new MOSOWeightedFitness();
|
||||
((AbstractMultiObjectiveOptimizationProblem) m_Mocco.m_State.m_CurrentProblem).setMOSOConverter(wf);
|
||||
((AbstractMultiObjectiveOptimizationProblem) mocco.state.currentProblem).setMOSOConverter(wf);
|
||||
double[] setWeights = mapObjectives2Fitness(weights);
|
||||
PropertyDoubleArray da = new PropertyDoubleArray(setWeights);
|
||||
wf.setWeights(da);
|
||||
m_Opt.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
m_Mocco.m_State.m_Optimizer = m_Opt;
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_JPanelParameters.validate();
|
||||
m_Finished = true;
|
||||
optimizer.setProblem(mocco.state.currentProblem);
|
||||
mocco.state.optimizer = optimizer;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.parameterPanel.validate();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -328,7 +324,7 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
*/
|
||||
public double[] mapObjectives2Fitness(double[] d) {
|
||||
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("obj.length = " + obj.length);
|
||||
System.out.println("d.length = " + d.length);
|
||||
|
@ -19,24 +19,20 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
private double[] m_RefPoint;
|
||||
private IslandModelEA m_Island;
|
||||
private GeneralOptimizationEditorProperty m_EIMEA;
|
||||
private int m_Perturbations = 4;
|
||||
private JTextField m_NumPer;
|
||||
JPanel m_Parameters;
|
||||
private JTextField[] m_UpperLimit, m_LowerLimit;
|
||||
private double[] refPoint;
|
||||
private IslandModelEA islandModelEA;
|
||||
private GeneralOptimizationEditorProperty optimizationEditorProperty;
|
||||
private int perturbations = 4;
|
||||
private JTextField numPer;
|
||||
JPanel parameterPanel;
|
||||
private JTextField[] upperLimit, lowerLimit;
|
||||
|
||||
public MOCCOParameterizeTchebycheff(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,51 +40,48 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Start optimization.");
|
||||
tmpB.setToolTipText("Start the adhoc online optimization.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
tmpB = new JButton("Save task.");
|
||||
tmpB.setToolTipText("Save the optimization problem and algorithm to *.ser file for offline optimization.");
|
||||
tmpB.addActionListener(saveState2FileForOfflineOptimization);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please parameterized the Tchebycheff method." +
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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." +
|
||||
" 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);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new BorderLayout());
|
||||
this.m_Parameters = new JPanel();
|
||||
// this.m_Choice.setBorder(BorderFactory.createCompoundBorder(
|
||||
// BorderFactory.createTitledBorder("Step Method:"),
|
||||
// BorderFactory.createEmptyBorder(0, 5, 5, 5)));
|
||||
tmpP.add(this.m_Parameters, BorderLayout.CENTER);
|
||||
this.parameterPanel = new JPanel();
|
||||
tmpP.add(this.parameterPanel, BorderLayout.CENTER);
|
||||
this.installChoice();
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
|
||||
this.m_Mocco.m_JPanelParameters.validate();
|
||||
this.m_Mocco.m_JPanelControl.validate();
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.validate();
|
||||
this.mocco.controlPanel.validate();
|
||||
}
|
||||
|
||||
private void installChoice() {
|
||||
this.m_Parameters.setLayout(new GridBagLayout());
|
||||
this.parameterPanel.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
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.gridy = 0;
|
||||
gbc.weightx = 1;
|
||||
this.m_NumPer = new JTextField("" + this.m_Perturbations);
|
||||
this.m_Parameters.add(this.m_NumPer, gbc);
|
||||
this.numPer = new JTextField("" + this.perturbations);
|
||||
this.parameterPanel.add(this.numPer, gbc);
|
||||
// weight constraints
|
||||
JComponent tmpP = this.makeLimits4Weigths();
|
||||
tmpP.setBorder(BorderFactory.createCompoundBorder(
|
||||
@ -98,31 +91,31 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridy = 1;
|
||||
gbc.weightx = 2;
|
||||
this.m_Parameters.add(tmpP, gbc);
|
||||
this.parameterPanel.add(tmpP, gbc);
|
||||
// IslandModelEA
|
||||
this.m_EIMEA = new GeneralOptimizationEditorProperty();
|
||||
this.m_Island = new IslandModelEA();
|
||||
this.m_Island.setHeterogeneousProblems(true);
|
||||
this.m_Island.setLocalOnly(true);
|
||||
this.m_Island.setMigrationRate(2);
|
||||
this.m_Island.setMigrationStrategy(new SOBestMigration());
|
||||
this.m_Island.setNumberLocalCPUs(this.m_Perturbations);
|
||||
this.m_Island.setProblem(this.m_Mocco.m_State.m_CurrentProblem);
|
||||
this.m_Mocco.m_State.m_Optimizer = this.m_Island;
|
||||
this.m_EIMEA.name = "Island Model EA";
|
||||
this.optimizationEditorProperty = new GeneralOptimizationEditorProperty();
|
||||
this.islandModelEA = new IslandModelEA();
|
||||
this.islandModelEA.setHeterogeneousProblems(true);
|
||||
this.islandModelEA.setLocalOnly(true);
|
||||
this.islandModelEA.setMigrationRate(2);
|
||||
this.islandModelEA.setMigrationStrategy(new SOBestMigration());
|
||||
this.islandModelEA.setNumberLocalCPUs(this.perturbations);
|
||||
this.islandModelEA.setProblem(this.mocco.state.currentProblem);
|
||||
this.mocco.state.optimizer = this.islandModelEA;
|
||||
this.optimizationEditorProperty.name = "Island Model EA";
|
||||
try {
|
||||
this.m_EIMEA.value = this.m_Island;
|
||||
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(this.m_EIMEA.value.getClass());
|
||||
if (this.m_EIMEA.editor == null) {
|
||||
this.m_EIMEA.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
this.optimizationEditorProperty.value = this.islandModelEA;
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(this.optimizationEditorProperty.value.getClass());
|
||||
if (this.optimizationEditorProperty.editor == null) {
|
||||
this.optimizationEditorProperty.editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
}
|
||||
if (this.m_EIMEA.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EIMEA.editor).setClassType(IslandModelEA.class);
|
||||
if (this.optimizationEditorProperty.editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.optimizationEditorProperty.editor).setClassType(IslandModelEA.class);
|
||||
}
|
||||
this.m_EIMEA.editor.setValue(this.m_EIMEA.value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EIMEA);
|
||||
if (this.m_EIMEA.view != null) {
|
||||
this.m_EIMEA.view.repaint();
|
||||
this.optimizationEditorProperty.editor.setValue(this.optimizationEditorProperty.value);
|
||||
AbstractObjectEditor.findViewFor(this.optimizationEditorProperty);
|
||||
if (this.optimizationEditorProperty.view != null) {
|
||||
this.optimizationEditorProperty.view.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
@ -130,16 +123,16 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 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.gridy = 2;
|
||||
gbc.weightx = 1;
|
||||
this.m_Parameters.add(this.m_EIMEA.view, gbc);
|
||||
this.parameterPanel.add(this.optimizationEditorProperty.view, gbc);
|
||||
// Terminator
|
||||
GeneralOptimizationEditorProperty editor = new GeneralOptimizationEditorProperty();
|
||||
editor.name = "Terminator";
|
||||
try {
|
||||
editor.value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.value = this.mocco.state.terminator;
|
||||
editor.editor = PropertyEditorProvider.findEditor(editor.value.getClass());
|
||||
if (editor.editor == null) {
|
||||
editor.editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
@ -158,18 +151,18 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 2;
|
||||
this.m_Parameters.add(new JLabel("" + editor.name), gbc);
|
||||
this.parameterPanel.add(new JLabel("" + editor.name), gbc);
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 1;
|
||||
this.m_Parameters.add(editor.view, gbc);
|
||||
this.parameterPanel.add(editor.view, gbc);
|
||||
}
|
||||
|
||||
private JComponent makeLimits4Weigths() {
|
||||
JPanel result = new JPanel();
|
||||
result.setLayout(new GridBagLayout());
|
||||
this.m_UpperLimit = new JTextField[this.m_RefPoint.length];
|
||||
this.m_LowerLimit = new JTextField[this.m_RefPoint.length];
|
||||
this.upperLimit = new JTextField[this.refPoint.length];
|
||||
this.lowerLimit = new JTextField[this.refPoint.length];
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
@ -188,7 +181,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 3;
|
||||
gbc.gridy = 0;
|
||||
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.gridy = i + 1;
|
||||
gbc.weightx = 1;
|
||||
@ -196,16 +189,16 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = i + 1;
|
||||
gbc.weightx = 2;
|
||||
result.add(new JLabel("" + this.m_RefPoint[i]), gbc);
|
||||
result.add(new JLabel("" + this.refPoint[i]), gbc);
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = i + 1;
|
||||
gbc.weightx = 1;
|
||||
this.m_LowerLimit[i] = new JTextField("0.0");
|
||||
result.add(this.m_LowerLimit[i], gbc);
|
||||
this.lowerLimit[i] = new JTextField("0.0");
|
||||
result.add(this.lowerLimit[i], gbc);
|
||||
gbc.gridx = 3;
|
||||
gbc.gridy = i + 1;
|
||||
this.m_UpperLimit[i] = new JTextField("1.0");
|
||||
result.add(this.m_UpperLimit[i], gbc);
|
||||
this.upperLimit[i] = new JTextField("1.0");
|
||||
result.add(this.upperLimit[i], gbc);
|
||||
|
||||
}
|
||||
return result;
|
||||
@ -218,7 +211,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
* @param point the reference point
|
||||
*/
|
||||
public void setReferencePoint(double[] point) {
|
||||
this.m_RefPoint = point;
|
||||
this.refPoint = point;
|
||||
}
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@ -226,43 +219,43 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
// first read the values
|
||||
try {
|
||||
m_Perturbations = new Integer(m_NumPer.getText()).intValue();
|
||||
perturbations = new Integer(numPer.getText()).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Can't read k.");
|
||||
}
|
||||
if (m_EIMEA.value instanceof IslandModelEA) {
|
||||
m_Island = (IslandModelEA) m_EIMEA.value;
|
||||
if (optimizationEditorProperty.value instanceof IslandModelEA) {
|
||||
islandModelEA = (IslandModelEA) optimizationEditorProperty.value;
|
||||
} else {
|
||||
System.out.println("The selected optimizer does not allow heterogenuous multi-starts!");
|
||||
}
|
||||
// then set the values
|
||||
// if (!m_Island.getLocalOnly()) {
|
||||
// if (!islandModelEA.getLocalOnly()) {
|
||||
// ToDo: Think of new ways to do this!
|
||||
/* PropertyRemoteServers servs = m_Island.getServers();
|
||||
/* PropertyRemoteServers servs = islandModelEA.getServers();
|
||||
String[] servers = servs.getServerNodes();
|
||||
if (servers.length != m_Perturbations) {
|
||||
if (servers.length != perturbations) {
|
||||
System.out.println("Warning: Number of servers overrides number of perturbations!");
|
||||
m_Perturbations = servers.length;
|
||||
perturbations = servers.length;
|
||||
}*/
|
||||
// } else {
|
||||
// m_Island.setNumberLocalCPUs(m_Perturbations);
|
||||
// islandModelEA.setNumberLocalCPUs(perturbations);
|
||||
// }
|
||||
m_Mocco.m_State.m_Optimizer = m_Island;
|
||||
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
m_Island.init();
|
||||
mocco.state.optimizer = islandModelEA;
|
||||
mocco.state.optimizer.setProblem(mocco.state.currentProblem);
|
||||
islandModelEA.init();
|
||||
double[] tmpD;
|
||||
double sum = 0, l = 0, u = 1;
|
||||
MOSOWeightedLPTchebycheff[] tmpLPs = new MOSOWeightedLPTchebycheff[m_Perturbations];
|
||||
for (int i = 0; i < m_Perturbations; i++) {
|
||||
tmpD = new double[m_RefPoint.length];
|
||||
MOSOWeightedLPTchebycheff[] tmpLPs = new MOSOWeightedLPTchebycheff[perturbations];
|
||||
for (int i = 0; i < perturbations; i++) {
|
||||
tmpD = new double[refPoint.length];
|
||||
sum = 0;
|
||||
for (int j = 0; j < tmpD.length; j++) {
|
||||
try {
|
||||
l = new Double(m_LowerLimit[j].getText()).doubleValue();
|
||||
l = new Double(lowerLimit[j].getText()).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
try {
|
||||
u = new Double(m_UpperLimit[j].getText()).doubleValue();
|
||||
u = new Double(upperLimit[j].getText()).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
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
|
||||
// output dimension based on the AbstractMultiObjectiveOptimizationProblem and
|
||||
// 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].getIdealPWeights().m_IdealValue = m_RefPoint;
|
||||
tmpLPs[i].getIdealPWeights().m_Weights = tmpD;
|
||||
tmpLPs[i].getIdealPWeights().idealValue = refPoint;
|
||||
tmpLPs[i].getIdealPWeights().weights = tmpD;
|
||||
}
|
||||
m_Mocco.m_View.removeReferencePoint();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_JPanelParameters.validate();
|
||||
m_Finished = true;
|
||||
mocco.view.removeReferencePoint();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.parameterPanel.validate();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
}
|
@ -16,8 +16,8 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public abstract class MOCCOPhase implements InterfaceProcessElement {
|
||||
|
||||
public MOCCOStandalone m_Mocco;
|
||||
public volatile boolean m_Finished = false;
|
||||
public MOCCOStandalone mocco;
|
||||
public volatile boolean hasFinished = false;
|
||||
|
||||
/**
|
||||
* This method will call the init method and will go to stall
|
||||
@ -32,7 +32,7 @@ public abstract class MOCCOPhase implements InterfaceProcessElement {
|
||||
*/
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return this.m_Finished;
|
||||
return this.hasFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,10 +19,10 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceProcessElement {
|
||||
|
||||
private JComboBox m_ProblemChooser;
|
||||
private JComboBox problemChooser;
|
||||
|
||||
public MOCCOProblemInitialization(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.mocco = mocco;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,24 +30,24 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Continue to choose the initial number of solution alternatives.");
|
||||
tmpB.setToolTipText("This finializes the original problem definition.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.initProblemDefinition();
|
||||
|
||||
this.m_Mocco.m_JFrame.setVisible(true);
|
||||
this.m_Mocco.m_JFrame.validate();
|
||||
this.mocco.getMainFrame().setVisible(true);
|
||||
this.mocco.getMainFrame().validate();
|
||||
}
|
||||
|
||||
private void initProblemDefinition() {
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.m_ProblemChooser = new JComboBox();
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
this.problemChooser = new JComboBox();
|
||||
JComponent tmpC = new JPanel();
|
||||
tmpC.setLayout(new BorderLayout());
|
||||
|
||||
@ -57,11 +57,11 @@ public class MOCCOProblemInitialization extends MOCCOPhase implements InterfaceP
|
||||
} catch (ClassNotFoundException e) {
|
||||
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());
|
||||
this.m_ProblemChooser.getModel().setSelectedItem(objectName);
|
||||
this.m_ProblemChooser.addActionListener(problemChanged);
|
||||
String objectName = (this.mocco.state.originalProblem.getClass().getName());
|
||||
this.problemChooser.getModel().setSelectedItem(objectName);
|
||||
this.problemChooser.addActionListener(problemChanged);
|
||||
JPanel tmpP = new JPanel();
|
||||
tmpP.setLayout(new GridBagLayout());
|
||||
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);
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
tmpP.add(this.m_ProblemChooser, gbc);
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.NORTH);
|
||||
JParaPanel paraPanel = new JParaPanel(this.m_Mocco.m_State.m_OriginalProblem, "MyGUI");
|
||||
this.m_Mocco.m_JPanelParameters.add(paraPanel.makePanel(), BorderLayout.CENTER);
|
||||
tmpP.add(this.problemChooser, gbc);
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
this.mocco.parameterPanel.add(tmpP, BorderLayout.NORTH);
|
||||
JParaPanel paraPanel = new JParaPanel(this.mocco.state.originalProblem, "MyGUI");
|
||||
this.mocco.parameterPanel.add(paraPanel.makePanel(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Finished = true;
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
mocco.parameterPanel.removeAll();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
ActionListener problemChanged = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String className = (String) m_ProblemChooser.getSelectedItem();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
String className = (String) problemChooser.getSelectedItem();
|
||||
mocco.parameterPanel.removeAll();
|
||||
Object n = null;
|
||||
try {
|
||||
n = (Object) Class.forName(className).newInstance();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
m_Mocco.m_State.m_OriginalProblem = (InterfaceOptimizationProblem) n;
|
||||
mocco.state.originalProblem = (InterfaceOptimizationProblem) n;
|
||||
initProblemDefinition();
|
||||
m_Mocco.m_JPanelParameters.validate();
|
||||
mocco.parameterPanel.validate();
|
||||
}
|
||||
};
|
||||
}
|
@ -19,11 +19,11 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfaceProcessElement {
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem;
|
||||
private InterfaceOptimizationProblem optimizationProblem;
|
||||
|
||||
public MOCCOProblemRedefinition(MOCCOStandalone mocco) {
|
||||
this.m_Mocco = mocco;
|
||||
this.m_Problem = (InterfaceOptimizationProblem) this.m_Mocco.m_State.m_CurrentProblem.clone();
|
||||
this.mocco = mocco;
|
||||
this.optimizationProblem = (InterfaceOptimizationProblem) this.mocco.state.currentProblem.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,16 +31,16 @@ public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfacePro
|
||||
*/
|
||||
@Override
|
||||
public void initProcessElementParametrization() {
|
||||
this.m_Mocco.m_JPanelControl.removeAll();
|
||||
this.mocco.controlPanel.removeAll();
|
||||
|
||||
// The button panel
|
||||
JButton tmpB = new JButton("Continue to choose the optimization strategy.");
|
||||
tmpB.setToolTipText("This finializes the problem redefinition process.");
|
||||
tmpB.addActionListener(continue2);
|
||||
this.m_Mocco.m_JPanelControl.add(tmpB);
|
||||
this.mocco.controlPanel.add(tmpB);
|
||||
|
||||
// the parameter panel
|
||||
this.m_Mocco.m_JPanelParameters.removeAll();
|
||||
this.mocco.parameterPanel.removeAll();
|
||||
JComponent tmpC = new JPanel();
|
||||
tmpC.setLayout(new BorderLayout());
|
||||
JPanel tmpP = new JPanel();
|
||||
@ -61,34 +61,34 @@ public class MOCCOProblemRedefinition extends MOCCOPhase implements InterfacePro
|
||||
tmpB = new JButton("Reevaluate Problem");
|
||||
tmpB.addActionListener(reevaluate);
|
||||
tmpP.add(tmpB, gbc);
|
||||
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.NORTH);
|
||||
this.mocco.parameterPanel.setLayout(new BorderLayout());
|
||||
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());
|
||||
this.m_Mocco.m_JPanelParameters.add(tmpC, BorderLayout.CENTER);
|
||||
this.mocco.parameterPanel.add(tmpC, BorderLayout.CENTER);
|
||||
|
||||
this.m_Mocco.m_JFrame.setVisible(true);
|
||||
this.m_Mocco.m_JFrame.validate();
|
||||
this.mocco.getMainFrame().setVisible(true);
|
||||
this.mocco.getMainFrame().validate();
|
||||
}
|
||||
|
||||
ActionListener continue2 = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) m_Problem.clone();
|
||||
m_Mocco.m_JPanelParameters.removeAll();
|
||||
m_Mocco.m_JPanelControl.removeAll();
|
||||
m_Mocco.m_JPanelControl.validate();
|
||||
m_Finished = true;
|
||||
mocco.state.currentProblem = (InterfaceOptimizationProblem) optimizationProblem.clone();
|
||||
mocco.parameterPanel.removeAll();
|
||||
mocco.controlPanel.removeAll();
|
||||
mocco.controlPanel.validate();
|
||||
hasFinished = true;
|
||||
}
|
||||
};
|
||||
ActionListener reevaluate = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_Mocco.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) m_Problem.clone();
|
||||
m_Mocco.m_State.m_CurrentProblem = m_Problem;
|
||||
m_Mocco.m_State.makeFitnessCache(true);
|
||||
m_Mocco.m_View.problemChanged(true);
|
||||
mocco.state.currentProblem = (InterfaceOptimizationProblem) optimizationProblem.clone();
|
||||
mocco.state.currentProblem = optimizationProblem;
|
||||
mocco.state.makeFitnessCache(true);
|
||||
mocco.view.problemChanged(true);
|
||||
}
|
||||
};
|
||||
}
|
@ -25,88 +25,88 @@ import java.util.ArrayList;
|
||||
public class MOCCOState {
|
||||
|
||||
public transient boolean isVisible = false;
|
||||
public InterfaceOptimizer m_Optimizer = new MultiObjectiveEA();
|
||||
public InterfaceOptimizer m_BackupOptimizer;
|
||||
public InterfaceTerminator m_Terminator = new EvaluationTerminator();
|
||||
public InterfaceOptimizationProblem m_OriginalProblem = null;
|
||||
public InterfaceOptimizationProblem m_CurrentProblem;
|
||||
public InterfaceOptimizationProblem m_BackupProblem;
|
||||
public int m_InitialPopulationSize = 50;
|
||||
public InterfaceOptimizer optimizer = new MultiObjectiveEA();
|
||||
public InterfaceOptimizer backupOptimizer;
|
||||
public InterfaceTerminator terminator = new EvaluationTerminator();
|
||||
public InterfaceOptimizationProblem originalProblem = null;
|
||||
public InterfaceOptimizationProblem currentProblem;
|
||||
public InterfaceOptimizationProblem backupProblem;
|
||||
public int initialPopulationSize = 50;
|
||||
// the population history
|
||||
public Population m_ParetoFront;
|
||||
public Population[] m_PopulationHistory = new Population[0];
|
||||
public boolean[] m_Show;
|
||||
public boolean[] m_Use;
|
||||
public Color[] m_Color;
|
||||
public Population paretoFront;
|
||||
public Population[] populationHistory = new Population[0];
|
||||
public boolean[] show;
|
||||
public boolean[] use;
|
||||
public Color[] colors;
|
||||
// the fitness cache for fast plotting
|
||||
public ArrayList m_FitnessCache = new ArrayList();
|
||||
public ArrayList m_ObjectiveCache = new ArrayList();
|
||||
public ArrayList m_ConstraintCache = new ArrayList();
|
||||
public ArrayList fitnessCache = new ArrayList();
|
||||
public ArrayList objectiveCache = new ArrayList();
|
||||
public ArrayList constraintCache = new ArrayList();
|
||||
|
||||
public MOCCOState() {
|
||||
}
|
||||
|
||||
public void restore() {
|
||||
Population pop = this.m_Optimizer.getPopulation();
|
||||
if (this.m_BackupProblem != null) {
|
||||
this.m_CurrentProblem = this.m_BackupProblem;
|
||||
this.m_BackupProblem = null;
|
||||
Population pop = this.optimizer.getPopulation();
|
||||
if (this.backupProblem != null) {
|
||||
this.currentProblem = this.backupProblem;
|
||||
this.backupProblem = null;
|
||||
}
|
||||
if (this.m_BackupOptimizer != null) {
|
||||
this.m_Optimizer = this.m_BackupOptimizer;
|
||||
this.m_BackupOptimizer = null;
|
||||
if (this.backupOptimizer != null) {
|
||||
this.optimizer = this.backupOptimizer;
|
||||
this.backupOptimizer = null;
|
||||
}
|
||||
this.m_Optimizer.setPopulation(pop);
|
||||
this.m_Optimizer.setProblem(this.m_CurrentProblem);
|
||||
this.m_CurrentProblem.evaluate(this.m_Optimizer.getPopulation());
|
||||
this.optimizer.setPopulation(pop);
|
||||
this.optimizer.setProblem(this.currentProblem);
|
||||
this.currentProblem.evaluate(this.optimizer.getPopulation());
|
||||
}
|
||||
|
||||
public void makeBackup() {
|
||||
this.m_BackupProblem = (InterfaceOptimizationProblem) this.m_CurrentProblem.clone();
|
||||
this.m_BackupOptimizer = (InterfaceOptimizer) this.m_Optimizer.clone();
|
||||
this.m_BackupOptimizer.setProblem(null);
|
||||
this.backupProblem = (InterfaceOptimizationProblem) this.currentProblem.clone();
|
||||
this.backupOptimizer = (InterfaceOptimizer) this.optimizer.clone();
|
||||
this.backupOptimizer.setProblem(null);
|
||||
}
|
||||
|
||||
public void addPopulation2History(Population pop) {
|
||||
InterfaceOptimizationObjective[] tmpObj = null;
|
||||
|
||||
if (this.m_Show == null) {
|
||||
this.m_Use = new boolean[1];
|
||||
this.m_Use[0] = true;
|
||||
this.m_Show = new boolean[1];
|
||||
this.m_Show[0] = true;
|
||||
this.m_Color = new Color[1];
|
||||
this.m_Color[0] = this.getColor4Index(0);
|
||||
if (this.show == null) {
|
||||
this.use = new boolean[1];
|
||||
this.use[0] = true;
|
||||
this.show = new boolean[1];
|
||||
this.show[0] = true;
|
||||
this.colors = new Color[1];
|
||||
this.colors[0] = this.getColor4Index(0);
|
||||
} else {
|
||||
boolean[] newUse = new boolean[this.m_Show.length + 1];
|
||||
boolean[] newShow = new boolean[this.m_Show.length + 1];
|
||||
Color[] newColor = new Color[this.m_Show.length + 1];
|
||||
for (int i = 0; i < this.m_Show.length; i++) {
|
||||
newUse[i] = this.m_Use[i];
|
||||
newShow[i] = this.m_Show[i];
|
||||
newColor[i] = this.m_Color[i];
|
||||
boolean[] newUse = new boolean[this.show.length + 1];
|
||||
boolean[] newShow = new boolean[this.show.length + 1];
|
||||
Color[] newColor = new Color[this.show.length + 1];
|
||||
for (int i = 0; i < this.show.length; i++) {
|
||||
newUse[i] = this.use[i];
|
||||
newShow[i] = this.show[i];
|
||||
newColor[i] = this.colors[i];
|
||||
}
|
||||
newUse[m_Show.length] = true;
|
||||
newShow[m_Show.length] = true;
|
||||
newColor[m_Show.length] = this.getColor4Index(this.m_PopulationHistory.length);
|
||||
this.m_Use = newUse;
|
||||
this.m_Show = newShow;
|
||||
this.m_Color = newColor;
|
||||
newUse[show.length] = true;
|
||||
newShow[show.length] = true;
|
||||
newColor[show.length] = this.getColor4Index(this.populationHistory.length);
|
||||
this.use = newUse;
|
||||
this.show = newShow;
|
||||
this.colors = newColor;
|
||||
}
|
||||
|
||||
Population[] newPop = new Population[this.m_PopulationHistory.length + 1];
|
||||
for (int i = 0; i < this.m_PopulationHistory.length; i++) {
|
||||
newPop[i] = this.m_PopulationHistory[i];
|
||||
Population[] newPop = new Population[this.populationHistory.length + 1];
|
||||
for (int i = 0; i < this.populationHistory.length; i++) {
|
||||
newPop[i] = this.populationHistory[i];
|
||||
}
|
||||
newPop[newPop.length - 1] = (Population) pop.clone();
|
||||
newPop[newPop.length - 1].addPopulation(newPop[newPop.length - 1].getArchive());
|
||||
newPop[newPop.length - 1].SetArchive(null);
|
||||
this.m_PopulationHistory = newPop;
|
||||
this.populationHistory = newPop;
|
||||
ArrayList fitness = new ArrayList();
|
||||
ArrayList objectives = new ArrayList();
|
||||
ArrayList constraint = new ArrayList();
|
||||
if (this.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_CurrentProblem).getProblemObjectives();
|
||||
if (this.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.currentProblem).getProblemObjectives();
|
||||
}
|
||||
for (int j = 0; j < newPop[newPop.length - 1].size(); j++) {
|
||||
if (tmpObj != null) {
|
||||
@ -119,11 +119,11 @@ public class MOCCOState {
|
||||
fitness.add(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getFitness());
|
||||
constraint.add(new Double(((AbstractEAIndividual) newPop[newPop.length - 1].get(j)).getConstraintViolation()));
|
||||
}
|
||||
if (this.m_ObjectiveCache != null) {
|
||||
this.m_ObjectiveCache.add(objectives);
|
||||
if (this.objectiveCache != null) {
|
||||
this.objectiveCache.add(objectives);
|
||||
}
|
||||
this.m_FitnessCache.add(fitness);
|
||||
this.m_ConstraintCache.add(constraint);
|
||||
this.fitnessCache.add(fitness);
|
||||
this.constraintCache.add(constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,9 +152,9 @@ public class MOCCOState {
|
||||
|
||||
public void reduce2ParetoFront(int i) {
|
||||
ArchivingAllDominating arch = new ArchivingAllDominating();
|
||||
arch.addElementsToArchive(this.m_PopulationHistory[i]);
|
||||
this.m_PopulationHistory[i] = this.m_PopulationHistory[i].getArchive();
|
||||
this.m_PopulationHistory[i].SetArchive(null);
|
||||
arch.addElementsToArchive(this.populationHistory[i]);
|
||||
this.populationHistory[i] = this.populationHistory[i].getArchive();
|
||||
this.populationHistory[i].SetArchive(null);
|
||||
this.makeFitnessCache(false);
|
||||
}
|
||||
|
||||
@ -165,12 +165,12 @@ public class MOCCOState {
|
||||
*/
|
||||
public Population getSelectedPopulations() {
|
||||
Population result = new Population();
|
||||
for (int i = 0; i < this.m_PopulationHistory.length; i++) {
|
||||
if (this.m_Use[i]) {
|
||||
result.addPopulation(this.m_PopulationHistory[i]);
|
||||
for (int i = 0; i < this.populationHistory.length; i++) {
|
||||
if (this.use[i]) {
|
||||
result.addPopulation(this.populationHistory[i]);
|
||||
}
|
||||
}
|
||||
this.m_CurrentProblem.evaluate(result);
|
||||
this.currentProblem.evaluate(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -184,65 +184,65 @@ public class MOCCOState {
|
||||
InterfaceOptimizationObjective[] tmpObj = null;
|
||||
if (reevaluate) {
|
||||
// clear all archives, since problem dimension may have changed
|
||||
for (int i = 0; i < this.m_PopulationHistory.length; i++) {
|
||||
if (this.m_PopulationHistory[i].getArchive() != null) {
|
||||
this.m_PopulationHistory[i].addPopulation(this.m_PopulationHistory[i].getArchive());
|
||||
this.m_PopulationHistory[i].SetArchive(null);
|
||||
for (int i = 0; i < this.populationHistory.length; i++) {
|
||||
if (this.populationHistory[i].getArchive() != null) {
|
||||
this.populationHistory[i].addPopulation(this.populationHistory[i].getArchive());
|
||||
this.populationHistory[i].SetArchive(null);
|
||||
}
|
||||
}
|
||||
Population pop = this.m_Optimizer.getPopulation();
|
||||
Population pop = this.optimizer.getPopulation();
|
||||
if (pop.getArchive() != null) {
|
||||
pop.addPopulation(pop.getArchive());
|
||||
pop.SetArchive(null);
|
||||
}
|
||||
this.m_CurrentProblem.evaluate(pop);
|
||||
this.currentProblem.evaluate(pop);
|
||||
}
|
||||
this.m_FitnessCache = new ArrayList();
|
||||
this.m_ObjectiveCache = null;
|
||||
this.m_ConstraintCache = new ArrayList();
|
||||
if (this.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
this.m_ObjectiveCache = new ArrayList();
|
||||
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_CurrentProblem).getProblemObjectives();
|
||||
this.fitnessCache = new ArrayList();
|
||||
this.objectiveCache = null;
|
||||
this.constraintCache = new ArrayList();
|
||||
if (this.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
this.objectiveCache = new ArrayList();
|
||||
tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.currentProblem).getProblemObjectives();
|
||||
}
|
||||
this.m_ParetoFront = new Population();
|
||||
for (int i = 0; i < this.m_PopulationHistory.length; i++) {
|
||||
this.paretoFront = new Population();
|
||||
for (int i = 0; i < this.populationHistory.length; i++) {
|
||||
if (reevaluate) {
|
||||
((AbstractMultiObjectiveOptimizationProblem) this.m_CurrentProblem).resetParetoFront();
|
||||
this.m_CurrentProblem.evaluate(this.m_PopulationHistory[i]);
|
||||
((AbstractMultiObjectiveOptimizationProblem) this.currentProblem).resetParetoFront();
|
||||
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 objectives = 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) {
|
||||
double[] tmoF = new double[tmpObj.length];
|
||||
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!");
|
||||
}
|
||||
if (tmpObj[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!");
|
||||
}
|
||||
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);
|
||||
}
|
||||
fitness.add(((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getFitness());
|
||||
constraint.add(new Double(((AbstractEAIndividual) this.m_PopulationHistory[i].get(j)).getConstraintViolation()));
|
||||
fitness.add(((AbstractEAIndividual) this.populationHistory[i].get(j)).getFitness());
|
||||
constraint.add(new Double(((AbstractEAIndividual) this.populationHistory[i].get(j)).getConstraintViolation()));
|
||||
}
|
||||
if (this.m_ObjectiveCache != null) {
|
||||
this.m_ObjectiveCache.add(objectives);
|
||||
if (this.objectiveCache != null) {
|
||||
this.objectiveCache.add(objectives);
|
||||
}
|
||||
this.m_FitnessCache.add(fitness);
|
||||
this.m_ConstraintCache.add(constraint);
|
||||
this.fitnessCache.add(fitness);
|
||||
this.constraintCache.add(constraint);
|
||||
}
|
||||
ArchivingAllDominating arch = new ArchivingAllDominating();
|
||||
arch.addElementsToArchive(this.m_ParetoFront);
|
||||
this.m_ParetoFront = this.m_ParetoFront.getArchive();
|
||||
this.m_ParetoFront.SetArchive(null);
|
||||
arch.addElementsToArchive(this.paretoFront);
|
||||
this.paretoFront = this.paretoFront.getArchive();
|
||||
this.paretoFront.SetArchive(null);
|
||||
}
|
||||
}
|
||||
|
@ -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 MOCCOStandalone m_MOCCO;
|
||||
public MOCCOViewer m_self;
|
||||
private InterfaceParetoFrontView m_View;
|
||||
private FunctionArea m_1DView;
|
||||
public JSplitPane m_JSplit;
|
||||
public JPanel m_ViewPanel, m_Choices;
|
||||
private InterfaceRefSolutionListener m_RefSolutionListener;
|
||||
private InterfaceRefPointListener m_RefPointListener;
|
||||
public double[] m_ReferencePoint = null;
|
||||
public boolean m_SelectUniqueSolution = true;
|
||||
public boolean m_RefPointSelectable = false;
|
||||
public boolean m_RefSolutionSelectable = false;
|
||||
public MOCCOStandalone moccoStandalone;
|
||||
public MOCCOViewer instance;
|
||||
private InterfaceParetoFrontView paretoFrontView;
|
||||
private FunctionArea functionAre;
|
||||
public JPanel viewPanel, choicesPanel;
|
||||
private InterfaceRefSolutionListener refSolutionListener;
|
||||
private InterfaceRefPointListener refPointListener;
|
||||
public double[] referencePoint = null;
|
||||
public boolean selectUniqueSolution = true;
|
||||
public boolean refPointSelectable = false;
|
||||
public boolean refSolutionSelectable = false;
|
||||
|
||||
public MOCCOViewer(MOCCOStandalone t) {
|
||||
this.m_MOCCO = t;
|
||||
this.m_self = this;
|
||||
this.moccoStandalone = t;
|
||||
this.instance = this;
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.setLayout(new BorderLayout());
|
||||
// the view
|
||||
this.m_ViewPanel = new JPanel();
|
||||
this.m_ViewPanel.setLayout(new BorderLayout());
|
||||
this.m_View = new ParetoFrontView2D(this);
|
||||
this.m_ViewPanel.add((JPanel) this.m_View, BorderLayout.CENTER);
|
||||
this.viewPanel = new JPanel();
|
||||
this.viewPanel.setLayout(new BorderLayout());
|
||||
this.paretoFrontView = new ParetoFrontView2D(this);
|
||||
this.viewPanel.add((JPanel) this.paretoFrontView, BorderLayout.CENTER);
|
||||
// the parameters
|
||||
this.m_Choices = new JPanel();
|
||||
this.choicesPanel = new JPanel();
|
||||
JPanel tmpP = new JPanel();
|
||||
this.m_Choices.setLayout(new GridLayout(1, 2));
|
||||
this.m_Choices.add(tmpP);
|
||||
this.choicesPanel.setLayout(new GridLayout(1, 2));
|
||||
this.choicesPanel.add(tmpP);
|
||||
tmpP.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
@ -90,70 +85,12 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
tmpP.add(tmpC, gbc);
|
||||
JButton JBSaveParetoFront = new JButton("Save Pareto Front");
|
||||
JBSaveParetoFront.addActionListener(this.saveParetoFront);
|
||||
this.m_Choices.add(JBSaveParetoFront);
|
||||
this.choicesPanel.add(JBSaveParetoFront);
|
||||
// the main panel
|
||||
this.add(this.m_ViewPanel, BorderLayout.CENTER);
|
||||
this.add(this.m_Choices, 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();
|
||||
this.add(this.viewPanel, BorderLayout.CENTER);
|
||||
this.add(this.choicesPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
// 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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
@ -161,35 +98,35 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
int index = tmpC.getSelectedIndex();
|
||||
switch (index) {
|
||||
case 0: {
|
||||
m_ViewPanel.removeAll();
|
||||
m_View = new ParetoFrontView2D(m_self);
|
||||
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER);
|
||||
viewPanel.removeAll();
|
||||
paretoFrontView = new ParetoFrontView2D(instance);
|
||||
viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
|
||||
//problemChanged(false);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
m_ViewPanel.removeAll();
|
||||
m_View = new ParetoFrontViewScatterPlot(m_self);
|
||||
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER);
|
||||
viewPanel.removeAll();
|
||||
paretoFrontView = new ParetoFrontViewScatterPlot(instance);
|
||||
viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
|
||||
//problemChanged(false);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
m_ViewPanel.removeAll();
|
||||
m_View = new ParetoFrontViewParallelAxsis(m_self);
|
||||
m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER);
|
||||
viewPanel.removeAll();
|
||||
paretoFrontView = new ParetoFrontViewParallelAxis(instance);
|
||||
viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
|
||||
//problemChanged(false);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
m_ViewPanel.removeAll();
|
||||
m_View = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getParetoFrontViewer4MOCCO(m_self);
|
||||
m_ViewPanel.add((JComponent) m_View, BorderLayout.CENTER);
|
||||
viewPanel.removeAll();
|
||||
paretoFrontView = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getParetoFrontViewer4MOCCO(instance);
|
||||
viewPanel.add((JComponent) paretoFrontView, BorderLayout.CENTER);
|
||||
//problemChanged(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ViewPanel.updateUI();
|
||||
viewPanel.updateUI();
|
||||
}
|
||||
};
|
||||
|
||||
@ -197,19 +134,19 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
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;
|
||||
Population pop;
|
||||
|
||||
String name = "MOCCO_" + m_StartDate + "_PF_Iteration_" + m_MOCCO.m_Iteration + ".dat", tmp;
|
||||
pop = m_MOCCO.m_State.m_ParetoFront;
|
||||
String name = "MOCCO_" + startDate + "_PF_Iteration_" + moccoStandalone.iteration + ".dat", tmp;
|
||||
pop = moccoStandalone.state.paretoFront;
|
||||
try {
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Could not open output file! Filename: " + name);
|
||||
return;
|
||||
}
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
InterfaceOptimizationObjective[] obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
tmp = "";
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
tmp += obj[j].getIdentName() + "\t";
|
||||
@ -237,7 +174,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
} 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 {
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -245,10 +182,10 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
return;
|
||||
}
|
||||
pop = new Population();
|
||||
for (int i = 0; i < m_MOCCO.m_State.m_PopulationHistory.length; i++) {
|
||||
pop.addPopulation(m_MOCCO.m_State.m_PopulationHistory[i]);
|
||||
for (int i = 0; i < moccoStandalone.state.populationHistory.length; i++) {
|
||||
pop.addPopulation(moccoStandalone.state.populationHistory[i]);
|
||||
}
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
tmp = "";
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
tmp += obj[j].getIdentName() + "\t";
|
||||
@ -276,7 +213,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
} 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 {
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -284,10 +221,10 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
return;
|
||||
}
|
||||
pop = new Population();
|
||||
for (int i = 0; i < m_MOCCO.m_State.m_PopulationHistory.length; i++) {
|
||||
pop.addPopulation(m_MOCCO.m_State.m_PopulationHistory[i]);
|
||||
for (int i = 0; i < moccoStandalone.state.populationHistory.length; i++) {
|
||||
pop.addPopulation(moccoStandalone.state.populationHistory[i]);
|
||||
}
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
tmp = "";
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
tmp += obj[j].getIdentName() + "\t";
|
||||
@ -315,15 +252,15 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
} 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 {
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Could not open output file! Filename: " + name);
|
||||
return;
|
||||
}
|
||||
pop = m_MOCCO.m_State.m_ParetoFront.getMarkedIndividuals();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
pop = moccoStandalone.state.paretoFront.getMarkedIndividuals();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
tmp = "";
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
tmp += obj[j].getIdentName() + "\t";
|
||||
@ -349,15 +286,15 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
} 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 {
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Could not open output file! Filename: " + name);
|
||||
return;
|
||||
}
|
||||
pop = m_MOCCO.m_State.m_ParetoFront.getMarkedIndividuals();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
pop = moccoStandalone.state.paretoFront.getMarkedIndividuals();
|
||||
obj = ((InterfaceMultiObjectiveDeNovoProblem) moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
tmp = "";
|
||||
for (int j = 0; j < obj.length; j++) {
|
||||
tmp += obj[j].getIdentName() + "\t";
|
||||
@ -367,9 +304,9 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
} catch (java.io.IOException e) {
|
||||
}
|
||||
tmp = "";
|
||||
if (m_ReferencePoint != null) {
|
||||
for (int j = 0; j < m_ReferencePoint.length; j++) {
|
||||
tmp += m_ReferencePoint[j] + "\t";
|
||||
if (referencePoint != null) {
|
||||
for (int j = 0; j < referencePoint.length; j++) {
|
||||
tmp += referencePoint[j] + "\t";
|
||||
}
|
||||
try {
|
||||
out.write(tmp + "\n");
|
||||
@ -384,29 +321,29 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
};
|
||||
|
||||
public void problemChanged(boolean t) {
|
||||
this.m_MOCCO.m_State.makeFitnessCache(t);
|
||||
this.moccoStandalone.state.makeFitnessCache(t);
|
||||
//this.updateHistory();
|
||||
if (this.m_MOCCO.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||
if (this.m_1DView != null) {
|
||||
this.m_ViewPanel.removeAll();
|
||||
this.m_ViewPanel.add((JPanel) m_View, BorderLayout.CENTER);
|
||||
if (this.moccoStandalone.state.currentProblem.isMultiObjective()) {
|
||||
if (this.functionAre != null) {
|
||||
this.viewPanel.removeAll();
|
||||
this.viewPanel.add((JPanel) paretoFrontView, BorderLayout.CENTER);
|
||||
}
|
||||
this.m_View.updateView();
|
||||
this.m_1DView = null;
|
||||
this.paretoFrontView.updateView();
|
||||
this.functionAre = null;
|
||||
} else {
|
||||
// here I simply add a single-objective view..
|
||||
if (this.m_1DView == null) {
|
||||
this.m_ViewPanel.removeAll();
|
||||
this.m_ViewPanel.setLayout(new BorderLayout());
|
||||
this.m_1DView = new FunctionArea("?", "?");
|
||||
this.m_1DView.setPreferredSize(new Dimension(450, 450));
|
||||
this.m_1DView.setMinimumSize(new Dimension(450, 450));
|
||||
if (this.functionAre == null) {
|
||||
this.viewPanel.removeAll();
|
||||
this.viewPanel.setLayout(new BorderLayout());
|
||||
this.functionAre = new FunctionArea("?", "?");
|
||||
this.functionAre.setPreferredSize(new Dimension(450, 450));
|
||||
this.functionAre.setMinimumSize(new Dimension(450, 450));
|
||||
ScaledBorder areaBorder = new ScaledBorder();
|
||||
areaBorder.x_label = "Optimzation Step";
|
||||
areaBorder.y_label = "Fitness";
|
||||
this.m_1DView.setBorder(areaBorder);
|
||||
this.m_1DView.setBackground(Color.WHITE);
|
||||
this.m_ViewPanel.add(this.m_1DView, BorderLayout.CENTER);
|
||||
areaBorder.xLabel = "Optimzation Step";
|
||||
areaBorder.yLabel = "Fitness";
|
||||
this.functionAre.setBorder(areaBorder);
|
||||
this.functionAre.setBackground(Color.WHITE);
|
||||
this.viewPanel.add(this.functionAre, BorderLayout.CENTER);
|
||||
}
|
||||
this.plot1DFitnessPlot();
|
||||
}
|
||||
@ -418,23 +355,22 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
*/
|
||||
public void plot1DFitnessPlot() {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
GraphPointSet mySet;
|
||||
DPoint myPoint;
|
||||
DPointIcon icon;
|
||||
this.m_1DView.removeAll();
|
||||
mySet = new GraphPointSet(1, this.m_1DView);
|
||||
this.functionAre.removeAll();
|
||||
mySet = new GraphPointSet(1, this.functionAre);
|
||||
mySet.setConnectedMode(true);
|
||||
mySet.setColor(Color.BLACK);
|
||||
for (int i = 0; i < pops.length; i++) {
|
||||
fitness = pops[i].getBestEAIndividual().getFitness()[0];
|
||||
myPoint = new DPoint(i + 1, fitness);
|
||||
icon = new Chart2DDPointContentSelectable();
|
||||
//if (this.m_MOCCOViewer.m_RefSolutionSelectable) ((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_MOCCOViewer);
|
||||
((InterfaceDPointWithContent) icon).setProblem(this.m_MOCCO.m_State.m_CurrentProblem);
|
||||
((InterfaceDPointWithContent) icon).setProblem(this.moccoStandalone.state.currentProblem);
|
||||
((InterfaceDPointWithContent) icon).setEAIndividual(pops[i].getBestEAIndividual());
|
||||
myPoint.setIcon(icon);
|
||||
mySet.addDPoint(myPoint);
|
||||
@ -445,7 +381,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
ymax = fitness;
|
||||
}
|
||||
}
|
||||
mySet = new GraphPointSet(2, this.m_1DView);
|
||||
mySet = new GraphPointSet(2, this.functionAre);
|
||||
mySet.setConnectedMode(false);
|
||||
double yrange = ymax - ymin;
|
||||
if (yrange < 0.00001) {
|
||||
@ -453,7 +389,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
}
|
||||
mySet.addDPoint(0, ymin - 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()) {
|
||||
indy.unmark();
|
||||
} else {
|
||||
if (this.m_SelectUniqueSolution) {
|
||||
this.m_MOCCO.m_State.m_ParetoFront.unmarkAllIndividuals();
|
||||
if (this.selectUniqueSolution) {
|
||||
this.moccoStandalone.state.paretoFront.unmarkAllIndividuals();
|
||||
}
|
||||
indy.mark();
|
||||
}
|
||||
this.m_View.updateView();
|
||||
if (this.m_RefSolutionListener != null) {
|
||||
this.m_RefSolutionListener.individualSelected(indy);
|
||||
this.paretoFrontView.updateView();
|
||||
if (this.refSolutionListener != null) {
|
||||
this.refSolutionListener.individualSelected(indy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,7 +425,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
* @param 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
|
||||
*/
|
||||
public void setRefSolutionSelectable(boolean t) {
|
||||
this.m_RefSolutionSelectable = t;
|
||||
this.m_View.updateView();
|
||||
this.refSolutionSelectable = t;
|
||||
this.paretoFrontView.updateView();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,7 +445,7 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
* @param a The selection listener
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public InterfaceRefSolutionListener getRefSolutionSelectionListener() {
|
||||
return this.m_RefSolutionListener;
|
||||
return this.refSolutionListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to remove the selection listner to the PointIcon
|
||||
*/
|
||||
public void removeRefSolutionSelectionListeners() {
|
||||
this.m_RefSolutionListener = null;
|
||||
this.refSolutionListener = null;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -539,11 +475,11 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
*/
|
||||
@Override
|
||||
public void refPointGiven(double[] point) {
|
||||
this.m_ReferencePoint = point;
|
||||
if (this.m_RefPointListener != null) {
|
||||
this.m_RefPointListener.refPointGiven(point);
|
||||
this.referencePoint = point;
|
||||
if (this.refPointListener != null) {
|
||||
this.refPointListener.refPointGiven(point);
|
||||
}
|
||||
this.m_View.updateView();
|
||||
this.paretoFrontView.updateView();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -552,24 +488,24 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
* @param t
|
||||
*/
|
||||
public void setRefPointSelectable(boolean t) {
|
||||
this.m_RefPointSelectable = t;
|
||||
if (this.m_RefPointSelectable) {
|
||||
int dim = ((AbstractEAIndividual) this.m_MOCCO.m_State.m_ParetoFront.get(0)).getFitness().length;
|
||||
this.m_ReferencePoint = new double[dim];
|
||||
this.refPointSelectable = t;
|
||||
if (this.refPointSelectable) {
|
||||
int dim = ((AbstractEAIndividual) this.moccoStandalone.state.paretoFront.get(0)).getFitness().length;
|
||||
this.referencePoint = new double[dim];
|
||||
for (int i = 0; i < dim; i++) {
|
||||
this.m_ReferencePoint[i] = 0;
|
||||
this.referencePoint[i] = 0;
|
||||
}
|
||||
} else {
|
||||
//this.m_ReferencePoint = null;
|
||||
//this.referencePoint = null;
|
||||
}
|
||||
this.m_View.updateView();
|
||||
this.paretoFrontView.updateView();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes the reference point
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public InterfaceRefPointListener getRefPointSelectionListener() {
|
||||
return this.m_RefPointListener;
|
||||
return this.refPointListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to remove the selection listner to the PointIcon
|
||||
*/
|
||||
public void removeRefPointSelectionListeners() {
|
||||
this.m_RefPointListener = null;
|
||||
this.m_View.updateView();
|
||||
this.refPointListener = null;
|
||||
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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.optimization.mocco.paretofrontviewer;
|
||||
|
||||
|
||||
import eva2.gui.plot.FunctionArea;
|
||||
import eva2.gui.plot.GraphPointSet;
|
||||
import eva2.gui.plot.InterfaceDPointWithContent;
|
||||
@ -16,68 +15,63 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
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 MOCCOViewer m_MOCCOViewer;
|
||||
private JPanel m_JPMain;
|
||||
private JPanel m_JPTop;
|
||||
private JComboBox m_JCObjective1, m_JCObjective2, m_JCFitObj;
|
||||
private FunctionArea m_Area;
|
||||
private ScaledBorder m_AreaBorder;
|
||||
private InterfaceRefPointListener m_RefPointListener;
|
||||
public MOCCOViewer moccoViewer;
|
||||
private JPanel mainPanel;
|
||||
private JPanel topPanel;
|
||||
private JComboBox objective1, objective2, fitObjective;
|
||||
private FunctionArea functionArea;
|
||||
private ScaledBorder areaBorder;
|
||||
private InterfaceRefPointListener refPointListener;
|
||||
|
||||
public ParetoFrontView2D(MOCCOViewer t) {
|
||||
this.m_MOCCOViewer = t;
|
||||
this.moccoViewer = t;
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.m_JPMain = new JPanel();
|
||||
this.m_JPMain.setLayout(new BorderLayout());
|
||||
this.mainPanel = new JPanel();
|
||||
this.mainPanel.setLayout(new BorderLayout());
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(this.m_JPMain, BorderLayout.CENTER);
|
||||
this.m_Area = new FunctionArea("?", "?");
|
||||
this.m_Area.setPreferredSize(new Dimension(450, 450));
|
||||
this.m_Area.setMinimumSize(new Dimension(450, 450));
|
||||
this.m_AreaBorder = new ScaledBorder();
|
||||
this.m_AreaBorder.x_label = "?";
|
||||
this.m_AreaBorder.y_label = "?";
|
||||
this.m_Area.setBorder(this.m_AreaBorder);
|
||||
this.m_Area.setBackground(Color.WHITE);
|
||||
this.m_JPMain.add(this.m_Area, BorderLayout.CENTER);
|
||||
this.m_JPTop = new JPanel();
|
||||
this.m_JPTop.setLayout(new GridLayout(1, 5));
|
||||
this.add(this.mainPanel, BorderLayout.CENTER);
|
||||
this.functionArea = new FunctionArea("?", "?");
|
||||
this.functionArea.setPreferredSize(new Dimension(450, 450));
|
||||
this.functionArea.setMinimumSize(new Dimension(450, 450));
|
||||
this.areaBorder = new ScaledBorder();
|
||||
this.areaBorder.xLabel = "?";
|
||||
this.areaBorder.yLabel = "?";
|
||||
this.functionArea.setBorder(this.areaBorder);
|
||||
this.functionArea.setBackground(Color.WHITE);
|
||||
this.mainPanel.add(this.functionArea, BorderLayout.CENTER);
|
||||
this.topPanel = new JPanel();
|
||||
this.topPanel.setLayout(new GridLayout(1, 5));
|
||||
String[] tmp = new String[2];
|
||||
tmp[0] = "Fitness";
|
||||
tmp[1] = "Objective";
|
||||
this.m_JCFitObj = new JComboBox(tmp);
|
||||
this.m_JCFitObj.setSelectedIndex(0);
|
||||
this.m_JCFitObj.addActionListener(this.jcombobox2Listener);
|
||||
this.m_JCObjective1 = new JComboBox(this.getAvailableObjectiveNames());
|
||||
this.m_JCObjective1.setSelectedIndex(0);
|
||||
this.m_JCObjective1.addActionListener(this.jcomboboxListener);
|
||||
this.m_JPTop.add(this.m_JCObjective1);
|
||||
this.m_JPTop.add(new JLabel(" vs "));
|
||||
this.m_JCObjective2 = new JComboBox(this.getAvailableObjectiveNames());
|
||||
this.fitObjective = new JComboBox(tmp);
|
||||
this.fitObjective.setSelectedIndex(0);
|
||||
this.fitObjective.addActionListener(this.jcombobox2Listener);
|
||||
this.objective1 = new JComboBox(this.getAvailableObjectiveNames());
|
||||
this.objective1.setSelectedIndex(0);
|
||||
this.objective1.addActionListener(this.jcomboboxListener);
|
||||
this.topPanel.add(this.objective1);
|
||||
this.topPanel.add(new JLabel(" vs "));
|
||||
this.objective2 = new JComboBox(this.getAvailableObjectiveNames());
|
||||
try {
|
||||
this.m_JCObjective2.setSelectedIndex(1);
|
||||
this.objective2.setSelectedIndex(1);
|
||||
} catch (java.lang.IllegalArgumentException a) {
|
||||
// there seems to be no alternative
|
||||
}
|
||||
this.m_JCObjective2.addActionListener(this.jcomboboxListener);
|
||||
this.m_JPTop.add(this.m_JCObjective2);
|
||||
this.m_JPTop.add(new JLabel(" using:"));
|
||||
this.objective2.addActionListener(this.jcomboboxListener);
|
||||
this.topPanel.add(this.objective2);
|
||||
this.topPanel.add(new JLabel(" using:"));
|
||||
|
||||
this.m_JPTop.add(this.m_JCFitObj);
|
||||
this.m_JPMain.add(this.m_JPTop, BorderLayout.NORTH);
|
||||
this.topPanel.add(this.fitObjective);
|
||||
this.mainPanel.add(this.topPanel, BorderLayout.NORTH);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
@ -96,39 +90,39 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
};
|
||||
|
||||
public void updateObjectiveComboBoxes() {
|
||||
m_JCObjective1.removeActionListener(jcomboboxListener);
|
||||
m_JCObjective2.removeActionListener(jcomboboxListener);
|
||||
m_JCObjective1.removeAllItems();
|
||||
objective1.removeActionListener(jcomboboxListener);
|
||||
objective2.removeActionListener(jcomboboxListener);
|
||||
objective1.removeAllItems();
|
||||
String[] tmpS = getAvailableObjectiveNames();
|
||||
for (int i = 0; i < tmpS.length; i++) {
|
||||
m_JCObjective1.addItem(tmpS[i]);
|
||||
objective1.addItem(tmpS[i]);
|
||||
}
|
||||
m_JCObjective1.setSelectedIndex(0);
|
||||
m_JCObjective2.removeAllItems();
|
||||
objective1.setSelectedIndex(0);
|
||||
objective2.removeAllItems();
|
||||
tmpS = getAvailableObjectiveNames();
|
||||
for (int i = 0; i < tmpS.length; i++) {
|
||||
m_JCObjective2.addItem(tmpS[i]);
|
||||
objective2.addItem(tmpS[i]);
|
||||
}
|
||||
m_JCObjective2.setSelectedIndex(1);
|
||||
m_JCObjective1.addActionListener(jcomboboxListener);
|
||||
m_JCObjective2.addActionListener(jcomboboxListener);
|
||||
objective2.setSelectedIndex(1);
|
||||
objective1.addActionListener(jcomboboxListener);
|
||||
objective2.addActionListener(jcomboboxListener);
|
||||
updateView();
|
||||
}
|
||||
|
||||
private String[] getAvailableObjectiveNames() {
|
||||
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[0] = "none";
|
||||
return result;
|
||||
}
|
||||
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
result = new String[tmp.length];
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
result[i] = tmp[i].getIdentName();
|
||||
}
|
||||
if (this.m_JCFitObj.getSelectedIndex() == 0) {
|
||||
if (this.fitObjective.getSelectedIndex() == 0) {
|
||||
// in this case constraints have to be omitted
|
||||
ArrayList tmpList = new ArrayList();
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
@ -154,28 +148,28 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
public void updateView() {
|
||||
// i assume that all the populations are evaluated
|
||||
// all using the same problem
|
||||
this.m_Area.removeAll();
|
||||
this.functionArea.removeAll();
|
||||
// first set the names of the objectives
|
||||
String[] tmpS = this.getAvailableObjectiveNames();
|
||||
if (tmpS.length != this.m_JCObjective1.getItemCount()) {
|
||||
if (tmpS.length != this.objective1.getItemCount()) {
|
||||
updateObjectiveComboBoxes();
|
||||
}
|
||||
boolean equal = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (!equal) {
|
||||
updateObjectiveComboBoxes();
|
||||
}
|
||||
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
//InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
//InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
String[] objectives = this.getAvailableObjectiveNames();
|
||||
this.m_AreaBorder.x_label = "" + objectives[this.m_JCObjective1.getSelectedIndex()];
|
||||
this.m_AreaBorder.y_label = "" + objectives[this.m_JCObjective2.getSelectedIndex()];
|
||||
this.areaBorder.xLabel = "" + objectives[this.objective1.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.validate();
|
||||
@ -186,28 +180,27 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
*/
|
||||
public void plot2DParetoFront() {
|
||||
double xmin = Double.POSITIVE_INFINITY, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY;
|
||||
this.m_Area.clearAll();
|
||||
this.m_Area.setBackground(Color.WHITE);
|
||||
this.functionArea.clearAll();
|
||||
this.functionArea.setBackground(Color.WHITE);
|
||||
GraphPointSet mySet;
|
||||
DPoint myPoint;
|
||||
double[] fitness;
|
||||
int indexX, indexY;
|
||||
indexX = this.m_JCObjective1.getSelectedIndex();
|
||||
indexY = this.m_JCObjective2.getSelectedIndex();
|
||||
indexX = this.objective1.getSelectedIndex();
|
||||
indexY = this.objective2.getSelectedIndex();
|
||||
// first plot the populations
|
||||
if (false) {
|
||||
for (int i = 0; i < this.m_MOCCOViewer.m_MOCCO.m_State.m_PopulationHistory.length; i++) {
|
||||
//System.out.println("Population " + i+" show " +this.m_MOCCOViewer.m_MOCCO.m_State.show[i]);
|
||||
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_Show[i]) {
|
||||
mySet = new GraphPointSet(i + 10, this.m_Area);
|
||||
for (int i = 0; i < this.moccoViewer.moccoStandalone.state.populationHistory.length; i++) {
|
||||
//System.out.println("Population " + i+" show " +this.moccoViewer.moccoStandalone.state.show[i]);
|
||||
if (this.moccoViewer.moccoStandalone.state.show[i]) {
|
||||
mySet = new GraphPointSet(i + 10, this.functionArea);
|
||||
mySet.setConnectedMode(false);
|
||||
mySet.setColor(this.m_MOCCOViewer.m_MOCCO.m_State.m_Color[i]);
|
||||
//System.out.println(((ArrayList)this.m_Boss.m_FitnessCache.get(i)).size()+"/"+((ArrayList)this.m_Boss.m_ObjectiveCache.get(i)).size());
|
||||
if (this.m_JCFitObj.getSelectedIndex() == 0) {
|
||||
for (int j = 0; j < ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).size(); j++) {
|
||||
fitness = (double[]) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).get(j);
|
||||
mySet.setColor(this.moccoViewer.moccoStandalone.state.colors[i]);
|
||||
if (this.fitObjective.getSelectedIndex() == 0) {
|
||||
for (int j = 0; j < ((ArrayList) this.moccoViewer.moccoStandalone.state.fitnessCache.get(i)).size(); j++) {
|
||||
fitness = (double[]) ((ArrayList) this.moccoViewer.moccoStandalone.state.fitnessCache.get(i)).get(j);
|
||||
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());
|
||||
} else {
|
||||
myPoint.setIcon(new Chart2DDPointIconPoint());
|
||||
@ -227,10 +220,10 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).size(); j++) {
|
||||
fitness = (double[]) ((ArrayList) this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).get(j);
|
||||
for (int j = 0; j < ((ArrayList) this.moccoViewer.moccoStandalone.state.objectiveCache.get(i)).size(); j++) {
|
||||
fitness = (double[]) ((ArrayList) this.moccoViewer.moccoStandalone.state.objectiveCache.get(i)).get(j);
|
||||
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());
|
||||
} else {
|
||||
myPoint.setIcon(new Chart2DDPointIconPoint());
|
||||
@ -254,18 +247,18 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
DPoint point;
|
||||
DPointIcon icon;
|
||||
mySet = new GraphPointSet(1, this.m_Area);
|
||||
mySet = new GraphPointSet(1, this.functionArea);
|
||||
mySet.setConnectedMode(false);
|
||||
mySet.setColor(Color.BLACK);
|
||||
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();
|
||||
} 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];
|
||||
for (int k = 0; k < tmpObj.length; k++) {
|
||||
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]);
|
||||
icon = new Chart2DDPointContentSelectable();
|
||||
if (this.m_MOCCOViewer.m_RefSolutionSelectable) {
|
||||
((Chart2DDPointContentSelectable) icon).addSelectionListener(this.m_MOCCOViewer);
|
||||
if (this.moccoViewer.refSolutionSelectable) {
|
||||
((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));
|
||||
point.setIcon(icon);
|
||||
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);
|
||||
double xrange = (xmax - xmin), yrange = (ymax - ymin);
|
||||
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...
|
||||
if ((this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
|
||||
(this.m_JCFitObj.getSelectedIndex() == 1)) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if ((this.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
|
||||
(this.fitObjective.getSelectedIndex() == 1)) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
if ((!(tmp[i].getOptimizationMode().equalsIgnoreCase("Objective"))) &&
|
||||
((this.m_JCObjective1.getSelectedIndex() == i) ||
|
||||
(this.m_JCObjective2.getSelectedIndex() == i))) {
|
||||
((this.objective1.getSelectedIndex() == i) ||
|
||||
(this.objective2.getSelectedIndex() == i))) {
|
||||
double tmpD = tmp[i].getConstraintGoal();
|
||||
if (!(new Double(tmpD)).isNaN()) {
|
||||
// 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);
|
||||
if (this.m_JCObjective1.getSelectedIndex() == i) {
|
||||
if (this.objective1.getSelectedIndex() == i) {
|
||||
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);
|
||||
@ -342,29 +335,29 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
}
|
||||
|
||||
// lets prepare to reference point selection
|
||||
if (this.m_MOCCOViewer.m_RefPointSelectable) {
|
||||
this.m_Area.addRefPointSelectionListener(this);
|
||||
if (this.moccoViewer.refPointSelectable) {
|
||||
this.functionArea.addRefPointSelectionListener(this);
|
||||
} else {
|
||||
this.m_Area.removeRefPointSelectionListeners();
|
||||
this.functionArea.removeRefPointSelectionListeners();
|
||||
this.removeRefPointSelectionListeners();
|
||||
}
|
||||
|
||||
// lets show a reference point if given...
|
||||
if ((this.m_MOCCOViewer.m_ReferencePoint != null) && (this.m_JCFitObj.getSelectedIndex() == 0)) {
|
||||
mySet = new GraphPointSet(1001, this.m_Area);
|
||||
if ((this.moccoViewer.referencePoint != null) && (this.fitObjective.getSelectedIndex() == 0)) {
|
||||
mySet = new GraphPointSet(1001, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
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)) {
|
||||
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 = new GraphPointSet(1002, this.m_Area);
|
||||
mySet = new GraphPointSet(1002, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
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)) {
|
||||
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
|
||||
public void refPointGiven(double[] point) {
|
||||
if (this.m_JCFitObj.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.m_MOCCOViewer.m_MOCCO.m_JFrame,
|
||||
if (this.fitObjective.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.moccoViewer.moccoStandalone.getMainFrame(),
|
||||
"Reference point needs to be selected in fitness space!",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
double[] tmpD = this.m_MOCCOViewer.m_ReferencePoint;
|
||||
tmpD[this.m_JCObjective1.getSelectedIndex()] = point[0];
|
||||
tmpD[this.m_JCObjective2.getSelectedIndex()] = point[1];
|
||||
this.m_MOCCOViewer.refPointGiven(tmpD);
|
||||
double[] tmpD = this.moccoViewer.referencePoint;
|
||||
tmpD[this.objective1.getSelectedIndex()] = point[0];
|
||||
tmpD[this.objective2.getSelectedIndex()] = point[1];
|
||||
this.moccoViewer.refPointGiven(tmpD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +399,7 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
* @param a The selection listener
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public InterfaceRefPointListener getRefPointSelectionListener() {
|
||||
return this.m_RefPointListener;
|
||||
return this.refPointListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to remove the selection listner to the PointIcon
|
||||
*/
|
||||
public void removeRefPointSelectionListeners() {
|
||||
this.m_RefPointListener = null;
|
||||
this.refPointListener = null;
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
@ -19,101 +19,97 @@ import java.awt.event.ActionEvent;
|
||||
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 {
|
||||
|
||||
private InterfaceRefPointListener m_RefPointListener;
|
||||
private FunctionArea m_Area = null;
|
||||
private ScaledBorder m_AreaBorder;
|
||||
ParetoFrontViewScatterPlot m_Dad;
|
||||
int m_Obj1, m_Obj2;
|
||||
JLabel m_JLabel;
|
||||
private InterfaceRefPointListener refPointListener;
|
||||
private FunctionArea functionArea = null;
|
||||
private ScaledBorder areaBorder;
|
||||
ParetoFrontViewScatterPlot paretoFrontViewScatterPlot;
|
||||
int object1, object2;
|
||||
JLabel label;
|
||||
|
||||
public SimpleView(ParetoFrontViewScatterPlot dad, int obj1, int obj2) {
|
||||
this.m_Dad = dad;
|
||||
this.m_Obj1 = obj1;
|
||||
this.m_Obj2 = obj2;
|
||||
this.paretoFrontViewScatterPlot = dad;
|
||||
this.object1 = obj1;
|
||||
this.object2 = obj2;
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.setLayout(new BorderLayout());
|
||||
if (this.m_Obj1 == this.m_Obj2) {
|
||||
this.m_JLabel = new JLabel("" + ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj1].getIdentName());
|
||||
this.add(this.m_JLabel, BorderLayout.CENTER);
|
||||
if (this.object1 == this.object2) {
|
||||
this.label = new JLabel("" + ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName());
|
||||
this.add(this.label, BorderLayout.CENTER);
|
||||
} else {
|
||||
this.m_Area = new FunctionArea("?", "?");
|
||||
this.m_Area.setPreferredSize(new Dimension(200, 200));
|
||||
this.m_Area.setMinimumSize(new Dimension(200, 200));
|
||||
this.m_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.m_AreaBorder.y_label = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj2].getIdentName();
|
||||
this.m_Area.setBorder(this.m_AreaBorder);
|
||||
this.m_Area.setBackground(Color.WHITE);
|
||||
this.add(this.m_Area, BorderLayout.CENTER);
|
||||
this.functionArea = new FunctionArea("?", "?");
|
||||
this.functionArea.setPreferredSize(new Dimension(200, 200));
|
||||
this.functionArea.setMinimumSize(new Dimension(200, 200));
|
||||
this.areaBorder = new ScaledBorder();
|
||||
this.areaBorder.xLabel = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName();
|
||||
this.areaBorder.yLabel = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object2].getIdentName();
|
||||
this.functionArea.setBorder(this.areaBorder);
|
||||
this.functionArea.setBackground(Color.WHITE);
|
||||
this.add(this.functionArea, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
private double[] fetchPlotValueFor(AbstractEAIndividual indy) {
|
||||
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
|
||||
// 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
|
||||
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (tmpObj[this.m_Obj1].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
if (tmpObj[this.object1].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
result[0] = 0;
|
||||
} else {
|
||||
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")) {
|
||||
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);
|
||||
result[0] = indy.getFitness(index);
|
||||
}
|
||||
if (tmpObj[this.m_Obj2].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
if (tmpObj[this.object2].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
result[1] = 0;
|
||||
} else {
|
||||
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")) {
|
||||
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);
|
||||
result[1] = indy.getFitness(index);
|
||||
}
|
||||
} else {
|
||||
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
result[0] = ((Double) indy.getData(tmpObj[this.m_Obj1].getIdentName())).doubleValue();
|
||||
result[1] = ((Double) indy.getData(tmpObj[this.m_Obj2].getIdentName())).doubleValue();
|
||||
InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
result[0] = ((Double) indy.getData(tmpObj[this.object1].getIdentName())).doubleValue();
|
||||
result[1] = ((Double) indy.getData(tmpObj[this.object2].getIdentName())).doubleValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
// InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem)this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
// System.out.println("Plotting ("+this.m_Obj1+"/"+this.m_Obj2+") 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()+")");
|
||||
if (this.m_Obj1 == this.m_Obj2) {
|
||||
this.m_JLabel.setText("" + ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives()[this.m_Obj1].getIdentName());
|
||||
// InterfaceOptimizationObjective[] tmpObj = ((InterfaceMultiObjectiveDeNovoProblem)this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
// System.out.println("Plotting ("+this.object1+"/"+this.object2+") of " + tmpObj.length +" objectives.");
|
||||
// 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.object1 == this.object2) {
|
||||
this.label.setText("" + ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives()[this.object1].getIdentName());
|
||||
} else {
|
||||
// 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;
|
||||
this.m_Area.clearAll();
|
||||
this.m_Area.setBackground(Color.WHITE);
|
||||
this.functionArea.clearAll();
|
||||
this.functionArea.setBackground(Color.WHITE);
|
||||
GraphPointSet mySet;
|
||||
DPoint myPoint;
|
||||
//double[] fitness;
|
||||
@ -123,17 +119,17 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
if (pf.size() > 0) {
|
||||
DPoint point;
|
||||
DPointIcon icon;
|
||||
mySet = new GraphPointSet(1, this.m_Area);
|
||||
mySet = new GraphPointSet(1, this.functionArea);
|
||||
mySet.setConnectedMode(false);
|
||||
mySet.setColor(Color.BLACK);
|
||||
for (int i = 0; i < pf.size(); i++) {
|
||||
plotValue = this.fetchPlotValueFor((AbstractEAIndividual) pf.get(i));
|
||||
point = new DPoint(plotValue[0], plotValue[1]);
|
||||
icon = new Chart2DDPointContentSelectable();
|
||||
if (this.m_Dad.m_MOCCOViewer.m_RefSolutionSelectable) {
|
||||
((Chart2DDPointContentSelectable) icon).addSelectionListener(this.m_Dad.m_MOCCOViewer);
|
||||
if (this.paretoFrontViewScatterPlot.moccoViewer.refSolutionSelectable) {
|
||||
((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));
|
||||
point.setIcon(icon);
|
||||
mySet.addDPoint(point);
|
||||
@ -150,7 +146,7 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
ymax = plotValue[1];
|
||||
}
|
||||
}
|
||||
mySet = new GraphPointSet(0, this.m_Area);
|
||||
mySet = new GraphPointSet(0, this.functionArea);
|
||||
mySet.setConnectedMode(false);
|
||||
double xrange = (xmax - xmin), yrange = (ymax - ymin);
|
||||
if (xrange < 0.0000001) {
|
||||
@ -170,13 +166,13 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
}
|
||||
|
||||
// now lets prepare the contraints or goals if any...
|
||||
if ((this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
|
||||
(this.m_Dad.m_JCFitObj.getSelectedIndex() == 1)) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (tmp[this.m_Obj1].getOptimizationMode().equalsIgnoreCase("Objective")) {
|
||||
double tmpD = tmp[this.m_Obj1].getConstraintGoal();
|
||||
if ((this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) &&
|
||||
(this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 1)) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
if (tmp[this.object1].getOptimizationMode().equalsIgnoreCase("Objective")) {
|
||||
double tmpD = tmp[this.object1].getConstraintGoal();
|
||||
if (!(new Double(tmpD)).isNaN()) {
|
||||
mySet = new GraphPointSet(500 + 1, this.m_Area);
|
||||
mySet = new GraphPointSet(500 + 1, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
if ((tmpD > xmin - 0.1 * xrange) && (tmpD < xmax + 0.1 * xrange)) {
|
||||
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")) {
|
||||
double tmpD = tmp[this.m_Obj2].getConstraintGoal();
|
||||
if (tmp[this.object2].getOptimizationMode().equalsIgnoreCase("Objective")) {
|
||||
double tmpD = tmp[this.object2].getConstraintGoal();
|
||||
if (!(new Double(tmpD)).isNaN()) {
|
||||
mySet = new GraphPointSet(500 + 2, this.m_Area);
|
||||
mySet = new GraphPointSet(500 + 2, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
if ((tmpD > ymin - 0.1 * yrange) && (tmpD < ymax + 0.1 * yrange)) {
|
||||
mySet.addDPoint(xmin - 0.1 * xrange, tmpD);
|
||||
@ -201,21 +197,21 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
}
|
||||
}
|
||||
// lets show a reference point if given...
|
||||
if ((this.m_Dad.m_MOCCOViewer.m_ReferencePoint != null) && (this.m_Dad.m_JCFitObj.getSelectedIndex() == 0)) {
|
||||
mySet = new GraphPointSet(1001, this.m_Area);
|
||||
if ((this.paretoFrontViewScatterPlot.moccoViewer.referencePoint != null) && (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 0)) {
|
||||
mySet = new GraphPointSet(1001, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
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)) {
|
||||
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 = new GraphPointSet(1002, this.m_Area);
|
||||
mySet = new GraphPointSet(1002, this.functionArea);
|
||||
mySet.setConnectedMode(true);
|
||||
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)) {
|
||||
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
|
||||
if (this.m_Dad.m_MOCCOViewer.m_RefPointSelectable) {
|
||||
this.m_Area.addRefPointSelectionListener(this);
|
||||
if (this.paretoFrontViewScatterPlot.moccoViewer.refPointSelectable) {
|
||||
this.functionArea.addRefPointSelectionListener(this);
|
||||
} else {
|
||||
this.removeRefPointSelectionListeners();
|
||||
this.m_Area.removeRefPointSelectionListeners();
|
||||
this.m_Dad.removeRefPointSelectionListeners();
|
||||
this.functionArea.removeRefPointSelectionListeners();
|
||||
this.paretoFrontViewScatterPlot.removeRefPointSelectionListeners();
|
||||
}
|
||||
|
||||
|
||||
@ -251,15 +247,15 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
*/
|
||||
@Override
|
||||
public void refPointGiven(double[] point) {
|
||||
if (this.m_Dad.m_JCFitObj.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.m_Dad.m_MOCCOViewer.m_MOCCO.m_JFrame,
|
||||
if (this.paretoFrontViewScatterPlot.fitnessObjectiveComboBox.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.paretoFrontViewScatterPlot.moccoViewer.moccoStandalone.getMainFrame(),
|
||||
"Reference point needs to be selected in fitness space!",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
double[] tmpD = this.m_Dad.m_MOCCOViewer.m_ReferencePoint;
|
||||
tmpD[this.m_Obj1] = point[0];
|
||||
tmpD[this.m_Obj1] = point[1];
|
||||
this.m_Dad.m_MOCCOViewer.refPointGiven(tmpD);
|
||||
double[] tmpD = this.paretoFrontViewScatterPlot.moccoViewer.referencePoint;
|
||||
tmpD[this.object1] = point[0];
|
||||
tmpD[this.object1] = point[1];
|
||||
this.paretoFrontViewScatterPlot.moccoViewer.refPointGiven(tmpD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +266,7 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
* @param a The selection listener
|
||||
*/
|
||||
public void addRefPointSelectionListener(InterfaceRefPointListener a) {
|
||||
this.m_RefPointListener = a;
|
||||
this.refPointListener = a;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,52 +275,52 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
* @return InterfaceSelectionListener
|
||||
*/
|
||||
public InterfaceRefPointListener getRefPointSelectionListener() {
|
||||
return this.m_RefPointListener;
|
||||
return this.refPointListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to remove the selection listner to the PointIcon
|
||||
*/
|
||||
public void removeRefPointSelectionListeners() {
|
||||
this.m_RefPointListener = null;
|
||||
this.refPointListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParetoFrontView {
|
||||
|
||||
public MOCCOViewer m_MOCCOViewer;
|
||||
private JPanel m_JPMain;
|
||||
private JPanel m_JPCenter;
|
||||
private JPanel m_JPTop;
|
||||
public JComboBox m_JCFitObj;
|
||||
public MOCCOViewer moccoViewer;
|
||||
private JPanel mainPanel;
|
||||
private JPanel centerPanel;
|
||||
private JPanel topPanel;
|
||||
public JComboBox fitnessObjectiveComboBox;
|
||||
|
||||
|
||||
private InterfaceRefPointListener m_RefPointListener;
|
||||
private SimpleView[][] m_Scatter;
|
||||
private InterfaceRefPointListener refPointListener;
|
||||
private SimpleView[][] simpleViews;
|
||||
|
||||
public ParetoFrontViewScatterPlot(MOCCOViewer t) {
|
||||
this.m_MOCCOViewer = t;
|
||||
this.moccoViewer = t;
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.m_JPMain = new JPanel();
|
||||
this.m_JPMain.setLayout(new BorderLayout());
|
||||
this.mainPanel = new JPanel();
|
||||
this.mainPanel.setLayout(new BorderLayout());
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(this.m_JPMain, BorderLayout.CENTER);
|
||||
this.m_JPCenter = new JPanel();
|
||||
this.m_JPMain.add(new JScrollPane(this.m_JPCenter), BorderLayout.CENTER);
|
||||
this.m_JPTop = new JPanel();
|
||||
this.m_JPTop.setLayout(new GridLayout(1, 2));
|
||||
this.add(this.mainPanel, BorderLayout.CENTER);
|
||||
this.centerPanel = new JPanel();
|
||||
this.mainPanel.add(new JScrollPane(this.centerPanel), BorderLayout.CENTER);
|
||||
this.topPanel = new JPanel();
|
||||
this.topPanel.setLayout(new GridLayout(1, 2));
|
||||
String[] tmp = new String[2];
|
||||
tmp[0] = "Fitness";
|
||||
tmp[1] = "Objective";
|
||||
this.m_JCFitObj = new JComboBox(tmp);
|
||||
this.m_JCFitObj.setSelectedIndex(0);
|
||||
this.m_JCFitObj.addActionListener(this.jcomboboxListener);
|
||||
this.m_JPTop.add(new JLabel("Showing:"));
|
||||
this.m_JPTop.add(this.m_JCFitObj);
|
||||
this.m_JPMain.add(this.m_JPTop, BorderLayout.NORTH);
|
||||
this.fitnessObjectiveComboBox = new JComboBox(tmp);
|
||||
this.fitnessObjectiveComboBox.setSelectedIndex(0);
|
||||
this.fitnessObjectiveComboBox.addActionListener(this.jcomboboxListener);
|
||||
this.topPanel.add(new JLabel("Showing:"));
|
||||
this.topPanel.add(this.fitnessObjectiveComboBox);
|
||||
this.mainPanel.add(this.topPanel, BorderLayout.NORTH);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
@ -336,14 +332,14 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
|
||||
};
|
||||
|
||||
private void makeScatter() {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
this.m_Scatter = new SimpleView[tmp.length][tmp.length];
|
||||
this.m_JPCenter.removeAll();
|
||||
this.m_JPCenter.setLayout(new GridLayout(tmp.length, tmp.length));
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
this.simpleViews = new SimpleView[tmp.length][tmp.length];
|
||||
this.centerPanel.removeAll();
|
||||
this.centerPanel.setLayout(new GridLayout(tmp.length, tmp.length));
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
for (int j = 0; j < tmp.length; j++) {
|
||||
this.m_Scatter[i][j] = new SimpleView(this, i, j);
|
||||
this.m_JPCenter.add(this.m_Scatter[i][j]);
|
||||
this.simpleViews[i][j] = new SimpleView(this, i, j);
|
||||
this.centerPanel.add(this.simpleViews[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -355,26 +351,26 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
|
||||
*/
|
||||
@Override
|
||||
public void updateView() {
|
||||
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem == null) {
|
||||
this.m_Scatter = null;
|
||||
this.m_JPCenter.removeAll();
|
||||
this.m_JPCenter.add(new JLabel("no problem given"));
|
||||
if (this.moccoViewer.moccoStandalone.state.currentProblem == null) {
|
||||
this.simpleViews = null;
|
||||
this.centerPanel.removeAll();
|
||||
this.centerPanel.add(new JLabel("no problem given"));
|
||||
this.validate();
|
||||
return;
|
||||
}
|
||||
|
||||
// first set the names of the objectives
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (this.m_Scatter == null) {
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem) this.moccoViewer.moccoStandalone.state.currentProblem).getProblemObjectives();
|
||||
if (this.simpleViews == null) {
|
||||
this.makeScatter();
|
||||
}
|
||||
if (this.m_Scatter.length != tmp.length) {
|
||||
if (this.simpleViews.length != tmp.length) {
|
||||
this.makeScatter();
|
||||
}
|
||||
if (this.m_Scatter != null) {
|
||||
if (this.simpleViews != null) {
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
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
|
||||
*/
|
||||
public void refPointGiven(double[] point) {
|
||||
if (this.m_JCFitObj.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.m_MOCCOViewer.m_MOCCO.m_JFrame,
|
||||
if (this.fitnessObjectiveComboBox.getSelectedIndex() == 1) {
|
||||
JOptionPane.showMessageDialog(this.moccoViewer.moccoStandalone.getMainFrame(),
|
||||
"Reference point needs to be selected in fitness space!",
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
} 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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public InterfaceRefPointListener getRefPointSelectionListener() {
|
||||
return this.m_RefPointListener;
|
||||
return this.refPointListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to remove the selection listner to the PointIcon
|
||||
*/
|
||||
public void removeRefPointSelectionListeners() {
|
||||
this.m_RefPointListener = null;
|
||||
this.refPointListener = null;
|
||||
}
|
||||
}
|
@ -22,12 +22,12 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_WLPT.m_IdealValue = tmpD;
|
||||
this.m_WLPT.idealValue = tmpD;
|
||||
tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 1.0;
|
||||
}
|
||||
this.m_WLPT.m_Weights = tmpD;
|
||||
this.m_WLPT.weights = tmpD;
|
||||
}
|
||||
|
||||
public MOSOWeightedLPTchebycheff(MOSOWeightedLPTchebycheff b) {
|
||||
@ -72,9 +72,9 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
resultFit[0] = 0;
|
||||
for (int i = 0; i < tmpFit.length; i++) {
|
||||
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 {
|
||||
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) {
|
||||
@ -99,12 +99,12 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
newTarget[i] = 0;
|
||||
newWeights[i] = 1.0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_WLPT.m_IdealValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.m_WLPT.m_IdealValue[i];
|
||||
newWeights[i] = this.m_WLPT.m_Weights[i];
|
||||
for (int i = 0; (i < this.m_WLPT.idealValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.m_WLPT.idealValue[i];
|
||||
newWeights[i] = this.m_WLPT.weights[i];
|
||||
}
|
||||
this.m_WLPT.m_IdealValue = newTarget;
|
||||
this.m_WLPT.m_Weights = newWeights;
|
||||
this.m_WLPT.idealValue = newTarget;
|
||||
this.m_WLPT.weights = newWeights;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +117,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
String result = "Lp Metric\n";
|
||||
result += " P = " + this.m_WLPT.m_P + "\n";
|
||||
result += " Ref.Fitness = (";
|
||||
double[] p = this.m_WLPT.m_IdealValue;
|
||||
double[] p = this.m_WLPT.idealValue;
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
result += p[i];
|
||||
if (i < (p.length - 1)) {
|
||||
@ -126,7 +126,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
}
|
||||
result += ")\n";
|
||||
result += " Weights = (";
|
||||
p = this.m_WLPT.m_Weights;
|
||||
p = this.m_WLPT.weights;
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
result += p[i];
|
||||
if (i < (p.length - 1)) {
|
||||
|
@ -58,13 +58,9 @@ public class F3Problem extends AbstractProblemDoubleOffset implements java.io.Se
|
||||
result += "Dimension : " + this.problemDimension + "\n";
|
||||
result += "Noise level : " + this.getNoise() + "\n";
|
||||
result += "Solution representation:\n";
|
||||
//result += this.template.getSolutionRepresentationFor();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
|
@ -29,8 +29,8 @@ public class TestingDArea {
|
||||
area.setVisibleRectangle(0, -3, 10, 10);//plotArea.setAutoFocus(true);
|
||||
area.setMinRectangle(0, 0, 1, 1);
|
||||
ScaledBorder myBorder = new ScaledBorder();
|
||||
myBorder.x_label = "x";//"App. " + Name + " func. calls";
|
||||
myBorder.y_label = "y";//"fitness";
|
||||
myBorder.xLabel = "x";//"App. " + Name + " func. calls";
|
||||
myBorder.yLabel = "y";//"fitness";
|
||||
area.setBorder(myBorder);
|
||||
area.setAutoGrid(true);
|
||||
area.setGridVisible(true);
|
||||
|
@ -78,7 +78,7 @@ public class ScaledBorder implements Border {
|
||||
/**
|
||||
* the displayed labels
|
||||
*/
|
||||
public String x_label, y_label;
|
||||
public String xLabel, yLabel;
|
||||
|
||||
/**
|
||||
* foreground and background colors
|
||||
@ -281,18 +281,18 @@ public class ScaledBorder implements Border {
|
||||
inner_insets.top + cd.height + marker_length);
|
||||
}
|
||||
|
||||
if (y_label != null) {
|
||||
Dimension yld = new Dimension(fm.getAscent() + fm.getDescent(), fm.stringWidth(y_label));
|
||||
if (yLabel != null) {
|
||||
Dimension yld = new Dimension(fm.getAscent() + fm.getDescent(), fm.stringWidth(yLabel));
|
||||
AffineTransform T = new AffineTransform(0, -1, 1, 0, 0, 0);
|
||||
Font old = g.getFont(), f = old.deriveFont(T);
|
||||
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);
|
||||
}
|
||||
|
||||
if (x_label != null) {
|
||||
if (xLabel != null) {
|
||||
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());
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ public class ScaledBorder implements Border {
|
||||
}
|
||||
|
||||
// left:
|
||||
if (y_label != null) {
|
||||
if (yLabel != null) {
|
||||
insets.left += fm.getAscent() + fm.getDescent();
|
||||
}
|
||||
insets.left += y_label2values * digit_width;
|
||||
@ -670,7 +670,7 @@ public class ScaledBorder implements Border {
|
||||
|
||||
// bottom:
|
||||
insets.bottom += 1 + fontHeight + x_label2border;
|
||||
if (x_label != null) {
|
||||
if (xLabel != null) {
|
||||
insets.bottom += fontHeight;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user