Slight change of the InterfaceDataListener (AbstractStatistics) - header and meta info fields should not depend on a population.

This commit is contained in:
Marcel Kronfeld 2010-09-02 12:32:19 +00:00
parent 8aeb94411e
commit 09ef318b93
32 changed files with 302 additions and 165 deletions

View File

@ -63,11 +63,11 @@ import eva2.gui.LogPanel;
import eva2.server.EvAServer; import eva2.server.EvAServer;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.AbstractModuleAdapter; import eva2.server.modules.AbstractModuleAdapter;
import eva2.server.modules.GOParameters;
import eva2.server.modules.GenericModuleAdapter; import eva2.server.modules.GenericModuleAdapter;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.server.stat.AbstractStatistics; import eva2.server.stat.AbstractStatistics;
import eva2.server.stat.InterfaceStatisticsParameter; import eva2.server.stat.InterfaceStatisticsParameter;
import eva2.server.stat.StatsParameter;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
@ -86,6 +86,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
public static boolean TRACE = false; public static boolean TRACE = false;
public JEFrame m_Frame; public JEFrame m_Frame;
Runnable initRnbl = null;
private EvAComAdapter m_ComAdapter; private EvAComAdapter m_ComAdapter;
private transient JMenuBar m_barMenu; private transient JMenuBar m_barMenu;
@ -148,6 +149,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* Constructor of GUI of EvA2. * Constructor of GUI of EvA2.
* Works as client for the EvA2 server. * Works as client for the EvA2 server.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
* *
*/ */
public EvAClient(final String hostName) { public EvAClient(final String hostName) {
@ -156,6 +159,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* A constructor. Splash screen is optional, Gui is activated, no parent window. * A constructor. Splash screen is optional, Gui is activated, no parent window.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
* *
* @see #EvAClient(String, Window, String, boolean, boolean, boolean) * @see #EvAClient(String, Window, String, boolean, boolean, boolean)
* @param hostName * @param hostName
@ -164,11 +169,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param nosplash * @param nosplash
*/ */
public EvAClient(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) { public EvAClient(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
this(hostName, null, paramsFile, autorun, nosplash, false); this(hostName, null, paramsFile, null, autorun, nosplash, false);
} }
/** /**
* A constructor with optional spash screen. * A constructor with optional spash screen.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
* @see #EvAClient(String, String, boolean, boolean) * @see #EvAClient(String, String, boolean, boolean)
* *
* @param hostName * @param hostName
@ -180,7 +187,26 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* A constructor with optional spash screen. * A constructor with optional splash screen.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
*
* @see #EvAClient(String, String, boolean, boolean)
* @param hostName
* @param paramsFile
* @param autorun
* @param noSplash
* @param noGui
*/
public EvAClient(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui) {
this(hostName, null, paramsFile, null, autorun, noSplash, noGui);
}
/**
* A constructor with optional splash screen.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
*
* @see #EvAClient(String, String, boolean, boolean) * @see #EvAClient(String, String, boolean, boolean)
* *
* @param hostName * @param hostName
@ -189,11 +215,17 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param noSplash * @param noSplash
* @param noGui * @param noGui
*/ */
public EvAClient(final String hostName, String paramsFile, boolean autorun, boolean noSplash, boolean noGui) { public EvAClient(final String hostName, InterfaceGOParameters goParams, boolean autorun, boolean noSplash, boolean noGui) {
this(hostName, null, paramsFile, autorun, noSplash, noGui); this(hostName, null, null, goParams, autorun, noSplash, noGui);
} }
/** /**
* Constructor of GUI of EvA2. Works as client for the EvA2 server. * Constructor of GUI of EvA2. Works as client for the EvA2 server. GO parameters may be
* loaded from a file (paramsFile) or given directly as a java instance. Both may be null
* to start with standard parameters. If both are non null, the java instance has the
* higher priority.
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary.
* *
* @param hostName * @param hostName
* @param parent * @param parent
@ -202,8 +234,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param noSplash * @param noSplash
* @param noGui * @param noGui
*/ */
public EvAClient(final String hostName, final Window parent, final String paramsFile, final InterfaceGOParameters goParams, final boolean autorun, final boolean noSplash, final boolean noGui) {
public EvAClient(final String hostName, final Window parent, final String paramsFile, final boolean autorun, final boolean noSplash, final boolean noGui) {
final SplashScreenShell fSplashScreen = new SplashScreenShell(EvAInfo.splashLocation); final SplashScreenShell fSplashScreen = new SplashScreenShell(EvAInfo.splashLocation);
// preload some classes (into system cache) in a parallel thread // preload some classes (into system cache) in a parallel thread
@ -224,10 +255,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_ComAdapter = EvAComAdapter.getInstance(); m_ComAdapter = EvAComAdapter.getInstance();
SwingUtilities.invokeLater( new Runnable() { SwingUtilities.invokeLater( initRnbl = new Runnable() {
public void run(){ public void run(){
synchronized (this) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
init(hostName, paramsFile, parent); // this takes a bit init(hostName, paramsFile, goParams, parent); // this takes a bit
long wait = System.currentTimeMillis() - startTime; long wait = System.currentTimeMillis() - startTime;
if (!autorun) { if (!autorun) {
if (!noSplash) try { if (!noSplash) try {
@ -245,10 +278,30 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
// close splash screen // close splash screen
if (!noSplash && withGUI) fSplashScreen.dispose(); if (!noSplash && withGUI) fSplashScreen.dispose();
notify();
}
} }
}); });
} }
/**
* Since the constructor runs multi-threaded for efficiency, this method
* may be called to await the full initialization of a client instance.
* As soon as it returns, the EvAClient GUI is fully initialized.
*/
public void awaitGuiInitialized() {
if (initRnbl!=null) {
synchronized (initRnbl) {
try {
initRnbl.wait();
initRnbl=null;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
private void preloadClasses() { private void preloadClasses() {
ClassPreloader cp = new ClassPreloader( "eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator"); ClassPreloader cp = new ClassPreloader( "eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator");
new Thread(cp).start(); new Thread(cp).start();
@ -270,7 +323,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* Sets given hostname and tries to load GOParamsters from given file if non null. * Sets given hostname and tries to load GOParamsters from given file if non null.
*/ */
private void init(String hostName, String paramsFile, final Window parent) { private void init(String hostName, String paramsFile, InterfaceGOParameters goParams, final Window parent) {
//EVA_EDITOR_PROPERTIES //EVA_EDITOR_PROPERTIES
useDefaultModule = EvAInfo.propDefaultModule(); useDefaultModule = EvAInfo.propDefaultModule();
@ -304,7 +357,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
createActions(); createActions();
} }
if (useDefaultModule != null) { if (useDefaultModule != null) {
loadModuleFromServer(useDefaultModule, paramsFile);//loadSpecificModule // if goParams are not defined and a params file is defined
// try to load parameters from file
if (goParams==null && (paramsFile!=null && (paramsFile.length()>0))) goParams = GOParameters.getInstance(paramsFile, false);
loadModuleFromServer(useDefaultModule, goParams);//loadSpecificModule
} }
if (withGUI) { if (withGUI) {
@ -649,7 +705,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* *
*/ */
private void loadModuleFromServer(String selectedModule, String paramsFile) { private void loadModuleFromServer(String selectedModule, InterfaceGOParameters goParams) {
if (m_ComAdapter.getHostName() == null) { if (m_ComAdapter.getHostName() == null) {
System.err.println("error in loadModuleFromServer!"); System.err.println("error in loadModuleFromServer!");
return; return;
@ -691,7 +747,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} else { } else {
Serializer.storeString("lastmodule.ser", selectedModule); Serializer.storeString("lastmodule.ser", selectedModule);
loadSpecificModule(selectedModule, paramsFile); loadSpecificModule(selectedModule, goParams);
if (withGUI) { if (withGUI) {
m_actHost.setEnabled(true); m_actHost.setEnabled(true);
@ -735,11 +791,11 @@ public class EvAClient implements RemoteStateListener, Serializable {
} else return false; } else return false;
} }
private void loadSpecificModule(String selectedModule, String paramsFile) { private void loadSpecificModule(String selectedModule, InterfaceGOParameters goParams) {
ModuleAdapter newModuleAdapter = null; ModuleAdapter newModuleAdapter = null;
// //
try { try {
newModuleAdapter = m_ComAdapter.getModuleAdapter(selectedModule, paramsFile, withGUI ? null : "EvA2"); newModuleAdapter = m_ComAdapter.getModuleAdapter(selectedModule, goParams, withGUI ? null : "EvA2");
} catch (Exception e) { } catch (Exception e) {
logMessage("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage()); logMessage("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
@ -755,7 +811,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + baseDir.getPath()); System.setProperty("java.class.path", cp + System.getProperty("path.separator") + baseDir.getPath());
ReflectPackage.resetDynCP(); ReflectPackage.resetDynCP();
m_ComAdapter.updateLocalMainAdapter(); m_ComAdapter.updateLocalMainAdapter();
loadSpecificModule(selectedModule, paramsFile); // end recursive call! handle with care! loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!
return; return;
} }
showLoadModules = true; showLoadModules = true;

View File

@ -20,6 +20,7 @@ import eva2.EvAInfo;
import eva2.gui.LogPanel; import eva2.gui.LogPanel;
import eva2.server.EvAMainAdapter; import eva2.server.EvAMainAdapter;
import eva2.server.EvAMainAdapterImpl; import eva2.server.EvAMainAdapterImpl;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.ComAdapter; import eva2.tools.jproxy.ComAdapter;
import eva2.tools.jproxy.MainAdapter; import eva2.tools.jproxy.MainAdapter;
@ -59,11 +60,11 @@ public class EvAComAdapter extends ComAdapter {
* Creates the ModulAdapters RMI Object on the server * Creates the ModulAdapters RMI Object on the server
* @return * @return
*/ */
public ModuleAdapter getModuleAdapter(String selectedModuleName, String paramsFile, String noGuiStatsFile) { public ModuleAdapter getModuleAdapter(String selectedModuleName, InterfaceGOParameters goParams, String noGuiStatsFile) {
ModuleAdapter newModuleAdapter; ModuleAdapter newModuleAdapter;
if ((m_RMIServer == null) && isRunLocally()) { if ((m_RMIServer == null) && isRunLocally()) {
//ret = evaAdapter.getModuleAdapter(Modul, hostAdd, this.m_MainAdapterClient); //ret = evaAdapter.getModuleAdapter(Modul, hostAdd, this.m_MainAdapterClient);
newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, true, getHostName(), paramsFile, noGuiStatsFile, null); newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, true, getHostName(), goParams, noGuiStatsFile, null);
} else { } else {
newModuleAdapter = ((RMIConnectionEvA)getConnection(getHostName())).getModuleAdapter(selectedModuleName); newModuleAdapter = ((RMIConnectionEvA)getConnection(getHostName())).getModuleAdapter(selectedModuleName);
if (newModuleAdapter == null) System.err.println("RMI Error for getting ModuleAdapterObject : " + selectedModuleName); if (newModuleAdapter == null) System.err.println("RMI Error for getting ModuleAdapterObject : " + selectedModuleName);

View File

@ -199,16 +199,42 @@ public class GenericObjectEditor implements PropertyEditor {
* *
* @param cls * @param cls
* @param hide * @param hide
* @return the original hidden states or null if an error occurred.
*/ */
public static void setHideAllProperties(Class<?> cls, boolean hide) { public static boolean[] setHideAllProperties(Class<?> cls, boolean hide) {
try { try {
BeanInfo bi = Introspector.getBeanInfo(cls); BeanInfo bi = Introspector.getBeanInfo(cls);
PropertyDescriptor[] props = bi.getPropertyDescriptors(); PropertyDescriptor[] props = bi.getPropertyDescriptors();
boolean[] orig = new boolean[props.length];
for (int i=0; i<props.length; i++) { for (int i=0; i<props.length; i++) {
orig[i]=props[i].isHidden();
props[i].setHidden(hide); props[i].setHidden(hide);
} }
return orig;
} catch (Exception e) { } catch (Exception e) {
System.err.println("exception in setHideProperty for " + cls.getName() + "/all : " + e.getMessage()); System.err.println("exception in setHideProperty for " + cls.getName() + "/all : " + e.getMessage());
return null;
}
}
public static void setHideProperties(Class<?> cls, boolean[] hideStates) {
if (hideStates!=null) {
BeanInfo bi;
try {
bi = Introspector.getBeanInfo(cls);
} catch (IntrospectionException e) {
System.err.println("Error on introspection of " + cls.getName() + ", " + e.getMessage());
e.printStackTrace();
return;
}
PropertyDescriptor[] props = bi.getPropertyDescriptors();
if (hideStates.length == props.length) {
for (int i=0; i<props.length; i++) {
props[i].setHidden(hideStates[i]);
}
} else {
System.err.println("Error, mismatching length of hide state array in GenericObjectEditor.setHideProperites");
}
} }
} }

View File

@ -204,7 +204,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
// Look for a globalInfo method that returns a string // Look for a globalInfo method that returns a string
// describing the target // describing the target
int methsFound = 0; // dont loop too long, so count until all found int methsFound = 0; // dont loop too long, so count until all found
GenericObjectEditor.setHideAllProperties(m_Target.getClass(), false); // unhide all properties
// TODO this may be superfluous?
boolean[] hideStateBackup = GenericObjectEditor.setHideAllProperties(m_Target.getClass(), false);
// System.out.println("hide stats were: " + BeanInspector.toString(hideStateBackup));
for (int i = 0; i < m_Methods.length; i++) { for (int i = 0; i < m_Methods.length; i++) {
String name = m_Methods[i].getDisplayName(); String name = m_Methods[i].getDisplayName();
Method meth = m_Methods[i].getMethod(); Method meth = m_Methods[i].getMethod();
@ -228,6 +231,8 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
} }
if (methsFound == 3) break; // small speed-up if (methsFound == 3) break; // small speed-up
} // end for (int i = 0; i < m_Methods.length; i++) { } // end for (int i = 0; i < m_Methods.length; i++) {
// restore hide states of all properties
GenericObjectEditor.setHideProperties(m_Target.getClass(), hideStateBackup);
// Now lets search for the individual properties, their // Now lets search for the individual properties, their
// values, views and editors... // values, views and editors...

View File

@ -12,6 +12,7 @@ package eva2.server;
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.MainAdapter; import eva2.tools.jproxy.MainAdapter;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
@ -33,7 +34,7 @@ public interface EvAMainAdapter extends MainAdapter {
public ModuleAdapter getModuleAdapter(String selectedModuleName, public ModuleAdapter getModuleAdapter(String selectedModuleName,
boolean withoutRMI, boolean withoutRMI,
String hostAddress, String hostAddress,
String paramsFile, InterfaceGOParameters goParams,
String noGuiStatsFile, String noGuiStatsFile,
MainAdapterClient client); MainAdapterClient client);
} }

View File

@ -13,6 +13,7 @@ package eva2.server;
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.MainAdapterImpl; import eva2.tools.jproxy.MainAdapterImpl;
@ -38,10 +39,10 @@ public class EvAMainAdapterImpl extends MainAdapterImpl implements EvAMainAdapte
return getModuleAdapter(selectedModuleName, withoutRMI, hostAddress, null, null, client); return getModuleAdapter(selectedModuleName, withoutRMI, hostAddress, null, null, client);
} }
public ModuleAdapter getModuleAdapter(String selectedModuleName, boolean withoutRMI, String hostAddress, String paramsFile, String noGuiStatsFile, MainAdapterClient client) { public ModuleAdapter getModuleAdapter(String selectedModuleName, boolean withoutRMI, String hostAddress, InterfaceGOParameters goParams,String noGuiStatsFile, MainAdapterClient client) {
if (TRACE) System.out.println("MainAdapterImpl.GetModuleAdapter() for module " + if (TRACE) System.out.println("MainAdapterImpl.GetModuleAdapter() for module " +
selectedModuleName +" for Client: "+hostAddress+ " called"); selectedModuleName +" for Client: "+hostAddress+ " called");
return m_ModulServer.createModuleAdapter(selectedModuleName,client,withoutRMI,hostAddress, paramsFile, noGuiStatsFile); return m_ModulServer.createModuleAdapter(selectedModuleName,client,withoutRMI,hostAddress, goParams, noGuiStatsFile);
} }
} }

View File

@ -18,6 +18,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.GOModuleAdapter; import eva2.server.modules.GOModuleAdapter;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
@ -125,7 +126,7 @@ public class ModuleServer {
*/ */
public ModuleAdapter createModuleAdapter(String selectedModuleName, public ModuleAdapter createModuleAdapter(String selectedModuleName,
MainAdapterClient Client, boolean runWithoutRMI, MainAdapterClient Client, boolean runWithoutRMI,
String hostAddress, String paramsFile, String noGuiLogFile) { String hostAddress, InterfaceGOParameters goParams, String noGuiLogFile) {
m_ModuleAdapterCounter++; m_ModuleAdapterCounter++;
String adapterName = new String("ERROR MODULADAPTER !!"); String adapterName = new String("ERROR MODULADAPTER !!");
if (TRACE) { if (TRACE) {
@ -163,8 +164,8 @@ public class ModuleServer {
Constructor<?>[] constructorArr = module.getConstructors(); Constructor<?>[] constructorArr = module.getConstructors();
// create a module instance // create a module instance
if ((paramsFile==null && noGuiLogFile==null) || !module.equals(GOModuleAdapter.class)) { if ((goParams==null && noGuiLogFile==null) || !module.equals(GOModuleAdapter.class)) {
if (paramsFile!=null) System.err.println("Cant load params - no matching constructor found for " + adapterName + " (ModuleServer)"); if (goParams!=null) System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)");
if (noGuiLogFile!=null) System.err.println("Cant deactivate GUI - no matching constructor found for " + adapterName + " (ModuleServer)"); if (noGuiLogFile!=null) System.err.println("Cant deactivate GUI - no matching constructor found for " + adapterName + " (ModuleServer)");
Object[] Para = new Object[2]; Object[] Para = new Object[2];
Class<?> paramTypes[] = (constructorArr[0]).getParameterTypes(); Class<?> paramTypes[] = (constructorArr[0]).getParameterTypes();
@ -174,7 +175,7 @@ public class ModuleServer {
} else { } else {
Object[] Para = new Object[4]; Object[] Para = new Object[4];
Para[0] = (String)adapterName; Para[0] = (String)adapterName;
Para[1] = (String)paramsFile; Para[1] = (InterfaceGOParameters)goParams;
Para[2] = (String)noGuiLogFile; Para[2] = (String)noGuiLogFile;
Para[3] = (MainAdapterClient)Client; Para[3] = (MainAdapterClient)Client;
int constrIndex=0; int constrIndex=0;

View File

@ -1,24 +0,0 @@
package eva2.server.go;
/*
* Title: EvA2
* Description:
* Copyright: Copyright (c) 2003
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 306 $
* $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $
* $Author: mkron $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.server.stat.InterfaceStatistics;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface CrossoverInterface {
public void addListener(InterfaceStatistics e);
}

View File

@ -411,7 +411,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
if (Thread.interrupted()) if (Thread.interrupted())
throw new InterruptedException(); throw new InterruptedException();
// write header to file // write header to file
this.writeToFile(" FitnessCalls\t Best\t Mean\t Worst \t" + BeanInspector.toString(this.m_GO.getProblem().getAdditionalFileStringHeader(this.m_GO.getOptimizer().getPopulation()), '\t', false)); this.writeToFile(" FitnessCalls\t Best\t Mean\t Worst \t" + BeanInspector.toString(this.m_GO.getProblem().getAdditionalFileStringHeader(), '\t', false));
if ((this.m_ContinueFlag) && (this.m_Backup != null)) { if ((this.m_ContinueFlag) && (this.m_Backup != null)) {
this.m_RecentFC += this.m_Backup.getFunctionCalls(); this.m_RecentFC += this.m_Backup.getFunctionCalls();
this.m_GO.getOptimizer().getProblem().initProblem(); this.m_GO.getOptimizer().getProblem().initProblem();

View File

@ -122,8 +122,8 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
public abstract double[] evalUnnormalized(double[] x); public abstract double[] evalUnnormalized(double[] x);
@Override @Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
return ToolBox.appendArrays(new String[]{"numOptsFound", "maxPeakRatio"}, super.getAdditionalFileStringHeader(pop)); return ToolBox.appendArrays(new String[]{"numOptsFound", "maxPeakRatio"}, super.getAdditionalFileStringHeader());
} }
@Override @Override

View File

@ -489,8 +489,8 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
} }
@Override @Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
String[] superHd = super.getAdditionalFileStringHeader(pop); String[] superHd = super.getAdditionalFileStringHeader();
return ToolBox.appendArrays(new String[]{"paretoMetricCurrent","paretoMetricFront"}, superHd); return ToolBox.appendArrays(new String[]{"paretoMetricCurrent","paretoMetricFront"}, superHd);
} }
@ -507,8 +507,8 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
* @see eva2.server.go.problems.AbstractOptimizationProblem#getAdditionalFileStringInfo(eva2.server.go.PopulationInterface) * @see eva2.server.go.problems.AbstractOptimizationProblem#getAdditionalFileStringInfo(eva2.server.go.PopulationInterface)
*/ */
@Override @Override
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { public String[] getAdditionalFileStringInfo() {
String[] superInfo = super.getAdditionalFileStringInfo(pop); String[] superInfo = super.getAdditionalFileStringInfo();
return ToolBox.appendArrays(new String[]{"Pareto metric on the current population (per generation)", return ToolBox.appendArrays(new String[]{"Pareto metric on the current population (per generation)",
"Pareto metric on the collected pareto front"}, superInfo); "Pareto metric on the collected pareto front"}, superInfo);
} }

View File

@ -241,7 +241,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial
* @param pop The population that is to be refined. * @param pop The population that is to be refined.
* @return String * @return String
*/ */
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
if (this instanceof InterfaceInterestingHistogram) return new String[]{"solution","histogram","score"}; if (this instanceof InterfaceInterestingHistogram) return new String[]{"solution","histogram","score"};
else return new String[]{"solution"}; else return new String[]{"solution"};
} }
@ -250,7 +250,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial
* @param pop The population that is to be refined. * @param pop The population that is to be refined.
* @return String * @return String
*/ */
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { public String[] getAdditionalFileStringInfo() {
if (this instanceof InterfaceInterestingHistogram) if (this instanceof InterfaceInterestingHistogram)
return new String[]{"Representation of the current best individual", return new String[]{"Representation of the current best individual",
"Fitness histogram of the current population", "Fitness histogram of the current population",

View File

@ -574,8 +574,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
} }
@Override @Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
String[] superHeader = super.getAdditionalFileStringHeader(pop); String[] superHeader = super.getAdditionalFileStringHeader();
if (isWithConstraints()) if (isWithConstraints())
return ToolBox.appendArrays(superHeader, new String[] { "rawFit", return ToolBox.appendArrays(superHeader, new String[] { "rawFit",
"numViol", "sumViol" }); "numViol", "sumViol" });
@ -584,8 +584,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
} }
@Override @Override
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { public String[] getAdditionalFileStringInfo() {
String[] superInfo = super.getAdditionalFileStringInfo(pop); String[] superInfo = super.getAdditionalFileStringInfo();
if (isWithConstraints()) if (isWithConstraints())
return ToolBox return ToolBox
.appendArrays( .appendArrays(

View File

@ -158,8 +158,8 @@ public class F8Problem extends AbstractProblemDoubleOffset
} }
@Override @Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
String[] superHd = super.getAdditionalFileStringHeader(pop); String[] superHd = super.getAdditionalFileStringHeader();
return ToolBox.appendArrays(new String[]{"numOptimaFound","maxPeakRatio"}, superHd); return ToolBox.appendArrays(new String[]{"numOptimaFound","maxPeakRatio"}, superHd);
// return "#Optima found \tMaximum Peak Ratio \t" + super.getAdditionalFileStringHeader(pop); // return "#Optima found \tMaximum Peak Ratio \t" + super.getAdditionalFileStringHeader(pop);
} }

View File

@ -345,19 +345,6 @@ public class FLensProblem extends AbstractOptimizationProblem implements Interfa
return result; return result;
} }
@Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) {
return new String[]{"Solution"};
}
@Override
public Object[] getAdditionalFileStringValue(PopulationInterface pop) {
String result ="{";
double[] data = ((InterfaceDataTypeDouble) pop.getBestIndividual()).getDoubleData();
for (int i = 0; i < data.length; i++) result += data[i] +"; ";
result += "}";
return new Object[]{result};
}
/** This method allows you to output a string that describes a found solution /** This method allows you to output a string that describes a found solution
* in a way that is most suiteable for a given problem. * in a way that is most suiteable for a given problem.
* @param optimizer The individual that is to be shown. * @param optimizer The individual that is to be shown.

View File

@ -17,7 +17,7 @@ public interface InterfaceAdditionalPopulationInformer {
* @param pop The population of the optimization run. * @param pop The population of the optimization run.
* @return String * @return String
*/ */
public String[] getAdditionalFileStringHeader(PopulationInterface pop); public String[] getAdditionalFileStringHeader();
/** /**
* Optionally return informative descriptions of the data fields. * Optionally return informative descriptions of the data fields.
@ -25,7 +25,7 @@ public interface InterfaceAdditionalPopulationInformer {
* @param pop * @param pop
* @return * @return
*/ */
public String[] getAdditionalFileStringInfo(PopulationInterface pop); public String[] getAdditionalFileStringInfo();
/** /**
* This method returns additional statistical data. * This method returns additional statistical data.

View File

@ -510,8 +510,8 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
} }
@Override @Override
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
String[] superHd = super.getAdditionalFileStringHeader(pop); String[] superHd = super.getAdditionalFileStringHeader();
return ToolBox.appendArrays(new String[]{"bestIndySize","avgIndySize","avgMaxIndyDepth"}, superHd); return ToolBox.appendArrays(new String[]{"bestIndySize","avgIndySize","avgMaxIndyDepth"}, superHd);
} }

View File

@ -1142,14 +1142,14 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
return "If fitness improves less than this value within the halting window, convergence is assumed. May be set to zero."; return "If fitness improves less than this value within the halting window, convergence is assumed. May be set to zero.";
} }
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
return new String[]{"numUndiff","numActSpec","avgSpecMeas","numArchived", return new String[]{"numUndiff","numActSpec","avgSpecMeas","numArchived",
"archivedMedCorr", "archivedMeanDist" "archivedMedCorr", "archivedMeanDist"
// , "numCollisions", "clustSig" // , "numCollisions", "clustSig"
}; };
} }
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { // TODO use these as Tool Tip Texts??? public String[] getAdditionalFileStringInfo() {
return new String[] { return new String[] {
"The number of exploring individuals in the main population", "The number of exploring individuals in the main population",
"The number of active species (sub-populations)", "The number of active species (sub-populations)",

View File

@ -418,11 +418,11 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
return "Set the method to be used for the hill climbing as local search"; return "Set the method to be used for the hill climbing as local search";
} }
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
return new String[]{"numIndies"}; return new String[]{"numIndies"};
} }
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { public String[] getAdditionalFileStringInfo() {
return new String[]{"The current population size"}; return new String[]{"The current population size"};
} }

View File

@ -2060,12 +2060,12 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
// public void setDoLocalSearch(boolean doLocalSearch) { // public void setDoLocalSearch(boolean doLocalSearch) {
// this.doLocalSearch = doLocalSearch; // this.doLocalSearch = doLocalSearch;
// } // }
public String[] getAdditionalFileStringHeader(PopulationInterface pop) { public String[] getAdditionalFileStringHeader() {
if (emaPeriods > 0) return new String[]{"meanEMASpeed", "meanCurSpeed"}; if (emaPeriods > 0) return new String[]{"meanEMASpeed", "meanCurSpeed"};
else return new String[]{"meanCurSpeed"}; else return new String[]{"meanCurSpeed"};
} }
public String[] getAdditionalFileStringInfo(PopulationInterface pop) { public String[] getAdditionalFileStringInfo() {
if (emaPeriods > 0) return new String[]{"Exponential moving average of the (range-relative) speed of all particles", "The mean (range-relative) current speed of all particles"}; if (emaPeriods > 0) return new String[]{"Exponential moving average of the (range-relative) speed of all particles", "The mean (range-relative) current speed of all particles"};
else return new String[]{"The mean (range-relative) current speed of all particles"}; else return new String[]{"The mean (range-relative) current speed of all particles"};
} }

View File

@ -122,11 +122,11 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
} else return null; } else return null;
} }
// public void setGOParameters(InterfaceGOParameters params) { public void setGOParameters(InterfaceGOParameters goParams) {
// if ((m_Processor != null) && (m_Processor instanceof Processor)) { if ((m_Processor != null) && (m_Processor instanceof Processor)) {
// ((Processor)m_Processor).setGOParams(params); ((Processor)m_Processor).setGOParams(goParams);
// } }
// } }
// public void loadGOParameters(String serParamsFile) { // public void loadGOParameters(String serParamsFile) {
// if ((m_Processor != null) && (m_Processor instanceof Processor)) { // if ((m_Processor != null) && (m_Processor instanceof Processor)) {

View File

@ -2,6 +2,7 @@ package eva2.server.modules;
import java.io.Serializable; import java.io.Serializable;
import eva2.server.go.InterfaceGOParameters;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
@ -39,8 +40,19 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
* @param AdapterName the title of the ModulAdapter * @param AdapterName the title of the ModulAdapter
* @param Client the client instance * @param Client the client instance
*/ */
public GOModuleAdapter(String adapterName, String serParamsFile, String noGuiLogFile, MainAdapterClient client) { public GOModuleAdapter(String adapterName, InterfaceGOParameters goParams, String noGuiLogFile, MainAdapterClient client) {
//super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false); //super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false);
super(adapterName, "", client, GOParameters.getInstance(serParamsFile, serParamsFile==null), false, noGuiLogFile); super(adapterName, "", client, goParams, false, noGuiLogFile);
} }
// /**
// * Starts a statistics GUI and the GOProcessor thread with a given GOParameters file.
// *
// * @param AdapterName the title of the ModulAdapter
// * @param Client the client instance
// */
// public GOModuleAdapter(String adapterName, String serParamsFile, String noGuiLogFile, MainAdapterClient client) {
// //super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false);
// super(adapterName, "", client, GOParameters.getInstance(serParamsFile, serParamsFile==null), false, noGuiLogFile);
// }
} }

View File

@ -13,9 +13,6 @@ package eva2.server.modules;
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import eva2.gui.EvATabbedFrameMaker; import eva2.gui.EvATabbedFrameMaker;
import eva2.gui.LogPanel;
import eva2.server.go.operators.postprocess.PostProcessParams;
import eva2.server.stat.InterfaceTextListener;
import eva2.tools.jproxy.RemoteStateListener; import eva2.tools.jproxy.RemoteStateListener;
/*==========================================================================* /*==========================================================================*
* INTERFACE DECLARATION * INTERFACE DECLARATION

View File

@ -1,5 +1,6 @@
package eva2.server.modules; package eva2.server.modules;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -228,7 +229,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
String popLog = null; //"populationLog.txt"; String popLog = null; //"populationLog.txt";
while (isOptRunning() && (runCounter<m_Statistics.getStatisticsParameter().getMultiRuns())) { while (isOptRunning() && (runCounter<m_Statistics.getStatisticsParameter().getMultiRuns())) {
m_Statistics.startOptPerformed(getInfoString(),runCounter, goParams); m_Statistics.startOptPerformed(getInfoString(),runCounter, goParams, getInformerList());
this.goParams.getProblem().initProblem(); this.goParams.getProblem().initProblem();
this.goParams.getOptimizer().SetProblem(this.goParams.getProblem()); this.goParams.getOptimizer().SetProblem(this.goParams.getProblem());
@ -355,13 +356,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
public void registerPopulationStateChanged(Object source, String name) { public void registerPopulationStateChanged(Object source, String name) {
if (name.equals(Population.nextGenerationPerformed)) { if (name.equals(Population.nextGenerationPerformed)) {
// System.out.println(getGOParams().getOptimizer().getPopulation().getFunctionCalls() + " " + getGOParams().getOptimizer().getPopulation().getBestFitness()[0]); // System.out.println(getGOParams().getOptimizer().getPopulation().getFunctionCalls() + " " + getGOParams().getOptimizer().getPopulation().getBestFitness()[0]);
Vector informerList = new Vector<InterfaceAdditionalPopulationInformer>(2);
informerList.add(this.goParams.getProblem());
if (this.goParams.getOptimizer() instanceof InterfaceAdditionalPopulationInformer) informerList.add(this.goParams.getOptimizer());
m_Statistics.createNextGenerationPerformed( m_Statistics.createNextGenerationPerformed(
(PopulationInterface)this.goParams.getOptimizer().getPopulation(), (PopulationInterface)this.goParams.getOptimizer().getPopulation(),
this.goParams.getOptimizer(), this.goParams.getOptimizer(),
informerList); getInformerList());
if (m_ListenerModule != null) { if (m_ListenerModule != null) {
m_ListenerModule.updateProgress( m_ListenerModule.updateProgress(
getStatusPercent( getStatusPercent(
@ -373,6 +371,13 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
} }
} }
protected List<InterfaceAdditionalPopulationInformer> getInformerList() {
Vector<InterfaceAdditionalPopulationInformer> informerList = new Vector<InterfaceAdditionalPopulationInformer>(2);
informerList.add(this.goParams.getProblem());
if (this.goParams.getOptimizer() instanceof InterfaceAdditionalPopulationInformer) informerList.add((InterfaceAdditionalPopulationInformer)this.goParams.getOptimizer());
return informerList;
}
/** This method writes Data to file. /** This method writes Data to file.
* @param line The line that is to be added to the file * @param line The line that is to be added to the file
*/ */

View File

@ -65,7 +65,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private ArrayList<Double[]> sumDataCollection; // collect summed-up data of multiple runs indexed per iteration private ArrayList<Double[]> sumDataCollection; // collect summed-up data of multiple runs indexed per iteration
protected Object[] currentStatObjectData = null; // the raw Object data collected in an iteration protected Object[] currentStatObjectData = null; // the raw Object data collected in an iteration
protected Double[] currentStatDoubleData = null; // the parsed doubles collected in an iteration (or null for complex data fields) protected Double[] currentStatDoubleData = null; // the parsed doubles collected in an iteration (or null for complex data fields)
protected String[] currentHeaderData = null; // the header Strings of the currently provided data protected String[] currentStatHeader = null; // the header Strings of the currently provided data
protected String[] currentStatMetaInfo = null; // meta information on the statistical data
private Double[] statDataSumOverAll = null; private Double[] statDataSumOverAll = null;
// , lastAdditionalInfoSums=null; // , lastAdditionalInfoSums=null;
@ -133,7 +134,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private void fireDataListeners() { private void fireDataListeners() {
if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) { if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) {
l.notifyGenerationPerformed(currentHeaderData, currentStatObjectData, currentStatDoubleData); l.notifyGenerationPerformed(currentStatHeader, currentStatObjectData, currentStatDoubleData);
} }
} }
@ -146,10 +147,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
*/ */
private void fireDataListenersStartStop(int runNumber, boolean normal, boolean start) { private void fireDataListenersStartStop(int runNumber, boolean normal, boolean start) {
if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) { if (dataListeners!=null) for (InterfaceStatisticsListener l : dataListeners) {
if (start) l.notifyRunStarted(runNumber, m_StatsParams.getMultiRuns()); if (start) l.notifyRunStarted(runNumber, m_StatsParams.getMultiRuns(), currentStatHeader, currentStatMetaInfo);
else { else {
l.notifyRunStopped(optRunsPerformed, normal); l.notifyRunStopped(optRunsPerformed, normal);
if (optRunsPerformed>1) l.finalMultiRunResults(currentHeaderData, finalObjectData); if (optRunsPerformed>1) l.finalMultiRunResults(currentStatHeader, finalObjectData);
} }
} }
} }
@ -221,17 +222,24 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
saveParams = doSave; saveParams = doSave;
} }
public void startOptPerformed(String infoString, int runNumber, Object params) { public void startOptPerformed(String infoString, int runNumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
if (TRACE) { if (TRACE) {
System.out.println("AbstractStatistics.startOptPerformed " + runNumber); System.out.println("AbstractStatistics.startOptPerformed " + runNumber);
System.out.println("Statsparams were " + BeanInspector.toString(m_StatsParams)); System.out.println("Statsparams were " + BeanInspector.toString(m_StatsParams));
} }
if (runNumber == 0) { if (runNumber == 0) {
currentHeaderData=null; // store the intial graph selection state, so that modifications during runtime cannot cause inconsistencies
lastFieldSelection = (StringSelection)m_StatsParams.getFieldSelection().clone();
lastIsShowFull = m_StatsParams.isOutputAllFieldsAsText();
currentStatDoubleData=null; currentStatDoubleData=null;
currentStatObjectData=null; currentStatObjectData=null;
List<String> headerFields=getOutputHeaderFieldNames(informerList);
currentStatHeader = headerFields.toArray(new String[headerFields.size()]);
currentStatMetaInfo = getOutputMetaInfoAsArray(informerList);
functionCallSum = 0; functionCallSum = 0;
firstPlot = true; firstPlot = true;
optRunsPerformed = 0; optRunsPerformed = 0;
@ -256,9 +264,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
feasibleFoundAfterSum=-1; feasibleFoundAfterSum=-1;
numOfRunsFeasibleFound=0; numOfRunsFeasibleFound=0;
// store the intial graph selection state, so that modifications during runtime cannot cause inconsistencies
lastFieldSelection = (StringSelection)m_StatsParams.getFieldSelection().clone();
lastIsShowFull = m_StatsParams.isOutputAllFieldsAsText();
} }
feasibleFoundAfter=-1; feasibleFoundAfter=-1;
bestCurrentIndy = null; bestCurrentIndy = null;
@ -456,7 +461,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
private String getFinalAdditionalInfo() { private String getFinalAdditionalInfo() {
PopulationInterface bestPop = makeStatsPop(); PopulationInterface bestPop = makeStatsPop();
// List<String> additionalFields = getAdditionalInfoHeader(lastInformerList, bestPop); // List<String> additionalFields = getAdditionalInfoHeader(lastInformerList, bestPop);
String additionalFields = getOutputHeaderString(lastInformerList, bestPop); String additionalFields = getOutputHeaderFieldNamesAsString(lastInformerList);
// String header = getOutputHeader(lastInformerList, bestPop); // String header = getOutputHeader(lastInformerList, bestPop);
List<Object> vals = getOutputValues(lastInformerList, bestPop); List<Object> vals = getOutputValues(lastInformerList, bestPop);
@ -502,7 +507,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
public String refineToText(ArrayList<Double[]> data, int iterationsToShow) { public String refineToText(ArrayList<Double[]> data, int iterationsToShow) {
String hd = getOutputHeaderString(lastInformerList, null); String hd = getOutputHeaderFieldNamesAsString(lastInformerList);
StringBuffer sbuf = new StringBuffer("Iteration"); StringBuffer sbuf = new StringBuffer("Iteration");
sbuf.append(textFieldDelimiter); sbuf.append(textFieldDelimiter);
sbuf.append(hd); sbuf.append(hd);
@ -591,11 +596,28 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @param pop * @param pop
* @return * @return
*/ */
protected String getOutputHeaderString(List<InterfaceAdditionalPopulationInformer> informerList, PopulationInterface pop) { protected String getOutputHeaderFieldNamesAsString(List<InterfaceAdditionalPopulationInformer> informerList) {
List<String> headlineFields = getOutputHeaderFieldNames(informerList, pop); List<String> headlineFields = getOutputHeaderFieldNames(informerList);
return StringTools.concatFields(headlineFields, textFieldDelimiter); return StringTools.concatFields(headlineFields, textFieldDelimiter);
} }
/**
* Collect meta information on both internal fields and fields of external informers.
* The length of this list depends on the field selection state.
*
* @param informerList
* @param pop
* @return
*/
protected List<String> getOutputHeaderFieldNames(List<InterfaceAdditionalPopulationInformer> informerList) {
ArrayList<String> headlineFields = new ArrayList<String>(5);
headlineFields.addAll(Arrays.asList(getSimpleOutputHeader()));
if (informerList != null) {
headlineFields.addAll(getAdditionalHeaderMetaInfo(informerList, null));
}
return headlineFields;
}
/** /**
* Collect all field names of both internal fields and fields of external informers. * Collect all field names of both internal fields and fields of external informers.
* The length of this list depends on the field selection state. * The length of this list depends on the field selection state.
@ -604,15 +626,23 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
* @param pop * @param pop
* @return * @return
*/ */
protected List<String> getOutputHeaderFieldNames(List<InterfaceAdditionalPopulationInformer> informerList, PopulationInterface pop) { protected List<String> getOutputMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList) {
ArrayList<String> headlineFields = new ArrayList<String>(5); ArrayList<String> infoStrings = new ArrayList<String>(5);
headlineFields.addAll(Arrays.asList(getSimpleOutputHeader())); ArrayList<String> addStrings = new ArrayList<String>(5);
infoStrings.addAll(Arrays.asList(getSimpleOutputMetaInfo()));
if (informerList != null) { if (informerList != null) {
headlineFields.addAll(getAdditionalInfoHeader(informerList, pop)); getAdditionalHeaderMetaInfo(informerList, addStrings);
} }
return headlineFields; infoStrings.addAll(addStrings);
return infoStrings;
} }
protected String[] getOutputMetaInfoAsArray(List<InterfaceAdditionalPopulationInformer> informerList) {
List<String> metaStrings = getOutputMetaInfo(informerList);
return metaStrings.toArray( new String[metaStrings.size()]);
}
/** /**
* Collect the names of data fields which are collected internally.This must correspond to the * Collect the names of data fields which are collected internally.This must correspond to the
* method {@link #getSimpleOutputValues()}. * method {@link #getSimpleOutputValues()}.
@ -632,6 +662,24 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
return headerEntries.toArray(new String[headerEntries.size()]); return headerEntries.toArray(new String[headerEntries.size()]);
} }
/**
* Collect the info strings of data fields collected internally. This must correspond to
* the method {@link #getSimpleOutputValues()}.
*
* @see #getSimpleOutputValues()
* @return
*/
protected String[] getSimpleOutputMetaInfo() {
GraphSelectionEnum[] vals = GraphSelectionEnum.values();
ArrayList<String> headerInfo = new ArrayList<String>();
headerInfo.add("The number of function evaluations");
for (int i=0; i<vals.length; i++) {
if (isRequestedField(vals[i])) headerInfo.add(GraphSelectionEnum.getInfoStrings()[i]);
}
// return new String[]{"Fun.calls","Best","Mean", "Worst"};
return headerInfo.toArray(new String[headerInfo.size()]);
}
/** /**
* Indicate whether the given statistics data type is requested to * Indicate whether the given statistics data type is requested to
* be displayed (and thus needs to be calculated). * be displayed (and thus needs to be calculated).
@ -739,23 +787,32 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
/** /**
* Collect all field names of external informer instances. * Collect additional info header and (optionally) meta information for the fields selected.
* The length of this list depends on the field selection state. * The length of this list depends on the field selection state.
*
* @param informerList * @param informerList
* @param pop * @param pop
* @param metaInfo if non null, the meta info strings are returned in this list
* @return * @return
*/ */
protected List<String> getAdditionalInfoHeader(List<InterfaceAdditionalPopulationInformer> informerList, PopulationInterface pop) { protected List<String> getAdditionalHeaderMetaInfo(List<InterfaceAdditionalPopulationInformer> informerList, List<String> metaInfo) {
LinkedList<String> additionals = new LinkedList<String>(); LinkedList<String> headers = new LinkedList<String>();
if (metaInfo!=null && (metaInfo.size()>0)) System.err.println("Warning, metaInfo list should be empty in AbstractStatistics.getAdditionalInfoInfo");
for (InterfaceAdditionalPopulationInformer informer : informerList) { for (InterfaceAdditionalPopulationInformer informer : informerList) {
additionals.addAll(Arrays.asList(informer.getAdditionalFileStringHeader(pop))); headers.addAll(Arrays.asList(informer.getAdditionalFileStringHeader()));
if (metaInfo!=null) metaInfo.addAll(Arrays.asList(informer.getAdditionalFileStringInfo()));
// hdr = hdr + "\t " + informer.getAdditionalFileStringHeader(pop); // hdr = hdr + "\t " + informer.getAdditionalFileStringHeader(pop);
} }
Iterator<String> iter = additionals.iterator(); Iterator<String> hIter = headers.iterator();
if (!lastIsShowFull) while (iter.hasNext()) { Iterator<String> mIter = (metaInfo!=null) ? metaInfo.iterator() : null;
if (!isRequestedAdditionalField(iter.next())) iter.remove(); if (!lastIsShowFull) while (hIter.hasNext()) {
if (mIter!=null) mIter.next();
if (!isRequestedAdditionalField(hIter.next())) {
hIter.remove();
if (mIter!=null) mIter.remove();
} }
return additionals; }
return headers;
} }
/** /**
@ -824,7 +881,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
// if (doTextOutput()) printToTextListener(getOutputHeader(null, null)+'\n'); // if (doTextOutput()) printToTextListener(getOutputHeader(null, null)+'\n');
firstPlot = false; firstPlot = false;
} }
if ((iterationCounter == 0) && printHeaderByVerbosity()) printToTextListener(getOutputHeaderString(null, null)+'\n'); if ((iterationCounter == 0) && printHeaderByVerbosity()) printToTextListener(getOutputHeaderFieldNamesAsString(null)+'\n');
if (doTextOutput() && printLineByVerbosity(calls)) { if (doTextOutput() && printLineByVerbosity(calls)) {
Pair<String,Object[]> addInfo = getOutputData(null, null); Pair<String,Object[]> addInfo = getOutputData(null, null);
@ -943,7 +1000,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
} }
/** /**
* Do some data collection on the population. The informer parameter will not be handled by this method. * Do some data collection on the population.
* *
*/ */
public synchronized void createNextGenerationPerformed(PopulationInterface public synchronized void createNextGenerationPerformed(PopulationInterface
@ -964,9 +1021,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
collectPopData(pop); collectPopData(pop);
if (iterationCounter==0) { if (iterationCounter==0) {
List<String> headerFields=getOutputHeaderFieldNames(informerList, pop); String headerLine = StringTools.concatFields(currentStatHeader, textFieldDelimiter);
currentHeaderData = headerFields.toArray(new String[headerFields.size()]);
String headerLine = StringTools.concatFields(headerFields, textFieldDelimiter);
if (printHeaderByVerbosity()) printToTextListener(headerLine+'\n'); if (printHeaderByVerbosity()) printToTextListener(headerLine+'\n');
} }

View File

@ -28,7 +28,7 @@ public interface InterfaceStatistics {
/** /**
* Initialize statistics computations. * Initialize statistics computations.
*/ */
public void startOptPerformed(String InfoString,int runnumber, Object params); // called from processor public void startOptPerformed(String InfoString,int runnumber, Object params, List<InterfaceAdditionalPopulationInformer> informerList); // called from processor
/** /**
* Finalize statistics computations. * Finalize statistics computations.
*/ */

View File

@ -26,8 +26,10 @@ public interface InterfaceStatisticsListener {
* *
* @param runNumber the number of the new run, starting with 0 * @param runNumber the number of the new run, starting with 0
* @param plannedMultiRuns the number of planned multi-runs * @param plannedMultiRuns the number of planned multi-runs
* @param header field names of the data
* @param metaInfo additional meta information on the data fields
*/ */
public void notifyRunStarted(int runNumber, int plannedMultiRuns); public void notifyRunStarted(int runNumber, int plannedMultiRuns, String[] header, String[] metaInfo);
/** /**
* Method called at the end of a single run. * Method called at the end of a single run.

View File

@ -79,7 +79,7 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen
} }
public void startOptPerformed(String InfoString, int runnumber, public void startOptPerformed(String InfoString, int runnumber,
Object params) { Object params, List<InterfaceAdditionalPopulationInformer> informerList) {
if (runnumber==0) bestIndividualAllover = null; if (runnumber==0) bestIndividualAllover = null;
bestRunIndy = null; bestRunIndy = null;
} }

View File

@ -77,7 +77,7 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) { protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) {
if (collectData) { if (collectData) {
m_ResultData = new ArrayList<ArrayList<Object[]>>(m_StatsParams.getMultiRuns()); m_ResultData = new ArrayList<ArrayList<Object[]>>(m_StatsParams.getMultiRuns());
List<String> description = getOutputHeaderFieldNames(informerList, pop); List<String> description = getOutputHeaderFieldNames(informerList);
m_ResultHeaderStrings = new ArrayList<String>(); m_ResultHeaderStrings = new ArrayList<String>();
for (String str : description) m_ResultHeaderStrings.add(str); for (String str : description) m_ResultHeaderStrings.add(str);
for (int i = 0; i < m_StatsParams.getMultiRuns(); i++) for (int i = 0; i < m_StatsParams.getMultiRuns(); i++)

View File

@ -99,8 +99,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
/** /**
* *
*/ */
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams) { public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams, List<InterfaceAdditionalPopulationInformer> informerList) {
super.startOptPerformed(infoString, runNumber, goParams); super.startOptPerformed(infoString, runNumber, goParams, informerList);
m_GraphInfoString = infoString; m_GraphInfoString = infoString;
// m_TextCounter = m_StatisticsParameter.GetTextoutput(); // m_TextCounter = m_StatisticsParameter.GetTextoutput();

View File

@ -384,9 +384,9 @@ public class StatsParameter implements InterfaceStatisticsParameter, InterfaceNo
ArrayList<String> infoFields = new ArrayList<String>(); ArrayList<String> infoFields = new ArrayList<String>();
// parse list of header elements, show additional Strings according to names. // parse list of header elements, show additional Strings according to names.
for (InterfaceAdditionalPopulationInformer inf : informers) { for (InterfaceAdditionalPopulationInformer inf : informers) {
headerFields.addAll(Arrays.asList(inf.getAdditionalFileStringHeader(null))); headerFields.addAll(Arrays.asList(inf.getAdditionalFileStringHeader()));
if (infoFields.size()<headerFields.size()) { // add info strings for tool tips - fill up with null if none have been returned. if (infoFields.size()<headerFields.size()) { // add info strings for tool tips - fill up with null if none have been returned.
String[] infos = inf.getAdditionalFileStringInfo(null); String[] infos = inf.getAdditionalFileStringInfo();
if (infos!=null) infoFields.addAll(Arrays.asList(infos)); if (infos!=null) infoFields.addAll(Arrays.asList(infos));
while (infoFields.size()<headerFields.size()) infoFields.add(null); while (infoFields.size()<headerFields.size()) infoFields.add(null);
} }

View File

@ -279,5 +279,17 @@ public class StringTools {
} }
return sb.toString(); return sb.toString();
} }
public static String concatFields(String[] strs,
String delim) {
StringBuffer sb = new StringBuffer();
int cnt=0;
for (String str : strs) {
if (cnt>0) sb.append(delim);
sb.append(str);
cnt++;
}
return sb.toString();
}
} }