diff --git a/src/eva2/OptimizerRunnable.java b/src/eva2/OptimizerRunnable.java index 2961bfd5..bf86958c 100644 --- a/src/eva2/OptimizerRunnable.java +++ b/src/eva2/OptimizerRunnable.java @@ -88,10 +88,7 @@ public class OptimizerRunnable implements Runnable { public OptimizerRunnable(GOParameters params, InterfaceStatistics stats, boolean restart) { rnblID = 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); if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false); doRestart = restart; @@ -126,10 +123,6 @@ public class OptimizerRunnable implements Runnable { InterfaceGOParameters params = proc.getGOParams(); proc = new Processor(stats, null, params); 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) { diff --git a/src/eva2/server/modules/GenericModuleAdapter.java b/src/eva2/server/modules/GenericModuleAdapter.java index 601755cd..b98ded92 100644 --- a/src/eva2/server/modules/GenericModuleAdapter.java +++ b/src/eva2/server/modules/GenericModuleAdapter.java @@ -49,8 +49,9 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria 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. - if (m_StatisticsModul.getStatisticsParameter() instanceof InterfaceNotifyOnInformers) - params.addInformableInstance((InterfaceNotifyOnInformers)m_StatisticsModul.getStatisticsParameter()); + // THIS is now done directly in the constructor of a Processor +// 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 GenericObjectEditor.setExpertProperty(params.getClass(), "optimizer", optimizerExpert); diff --git a/src/eva2/server/modules/Processor.java b/src/eva2/server/modules/Processor.java index 96cd9f51..f76e641d 100644 --- a/src/eva2/server/modules/Processor.java +++ b/src/eva2/server/modules/Processor.java @@ -6,13 +6,13 @@ import javax.swing.JOptionPane; import eva2.gui.BeanInspector; import eva2.server.go.InterfaceGOParameters; +import eva2.server.go.InterfaceNotifyOnInformers; import eva2.server.go.InterfacePopulationChangedEventListener; import eva2.server.go.InterfaceProcessor; import eva2.server.go.InterfaceTerminator; import eva2.server.go.PopulationInterface; import eva2.server.go.operators.paramcontrol.ConstantParameters; 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.PostProcessParams; import eva2.server.go.operators.terminators.EvaluationTerminator; @@ -26,7 +26,6 @@ import eva2.server.stat.InterfaceTextListener; import eva2.server.stat.StatisticsWithGUI; import eva2.tools.EVAERROR; import eva2.tools.EVAHELP; -import eva2.tools.Pair; import eva2.tools.StringTools; import eva2.tools.jproxy.RemoteStateListener; 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) { goParams = params; m_Statistics = Stat; m_ListenerModule = Adapter; - } - - /** - * - */ - public Processor(InterfaceStatistics Stat) { - m_Statistics = Stat; + + // 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 + params.addInformableInstance((InterfaceNotifyOnInformers)(Stat.getStatisticsParameter())); + } + } } public boolean isOptRunning() { diff --git a/src/eva2/tools/Serializer.java b/src/eva2/tools/Serializer.java index 80db7ceb..281c6f39 100644 --- a/src/eva2/tools/Serializer.java +++ b/src/eva2/tools/Serializer.java @@ -64,7 +64,9 @@ public class Serializer { FileInputStream file = new FileInputStream(f); ObjectInputStream in = new ObjectInputStream(file); Object ret = in.readObject(); - if (ret instanceof SerializedObject) ret = ((SerializedObject)ret).getObject(); + if (ret instanceof SerializedObject) { + ret = ((SerializedObject)ret).getObject(); + } in.close(); file.close(); return ret; @@ -210,6 +212,9 @@ public class Serializer { } catch (InvalidClassException e) { System.err.println("WARNING: loading object File "+Filename+ " not possible, this may happen on source code changes."); 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) { throw new RuntimeException("WARNING: loading object File "+Filename+ " not possible! ("+e.getMessage()+")"); }