More refactoring.
This commit is contained in:
parent
c3dce7ac1b
commit
bbaead0515
@ -132,8 +132,8 @@ public class OptimizerFactory {
|
||||
de.setProblem(problem);
|
||||
de.getPopulation().setTargetSize(popsize);
|
||||
de.setDEType(DETypeEnum.DE2_CurrentToBest);
|
||||
de.setF(f);
|
||||
de.setK(CR);
|
||||
de.setDifferentialWeight(f);
|
||||
de.setCrossoverRate(CR);
|
||||
de.setLambda(lambda);
|
||||
de.addPopulationChangedEventListener(listener);
|
||||
de.init();
|
||||
@ -1476,8 +1476,8 @@ public class OptimizerFactory {
|
||||
AbstractOptimizationProblem problem) {
|
||||
DifferentialEvolution de = new DifferentialEvolution();
|
||||
de.setDEType(DETypeEnum.DE2_CurrentToBest); // this sets current-to-best
|
||||
de.setF(0.8);
|
||||
de.setK(0.6);
|
||||
de.setDifferentialWeight(0.8);
|
||||
de.setCrossoverRate(0.6);
|
||||
de.setLambda(0.6);
|
||||
de.setMt(0.05); // this is not really employed for currentToBest
|
||||
return makeParams(de, 50, problem, randSeed, getTerminator());
|
||||
|
@ -85,7 +85,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
// this means user break
|
||||
moduleAdapter.stopOpt();
|
||||
moduleAdapter.stopOptimization();
|
||||
} catch (Exception ee) {
|
||||
LOGGER.log(Level.WARNING, "Error while stopping job.", ee);
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
|
||||
|
||||
public void onUserStart() {
|
||||
try {
|
||||
moduleAdapter.startOpt();
|
||||
moduleAdapter.startOptimization();
|
||||
stopButton.setEnabled(true);
|
||||
runButton.setEnabled(false);
|
||||
postProcessButton.setEnabled(false);
|
||||
|
@ -36,39 +36,21 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* Generated serial version identifier.
|
||||
*/
|
||||
private static final long serialVersionUID = 8232856334379977970L;
|
||||
private final int splashScreenTime = 2500;
|
||||
private final int splashScreenTime;
|
||||
private boolean clientInited = false;
|
||||
private JExtDesktopPaneToolBar desktopToolBar;
|
||||
private JDesktopPane desktopPane;
|
||||
private JPanel configurationPane;
|
||||
private JSplitPane horizontalSplit;
|
||||
private Runnable initRnbl = null;
|
||||
private Runnable initRunnable = null;
|
||||
|
||||
//private EvAComAdapter comAdapter;
|
||||
private transient JMenuBar menuBar;
|
||||
private transient JExtMenu menuHelp;
|
||||
private transient JExtMenu menuSelHosts;
|
||||
private transient JExtMenu menuModule;
|
||||
private transient JExtMenu menuOptions;
|
||||
private JPanel statusBar;
|
||||
private transient JProgressBar progressBar;
|
||||
|
||||
// Option
|
||||
private ExtAction actPreferences;
|
||||
private ExtAction actQuit;
|
||||
|
||||
// LogPanel
|
||||
private LoggingPanel logPanel;
|
||||
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
|
||||
|
||||
// Module:
|
||||
private ExtAction actModuleLoad;
|
||||
|
||||
// Hosts:
|
||||
private ExtAction actHost;
|
||||
private ExtAction actAvailableHost;
|
||||
private ExtAction actKillHost;
|
||||
private ExtAction actKillAllHosts;
|
||||
private ModuleAdapter currentModuleAdapter = null;
|
||||
|
||||
// Help:
|
||||
@ -78,13 +60,10 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
|
||||
// if not null, the module is loaded automatically and no other can be selected
|
||||
private String useDefaultModule = null; //"Genetic_Optimization";
|
||||
private boolean showLoadModules = false;
|
||||
private boolean localMode = false;
|
||||
|
||||
// measuring optimization runtime
|
||||
private long startTime = 0;
|
||||
// remember the module in use
|
||||
private transient String currentModule = null;
|
||||
private boolean withGUI = true;
|
||||
private boolean withTreeView = false;
|
||||
private EvATabbedFrameMaker frameMaker = null;
|
||||
@ -103,11 +82,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
}
|
||||
|
||||
public boolean removeOptimizationStateListener(OptimizationStateListener l) {
|
||||
if (superListenerList != null) {
|
||||
return superListenerList.remove(l);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return superListenerList != null && superListenerList.remove(l);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,8 +152,8 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* @param noGui
|
||||
* @see #Main(String, String, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, InterfaceOptimizationParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
|
||||
this(hostName, null, null, goParams, autorun, noSplash, noGui, false);
|
||||
public Main(final String hostName, InterfaceOptimizationParameters optimizationParameters, boolean autorun, boolean noSplash, boolean noGui) {
|
||||
this(hostName, null, null, optimizationParameters, autorun, noSplash, noGui, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,11 +206,11 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
}
|
||||
}
|
||||
|
||||
currentModule = null;
|
||||
|
||||
comAdapter = EvAComAdapter.getInstance();
|
||||
|
||||
SwingUtilities.invokeLater(initRnbl = new Runnable() {
|
||||
splashScreenTime = 2500;
|
||||
SwingUtilities.invokeLater(initRunnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -263,7 +238,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
if (withGUI) {
|
||||
frameMaker.onUserStart();
|
||||
} else {
|
||||
currentModuleAdapter.startOpt();
|
||||
currentModuleAdapter.startOptimization();
|
||||
}
|
||||
}
|
||||
// close splash screen
|
||||
@ -283,12 +258,12 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* as it returns, the Main GUI is fully initialized.
|
||||
*/
|
||||
public void awaitClientInitialized() {
|
||||
if (initRnbl != null) {
|
||||
synchronized (initRnbl) {
|
||||
if (initRunnable != null) {
|
||||
synchronized (initRunnable) {
|
||||
if (!clientInited) {
|
||||
try {
|
||||
initRnbl.wait();
|
||||
initRnbl = null;
|
||||
initRunnable.wait();
|
||||
initRunnable = null;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -310,7 +285,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
*/
|
||||
public boolean startOptimization() {
|
||||
if (currentModuleAdapter != null) {
|
||||
currentModuleAdapter.startOpt();
|
||||
currentModuleAdapter.startOptimization();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -371,7 +346,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
desktopPane = new JExtDesktopPane();
|
||||
JEFrameRegister.getInstance().setDesktopPane(desktopPane);
|
||||
/* Creates desktopPane ToolBar to show tiling buttons */
|
||||
desktopToolBar = new JExtDesktopPaneToolBar((JExtDesktopPane) desktopPane);
|
||||
JExtDesktopPaneToolBar desktopToolBar = new JExtDesktopPaneToolBar((JExtDesktopPane) desktopPane);
|
||||
|
||||
/* Pane to hold ToolBar + DesktopPane */
|
||||
JPanel desktopPanel = new JPanel(new GridBagLayout());
|
||||
@ -397,15 +372,11 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
System.out.println("Error" + e.getMessage());
|
||||
}
|
||||
|
||||
logPanel = new LoggingPanel(LOGGER);
|
||||
LoggingPanel logPanel = new LoggingPanel(LOGGER);
|
||||
logPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
|
||||
if (EvAInfo.propShowModules() != null) {
|
||||
showLoadModules = true;
|
||||
} else {
|
||||
showLoadModules = false; // may be set to true again if default module couldnt be loaded
|
||||
}
|
||||
boolean showLoadModules = EvAInfo.propShowModules() != null;
|
||||
createActions();
|
||||
|
||||
setSize(800, 600);
|
||||
@ -424,7 +395,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
add(configurationPane, gbConstraints);
|
||||
|
||||
/* SplitPane for desktopPanel and loggingPanel */
|
||||
horizontalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
|
||||
JSplitPane horizontalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
|
||||
horizontalSplit.setTopComponent(desktopPanel);
|
||||
horizontalSplit.setBottomComponent(logPanel);
|
||||
horizontalSplit.setDividerLocation(0.25);
|
||||
@ -442,7 +413,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
add(horizontalSplit, gbConstraints);
|
||||
|
||||
/* StatusBar of the main frame */
|
||||
statusBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
JPanel statusBarControls = new JPanel();
|
||||
statusBarControls.setLayout(new BoxLayout(statusBarControls, BoxLayout.LINE_AXIS));
|
||||
|
||||
@ -504,9 +475,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (withGUI) {
|
||||
LOGGER.log(Level.INFO, "Working directory is: {0}", System.getProperty("user.dir"));
|
||||
LOGGER.log(Level.INFO, "Class path is: {0}", System.getProperty("java.class.path", "."));
|
||||
|
||||
@ -754,12 +723,12 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* Create the main menu and add actions.
|
||||
*/
|
||||
private void buildMenu() {
|
||||
menuBar = new JMenuBar();
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
setJMenuBar(menuBar);
|
||||
menuModule = new JExtMenu("&Module");
|
||||
JExtMenu menuModule = new JExtMenu("&Module");
|
||||
//menuModule.add(actModuleLoad);
|
||||
|
||||
menuSelHosts = new JExtMenu("&Select Hosts");
|
||||
JExtMenu menuSelHosts = new JExtMenu("&Select Hosts");
|
||||
//menuSelHosts.setToolTipText("Select a host for the server application");
|
||||
//menuSelHosts.add(actHost);
|
||||
//menuSelHosts.add(actAvailableHost);
|
||||
@ -767,13 +736,13 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
//menuSelHosts.add(actKillHost);
|
||||
//menuSelHosts.add(actKillAllHosts);
|
||||
|
||||
menuHelp = new JExtMenu("&Help");
|
||||
JExtMenu menuHelp = new JExtMenu("&Help");
|
||||
menuHelp.add(actHelp);
|
||||
menuHelp.addSeparator();
|
||||
menuHelp.add(actAbout);
|
||||
menuHelp.add(actLicense);
|
||||
|
||||
menuOptions = new JExtMenu("&Options");
|
||||
JExtMenu menuOptions = new JExtMenu("&Options");
|
||||
menuOptions.add(actPreferences);
|
||||
//menuOptions.add(menuSelHosts);
|
||||
menuOptions.addSeparator();
|
||||
@ -797,7 +766,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
public InterfaceOptimizationParameters getGOParameters() {
|
||||
if (currentModuleAdapter != null) {
|
||||
if (currentModuleAdapter instanceof AbstractModuleAdapter) {
|
||||
return ((AbstractModuleAdapter) currentModuleAdapter).getGOParameters();
|
||||
return ((AbstractModuleAdapter) currentModuleAdapter).getOptimizationParameters();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -816,12 +785,8 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOptRunning() {
|
||||
if ((currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter)) {
|
||||
return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean isOptimizationRunning() {
|
||||
return (currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter) && ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
|
||||
}
|
||||
|
||||
private void loadSpecificModule(String selectedModule, InterfaceOptimizationParameters goParams) {
|
||||
@ -838,10 +803,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
URL baseDir = getClass().getClassLoader().getResource("");
|
||||
String cp = System.getProperty("java.class.path", ".");
|
||||
String dir = (baseDir == null) ? System.getProperty("user.dir") : baseDir.getPath();
|
||||
// System.err.println("Working dir: " + dir);
|
||||
/*if (baseDir == null) {
|
||||
throw new RuntimeException("Cannot launch EvA2 due to an access restriction. If you are using Java Web Start, please download the application and try again.");
|
||||
}*/
|
||||
|
||||
if (!cp.contains(dir)) {
|
||||
// this was added due to matlab not adding base dir to base path...
|
||||
System.err.println("classpath does not contain base directory!");
|
||||
@ -852,10 +814,9 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!
|
||||
return;
|
||||
}
|
||||
showLoadModules = true;
|
||||
} else {
|
||||
newModuleAdapter.setConnection(!localMode);
|
||||
newModuleAdapter.addOptimizationStateListener((OptimizationStateListener) this);
|
||||
newModuleAdapter.addOptimizationStateListener(this);
|
||||
try {
|
||||
if (withGUI) {
|
||||
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from!
|
||||
@ -864,7 +825,6 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
/* This is the left TabPane on the main frame */
|
||||
JPanel moduleContainer = frameMaker.makePanel();
|
||||
|
||||
boolean wasVisible = configurationPane.isVisible();
|
||||
configurationPane.setVisible(false);
|
||||
configurationPane.removeAll();
|
||||
|
||||
@ -873,7 +833,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
/* ToDo: Find a way to properly add the TreeView to the GOPanel */
|
||||
if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) {
|
||||
JComponent tree = null;
|
||||
tree = getEvATreeView(frameMaker.getGOPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getGOParameters());
|
||||
tree = getEvATreeView(frameMaker.getGOPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters());
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
@ -896,29 +856,17 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
gbConstraints2.gridx = 0;
|
||||
gbConstraints2.gridy = 0;
|
||||
gbConstraints2.fill = GridBagConstraints.VERTICAL;
|
||||
//gbConstraints2.gridheight = GridBagConstraints.REMAINDER;
|
||||
gbConstraints2.weighty = 1.0;
|
||||
configurationPane.add(moduleContainer, gbConstraints2);
|
||||
configurationPane.validate();
|
||||
}
|
||||
|
||||
currentModule = selectedModule;
|
||||
|
||||
} catch (Exception e) {
|
||||
currentModule = null;
|
||||
LOGGER.log(Level.SEVERE, "Error while newModulAdapter.getModulFrame(): " + e.getMessage(), e);
|
||||
EVAERROR.EXIT("Error while newModulAdapter.getModulFrame(): " + e.getMessage());
|
||||
}
|
||||
// try { TODO whats this?
|
||||
// newModuleAdapter.setConnection(true);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// m_LogPanel.logMessage("Error while m_ComAdapter.AddRMIPlotListener Host: " + e.getMessage());
|
||||
// EVAERROR.EXIT("Error while m_ComAdapter.AddRMIPlotListener: " + e.getMessage());
|
||||
// }
|
||||
// set mode (rmi or not)
|
||||
|
||||
// ModuladapterListe adden
|
||||
// m_ModuleAdapterList.add(newModuleAdapter);
|
||||
currentModuleAdapter = newModuleAdapter;
|
||||
}
|
||||
}
|
||||
@ -927,6 +875,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* Create a tree view of an object based on EvATreeNode. It is encapsulated
|
||||
* in a JScrollPane.
|
||||
*
|
||||
* @param goPanel
|
||||
* @param title
|
||||
* @param object
|
||||
* @return
|
||||
|
@ -144,10 +144,10 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
try {
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
for (int i = 0; i < props.length; i++) {
|
||||
if ((props[i].getName().equals(property))) {
|
||||
if (expertValue != props[i].isExpert()) {
|
||||
props[i].setExpert(expertValue);
|
||||
for (PropertyDescriptor prop : props) {
|
||||
if ((prop.getName().equals(property))) {
|
||||
if (expertValue != prop.isExpert()) {
|
||||
prop.setExpert(expertValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,10 +174,10 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
try {
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
for (int i = 0; i < props.length; i++) {
|
||||
if ((props[i].getName().equals(property))) {
|
||||
if (hide != props[i].isHidden()) {
|
||||
props[i].setHidden(hide);
|
||||
for (PropertyDescriptor prop : props) {
|
||||
if ((prop.getName().equals(property))) {
|
||||
if (hide != prop.isHidden()) {
|
||||
prop.setHidden(hide);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -305,7 +305,6 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
//System.err.println("setValue()" + m_ClassType.toString());
|
||||
|
||||
if (o == null || classType == null) {
|
||||
logger.log(Level.WARNING, "No ClassType set up for GenericObjectEditor!");
|
||||
@ -315,15 +314,14 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
if (classType.isPrimitive()) {
|
||||
System.err.println("setValue object not of correct type! Expected " + classType.getName() + ", got " + o.getClass().getName());
|
||||
System.err.println("setting primitive type");
|
||||
setObject((Object) o);
|
||||
//throw new NullPointerException("ASDF");
|
||||
setObject(o);
|
||||
} else {
|
||||
System.err.println("setValue object not of correct type! Expected " + classType.getName() + ", got " + o.getClass().getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setObject((Object) o);
|
||||
setObject(o);
|
||||
if (editorComponent != null) {
|
||||
editorComponent.updateChooser();
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
//package eva2.gui;
|
||||
//
|
||||
//
|
||||
//import javax.swing.*;
|
||||
//
|
||||
//import eva2.optimization.individuals.codings.gp.AbstractGPNode;
|
||||
//import eva2.optimization.individuals.codings.gp.GPArea;
|
||||
//
|
||||
//import java.beans.PropertyEditor;
|
||||
//import java.beans.PropertyChangeSupport;
|
||||
//import java.beans.PropertyChangeListener;
|
||||
//import java.awt.*;
|
||||
//import java.awt.event.ActionListener;
|
||||
//import java.awt.event.ActionEvent;
|
||||
//import java.util.ArrayList;
|
||||
//
|
||||
///**
|
||||
// * TODO this should be redundant with the new GenericObjectListEditor.
|
||||
// *
|
||||
// * Created by IntelliJ IDEA.
|
||||
// * User: streiche
|
||||
// * Date: 23.03.2004
|
||||
// * Time: 15:03:29
|
||||
// * To change this template use File | Settings | File Templates.
|
||||
// */
|
||||
//public class GenericStringListSelectionEditor extends AbstractListSelectionEditor {
|
||||
// private PropertyStringList m_List;
|
||||
//
|
||||
// @Override
|
||||
// protected int getElementCount() {
|
||||
// return m_List.getStrings().length;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected String getElementName(int i) {
|
||||
// return m_List.getStrings()[i];
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean isElementAllowed(int i) {
|
||||
// return this.m_List.getSelection()[i];
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean performOnAction() {
|
||||
// for (int i = 0; i < this.m_BlackCheck.length; i++) {
|
||||
// this.m_List.setSelectionForElement(i, this.m_BlackCheck[i].isSelected());
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean setObject(Object o) {
|
||||
// if (o instanceof PropertyStringList) {
|
||||
// this.m_List = (PropertyStringList) o;
|
||||
// return true;
|
||||
// } else return false;
|
||||
// }
|
||||
//
|
||||
// /** Retruns the current object.
|
||||
// * @return the current object
|
||||
// */
|
||||
// public Object getValue() {
|
||||
// return this.m_List;
|
||||
// }
|
||||
//}
|
@ -62,7 +62,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
* Start optimization on processor.
|
||||
*/
|
||||
@Override
|
||||
public void startOpt() {
|
||||
public void startOptimization() {
|
||||
processor.startOpt();
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
* Restart optimization on processor.
|
||||
*/
|
||||
@Override
|
||||
public void restartOpt() {
|
||||
public void restartOptimization() {
|
||||
processor.restartOpt();
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
* Stop optimization on processor.
|
||||
*/
|
||||
@Override
|
||||
public void stopOpt() {
|
||||
public void stopOptimization() {
|
||||
// This means user break
|
||||
processor.stopOpt();
|
||||
}
|
||||
@ -108,7 +108,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
}
|
||||
}
|
||||
|
||||
public InterfaceOptimizationParameters getGOParameters() {
|
||||
public InterfaceOptimizationParameters getOptimizationParameters() {
|
||||
if ((processor != null) && (processor instanceof Processor)) {
|
||||
return ((Processor) processor).getGOParams();
|
||||
} else {
|
||||
@ -116,7 +116,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
}
|
||||
}
|
||||
|
||||
public void setGOParameters(InterfaceOptimizationParameters goParams) {
|
||||
public void setOptimizationParameters(InterfaceOptimizationParameters goParams) {
|
||||
if ((processor != null) && (processor instanceof Processor)) {
|
||||
((Processor) processor).setGOParams(goParams);
|
||||
}
|
||||
|
@ -107,15 +107,15 @@ public class DEParameters extends AbstractOptimizationParameters implements Inte
|
||||
* @param f
|
||||
*/
|
||||
public void setF(double f) {
|
||||
((DifferentialEvolution) this.optimizer).setF(f);
|
||||
((DifferentialEvolution) this.optimizer).setDifferentialWeight(f);
|
||||
}
|
||||
|
||||
public double getF() {
|
||||
return ((DifferentialEvolution) this.optimizer).getF();
|
||||
return ((DifferentialEvolution) this.optimizer).getDifferentialWeight();
|
||||
}
|
||||
|
||||
public String fTipText() {
|
||||
return "F is a real and constant factor which controlls the ampllification of the differential variation.";
|
||||
public String differentialWeightTipText() {
|
||||
return "F is a real and constant factor which controlls the amplification of the differential variation.";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,14 +124,14 @@ public class DEParameters extends AbstractOptimizationParameters implements Inte
|
||||
* @param k
|
||||
*/
|
||||
public void setK(double k) {
|
||||
((DifferentialEvolution) this.optimizer).setK(k);
|
||||
((DifferentialEvolution) this.optimizer).setCrossoverRate(k);
|
||||
}
|
||||
|
||||
public double getK() {
|
||||
return ((DifferentialEvolution) this.optimizer).getK();
|
||||
return ((DifferentialEvolution) this.optimizer).getCrossoverRate();
|
||||
}
|
||||
|
||||
public String kTipText() {
|
||||
public String crossoverRateTipText() {
|
||||
return "Probability of alteration through DE1.";
|
||||
}
|
||||
|
||||
|
@ -140,8 +140,8 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGOParameters(InterfaceOptimizationParameters goParams) {
|
||||
super.setGOParameters(goParams);
|
||||
public void setOptimizationParameters(InterfaceOptimizationParameters goParams) {
|
||||
super.setOptimizationParameters(goParams);
|
||||
paramPanel.getEditor().setValue(goParams);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public interface ModuleAdapter extends OptimizationStateListener {
|
||||
|
||||
EvATabbedFrameMaker getModuleFrame();
|
||||
|
||||
void startOpt(); // called from client
|
||||
void startOptimization(); // called from client
|
||||
|
||||
/**
|
||||
* Schedule a certain job to a job list.
|
||||
@ -30,9 +30,9 @@ public interface ModuleAdapter extends OptimizationStateListener {
|
||||
*/
|
||||
OptimizationJob scheduleJob();
|
||||
|
||||
void restartOpt();
|
||||
void restartOptimization();
|
||||
|
||||
void stopOpt();
|
||||
void stopOptimization();
|
||||
|
||||
//void runScript();
|
||||
|
||||
|
@ -32,7 +32,7 @@ import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
* The Processor may run as a thread permanently (GenericModuleAdapter) and is
|
||||
* then stopped and started by a switch in startOpt/stopOpt.
|
||||
* then stopped and started by a switch in startOptimization/stopOptimization.
|
||||
* <p/>
|
||||
* Processor also handles adaptive parameter control by checking for the method
|
||||
* getParamControl in (so far) Optimizer and Problem instances. The return-value
|
||||
@ -214,7 +214,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
Population resultPop = null;
|
||||
|
||||
if (!isOptRunning()) {
|
||||
System.err.println("warning, this shouldnt happen in processor! Was startOpt called?");
|
||||
System.err.println("warning, this shouldnt happen in processor! Was startOptimization called?");
|
||||
setOptRunning(true);
|
||||
}
|
||||
|
||||
|
@ -442,14 +442,14 @@ public class PostProcess {
|
||||
gda.initByPopulation(pop, false);
|
||||
|
||||
int funCallsBefore = pop.getFunctionCalls();
|
||||
pop.SetFunctionCalls(baseEvals);
|
||||
pop.setFunctionCalls(baseEvals);
|
||||
|
||||
OptimizerRunnable ppRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(gda, pop, problem, 0, term), true);
|
||||
runPP(ppRunnable);
|
||||
// ppRunnable.getStats().createNextGenerationPerformed(gda.getPopulation(), gda, null);
|
||||
|
||||
int funCallsDone = pop.getFunctionCalls() - baseEvals;
|
||||
pop.SetFunctionCalls(funCallsBefore);
|
||||
pop.setFunctionCalls(funCallsBefore);
|
||||
|
||||
return funCallsDone;
|
||||
}
|
||||
@ -476,26 +476,16 @@ public class PostProcess {
|
||||
nms.setGenerationCycle(5);
|
||||
nms.initByPopulation(pop, false);
|
||||
int funCallsBefore = pop.getFunctionCalls();
|
||||
pop.SetFunctionCalls(baseEvals);
|
||||
pop.setFunctionCalls(baseEvals);
|
||||
|
||||
OptimizerRunnable ppRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(nms, pop, problem, 0, term), true);
|
||||
// as nms creates a new population and has already evaluated them, send a signal to stats
|
||||
ppRunnable.getStats().createNextGenerationPerformed(nms.getPopulation(), nms, null);
|
||||
|
||||
// if (problem instanceof InterfaceFirstOrderDerivableProblem) {
|
||||
// double[] x = pop.getBestEAIndividual().getDoublePosition();
|
||||
// System.out.println("grads: " + BeanInspector.toString(((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(x)));
|
||||
// }
|
||||
|
||||
runPP(ppRunnable);
|
||||
|
||||
// if (problem instanceof InterfaceFirstOrderDerivableProblem) {
|
||||
// double[] x = pop.getBestEAIndividual().getDoublePosition();
|
||||
// System.out.println("grads: " + BeanInspector.toString(((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(x)));
|
||||
// }
|
||||
|
||||
int funCallsDone = pop.getFunctionCalls() - baseEvals;
|
||||
pop.SetFunctionCalls(funCallsBefore);
|
||||
pop.setFunctionCalls(funCallsBefore);
|
||||
|
||||
return new Pair<Integer, Boolean>(funCallsDone, ppRunnable.wasAborted());
|
||||
}
|
||||
@ -529,7 +519,7 @@ public class PostProcess {
|
||||
OptimizationParameters cmaParams = OptimizerFactory.makeParams(es, pop, problem, 0, term);
|
||||
|
||||
int funCallsBefore = pop.getFunctionCalls();
|
||||
pop.SetFunctionCalls(baseEvals);
|
||||
pop.setFunctionCalls(baseEvals);
|
||||
|
||||
OptimizerRunnable ppRunnable = new OptimizerRunnable(cmaParams, true);
|
||||
ppRunnable.getStats().createNextGenerationPerformed(cmaParams.getOptimizer().getPopulation(), cmaParams.getOptimizer(), null);
|
||||
@ -605,7 +595,6 @@ public class PostProcess {
|
||||
}
|
||||
subPop = NelderMeadSimplex.createNMSPopulation(candidates.getEAIndividual(index), absToRelPerturb(perturb, range), range, false);
|
||||
}
|
||||
// subPop.setSameParams(candidates);
|
||||
return subPop;
|
||||
}
|
||||
|
||||
@ -723,7 +712,6 @@ public class PostProcess {
|
||||
for (int i = 0; i < candidates.size(); i++) { // improve each single sub pop
|
||||
subPop = nmPops.get(i);
|
||||
term.init(prob);
|
||||
// if (TRACE) System.out.println("*** before " + subPop.getBestEAIndividual().getStringRepresentation());
|
||||
|
||||
switch (method) {
|
||||
case nelderMead:
|
||||
@ -744,23 +732,15 @@ public class PostProcess {
|
||||
break;
|
||||
}
|
||||
|
||||
// if (TRACE) System.out.println("*** after: " + subPop.getBestEAIndividual().getStringRepresentation());
|
||||
if (checkRange(subPop.getBestEAIndividual())) {
|
||||
// and replace corresponding individual (should usually be better)
|
||||
// if (subPop.getBestEAIndividual().isDominant(candidates.getEAIndividual(i))) { // TODO Multiobjective???
|
||||
if (subPop.getBestEAIndividual().getFitness(0) < candidates.getEAIndividual(i).getFitness(0)) {
|
||||
// System.out.println("moved by "+ PhenotypeMetric.dist(candidates.getEAIndividual(i), subPop.getBestEAIndividual()));
|
||||
subPop.getBestEAIndividual().putData(movedDistanceKey, new Double(PhenotypeMetric.dist(candidates.getEAIndividual(i), subPop.getBestEAIndividual())));
|
||||
// subPop.getBestEAIndividual().putData(movedToPositionKey, subPop.getBestEAIndividual().getDoublePosition());
|
||||
// ^ this makes no sense here since the new position is returned anyways by replacing the candidate individual
|
||||
subPop.getBestEAIndividual().putData(movedDistanceKey, PhenotypeMetric.dist(candidates.getEAIndividual(i), subPop.getBestEAIndividual()));
|
||||
candidates.set(i, subPop.getBestEAIndividual());
|
||||
}
|
||||
} else {
|
||||
// TODO esp. in nelder mead
|
||||
System.err.println("Warning, individual left the problem range during PP!");
|
||||
}
|
||||
|
||||
// if (TRACE) System.out.println("refined to " + subPop.getBestEAIndividual().getStringRepresentation());
|
||||
}
|
||||
|
||||
return stepsPerf;
|
||||
@ -864,9 +844,7 @@ public class PostProcess {
|
||||
rnbl.getGOParams().setDoPostProcessing(false);
|
||||
rnbl.setVerbosityLevel(StatisticsParameter.VERBOSITY_NONE);
|
||||
ppRunnables.add(rnbl);
|
||||
// System.err.println("Starting runbl " + rnbl);
|
||||
rnbl.run();
|
||||
// System.err.println("Aborted: " + rnbl.wasAborted());
|
||||
rnbl.getGOParams().setDoPostProcessing(true);
|
||||
ppRunnables.remove(rnbl);
|
||||
}
|
||||
@ -875,16 +853,15 @@ public class PostProcess {
|
||||
* Stop the post processing thread with the given ID.
|
||||
*/
|
||||
public static void stopPP(int rnblID) {
|
||||
// System.err.println("Stopping pp " + rnblID);
|
||||
OptimizerRunnable rnbl = getRunnable(rnblID);
|
||||
stopPP(rnbl);
|
||||
}
|
||||
|
||||
private static OptimizerRunnable getRunnable(int rnblID) {
|
||||
synchronized (ppRunnables) {
|
||||
for (int i = 0; i < ppRunnables.size(); i++) {
|
||||
if (rnblID == ppRunnables.get(i).getID()) {
|
||||
return ppRunnables.get(i);
|
||||
for (OptimizerRunnable ppRunnable : ppRunnables) {
|
||||
if (rnblID == ppRunnable.getID()) {
|
||||
return ppRunnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -895,7 +872,6 @@ public class PostProcess {
|
||||
* Stop the post processing if its currently running.
|
||||
*/
|
||||
public static void stopPP(OptimizerRunnable rnbl) {
|
||||
// System.err.println("Stopping rnbl " + rnbl);
|
||||
if (rnbl != null) {
|
||||
synchronized (rnbl) {
|
||||
rnbl.stopOpt();
|
||||
@ -954,7 +930,6 @@ public class PostProcess {
|
||||
OptimizerRunnable runnable = OptimizerFactory.getOptRunnable(OptimizerFactory.STD_GA, problem, 100, null);
|
||||
runnable.run();
|
||||
Population pop = runnable.getGOParams().getOptimizer().getPopulation();
|
||||
// System.out.println("no optima found: " + mmp.getNumberOfFoundOptima(pop));
|
||||
Population found = getFoundOptima(pop, mmp.getRealOptima(), 0.05, true);
|
||||
System.out.println("all found (" + found.size() + "): " + BeanInspector.toString(found));
|
||||
|
||||
@ -963,8 +938,6 @@ public class PostProcess {
|
||||
int evalCnt = 0;
|
||||
while (popD.tail() > 0.001) {
|
||||
i++;
|
||||
// public static PopDoublePair clusterHC(pop, problem, sigmaCluster, funCalls, keepClusterRatio, mute) {
|
||||
|
||||
popD = clusterLocalSearch(PostProcessMethod.hillClimber, popD.head(), problem, 0.01, 1500, 0.1, new MutateESFixedStepSize(0.02));
|
||||
evalCnt += popD.head().getFunctionCalls();
|
||||
System.out.println("popsize is " + popD.head().size());
|
||||
@ -972,11 +945,6 @@ public class PostProcess {
|
||||
found = getFoundOptima(popD.head(), mmp.getRealOptima(), 0.05, true);
|
||||
System.out.println("found at " + i + " (" + found.size() + "): " + BeanInspector.toString(found));
|
||||
System.out.println("funcalls: " + evalCnt);
|
||||
// System.out.println(BeanInspector.toString(pop.getMeanFitness()));
|
||||
|
||||
// System.out.println("no optima found: " + mmp.getNumberOfFoundOptima(pop));
|
||||
// System.out.println("best after: " + AbstractEAIndividual.getDefaultStringRepresentation(pop.getBestEAIndividual()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -999,7 +967,6 @@ public class PostProcess {
|
||||
|
||||
Population clust = (Population) clusterBest(pop, new ClusteringDensityBased(sigmaCluster, 2), keepClusterRatio, KEEP_LONERS, BEST_RAND).clone();
|
||||
|
||||
//clust.addPopulationChangedEventListener()
|
||||
double[] meanFit = clust.getMeanFitness();
|
||||
|
||||
if (TRACE) {
|
||||
@ -1008,7 +975,7 @@ public class PostProcess {
|
||||
|
||||
int evalsDone = processSingleCandidates(method, clust, funCalls, sigmaCluster / 2., problem, mute);
|
||||
|
||||
clust.SetFunctionCalls(evalsBefore + evalsDone);
|
||||
clust.setFunctionCalls(evalsBefore + evalsDone);
|
||||
|
||||
double improvement = EuclideanMetric.euclideanDistance(meanFit, clust.getMeanFitness());
|
||||
if (TRACE) {
|
||||
@ -1037,21 +1004,6 @@ public class PostProcess {
|
||||
listener.println("found " + getFoundOptima(solutions, mmkProb.getRealOptima(), epsilon, true).size() + " for epsilon = " + epsilon + ", maxPeakRatio: " + mmkProb.getMaximumPeakRatio(solutions));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO in this form it may cost a lot of time and cant be stopped, which is bad
|
||||
// double epsilonPhenoSpace = 0.01, epsilonFitConv = 1e-10, clusterSigma = 0.;
|
||||
// Population extrOpts;
|
||||
// for (int k=0; k<3; k++) {
|
||||
// extrOpts = prob.extractPotentialOptima(solutions, epsilonPhenoSpace, epsilonFitConv, clusterSigma, -1);
|
||||
// listener.println("estimated number of found optima: " + extrOpts.size() + " with crit. " + epsilonPhenoSpace);
|
||||
// if (extrOpts.size() > 0) {
|
||||
// listener.println("fit measures: ");
|
||||
// int critCnt = extrOpts.getEAIndividual(0).getFitness().length;
|
||||
// for (int i=0; i<critCnt; i++) listener.print(BeanInspector.toString(extrOpts.getFitnessMeasures(i)) + " ");
|
||||
// listener.println("");
|
||||
// }
|
||||
// epsilonPhenoSpace /= 10.;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,9 +212,9 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
|
||||
List<OptimizationJob> jobs = jobList.getSelectedJobs();
|
||||
if (jobs.size() == 1) {
|
||||
OptimizationJob job = jobs.get(0);
|
||||
AbstractOptimizationParameters curParams = (AbstractOptimizationParameters) ((AbstractModuleAdapter) jobList.module).getGOParameters();
|
||||
AbstractOptimizationParameters curParams = (AbstractOptimizationParameters) ((AbstractModuleAdapter) jobList.module).getOptimizationParameters();
|
||||
curParams.setSameParams((AbstractOptimizationParameters) job.getGOParams());
|
||||
((GenericModuleAdapter) jobList.module).setGOParameters(curParams);
|
||||
((GenericModuleAdapter) jobList.module).setOptimizationParameters(curParams);
|
||||
((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().setMultiRuns(job.getNumRuns());
|
||||
((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().setFieldSelection(job.getFieldSelection(((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().getFieldSelection()));
|
||||
} else {
|
||||
|
@ -200,7 +200,7 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
System.out.println("evalCycle: " + hcEvalCycle + ", evals now: " + evalsNow);
|
||||
}
|
||||
popD = PostProcess.clusterLocalSearch(localSearchMethod, m_Population, (AbstractOptimizationProblem) m_Problem, sigmaClust, evalsNow, 0.5, mutator);
|
||||
// (m_Population, (AbstractOptimizationProblem)problem, sigmaClust, hcEvalCycle - (m_Population.getFunctionCalls() % hcEvalCycle), 0.5);
|
||||
// (population, (AbstractOptimizationProblem)problem, sigmaClust, hcEvalCycle - (population.getFunctionCalls() % hcEvalCycle), 0.5);
|
||||
if (popD.head().getFunctionCalls() == funCallsBefore) {
|
||||
System.err.println("Bad case, increasing allowed evaluations!");
|
||||
evalsNow = Math.max(evalsNow++, (int) (evalsNow * 1.2));
|
||||
|
@ -32,19 +32,19 @@ import java.util.Vector;
|
||||
*/
|
||||
public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
protected Population m_Population = new Population();
|
||||
protected Population population = new Population();
|
||||
protected transient Population children = null;
|
||||
protected AbstractOptimizationProblem m_Problem = new F1Problem();
|
||||
private DETypeEnum m_DEType;
|
||||
protected AbstractOptimizationProblem optimizationProblem = new F1Problem();
|
||||
private DETypeEnum DEType;
|
||||
|
||||
@Parameter(name = "F", description = "Differential Weight")
|
||||
private double m_F = 0.8;
|
||||
private double differentialWeight = 0.8;
|
||||
|
||||
@Parameter(name = "CR", description = "Crossover Rate")
|
||||
private double m_k = 0.6; // AKA CR
|
||||
private double crossoverRate = 0.6; // AKA CR
|
||||
|
||||
@Parameter(name = "Lambda", description = "Lambda")
|
||||
private double m_Lambda = 0.6;
|
||||
private double lambda = 0.6;
|
||||
|
||||
private double m_Mt = 0.05;
|
||||
private int maximumAge = -1;
|
||||
@ -65,15 +65,15 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*/
|
||||
public DifferentialEvolution() {
|
||||
// sets DE2 as default
|
||||
m_DEType = DETypeEnum.DE2_CurrentToBest;
|
||||
DEType = DETypeEnum.DE2_CurrentToBest;
|
||||
}
|
||||
|
||||
public DifferentialEvolution(int popSize, DETypeEnum type, double f, double k, double lambda, double mt) {
|
||||
m_Population = new Population(popSize);
|
||||
m_DEType = type;
|
||||
m_F = f;
|
||||
m_k = k;
|
||||
m_Lambda = lambda;
|
||||
population = new Population(popSize);
|
||||
DEType = type;
|
||||
differentialWeight = f;
|
||||
crossoverRate = k;
|
||||
this.lambda = lambda;
|
||||
m_Mt = mt;
|
||||
}
|
||||
|
||||
@ -83,13 +83,13 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* @param a
|
||||
*/
|
||||
public DifferentialEvolution(DifferentialEvolution a) {
|
||||
this.m_DEType = a.m_DEType;
|
||||
this.m_Population = (Population) a.m_Population.clone();
|
||||
this.m_Problem = (AbstractOptimizationProblem) a.m_Problem.clone();
|
||||
this.DEType = a.DEType;
|
||||
this.population = (Population) a.population.clone();
|
||||
this.optimizationProblem = (AbstractOptimizationProblem) a.optimizationProblem.clone();
|
||||
this.m_Identifier = a.m_Identifier;
|
||||
this.m_F = a.m_F;
|
||||
this.m_k = a.m_k;
|
||||
this.m_Lambda = a.m_Lambda;
|
||||
this.differentialWeight = a.differentialWeight;
|
||||
this.crossoverRate = a.crossoverRate;
|
||||
this.lambda = a.lambda;
|
||||
this.m_Mt = a.m_Mt;
|
||||
|
||||
this.maximumAge = a.maximumAge;
|
||||
@ -106,9 +106,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.m_Problem.initializePopulation(this.m_Population);
|
||||
// children = new Population(m_Population.size());
|
||||
this.evaluatePopulation(this.m_Population);
|
||||
this.optimizationProblem.initializePopulation(this.population);
|
||||
// children = new Population(population.size());
|
||||
this.evaluatePopulation(this.population);
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
}
|
||||
|
||||
@ -124,14 +124,14 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*/
|
||||
@Override
|
||||
public void initByPopulation(Population pop, boolean reset) {
|
||||
this.m_Population = (Population) pop.clone();
|
||||
this.population = (Population) pop.clone();
|
||||
if (reset) {
|
||||
this.m_Population.init();
|
||||
this.evaluatePopulation(this.m_Population);
|
||||
this.population.init();
|
||||
this.evaluatePopulation(this.population);
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
}
|
||||
// if (reset) this.m_Population.init();
|
||||
// else children = new Population(m_Population.size());
|
||||
// if (reset) this.population.init();
|
||||
// else children = new Population(population.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +140,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
this.m_Problem.evaluate(population);
|
||||
this.optimizationProblem.evaluate(population);
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
x1 = indy.getDoubleData();
|
||||
result = new double[x1.length];
|
||||
if (m_Problem instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
if (optimizationProblem instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
// implements MODE for the multi-objective case: a dominating individual is selected for difference building
|
||||
Population domSet = pop.getDominatingSet((AbstractEAIndividual) indy);
|
||||
if (domSet.size() > 0) {
|
||||
@ -290,27 +290,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns two parents to the original individual
|
||||
*
|
||||
* @param pop The population to choose from
|
||||
* @return the delta vector
|
||||
*/
|
||||
// private double[][] chooseRandomParents(Population pop) {
|
||||
// InterfaceESIndividual indy1, indy2;
|
||||
// double[][] result = new double[2][];
|
||||
// try {
|
||||
// indy1 = (InterfaceESIndividual)pop.get(RNG.randomInt(0, pop.size()-1));
|
||||
// indy2 = (InterfaceESIndividual)pop.get(RNG.randomInt(0, pop.size()-1));
|
||||
// } catch (java.lang.ClassCastException e) {
|
||||
// System.out.println("Differential Evolution currently requires InterfaceESIndividual as basic data type!");
|
||||
// return result;
|
||||
// }
|
||||
// result[0] = indy1.getDGenotype();
|
||||
// result[1] = indy2.getDGenotype();
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method will generate one new individual from the given population
|
||||
*
|
||||
@ -318,7 +297,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* @return AbstractEAIndividual
|
||||
*/
|
||||
public AbstractEAIndividual generateNewIndividual(Population pop, int parentIndex) {
|
||||
// int firstParentIndex;
|
||||
AbstractEAIndividual indy;
|
||||
InterfaceDataTypeDouble esIndy;
|
||||
|
||||
@ -342,7 +320,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
oX = esIndy.getDoubleData();
|
||||
vX = oX.clone();
|
||||
nX = new double[oX.length];
|
||||
switch (this.m_DEType) {
|
||||
switch (this.DEType) {
|
||||
case DE1_Rand_1: {
|
||||
// this is DE1 or DE/rand/1
|
||||
double[] delta = this.fetchDeltaRandom(pop);
|
||||
@ -462,25 +440,25 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
private double getCurrentK() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_k * 0.8, m_k * 1.2);
|
||||
return RNG.randomDouble(crossoverRate * 0.8, crossoverRate * 1.2);
|
||||
} else {
|
||||
return m_k;
|
||||
return crossoverRate;
|
||||
}
|
||||
}
|
||||
|
||||
private double getCurrentLambda() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_Lambda * 0.8, m_Lambda * 1.2);
|
||||
return RNG.randomDouble(lambda * 0.8, lambda * 1.2);
|
||||
} else {
|
||||
return m_Lambda;
|
||||
return lambda;
|
||||
}
|
||||
}
|
||||
|
||||
private double getCurrentF() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_F * 0.8, m_F * 1.2);
|
||||
return RNG.randomDouble(differentialWeight * 0.8, differentialWeight * 1.2);
|
||||
} else {
|
||||
return m_F;
|
||||
return differentialWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,72 +502,69 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* However it may be easier to parallelize.
|
||||
*/
|
||||
public void optimizeGenerational() {
|
||||
// AbstractEAIndividual indy = null, orig;
|
||||
int parentIndex;
|
||||
// required for dynamic problems especially
|
||||
// problem.evaluatePopulationStart(m_Population);
|
||||
if (children == null) {
|
||||
children = new Population(m_Population.size());
|
||||
children = new Population(population.size());
|
||||
} else {
|
||||
children.clear();
|
||||
}
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
for (int i = 0; i < this.population.size(); i++) {
|
||||
if (cyclePop) {
|
||||
parentIndex = i;
|
||||
} else {
|
||||
parentIndex = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
parentIndex = RNG.randomInt(0, this.population.size() - 1);
|
||||
}
|
||||
AbstractEAIndividual indy = generateNewIndividual(m_Population, parentIndex);
|
||||
AbstractEAIndividual indy = generateNewIndividual(population, parentIndex);
|
||||
children.add(indy);
|
||||
}
|
||||
|
||||
children.setGenerationTo(m_Population.getGeneration());
|
||||
m_Problem.evaluate(children);
|
||||
children.setGeneration(population.getGeneration());
|
||||
optimizationProblem.evaluate(children);
|
||||
|
||||
/**
|
||||
* MdP: added a reevalutation mechanism for dynamically changing
|
||||
* problems
|
||||
*/
|
||||
if (isReEvaluate()) {
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
for (int i = 0; i < this.population.size(); i++) {
|
||||
|
||||
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
|
||||
this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i)));
|
||||
((AbstractEAIndividual) m_Population.get(i)).SetAge(0);
|
||||
m_Population.incrFunctionCalls();
|
||||
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
|
||||
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
|
||||
((AbstractEAIndividual) population.get(i)).SetAge(0);
|
||||
population.incrFunctionCalls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nextDoomed = getNextDoomed(m_Population, 0);
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
int nextDoomed = getNextDoomed(population, 0);
|
||||
for (int i = 0; i < this.population.size(); i++) {
|
||||
AbstractEAIndividual indy = children.getEAIndividual(i);
|
||||
if (cyclePop) {
|
||||
parentIndex = i;
|
||||
} else {
|
||||
parentIndex = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
parentIndex = RNG.randomInt(0, this.population.size() - 1);
|
||||
}
|
||||
if (nextDoomed >= 0) { // this one is lucky, may replace an 'old' one
|
||||
m_Population.replaceIndividualAt(nextDoomed, indy);
|
||||
nextDoomed = getNextDoomed(m_Population, nextDoomed + 1);
|
||||
population.replaceIndividualAt(nextDoomed, indy);
|
||||
nextDoomed = getNextDoomed(population, nextDoomed + 1);
|
||||
} else {
|
||||
if (m_Problem instanceof AbstractMultiObjectiveOptimizationProblem & indy.getFitness().length > 1) {
|
||||
if (optimizationProblem instanceof AbstractMultiObjectiveOptimizationProblem & indy.getFitness().length > 1) {
|
||||
ReplacementCrowding repl = new ReplacementCrowding();
|
||||
repl.insertIndividual(indy, m_Population, null);
|
||||
repl.insertIndividual(indy, population, null);
|
||||
} else {
|
||||
// index = RNG.randomInt(0, this.m_Population.size()-1);
|
||||
// index = RNG.randomInt(0, this.population.size()-1);
|
||||
if (!compareToParent) {
|
||||
parentIndex = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
parentIndex = RNG.randomInt(0, this.population.size() - 1);
|
||||
}
|
||||
AbstractEAIndividual orig = (AbstractEAIndividual) this.m_Population.get(parentIndex);
|
||||
AbstractEAIndividual orig = (AbstractEAIndividual) this.population.get(parentIndex);
|
||||
if (indy.isDominatingDebConstraints(orig)) {
|
||||
this.m_Population.replaceIndividualAt(parentIndex, indy);
|
||||
this.population.replaceIndividualAt(parentIndex, indy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.m_Population.incrFunctionCallsBy(children.size());
|
||||
this.m_Population.incrGeneration();
|
||||
this.population.incrFunctionCallsBy(children.size());
|
||||
this.population.incrGeneration();
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
}
|
||||
|
||||
@ -597,10 +572,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
AbstractEAIndividual indy = null, orig;
|
||||
int index;
|
||||
|
||||
int nextDoomed = getNextDoomed(m_Population, 0);
|
||||
int nextDoomed = getNextDoomed(population, 0);
|
||||
|
||||
// required for dynamic problems especially
|
||||
m_Problem.evaluatePopulationStart(m_Population);
|
||||
optimizationProblem.evaluatePopulationStart(population);
|
||||
|
||||
|
||||
/**
|
||||
@ -609,96 +584,52 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*/
|
||||
if (isReEvaluate()) {
|
||||
nextDoomed = -1;
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
for (int i = 0; i < this.population.size(); i++) {
|
||||
|
||||
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
|
||||
this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i)));
|
||||
((AbstractEAIndividual) m_Population.get(i)).SetAge(0);
|
||||
m_Population.incrFunctionCalls();
|
||||
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
|
||||
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
|
||||
((AbstractEAIndividual) population.get(i)).SetAge(0);
|
||||
population.incrFunctionCalls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
for (int i = 0; i < this.population.size(); i++) {
|
||||
if (cyclePop) {
|
||||
index = i;
|
||||
} else {
|
||||
index = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
index = RNG.randomInt(0, this.population.size() - 1);
|
||||
}
|
||||
indy = generateNewIndividual(m_Population, index);
|
||||
// if (cyclePop) indy = this.generateNewIndividual(this.m_Population, i);
|
||||
// else indy = this.generateNewIndividual(this.m_Population, -1);
|
||||
this.m_Problem.evaluate(indy);
|
||||
this.m_Population.incrFunctionCalls();
|
||||
indy = generateNewIndividual(population, index);
|
||||
this.optimizationProblem.evaluate(indy);
|
||||
this.population.incrFunctionCalls();
|
||||
if (nextDoomed >= 0) { // this one is lucky, may replace an 'old' one
|
||||
m_Population.replaceIndividualAt(nextDoomed, indy);
|
||||
nextDoomed = getNextDoomed(m_Population, nextDoomed + 1);
|
||||
population.replaceIndividualAt(nextDoomed, indy);
|
||||
nextDoomed = getNextDoomed(population, nextDoomed + 1);
|
||||
} else {
|
||||
if (m_Problem instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
if (optimizationProblem instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
|
||||
if (indy.isDominatingDebConstraints(m_Population.getEAIndividual(index))) { //child dominates the parent replace the parent
|
||||
m_Population.replaceIndividualAt(index, indy);
|
||||
} else if (!(m_Population.getEAIndividual(index).isDominatingDebConstraints(indy))) { //do nothing if parent dominates the child use crowding if neither one dominates the other one
|
||||
if (indy.isDominatingDebConstraints(population.getEAIndividual(index))) { //child dominates the parent replace the parent
|
||||
population.replaceIndividualAt(index, indy);
|
||||
} else if (!(population.getEAIndividual(index).isDominatingDebConstraints(indy))) { //do nothing if parent dominates the child use crowding if neither one dominates the other one
|
||||
ReplacementNondominatedSortingDistanceCrowding repl = new ReplacementNondominatedSortingDistanceCrowding();
|
||||
repl.insertIndividual(indy, m_Population, null);
|
||||
repl.insertIndividual(indy, population, null);
|
||||
}
|
||||
// ReplacementCrowding repl = new ReplacementCrowding();
|
||||
// repl.insertIndividual(indy, m_Population, null);
|
||||
|
||||
|
||||
} else {
|
||||
// index = RNG.randomInt(0, this.m_Population.size()-1);
|
||||
if (!compareToParent) {
|
||||
index = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
index = RNG.randomInt(0, this.population.size() - 1);
|
||||
}
|
||||
orig = (AbstractEAIndividual) this.m_Population.get(index);
|
||||
orig = (AbstractEAIndividual) this.population.get(index);
|
||||
if (indy.isDominatingDebConstraints(orig)) {
|
||||
this.m_Population.replaceIndividualAt(index, indy);
|
||||
this.population.replaceIndividualAt(index, indy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////// this was a non-steady-state-version
|
||||
// if (children==null) children = new Population(m_Population.size());
|
||||
// for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
// indy = this.generateNewIndividual(this.m_Population);
|
||||
// this.problem.evaluate(indy);
|
||||
// this.m_Population.incrFunctionCalls();
|
||||
// children.add(indy);
|
||||
// }
|
||||
// int nextDoomed = getNextDoomed(m_Population, 0);
|
||||
//
|
||||
// for (int i=0; i<this.m_Population.size(); i++) {
|
||||
// indy = (AbstractEAIndividual)children.get(i);
|
||||
// if (nextDoomed >= 0) { // kid is lucky, it may replace an 'old' individual
|
||||
// m_Population.replaceIndividualAt(nextDoomed, indy);
|
||||
// nextDoomed = getNextDoomed(m_Population, nextDoomed+1);
|
||||
// } else { // duel with random one
|
||||
// index = RNG.randomInt(0, this.m_Population.size()-1);
|
||||
// org = (AbstractEAIndividual)this.m_Population.get(index);
|
||||
// // if (envHasChanged) this.problem.evaluate(org);
|
||||
// if (indy.isDominatingDebConstraints(org)) {
|
||||
// this.m_Population.replaceIndividualAt(index, indy);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// children.clear();
|
||||
//////// this was the original version
|
||||
// for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
// indy = this.generateNewIndividual(this.m_Population);
|
||||
// this.problem.evaluate(indy);
|
||||
// this.m_Population.incrFunctionCalls();
|
||||
// index = RNG.randomInt(0, this.m_Population.size()-1);
|
||||
// org = (AbstractEAIndividual)this.m_Population.get(index);
|
||||
// if (indy.isDominatingDebConstraints(org)) {
|
||||
// this.m_Population.remove(index);
|
||||
// this.m_Population.add(index, indy);
|
||||
// }
|
||||
// }
|
||||
m_Problem.evaluatePopulationEnd(m_Population);
|
||||
this.m_Population.incrGeneration();
|
||||
optimizationProblem.evaluatePopulationEnd(population);
|
||||
this.population.incrGeneration();
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
}
|
||||
|
||||
@ -767,12 +698,12 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = (AbstractOptimizationProblem) problem;
|
||||
this.optimizationProblem = (AbstractOptimizationProblem) problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return (InterfaceOptimizationProblem) this.m_Problem;
|
||||
return (InterfaceOptimizationProblem) this.optimizationProblem;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -786,8 +717,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
String result = "";
|
||||
result += "Differential Evolution:\n";
|
||||
result += "Optimization Problem: ";
|
||||
result += this.m_Problem.getStringRepresentationForProblem(this) + "\n";
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
result += this.optimizationProblem.getStringRepresentationForProblem(this) + "\n";
|
||||
result += this.population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -838,12 +769,12 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
return this.population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
this.population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
@ -862,15 +793,15 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*
|
||||
* @param f
|
||||
*/
|
||||
public void setF(double f) {
|
||||
this.m_F = f;
|
||||
public void setDifferentialWeight(double f) {
|
||||
this.differentialWeight = f;
|
||||
}
|
||||
|
||||
public double getF() {
|
||||
return this.m_F;
|
||||
public double getDifferentialWeight() {
|
||||
return this.differentialWeight;
|
||||
}
|
||||
|
||||
public String fTipText() {
|
||||
public String differentialWeightTipText() {
|
||||
return "F is a real and constant factor which controls the amplification of the differential variation.";
|
||||
}
|
||||
|
||||
@ -880,21 +811,21 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
*
|
||||
* @param k
|
||||
*/
|
||||
public void setK(double k) {
|
||||
public void setCrossoverRate(double k) {
|
||||
if (k < 0) {
|
||||
k = 0;
|
||||
}
|
||||
if (k > 1) {
|
||||
k = 1;
|
||||
}
|
||||
this.m_k = k;
|
||||
this.crossoverRate = k;
|
||||
}
|
||||
|
||||
public double getK() {
|
||||
return this.m_k;
|
||||
public double getCrossoverRate() {
|
||||
return this.crossoverRate;
|
||||
}
|
||||
|
||||
public String kTipText() {
|
||||
public String crossoverrateTipText() {
|
||||
return "Probability of alteration through DE (a.k.a. CR, similar to discrete uniform crossover).";
|
||||
}
|
||||
|
||||
@ -905,11 +836,11 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* @param l
|
||||
*/
|
||||
public void setLambda(double l) {
|
||||
this.m_Lambda = l;
|
||||
this.lambda = l;
|
||||
}
|
||||
|
||||
public double getLambda() {
|
||||
return this.m_Lambda;
|
||||
return this.lambda;
|
||||
}
|
||||
|
||||
public String lambdaTipText() {
|
||||
@ -945,14 +876,14 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
* @param s The type.
|
||||
*/
|
||||
public void setDEType(DETypeEnum s) {
|
||||
this.m_DEType = s;
|
||||
this.DEType = s;
|
||||
// show mt for trig. DE only
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "lambda", s == DETypeEnum.DE2_CurrentToBest);
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "mt", s == DETypeEnum.TrigonometricDE);
|
||||
}
|
||||
|
||||
public DETypeEnum getDEType() {
|
||||
return this.m_DEType;
|
||||
return this.DEType;
|
||||
}
|
||||
|
||||
public String dETypeTipText() {
|
||||
@ -1009,17 +940,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return "If true, values for k, f, lambda are randomly sampled around +/- 20% of the given values.";
|
||||
}
|
||||
|
||||
// public boolean isCyclePop() {
|
||||
// return cyclePop;
|
||||
// }
|
||||
//
|
||||
// public void setCyclePop(boolean cyclePop) {
|
||||
// this.cyclePop = cyclePop;
|
||||
// }
|
||||
//
|
||||
// public String cyclePopTipText() {
|
||||
// return "Use all individuals as parents in cyclic sequence instead of randomly.";
|
||||
// }
|
||||
public boolean isCompareToParent() {
|
||||
return compareToParent;
|
||||
}
|
||||
@ -1071,6 +991,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
|
||||
public String reEvaluateTipText() {
|
||||
return "Reeavulates individuals which are older than maximum age instead of discarding them";
|
||||
return "Re-evaluates individuals which are older than maximum age instead of discarding them";
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ public class EvolutionStrategyIPOP extends EvolutionStrategies implements Interf
|
||||
// // first perform the environment selection to select myu parents
|
||||
// parents = selectParents();
|
||||
//
|
||||
// // m_Population / parents are of sizes lambda / mu
|
||||
// // population / parents are of sizes lambda / mu
|
||||
// if (parents.getEAIndividual(0).getMutationOperator() instanceof InterfaceMutationGenerational) {
|
||||
// ((InterfaceMutationGenerational)parents.getEAIndividual(0).getMutationOperator()).adaptAfterSelection(getPopulation(), parents);
|
||||
// }
|
||||
|
@ -92,7 +92,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
this.m_Problem.evaluate(this.m_Population);
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
if (((AbstractEAIndividual) original.get(i)).isDominatingDebConstraints(((AbstractEAIndividual) this.m_Population.get(i)))) {
|
||||
// this.m_Population.remove(i);
|
||||
// this.population.remove(i);
|
||||
// throw away mutated one and replace by old one
|
||||
this.m_Population.set(i, original.get(i));
|
||||
} else {
|
||||
@ -100,20 +100,20 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
}
|
||||
this.m_Population.incrGeneration();
|
||||
// for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
// indy1 = (AbstractEAIndividual) this.m_Population.get(i);
|
||||
// for (int i = 0; i < this.population.size(); i++) {
|
||||
// indy1 = (AbstractEAIndividual) this.population.get(i);
|
||||
// indy2 = (AbstractEAIndividual)(indy1).clone();
|
||||
// indy2.mutate();
|
||||
// this.problem.evaluate((AbstractEAIndividual) indy2);
|
||||
// //indy2.SetFitness(0, indy2.evaulateAsMiniBits());
|
||||
// this.m_Population.incrFunctionCalls();
|
||||
// this.population.incrFunctionCalls();
|
||||
// //if (indy2.getFitness(0) < indy1.getFitness(0)) {
|
||||
// if (indy2.isDominating(indy1)) {
|
||||
// this.m_Population.remove(i);
|
||||
// this.m_Population.add(i, indy2);
|
||||
// this.population.remove(i);
|
||||
// this.population.add(i, indy2);
|
||||
// }
|
||||
// }
|
||||
// this.m_Population.incrGeneration();
|
||||
// this.population.incrGeneration();
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
}
|
||||
|
||||
// this.m_Population = new Population();
|
||||
// this.population = new Population();
|
||||
this.m_Population.clear();
|
||||
this.m_Population.init();
|
||||
this.m_Optimizer.init();
|
||||
@ -284,7 +284,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.m_Population.addPopulation(pop);
|
||||
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||
}
|
||||
// System.out.println("Fitnesscalls :" + this.m_Population.getFunctionCalls());
|
||||
// System.out.println("Fitnesscalls :" + this.population.getFunctionCalls());
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED, this.m_Optimizer.getPopulation());
|
||||
double plotValue = (this.m_Problem.getDoublePlotValue(this.m_Population)).doubleValue();
|
||||
if (this.m_Show) {
|
||||
@ -366,7 +366,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
//result += "=> The Optimization Problem: ";
|
||||
//result += this.problem.getStringRepresentationForProblem(this) +"\n";
|
||||
//result += this.m_Population.getStringRepresentation();
|
||||
//result += this.population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
}
|
||||
|
||||
public MemeticAlgorithm(MemeticAlgorithm a) {
|
||||
// this.m_Population = (Population)a.m_Population.clone();
|
||||
// this.population = (Population)a.population.clone();
|
||||
this.m_Problem = (InterfaceLocalSearchable) a.m_Problem.clone();
|
||||
this.m_GlobalOptimizer = (InterfaceOptimizer) a.m_GlobalOptimizer;
|
||||
this.selectorPlug = (InterfaceSelection) a.selectorPlug;
|
||||
|
@ -88,7 +88,7 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
public void optimize() {
|
||||
Population original = (Population) this.m_Population.clone();
|
||||
|
||||
// this.problem.initializePopulation(this.m_Population);
|
||||
// this.problem.initializePopulation(this.population);
|
||||
for (int i = 0; i < m_Population.size(); i++) {
|
||||
m_Population.getEAIndividual(i).defaultInit(null);
|
||||
}
|
||||
|
@ -178,10 +178,10 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
// initByPopulation(m_Population, true);
|
||||
// initByPopulation(population, true);
|
||||
this.m_Population.setTargetSize(m_lambdamo);
|
||||
this.m_Problem.initializePopulation(this.m_Population);
|
||||
// children = new Population(m_Population.size());
|
||||
// children = new Population(population.size());
|
||||
this.evaluatePopulation(this.m_Population);
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
result += this.m_Optimizer.getStringRepresentation() + "\n";
|
||||
//result += "=> The Optimization Problem: ";
|
||||
//result += this.problem.getStringRepresentationForProblem(this) +"\n";
|
||||
//result += this.m_Population.getStringRepresentation();
|
||||
//result += this.population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
// Mathematics.projectToRange(x, range);
|
||||
// ((InterfaceDataTypeDouble)ind).setDoubleGenotype(x);
|
||||
// problem.evaluate(ind);
|
||||
// this.m_Population.incrFunctionCalls();
|
||||
// this.population.incrFunctionCalls();
|
||||
}
|
||||
m_Population.set(m_Population.getIndexOfWorstIndividualNoConstr(fitIndex), ind, fitIndex);
|
||||
} else {//keine Verbesserung gefunden shrink!!
|
||||
@ -309,7 +309,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
c[i] = 0.5 * c[i] + 0.5 * u_1[i];
|
||||
}
|
||||
((InterfaceDataTypeDouble) m_Population.getEAIndividual(j)).setDoubleGenotype(c);
|
||||
// m_Population.getEAIndividual(j).resetConstraintViolation(); // not a good idea because during evaluation, a stats update may be performed which mustnt see indies which are evaluated, but possible constraints have been reset.
|
||||
// population.getEAIndividual(j).resetConstraintViolation(); // not a good idea because during evaluation, a stats update may be performed which mustnt see indies which are evaluated, but possible constraints have been reset.
|
||||
}
|
||||
m_Problem.evaluate(m_Population);
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
//System.out.println("popsize is " + m_Population.size());
|
||||
//System.out.println("pops targ is " + m_Population.getPopulationSize());
|
||||
//System.out.println("popsize is " + population.size());
|
||||
//System.out.println("pops targ is " + population.getPopulationSize());
|
||||
|
||||
if (initialVelocity <= 0.) {
|
||||
(((AbstractOptimizationProblem) m_Problem).getIndividualTemplate()).setMutationOperator(new MutateESFixedStepSize(mutationSigma));
|
||||
@ -264,7 +264,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
|
||||
m_Population = evaluatePopulation(nextGeneration);
|
||||
|
||||
// collectStatistics(m_Population);
|
||||
// collectStatistics(population);
|
||||
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
|
||||
|
@ -698,7 +698,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
|
||||
// if (index != 0) return;
|
||||
// double[] bestPosition = (double[])m_BestIndividual.getData(partBestPosKey);
|
||||
// double[] localBestPos = findNeighbourhoodOptimum(index, m_Population);
|
||||
// double[] localBestPos = findNeighbourhoodOptimum(index, population);
|
||||
// this.m_Plot.setConnectedPoint(curPosition[0], curPosition[1], index+1);
|
||||
// this.m_Plot.setConnectedPoint(curPosition[0] + curVelocity[0], curPosition[1] + curVelocity[1], index+1);
|
||||
// this.m_Plot.setConnectedPoint(curPosition[0], curPosition[1], index+2);
|
||||
@ -1355,7 +1355,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
|
||||
@Override
|
||||
public void optimize() {
|
||||
// System.out.println(">>> " + m_Population.getStringRepresentation());
|
||||
// System.out.println(">>> " + population.getStringRepresentation());
|
||||
startOptimize();
|
||||
|
||||
// Update the individuals
|
||||
@ -1370,12 +1370,12 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
// log the best individual of the population
|
||||
logBestIndividual();
|
||||
|
||||
// System.out.println("<<< " + m_Population.getStringRepresentation());
|
||||
// System.out.println("<<< " + population.getStringRepresentation());
|
||||
|
||||
// if (doLocalSearch && (m_Population.getGeneration()%localSearchGens==0)) {
|
||||
//// System.out.println("Local search at gen "+m_Population.getGeneration());
|
||||
// Population bestN = m_Population.getBestNIndividuals(Math.max(1,(int)(lsCandidateRatio*m_Population.size())));
|
||||
//// Population bestN = m_Population.getSortedNIndividuals(Math.max(1,(int)(lsCandidateRatio*m_Population.size())), false);
|
||||
// if (doLocalSearch && (population.getGeneration()%localSearchGens==0)) {
|
||||
//// System.out.println("Local search at gen "+population.getGeneration());
|
||||
// Population bestN = population.getBestNIndividuals(Math.max(1,(int)(lsCandidateRatio*population.size())));
|
||||
//// Population bestN = population.getSortedNIndividuals(Math.max(1,(int)(lsCandidateRatio*population.size())), false);
|
||||
// Population cands=(Population)bestN.clone();
|
||||
// int maxSteps=cands.size()*lsStepsPerInd;
|
||||
// int stepsDone = PostProcess.processSingleCandidates(PostProcessMethod.nelderMead, cands, maxSteps, 0.01, (AbstractOptimizationProblem)this.problem, null);
|
||||
@ -1388,8 +1388,8 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
// }
|
||||
// if (stepsDone>maxSteps) {
|
||||
//// System.err.println("Warning: more steps performed than alloed in PSO LS: " + stepsDone + " vs. " + maxSteps);
|
||||
// m_Population.incrFunctionCallsBy(stepsDone);
|
||||
// } else m_Population.incrFunctionCallsBy(maxSteps);
|
||||
// population.incrFunctionCallsBy(stepsDone);
|
||||
// } else population.incrFunctionCallsBy(maxSteps);
|
||||
// }
|
||||
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
@ -1554,10 +1554,10 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
// }
|
||||
// for (int i=0; i<leaders.size(); i++) {
|
||||
// int sSize = (Integer)(leaders.get(i)).getData(multiSwSizeKey);
|
||||
// m_Population.indexOf(leaders.get(i));
|
||||
// System.out.print("s " + i + " w " + sSize + " (" + m_Population.indexOf(leaders.get(i)) + "), ");
|
||||
// population.indexOf(leaders.get(i));
|
||||
// System.out.print("s " + i + " w " + sSize + " (" + population.indexOf(leaders.get(i)) + "), ");
|
||||
// }
|
||||
//System.out.println(" -- best " + m_Population.indexOf(m_Population.getBestEAIndividual()));
|
||||
//System.out.println(" -- best " + population.indexOf(population.getBestEAIndividual()));
|
||||
}
|
||||
if (topology == PSOTopologyEnum.hpso) { // HPSO sorting the population
|
||||
int parentIndex;
|
||||
|
@ -117,8 +117,8 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
PBILPopulation result = (PBILPopulation) this.m_Population.clone();
|
||||
Population examples;
|
||||
|
||||
// this.m_NormationOperator.computeSelectionProbability(this.m_Population, "Fitness");
|
||||
//System.out.println("Population:"+this.m_Population.getSolutionRepresentationFor());
|
||||
// this.m_NormationOperator.computeSelectionProbability(this.population, "Fitness");
|
||||
//System.out.println("Population:"+this.population.getSolutionRepresentationFor());
|
||||
this.m_SelectionOperator.prepareSelection(this.m_Population);
|
||||
examples = this.m_SelectionOperator.selectFrom(this.m_Population, this.m_NumberOfPositiveSamples);
|
||||
//System.out.println("Parents:"+parents.getSolutionRepresentationFor());
|
||||
|
@ -174,7 +174,7 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
this.m_Problem.evaluate(this.m_Population);
|
||||
this.m_Population.SetFunctionCalls(oldFunctionCalls);
|
||||
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
|
||||
// double plotValue = (this.problem.getDoublePlotValue(this.m_Population)).doubleValue();
|
||||
// double plotValue = (this.problem.getDoublePlotValue(this.population)).doubleValue();
|
||||
// now they are synchronized lets migrate
|
||||
this.migrate();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user