Additions to bugfix of StringSelection (stats not being informed of GOParameters beforehand)

This commit is contained in:
Marcel Kronfeld 2010-06-02 15:16:31 +00:00
parent 0d2fe54df1
commit 30080dcd8f
4 changed files with 23 additions and 20 deletions

View File

@ -88,10 +88,7 @@ public class OptimizerRunnable implements Runnable {
public OptimizerRunnable(GOParameters params, InterfaceStatistics stats, boolean restart) { public OptimizerRunnable(GOParameters params, InterfaceStatistics stats, boolean restart) {
rnblID = cntID; rnblID = cntID;
cntID++; cntID++;
if (stats.getStatisticsParameter() instanceof InterfaceNotifyOnInformers) {
// addition for the statistics revision with selectable strings - make sure the go parameters are represented within the statistics
params.addInformableInstance((InterfaceNotifyOnInformers)(stats.getStatisticsParameter()));
}
proc = new Processor(stats, null, params); proc = new Processor(stats, null, params);
if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false); if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
doRestart = restart; doRestart = restart;
@ -126,10 +123,6 @@ public class OptimizerRunnable implements Runnable {
InterfaceGOParameters params = proc.getGOParams(); InterfaceGOParameters params = proc.getGOParams();
proc = new Processor(stats, null, params); proc = new Processor(stats, null, params);
if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false); if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
if (stats.getStatisticsParameter() instanceof InterfaceNotifyOnInformers) {
// addition for the statistics revision with selectable strings - make sure the go parameters are represented within the statistics
params.addInformableInstance((InterfaceNotifyOnInformers)(stats.getStatisticsParameter()));
}
} }
public void setTextListener(InterfaceTextListener lsnr) { public void setTextListener(InterfaceTextListener lsnr) {

View File

@ -49,8 +49,9 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
m_Processor = new Processor(m_StatisticsModul,this, params); m_Processor = new Processor(m_StatisticsModul,this, params);
// the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change. // the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change.
if (m_StatisticsModul.getStatisticsParameter() instanceof InterfaceNotifyOnInformers) // THIS is now done directly in the constructor of a Processor
params.addInformableInstance((InterfaceNotifyOnInformers)m_StatisticsModul.getStatisticsParameter()); // if (m_StatisticsModul.getStatisticsParameter() instanceof InterfaceNotifyOnInformers)
// params.addInformableInstance((InterfaceNotifyOnInformers)m_StatisticsModul.getStatisticsParameter());
// this prevents the optimizer property to be shown by the GOE if optimizerExpert is true // this prevents the optimizer property to be shown by the GOE if optimizerExpert is true
GenericObjectEditor.setExpertProperty(params.getClass(), "optimizer", optimizerExpert); GenericObjectEditor.setExpertProperty(params.getClass(), "optimizer", optimizerExpert);

View File

@ -6,13 +6,13 @@ import javax.swing.JOptionPane;
import eva2.gui.BeanInspector; import eva2.gui.BeanInspector;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.InterfaceNotifyOnInformers;
import eva2.server.go.InterfacePopulationChangedEventListener; import eva2.server.go.InterfacePopulationChangedEventListener;
import eva2.server.go.InterfaceProcessor; import eva2.server.go.InterfaceProcessor;
import eva2.server.go.InterfaceTerminator; import eva2.server.go.InterfaceTerminator;
import eva2.server.go.PopulationInterface; import eva2.server.go.PopulationInterface;
import eva2.server.go.operators.paramcontrol.ConstantParameters; import eva2.server.go.operators.paramcontrol.ConstantParameters;
import eva2.server.go.operators.paramcontrol.InterfaceParameterControl; import eva2.server.go.operators.paramcontrol.InterfaceParameterControl;
import eva2.server.go.operators.paramcontrol.ParamAdaption;
import eva2.server.go.operators.postprocess.PostProcess; import eva2.server.go.operators.postprocess.PostProcess;
import eva2.server.go.operators.postprocess.PostProcessParams; import eva2.server.go.operators.postprocess.PostProcessParams;
import eva2.server.go.operators.terminators.EvaluationTerminator; import eva2.server.go.operators.terminators.EvaluationTerminator;
@ -26,7 +26,6 @@ import eva2.server.stat.InterfaceTextListener;
import eva2.server.stat.StatisticsWithGUI; import eva2.server.stat.StatisticsWithGUI;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
import eva2.tools.Pair;
import eva2.tools.StringTools; import eva2.tools.StringTools;
import eva2.tools.jproxy.RemoteStateListener; import eva2.tools.jproxy.RemoteStateListener;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
@ -69,18 +68,23 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
} }
/** /**
* Construct a Processor instance and make statistics instance informable of the parameters,
* such they can by dynamically show additional information.
*
* @see InterfaceNotifyOnInformers
*/ */
public Processor(InterfaceStatistics Stat, ModuleAdapter Adapter, InterfaceGOParameters params) { public Processor(InterfaceStatistics Stat, ModuleAdapter Adapter, InterfaceGOParameters params) {
goParams = params; goParams = params;
m_Statistics = Stat; m_Statistics = Stat;
m_ListenerModule = Adapter; m_ListenerModule = Adapter;
}
// the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change.
/** if (Stat!=null && (params != null)) {
* if (Stat.getStatisticsParameter() instanceof InterfaceNotifyOnInformers) {
*/ // addition for the statistics revision with selectable strings - make sure the go parameters are represented within the statistics
public Processor(InterfaceStatistics Stat) { params.addInformableInstance((InterfaceNotifyOnInformers)(Stat.getStatisticsParameter()));
m_Statistics = Stat; }
}
} }
public boolean isOptRunning() { public boolean isOptRunning() {

View File

@ -64,7 +64,9 @@ public class Serializer {
FileInputStream file = new FileInputStream(f); FileInputStream file = new FileInputStream(f);
ObjectInputStream in = new ObjectInputStream(file); ObjectInputStream in = new ObjectInputStream(file);
Object ret = in.readObject(); Object ret = in.readObject();
if (ret instanceof SerializedObject) ret = ((SerializedObject)ret).getObject(); if (ret instanceof SerializedObject) {
ret = ((SerializedObject)ret).getObject();
}
in.close(); in.close();
file.close(); file.close();
return ret; return ret;
@ -210,6 +212,9 @@ public class Serializer {
} catch (InvalidClassException e) { } catch (InvalidClassException e) {
System.err.println("WARNING: loading object File "+Filename+ " not possible, this may happen on source code changes."); System.err.println("WARNING: loading object File "+Filename+ " not possible, this may happen on source code changes.");
System.err.println(e.getMessage()); System.err.println(e.getMessage());
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException on loading object File " + Filename + ". This may happen on refactorings.");
System.err.println(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("WARNING: loading object File "+Filename+ " not possible! ("+e.getMessage()+")"); throw new RuntimeException("WARNING: loading object File "+Filename+ " not possible! ("+e.getMessage()+")");
} }