There is now a PostProcess button (earlier Restart). The CBN haltingWindow param is accessible.
This commit is contained in:
parent
3e4caef0a7
commit
11258ddbbf
@ -61,7 +61,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
try {
|
||||
proc.setSaveParams(false);
|
||||
if (postProcessOnly) {
|
||||
proc.performNewPostProcessing((PostProcessParams)proc.getGOParams().getPostProcessParams(), listener);
|
||||
proc.performPostProcessing((PostProcessParams)proc.getGOParams().getPostProcessParams(), listener);
|
||||
} else {
|
||||
if (doRestart) proc.restartOpt();
|
||||
else proc.startOpt();
|
||||
|
@ -36,9 +36,9 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
public static boolean TRACE = false;
|
||||
private String m_Name ="undefined";
|
||||
private ModuleAdapter m_Adapter;
|
||||
private boolean m_State;
|
||||
private boolean m_StateRunning;
|
||||
private JButton m_RunButton;
|
||||
// private JButton m_RestartButton;
|
||||
private JButton m_PPButton;
|
||||
private JButton m_actStop;
|
||||
// private JButton m_actExitMod;
|
||||
private JButton m_JHelpButton;
|
||||
@ -50,7 +50,7 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
*/
|
||||
public JModuleGeneralPanel(ModuleAdapter Adapter, boolean state) {
|
||||
m_Name = "GENERAL";
|
||||
m_State = state;
|
||||
m_StateRunning = state;
|
||||
if (TRACE) System.out.println("Constructor JModuleGeneralPanel:");
|
||||
m_Adapter = Adapter;
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
m_RunButton= new JButton("Start Optimization");
|
||||
m_RunButton= new JButton("Start");
|
||||
m_RunButton.setToolTipText("Start the current optimization run.");
|
||||
//System.out.println("Start tm_RunButton.addActionListener Run Opt pressed ====================!!!!!!!!!!!!!!!!!!");
|
||||
m_RunButton.addActionListener(new ActionListener() {
|
||||
@ -96,34 +96,11 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
}
|
||||
);
|
||||
|
||||
if (m_State == false )
|
||||
m_RunButton.setEnabled(true);
|
||||
else
|
||||
m_RunButton.setEnabled(false);
|
||||
m_RunButton.setEnabled(!m_StateRunning); // enabled if not running
|
||||
|
||||
m_Panel.add(m_RunButton);
|
||||
// m_Panel.setBorder(BorderFactory.createTitledBorder("general action buttons"));
|
||||
// //////////////////////////////////////////////////////////////
|
||||
// m_RestartButton= new JButton("Restart Optimization");
|
||||
// m_RestartButton.setToolTipText("Restart the current optimization run.");
|
||||
// m_RestartButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e){
|
||||
// try {
|
||||
// m_Adapter.restartOpt();
|
||||
// m_actStop.setEnabled(true);
|
||||
// m_RunButton.setEnabled(false);
|
||||
// m_RestartButton.setEnabled(false);
|
||||
// } catch (Exception ee) {
|
||||
// ee.printStackTrace();
|
||||
// System.out.println("Error in run: " +ee +" : " + ee.getMessage() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// if (m_State == false )
|
||||
// m_RestartButton.setEnabled(false);
|
||||
// else
|
||||
// m_RestartButton.setEnabled(false);
|
||||
// m_Panel.add(m_RestartButton);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
m_actStop= new JButton("Stop");
|
||||
m_actStop.setToolTipText("Stop the current optimization run.");
|
||||
@ -139,7 +116,28 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
// m_RestartButton.setEnabled(false);
|
||||
// else
|
||||
// m_RestartButton.setEnabled(true);
|
||||
m_actStop.setEnabled(m_StateRunning);
|
||||
m_Panel.add(m_actStop);
|
||||
// //////////////////////////////////////////////////////////////
|
||||
m_PPButton= new JButton("Post Process");
|
||||
m_PPButton.setToolTipText("Start post processing according to available parameters.");
|
||||
m_PPButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
try {
|
||||
m_Adapter.startPostProcessing();
|
||||
// m_actStop.setEnabled(true);
|
||||
// m_RunButton.setEnabled(false);
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
System.out.println("Error in run: " +ee +" : " + ee.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
m_PPButton.setEnabled(m_StateRunning && m_Adapter.hasPostProcessing());
|
||||
m_Panel.add(m_PPButton);
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
if (m_HelperFileName.equals("")== false) {
|
||||
m_JHelpButton= new JButton("Description");
|
||||
m_JHelpButton.setToolTipText("Description of the current optimization algorithm.");
|
||||
@ -172,7 +170,7 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
||||
public void performedStop() {
|
||||
if (TRACE) System.out.println("JModuleGeneralPanel.stopOptPerformed");
|
||||
m_RunButton.setEnabled(true);
|
||||
// m_RestartButton.setEnabled(true);
|
||||
m_PPButton.setEnabled(true);
|
||||
m_RunButton.repaint();
|
||||
m_actStop.setEnabled(false);
|
||||
m_Panel.repaint();
|
||||
|
@ -354,6 +354,7 @@ public class PostProcess {
|
||||
hcRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(hc, pop, problem, 0, term), null, true);
|
||||
hcRunnable.getGOParams().setDoPostProcessing(false);
|
||||
hcRunnable.run();
|
||||
hcRunnable.getGOParams().setDoPostProcessing(true);
|
||||
hcRunnable = null;
|
||||
}
|
||||
|
||||
|
@ -203,10 +203,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
||||
*/
|
||||
public void setDefaultRange(double defaultRange) {
|
||||
this.m_DefaultRange = defaultRange;
|
||||
if (((InterfaceDataTypeDouble)this.m_Template).getDoubleData().length != getProblemDimension()) {
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(getProblemDimension());
|
||||
}
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(makeRange());
|
||||
initTemplate();
|
||||
}
|
||||
public String defaultRangeTipText() {
|
||||
return "Absolute limit for the symmetric range in any dimension";
|
||||
|
@ -13,9 +13,10 @@ import javaeva.server.go.populations.Population;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class F12Problem extends F1Problem implements java.io.Serializable {
|
||||
private final static double f12range = 5.;
|
||||
|
||||
public F12Problem() {
|
||||
this.m_Template = new ESIndividualDoubleData();
|
||||
setDefaultRange(f12range);
|
||||
}
|
||||
public F12Problem(F12Problem b) {
|
||||
super(b);
|
||||
@ -28,34 +29,6 @@ public class F12Problem extends F1Problem implements java.io.Serializable {
|
||||
return (Object) new F12Problem(this);
|
||||
}
|
||||
|
||||
/** This method inits a given population
|
||||
* @param population The populations that is to be inited
|
||||
*/
|
||||
public void initPopulation(Population population) {
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
// this.m_OverallBest = null;
|
||||
|
||||
population.clear();
|
||||
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension);
|
||||
double[][] range = new double[this.m_ProblemDimension][2];
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
range[i][0] = -5.0;
|
||||
range[i][1] = 5.0;
|
||||
}
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(range);
|
||||
|
||||
for (int i = 0; i < population.getPopulationSize(); i++) {
|
||||
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
|
||||
tmpIndy.init(this);
|
||||
population.add(tmpIndy);
|
||||
}
|
||||
// population init must be last
|
||||
// it set's fitcalls and generation to zero
|
||||
population.init();
|
||||
}
|
||||
|
||||
/** Ths method allows you to evaluate a double[] to determine the fitness
|
||||
* @param x The n-dimensional input vector
|
||||
* @return The m-dimensional output vector.
|
||||
|
@ -1,8 +1,6 @@
|
||||
package javaeva.server.go.problems;
|
||||
|
||||
import javaeva.server.go.individuals.AbstractEAIndividual;
|
||||
import javaeva.server.go.individuals.ESIndividualDoubleData;
|
||||
import javaeva.server.go.strategies.InterfaceOptimizer;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
|
@ -14,40 +14,13 @@ import javaeva.server.go.tools.RandomNumberGenerator;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class F4Problem extends F1Problem implements java.io.Serializable {
|
||||
|
||||
final static double f4range = 1.28;
|
||||
|
||||
public F4Problem() {
|
||||
this.m_Template = new ESIndividualDoubleData();
|
||||
setDefaultRange(f4range);
|
||||
}
|
||||
public F4Problem(F4Problem b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
/** This method inits a given population
|
||||
* @param population The populations that is to be inited
|
||||
*/
|
||||
public void initPopulation(Population population) {
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
// this.m_OverallBest = null;
|
||||
|
||||
population.clear();
|
||||
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension);
|
||||
double[][] range = new double[this.m_ProblemDimension][2];
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
range[i][0] = -1.28;
|
||||
range[i][1] = 1.28;
|
||||
}
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(range);
|
||||
|
||||
for (int i = 0; i < population.getPopulationSize(); i++) {
|
||||
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
|
||||
tmpIndy.init(this);
|
||||
population.add(tmpIndy);
|
||||
}
|
||||
// population init must be last
|
||||
// it set's fitcalls and generation to zero
|
||||
population.init();
|
||||
super(b);
|
||||
}
|
||||
|
||||
/** This method returns a deep clone of the problem.
|
||||
|
@ -14,40 +14,13 @@ import javaeva.server.go.tools.RandomNumberGenerator;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class F5Problem extends F1Problem implements java.io.Serializable {
|
||||
|
||||
final static double f5range = 65.536;
|
||||
|
||||
public F5Problem() {
|
||||
this.m_Template = new ESIndividualDoubleData();
|
||||
setDefaultRange(f5range);
|
||||
}
|
||||
public F5Problem(F5Problem b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
/** This method inits a given population
|
||||
* @param population The populations that is to be inited
|
||||
*/
|
||||
public void initPopulation(Population population) {
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
// this.m_OverallBest = null;
|
||||
|
||||
population.clear();
|
||||
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension);
|
||||
double[][] range = new double[this.m_ProblemDimension][2];
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
range[i][0] = -65.536;
|
||||
range[i][1] = 65.536;
|
||||
}
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(range);
|
||||
|
||||
for (int i = 0; i < population.getPopulationSize(); i++) {
|
||||
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
|
||||
tmpIndy.init(this);
|
||||
population.add(tmpIndy);
|
||||
}
|
||||
// population init must be last
|
||||
// it set's fitcalls and generation to zero
|
||||
population.init();
|
||||
super(b);
|
||||
}
|
||||
|
||||
/** This method returns a deep clone of the problem.
|
||||
|
@ -17,9 +17,10 @@ public class F8Problem extends F1Problem implements InterfaceMultimodalProblem,
|
||||
private double a = 20;
|
||||
private double b = 0.2;
|
||||
private double c = 2*Math.PI;
|
||||
final static double f8Range = 32768;
|
||||
|
||||
public F8Problem() {
|
||||
this.m_Template = new ESIndividualDoubleData();
|
||||
setDefaultRange(f8Range);
|
||||
}
|
||||
public F8Problem(F8Problem b) {
|
||||
super(b);
|
||||
@ -35,34 +36,6 @@ public class F8Problem extends F1Problem implements InterfaceMultimodalProblem,
|
||||
return (Object) new F8Problem(this);
|
||||
}
|
||||
|
||||
/** This method inits a given population
|
||||
* @param population The populations that is to be inited
|
||||
*/
|
||||
public void initPopulation(Population population) {
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
// this.m_OverallBest = null;
|
||||
|
||||
population.clear();
|
||||
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension);
|
||||
double[][] range = new double[this.m_ProblemDimension][2];
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
range[i][0] = -32.768;
|
||||
range[i][1] = 32.768;
|
||||
}
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(range);
|
||||
|
||||
for (int i = 0; i < population.getPopulationSize(); i++) {
|
||||
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
|
||||
tmpIndy.init(this);
|
||||
population.add(tmpIndy);
|
||||
}
|
||||
// population init must be last
|
||||
// it set's fitcalls and generation to zero
|
||||
population.init();
|
||||
}
|
||||
|
||||
/** Ths method allows you to evaluate a double[] to determine the fitness
|
||||
* @param x The n-dimensional input vector
|
||||
* @return The m-dimensional output vector.
|
||||
|
@ -61,7 +61,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
private boolean m_UseArchive = true;
|
||||
private boolean m_UseSpeciesDifferentation = true;
|
||||
private boolean m_UseSpeciesConvergence = true;
|
||||
private boolean m_UseHaltingWindow = true;
|
||||
// private boolean m_UseHaltingWindow = true;
|
||||
private int m_PopulationSize = 50;
|
||||
private int convergedCnt = 0;
|
||||
|
||||
@ -91,8 +91,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_UseClearing = a.m_UseClearing;
|
||||
this.m_UseSpeciesDifferentation = a.m_UseSpeciesDifferentation;
|
||||
this.m_UseSpeciesConvergence = a.m_UseSpeciesConvergence;
|
||||
this.m_UseHaltingWindow = a.m_UseHaltingWindow;
|
||||
// this.m_UseHaltingWindow = a.m_UseHaltingWindow;
|
||||
this.m_PopulationSize = a.m_PopulationSize;
|
||||
this.haltingWindow = a.haltingWindow;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
@ -270,7 +271,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks whether a species is converged.
|
||||
* This method checks whether a species is converged, i.e. the best fitness has not improved
|
||||
* for a number of generations.
|
||||
*
|
||||
* @param pop The species to test
|
||||
* @return True if converged.
|
||||
*/
|
||||
@ -374,7 +377,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
curSpecies.SetFunctionCalls(0);
|
||||
curSpecies.setPopulationSize(curSpecies.size());
|
||||
if (isActive(curSpecies)) {
|
||||
if ((this.m_UseHaltingWindow) && (this.testSpeciesForConvergence(curSpecies))) {
|
||||
if ((haltingWindow > 0) && (this.testSpeciesForConvergence(curSpecies))) {
|
||||
///////////////////////////////////////////// Halting Window /////////////////////////////////////////////////
|
||||
// if (this.m_Debug) {
|
||||
// System.out.println("Undiff.Size: " + this.m_Undifferentiated.size() +"/"+this.m_Undifferentiated.getPopulationSize());
|
||||
@ -726,15 +729,15 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// return "Clearing removes all but the best individuals from an identified species.";
|
||||
// }
|
||||
|
||||
/** This method allows you to toggle the use of the halting window.
|
||||
* @return The current status of this flag
|
||||
*/
|
||||
public boolean getUseHaltingWindow() {
|
||||
return this.m_UseHaltingWindow;
|
||||
}
|
||||
public void setUseHaltingWindow(boolean b){
|
||||
this.m_UseHaltingWindow = b;
|
||||
}
|
||||
// /** This method allows you to toggle the use of the halting window.
|
||||
// * @return The current status of this flag
|
||||
// */
|
||||
// public boolean getUseHaltingWindow() {
|
||||
// return this.m_UseHaltingWindow;
|
||||
// }
|
||||
// public void setUseHaltingWindow(boolean b){
|
||||
// this.m_UseHaltingWindow = b;
|
||||
// }
|
||||
public String useHaltingWindowTipText() {
|
||||
return "With a halting window converged species are frozen.";
|
||||
}
|
||||
@ -803,7 +806,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return m_UseArchive;
|
||||
}
|
||||
public String useArchiveTipText() {
|
||||
return "Toggle usage of an archive where converged species are savend and the individuals reinitialized.";
|
||||
return "Toggle usage of an archive where converged species are saved and the individuals reinitialized.";
|
||||
}
|
||||
|
||||
/** Determines how often species differentation/convergence is performed.
|
||||
@ -858,8 +861,22 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public void setMuLambdaRatio(double muLambdaRatio) {
|
||||
this.muLambdaRatio = muLambdaRatio;
|
||||
}
|
||||
|
||||
// public String muLambdaRatioTipText() {
|
||||
// return "ratio between mu and lambda for a CBN-ES";
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return the haltingWindow
|
||||
*/
|
||||
public int getHaltingWindow() {
|
||||
return haltingWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param haltingWindow the haltingWindow to set
|
||||
*/
|
||||
public void setHaltingWindow(int haltingWindow) {
|
||||
this.haltingWindow = haltingWindow;
|
||||
}
|
||||
|
||||
public String haltingWindowTipText() {
|
||||
return "Lenght of the halting window defining when a cluster is seen as converged and frozen; set to zero to disable.";
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import java.util.Vector;
|
||||
import javaeva.gui.JTabbedModuleFrame;
|
||||
import javaeva.gui.LogPanel;
|
||||
import javaeva.server.go.InterfaceProcessor;
|
||||
import javaeva.server.go.operators.postprocess.PostProcessParams;
|
||||
import javaeva.server.stat.InterfaceTextListener;
|
||||
|
||||
import wsi.ra.jproxy.MainAdapterClient;
|
||||
import wsi.ra.jproxy.RemoteStateListener;
|
||||
@ -108,6 +110,15 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
if (TRACE) System.out.println("Module AbstractModuleAdapter on EvA-Server StopOpt called:" );
|
||||
m_Processor.stopOpt(); // This means user break
|
||||
}
|
||||
|
||||
public boolean hasPostProcessing() {
|
||||
return (m_Processor instanceof Processor);
|
||||
}
|
||||
|
||||
public void startPostProcessing() {
|
||||
if (hasPostProcessing()) ((Processor)m_Processor).performPostProcessing();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -14,6 +14,8 @@ package javaeva.server.modules;
|
||||
*==========================================================================*/
|
||||
import javaeva.gui.JTabbedModuleFrame;
|
||||
import javaeva.gui.LogPanel;
|
||||
import javaeva.server.go.operators.postprocess.PostProcessParams;
|
||||
import javaeva.server.stat.InterfaceTextListener;
|
||||
import wsi.ra.jproxy.RemoteStateListener;
|
||||
/*==========================================================================*
|
||||
* INTERFACE DECLARATION
|
||||
@ -27,6 +29,8 @@ public interface ModuleAdapter extends RemoteStateListener {
|
||||
public void restartOpt();
|
||||
public void stopOpt();
|
||||
public void runScript();
|
||||
public boolean hasPostProcessing();
|
||||
public void startPostProcessing();
|
||||
public void addRemoteStateListener(RemoteStateListener x);
|
||||
public String getAdapterName();
|
||||
public void setConnection(boolean flag);
|
||||
|
@ -15,6 +15,13 @@ import javaeva.server.stat.InterfaceStatistics;
|
||||
import javaeva.server.stat.InterfaceTextListener;
|
||||
import wsi.ra.jproxy.RemoteStateListener;
|
||||
|
||||
/**
|
||||
* The Processor may run as a thread permanently (GenericModuleAdapter) and is then stopped and started
|
||||
* by a switch in startOpt/stopOpt.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
public class Processor extends Thread implements InterfaceProcessor, InterfacePopulationChangedEventListener {
|
||||
|
||||
private static final boolean TRACE=false;
|
||||
@ -95,7 +102,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
System.err.println("ERROR: Processor is already running !!");
|
||||
return;
|
||||
}
|
||||
wasRestarted = false;
|
||||
wasRestarted = true;
|
||||
setOptRunning(true);
|
||||
}
|
||||
|
||||
@ -146,8 +153,8 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
* Main optimization loop.
|
||||
* Return a population containing the solutions of the last run if there were multiple.
|
||||
*/
|
||||
public Population optimize(String infoString) {
|
||||
Population resPop = null;
|
||||
protected Population optimize(String infoString) {
|
||||
Population resultPop = null;
|
||||
|
||||
if (!isOptRunning()) {
|
||||
System.err.println("warning, this shouldnt happen in processor! Was startOpt called?");
|
||||
@ -209,24 +216,18 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
runCounter++;
|
||||
|
||||
//////////////// Default stats
|
||||
m_Statistics.stopOptPerformed(isOptRunning()); // stop is "normal" if opt wasnt set false by the user
|
||||
//////////////// PP
|
||||
performNewPostProcessing((PostProcessParams)goParams.getPostProcessParams(), (InterfaceTextListener)m_Statistics);
|
||||
m_Statistics.stopOptPerformed(isOptRunning()); // stop is "normal" if opt wasnt set false by the user (and thus still true)
|
||||
|
||||
//////////////// PP or set results without further PP
|
||||
if (isOptRunning()) {
|
||||
resultPop = performPostProcessing();
|
||||
} else resultPop = goParams.getOptimizer().getAllSolutions();
|
||||
|
||||
// moved to PostProcess
|
||||
// if ((goParams.getProblem() instanceof InterfaceMultimodalProblem)) {
|
||||
// InterfaceMultimodalProblem mmProb = (InterfaceMultimodalProblem)goParams.getProblem();
|
||||
// PostProcessInterim.outputResult((AbstractOptimizationProblem)mmProb, goParams.getOptimizer().getAllSolutions(), 0.01, System.out, 0, 2000, 20, goParams.getPostProcessSteps());
|
||||
//// PostProcessInterim.postProcess(mmProb, goParams.getOptimizer().getPopulation(), 0.01, System.out, 0, 2000, 20);
|
||||
// if ((goParams.getProblem() instanceof InterfaceMultimodalProblemKnown)) {
|
||||
// PostProcessInterim.outputResultKnown((InterfaceMultimodalProblemKnown)goParams.getProblem(), goParams.getOptimizer().getAllSolutions(), 0.01, System.out, 0., 2000., 20);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
setOptRunning(false); // normal finish
|
||||
if (m_ListenerModule!=null) m_ListenerModule.performedStop(); // is only needed in client server mode
|
||||
if (m_ListenerModule!=null) m_ListenerModule.updateProgress(0, null);
|
||||
return resPop;
|
||||
return resultPop;
|
||||
}
|
||||
|
||||
private int getStatusPercent(Population pop, int currentRun, int multiRuns) {
|
||||
@ -325,6 +326,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
return resPop;
|
||||
}
|
||||
|
||||
public Population performPostProcessing() {
|
||||
return performPostProcessing((PostProcessParams)goParams.getPostProcessParams(), (InterfaceTextListener)m_Statistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a post processing step with given parameters, based on all solutions found by the optimizer.
|
||||
* Use getResultPopulation() to retrieve results.
|
||||
@ -332,17 +337,17 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
* @param ppp
|
||||
* @param listener
|
||||
*/
|
||||
public void performNewPostProcessing(PostProcessParams ppp, InterfaceTextListener listener) {
|
||||
public Population performPostProcessing(PostProcessParams ppp, InterfaceTextListener listener) {
|
||||
if (ppp.isDoPostProcessing()) {
|
||||
ppp.hideHideable(); // a bit mean: as we may have several instances of ppp in different states, make sure Bean-"hidden" state is consistent for output.
|
||||
if (listener != null) listener.println("Post processing params: " + BeanInspector.toString(ppp));
|
||||
resPop = goParams.getOptimizer().getAllSolutions();
|
||||
if (resPop.getFunctionCalls() != goParams.getOptimizer().getPopulation().getFunctionCalls()) {
|
||||
Population resultPop = goParams.getOptimizer().getAllSolutions();
|
||||
if (resultPop.getFunctionCalls() != goParams.getOptimizer().getPopulation().getFunctionCalls()) {
|
||||
// System.err.println("bad case in Processor::performNewPostProcessing ");
|
||||
resPop.SetFunctionCalls(goParams.getOptimizer().getPopulation().getFunctionCalls());
|
||||
resultPop.SetFunctionCalls(goParams.getOptimizer().getPopulation().getFunctionCalls());
|
||||
}
|
||||
if (!resPop.contains(m_Statistics.getBestSolution())) resPop.add(m_Statistics.getBestSolution()); // this is a minor cheat but guarantees that the best solution ever found is contained in the final results
|
||||
resPop = PostProcess.postProcess(ppp, resPop, (AbstractOptimizationProblem)goParams.getProblem(), listener);
|
||||
}
|
||||
if (!resultPop.contains(m_Statistics.getBestSolution())) resultPop.add(m_Statistics.getBestSolution()); // this is a minor cheat but guarantees that the best solution ever found is contained in the final results
|
||||
resultPop = PostProcess.postProcess(ppp, resultPop, (AbstractOptimizationProblem)goParams.getProblem(), listener);
|
||||
return resultPop;
|
||||
} else return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user