All RMI has been removed. GUI not working properly right now, but at least the code compiles.
This commit is contained in:
parent
a4fe1498f2
commit
b0ab7aba0c
@ -1,5 +1,6 @@
|
||||
package eva2;
|
||||
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.server.go.IndividualInterface;
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.go.InterfaceTerminator;
|
||||
@ -13,7 +14,6 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.modules.GOParameters;
|
||||
import eva2.server.modules.Processor;
|
||||
import eva2.server.stat.*;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.BitSet;
|
||||
@ -132,7 +132,7 @@ public class OptimizerRunnable implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void addRemoteStateListener(RemoteStateListener rsl) {
|
||||
public void addOptimizationStateListener(OptimizationStateListener rsl) {
|
||||
if (proc != null) {
|
||||
proc.addListener(rsl);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ package eva2.client;
|
||||
*/
|
||||
import eva2.EvAInfo;
|
||||
import eva2.gui.*;
|
||||
import eva2.server.EvAServer;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.modules.AbstractModuleAdapter;
|
||||
import eva2.server.modules.GOParameters;
|
||||
@ -26,7 +26,6 @@ import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.ReflectPackage;
|
||||
import eva2.tools.StringTools;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.net.URL;
|
||||
@ -42,7 +41,7 @@ import javax.swing.*;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
public class EvAClient extends JFrame implements OptimizationStateListener {
|
||||
|
||||
/**
|
||||
* Generated serial version identifier.
|
||||
@ -52,12 +51,11 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
private boolean clientInited = false;
|
||||
private JExtDesktopPaneToolBar desktopToolBar;
|
||||
private JDesktopPane desktopPane;
|
||||
//private JFrame mainFrame;
|
||||
private JPanel configurationPane;
|
||||
private JSplitPane horizontalSplit;
|
||||
private Runnable initRnbl = null;
|
||||
|
||||
private EvAComAdapter comAdapter;
|
||||
//private EvAComAdapter comAdapter;
|
||||
private transient JMenuBar menuBar;
|
||||
private transient JExtMenu menuHelp;
|
||||
private transient JExtMenu menuSelHosts;
|
||||
@ -94,33 +92,34 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
private boolean showLoadModules = false;
|
||||
private boolean localMode = false;
|
||||
|
||||
// This variable says whether, if running locally, a local server should be addressed by RMI.
|
||||
// False should be preferred here to avoid overhead
|
||||
private boolean useLocalRMI = false;
|
||||
// measuring optimization runtime
|
||||
private long startTime = 0;
|
||||
// remember the module in use
|
||||
private transient String currentModule = null;
|
||||
private List<RemoteStateListener> superListenerList = null;
|
||||
private transient String currentModule = null;
|
||||
private boolean withGUI = true;
|
||||
private boolean withTreeView = false;
|
||||
private EvATabbedFrameMaker frameMaker = null;
|
||||
private Window parentWindow;
|
||||
|
||||
private List<OptimizationStateListener> superListenerList = null;
|
||||
|
||||
private EvAComAdapter comAdapter;
|
||||
|
||||
public void addRemoteStateListener(RemoteStateListener l) {
|
||||
|
||||
public void addOptimizationStateListener(OptimizationStateListener l) {
|
||||
if (superListenerList == null) {
|
||||
superListenerList = new ArrayList<RemoteStateListener>();
|
||||
superListenerList = new ArrayList<OptimizationStateListener>();
|
||||
}
|
||||
superListenerList.add(l);
|
||||
}
|
||||
|
||||
public boolean removeRemoteStateListener(RemoteStateListener l) {
|
||||
public boolean removeOptimizationStateListener(OptimizationStateListener l) {
|
||||
if (superListenerList != null) {
|
||||
return superListenerList.remove(l);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
|
||||
@ -212,7 +211,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main constructor of the EvA2 client GUI. Works as standalone verson
|
||||
* Main constructor of the EvA2 client GUI. Works as standalone version
|
||||
* locally or 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
|
||||
@ -500,7 +499,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
if (goParams == null && (paramsFile != null && (paramsFile.length() > 0))) {
|
||||
goParams = GOParameters.getInstance(paramsFile, false);
|
||||
}
|
||||
loadModuleFromServer(useDefaultModule, goParams);//loadSpecificModule
|
||||
loadSpecificModule(useDefaultModule, goParams);//loadSpecificModule
|
||||
}
|
||||
|
||||
if (withGUI) {
|
||||
@ -521,14 +520,6 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
});
|
||||
}
|
||||
|
||||
if (comAdapter != null) {
|
||||
if (hostName != null) {
|
||||
selectHost(hostName);
|
||||
}
|
||||
comAdapter.setLogPanel(logPanel);
|
||||
LOGGER.log(Level.INFO, "Selected Host: {0}", comAdapter.getHostName());
|
||||
}
|
||||
|
||||
if (withGUI) {
|
||||
LOGGER.log(Level.INFO, "Working directory is: {0}", System.getProperty("user.dir"));
|
||||
LOGGER.log(Level.INFO, "Class path is: {0}", System.getProperty("java.class.path", "."));
|
||||
@ -710,14 +701,6 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
*
|
||||
*/
|
||||
private void createActions() {
|
||||
actModuleLoad = new ExtAction("&Load", "Load Module",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
loadModuleFromServer(null, null);
|
||||
}
|
||||
};
|
||||
|
||||
actAbout = new ExtAction("&About", "Product Information") {
|
||||
|
||||
@ -735,61 +718,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
showLicense();
|
||||
}
|
||||
};
|
||||
actHost = new ExtAction("&List of all servers", "All servers in list",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
LOGGER.info(event.getActionCommand());
|
||||
selectAvailableHost(comAdapter.getHostNameList());
|
||||
}
|
||||
};
|
||||
actAvailableHost = new ExtAction("Available &Server", "Available server",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
LOGGER.info(event.getActionCommand());
|
||||
showPleaseWaitDialog();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectAvailableHost(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
};
|
||||
actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
LOGGER.info(event.getActionCommand());
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectAvailableHostToKill(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
}.start();
|
||||
showPleaseWaitDialog();
|
||||
}
|
||||
};
|
||||
actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
LOGGER.info(event.getActionCommand());
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectAllAvailableHostToKill(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
}.start();
|
||||
showPleaseWaitDialog();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
actQuit = new ExtAction("&Quit", "Quit EvA2 workbench",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)) {
|
||||
|
||||
@ -874,80 +803,6 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
menuBar.add(menuHelp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void loadModuleFromServer(String selectedModule, InterfaceGOParameters goParams) {
|
||||
if (comAdapter.getHostName() == null) {
|
||||
System.err.println("error in loadModuleFromServer!");
|
||||
return;
|
||||
}
|
||||
if (comAdapter.getHostName().equals("localhost")) {
|
||||
localMode = true;
|
||||
if (useLocalRMI) {
|
||||
EvAServer Server = new EvAServer(true, false);
|
||||
comAdapter.setLocalRMIServer(Server.getRMIServer());
|
||||
LOGGER.info("Local EvAServer started");
|
||||
comAdapter.setRunLocally(false); // this is not quite true but should have the desired effect
|
||||
} else {
|
||||
LOGGER.info("Working locally");
|
||||
comAdapter.setLocalRMIServer(null);
|
||||
comAdapter.setRunLocally(true);
|
||||
}
|
||||
} else {
|
||||
localMode = false;
|
||||
comAdapter.setRunLocally(false);
|
||||
}
|
||||
if (selectedModule == null) { // show a dialog and ask for a module
|
||||
String[] moduleNameList = comAdapter.getModuleNameList();
|
||||
if (moduleNameList == null) {
|
||||
JOptionPane.showMessageDialog(this, "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1);
|
||||
} else {
|
||||
String lastModule = null;
|
||||
|
||||
try {
|
||||
java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userRoot();
|
||||
lastModule = prefs.get("lastModule", null);
|
||||
} catch (SecurityException ex) {
|
||||
LOGGER.log(Level.WARNING, "Can't write user preference.", ex);
|
||||
}
|
||||
|
||||
if (lastModule == null) {
|
||||
lastModule = moduleNameList[0];
|
||||
LOGGER.log(Level.INFO, "Defaulting to module: {0}", lastModule);
|
||||
}
|
||||
|
||||
selectedModule = (String) JOptionPane.showInputDialog(this,
|
||||
"Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?",
|
||||
"Load optimization module on host",
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
moduleNameList,
|
||||
lastModule);
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedModule == null) {
|
||||
System.err.println("not loading any module");
|
||||
} else {
|
||||
try {
|
||||
java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userRoot();
|
||||
prefs.put("lastModule", selectedModule);
|
||||
} catch (SecurityException ex) {
|
||||
LOGGER.log(Level.WARNING, "Can't write user preference.", ex);
|
||||
}
|
||||
|
||||
loadSpecificModule(selectedModule, goParams);
|
||||
|
||||
if (withGUI) {
|
||||
actHost.setEnabled(true);
|
||||
actAvailableHost.setEnabled(true);
|
||||
}
|
||||
LOGGER.log(Level.INFO, "Selected Module: {0}", selectedModule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the GOParamters of a loaded module. Return null if no module is
|
||||
* loaded.
|
||||
@ -1015,10 +870,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
showLoadModules = true;
|
||||
} else {
|
||||
newModuleAdapter.setConnection(!localMode);
|
||||
if (comAdapter.isRunLocally()) {
|
||||
// TODO in rmi-mode this doesnt work yet! meaning e.g. that theres no content in the info log
|
||||
newModuleAdapter.addRemoteStateListener((RemoteStateListener) this);
|
||||
}
|
||||
newModuleAdapter.addOptimizationStateListener((OptimizationStateListener) this);
|
||||
try {
|
||||
if (withGUI) {
|
||||
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from!
|
||||
@ -1107,35 +959,6 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
return treeView;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void selectAvailableHost(String[] hostNames) {
|
||||
if (hostNames == null || hostNames.length == 0) {
|
||||
showNoHostFoundDialog();
|
||||
} else {
|
||||
String hostName = (String) JOptionPane.showInputDialog(this,
|
||||
"Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
hostNames, comAdapter.getHostName());
|
||||
if (hostName != null) {
|
||||
selectHost(hostName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void selectHost(String hostName) {
|
||||
comAdapter.setHostName(hostName);
|
||||
LOGGER.info("Selected Host: " + hostName);
|
||||
if (currentModule != null) {
|
||||
LOGGER.info("Reloading module from server...");
|
||||
loadModuleFromServer(currentModule, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPleaseWaitDialog() {
|
||||
JOptionPane.showMessageDialog(this, "Please wait one moment.", EvAInfo.infoTitle, 1);
|
||||
}
|
||||
|
||||
private void showAboutDialog() {
|
||||
AboutDialog aboutDialog = new AboutDialog(this);
|
||||
aboutDialog.setLocationRelativeTo(this);
|
||||
@ -1150,38 +973,10 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
lgpl.show();
|
||||
}
|
||||
|
||||
private void showNoHostFoundDialog() {
|
||||
JOptionPane.showMessageDialog(this, "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", EvAInfo.infoTitle, 1);
|
||||
}
|
||||
|
||||
private void selectAvailableHostToKill(String[] HostNames) {
|
||||
if (HostNames == null || HostNames.length == 0) {
|
||||
showNoHostFoundDialog();
|
||||
return;
|
||||
}
|
||||
String HostName = (String) JOptionPane.showInputDialog(this,
|
||||
"Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
HostNames, comAdapter.getHostName());
|
||||
if (HostName == null) {
|
||||
return;
|
||||
}
|
||||
LOGGER.info("Kill host process on = " + HostName);
|
||||
comAdapter.killServer(HostName);
|
||||
}
|
||||
|
||||
private void selectAllAvailableHostToKill(String[] hostNames) {
|
||||
System.out.println("SelectAllAvailableHostToKill");
|
||||
if (hostNames == null || hostNames.length == 0) {
|
||||
System.out.println("no host is running");
|
||||
return;
|
||||
}
|
||||
comAdapter.killAllServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performedRestart(String infoString) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
for (OptimizationStateListener l : superListenerList) {
|
||||
l.performedRestart(infoString);
|
||||
}
|
||||
}
|
||||
@ -1192,7 +987,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
@Override
|
||||
public void performedStart(String infoString) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
for (OptimizationStateListener l : superListenerList) {
|
||||
l.performedStart(infoString);
|
||||
}
|
||||
}
|
||||
@ -1203,7 +998,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
@Override
|
||||
public void performedStop() {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
for (OptimizationStateListener l : superListenerList) {
|
||||
l.performedStop();
|
||||
}
|
||||
}
|
||||
@ -1222,7 +1017,7 @@ public class EvAClient extends JFrame implements RemoteStateListener {
|
||||
@Override
|
||||
public void updateProgress(final int percent, String msg) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
for (OptimizationStateListener l : superListenerList) {
|
||||
l.updateProgress(percent, msg);
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,17 @@ import eva2.server.EvAMainAdapter;
|
||||
import eva2.server.EvAMainAdapterImpl;
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.tools.jproxy.*;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EvAComAdapter extends ComAdapter {
|
||||
public class EvAComAdapter {
|
||||
|
||||
private LoggingPanel loggingPanel;
|
||||
private EvAMainAdapterImpl localMainAdapter;
|
||||
private boolean runLocally = false;
|
||||
private static EvAComAdapter m_instance;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -41,7 +41,6 @@ public class EvAComAdapter extends ComAdapter {
|
||||
public static EvAComAdapter getInstance() {
|
||||
if (m_instance == null) {
|
||||
m_instance = new EvAComAdapter();
|
||||
m_instance.addServersFromProperties(EvAInfo.getProperties());
|
||||
}
|
||||
return (EvAComAdapter) m_instance;
|
||||
}
|
||||
@ -53,14 +52,8 @@ public class EvAComAdapter extends ComAdapter {
|
||||
*/
|
||||
public ModuleAdapter getModuleAdapter(String selectedModuleName, InterfaceGOParameters goParams, String noGuiStatsFile) {
|
||||
ModuleAdapter newModuleAdapter;
|
||||
if ((m_RMIServer == null) && isRunLocally()) {
|
||||
newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, true, getHostName(), goParams, noGuiStatsFile, null);
|
||||
} else {
|
||||
newModuleAdapter = ((RMIConnectionEvA) getConnection(getHostName())).getModuleAdapter(selectedModuleName);
|
||||
if (newModuleAdapter == null) {
|
||||
System.err.println("RMI Error for getting ModuleAdapterObject : " + selectedModuleName);
|
||||
}
|
||||
}
|
||||
newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, goParams, noGuiStatsFile);
|
||||
|
||||
return newModuleAdapter;
|
||||
}
|
||||
|
||||
@ -82,19 +75,9 @@ public class EvAComAdapter extends ComAdapter {
|
||||
*/
|
||||
public String[] getModuleNameList() {
|
||||
String[] list;
|
||||
|
||||
if ((m_RMIServer == null) && isRunLocally()) {
|
||||
list = getLocalMainAdapter().getModuleNameList();
|
||||
} else {
|
||||
RMIConnectionEvA Connection = (RMIConnectionEvA) getConnection(getHostName());
|
||||
if (Connection == null) {
|
||||
System.err.println("Couldnt create RMIConnection in EvAComAdapter.getModuleNameList");
|
||||
return null;
|
||||
}
|
||||
list = ((EvAMainAdapter) Connection.getMainAdapter()).getModuleNameList();
|
||||
}
|
||||
list = getLocalMainAdapter().getModuleNameList();
|
||||
if (loggingPanel != null) {
|
||||
loggingPanel.logMessage("List of modules on server:");
|
||||
loggingPanel.logMessage("List of modules available:");
|
||||
}
|
||||
if (list != null) {
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
@ -105,33 +88,4 @@ public class EvAComAdapter extends ComAdapter {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MainAdapter getMainAdapter(RMIInvocationHandler invocHandler) throws RemoteException {
|
||||
try {
|
||||
return (EvAMainAdapter) invocHandler.getWrapper();
|
||||
} catch (ClassCastException e) {
|
||||
System.err.println("Warning: cannot cast to EvAMainAdapter in EvAComAdapter.. trying MainAdapter...");
|
||||
}
|
||||
return (MainAdapter) invocHandler.getWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RMIConnection createRMIConnection(String Host, MainAdapter mainRemoteObject, MainAdapterClient client) {
|
||||
return new RMIConnectionEvA(Host, mainRemoteObject, client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the runLocally
|
||||
*/
|
||||
public boolean isRunLocally() {
|
||||
return runLocally;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param runLocally the runLocally to set
|
||||
*/
|
||||
public void setRunLocally(boolean runLocally) {
|
||||
this.runLocally = runLocally;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package eva2.client;
|
||||
|
||||
import eva2.server.EvAMainAdapter;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.tools.jproxy.MainAdapter;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class RMIConnectionEvA extends RMIConnection {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RMIConnectionEvA(String HostName, MainAdapter Adapter,
|
||||
MainAdapterClient AdapterClient) {
|
||||
super(HostName, Adapter, AdapterClient);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ModuleAdapter getModuleAdapter(String Modul) {
|
||||
if (m_MainAdapter instanceof EvAMainAdapter) {
|
||||
EvAMainAdapter evaAdapter = (EvAMainAdapter)m_MainAdapter;
|
||||
ModuleAdapter ret = null;
|
||||
if (TRACE) {
|
||||
System.out.println("ComAdapter.getModuleAdapter(" + Modul + ")");
|
||||
}
|
||||
String hostAdd = "";
|
||||
try {
|
||||
hostAdd = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
hostAdd = "unknown host";
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println(" Client is = " + hostAdd);
|
||||
}
|
||||
m_MainAdapter.setBuf("Test_1");
|
||||
|
||||
ret = evaAdapter.getModuleAdapter(Modul, false, hostAdd, this.m_MainAdapterClient);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
System.err.println("error, couldnt get module adapter in EvAComAdapter.getModuleAdapter. Main adapter is not of type EvAMainAdapter!");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -9,151 +9,127 @@ package eva2.gui;
|
||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIProxyRemote;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
/**
|
||||
* It represents one plot window in the client GUI.
|
||||
*/
|
||||
public class DataViewer implements DataViewerInterface {
|
||||
public static boolean TRACE = false;
|
||||
|
||||
static private int m_GraphCounter = -1;
|
||||
static private ViewContainer m_ViewContainer;
|
||||
private MainAdapterClient m_MainAdapterClient;
|
||||
private static String m_MyHostName;
|
||||
private PlotInterface m_Plotter;
|
||||
private String m_Name;
|
||||
private Plot m_Plot;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static DataViewerInterface getInstance (MainAdapterClient client,String GraphWindowName) {
|
||||
if (m_ViewContainer == null) {
|
||||
m_ViewContainer = new ViewContainer();
|
||||
}
|
||||
DataViewerInterface ret =null;
|
||||
try {
|
||||
if (!m_ViewContainer.containsName(GraphWindowName)) {
|
||||
////////////////////////////////////////////////
|
||||
public static boolean TRACE = false;
|
||||
static private int m_GraphCounter = -1;
|
||||
static private ViewContainer viewContainer;
|
||||
private String m_Name;
|
||||
private Plot m_Plot;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static DataViewerInterface getInstance(String graphWindowName) {
|
||||
if (viewContainer == null) {
|
||||
viewContainer = new ViewContainer();
|
||||
}
|
||||
DataViewerInterface ret = null;
|
||||
try {
|
||||
m_MyHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
System.out.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (client != null && client.getHostName().equals(m_MyHostName)== true) {
|
||||
if (TRACE) {
|
||||
System.out.println("no RMI");
|
||||
if (!viewContainer.containsName(graphWindowName)) {
|
||||
ret = new DataViewer(graphWindowName, true);
|
||||
viewContainer.add(ret);
|
||||
} else {
|
||||
ret = viewContainer.getPlot(graphWindowName);
|
||||
}
|
||||
ret = new DataViewer(GraphWindowName,true);
|
||||
} catch (Exception ee) {
|
||||
System.out.println("GraphWindow ERROR : " + ee.getMessage());
|
||||
ee.printStackTrace();
|
||||
}
|
||||
else {
|
||||
ret = (DataViewerInterface) RMIProxyRemote.newInstance(new DataViewer(GraphWindowName,false), client);
|
||||
ret.init();
|
||||
if (TRACE) {
|
||||
System.out.println("with RMI");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
m_ViewContainer.add(ret);
|
||||
}
|
||||
else {
|
||||
ret = m_ViewContainer.getPlot(GraphWindowName);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
System.out.println("GraphWindow ERROR : "+ee.getMessage());
|
||||
ee.printStackTrace();
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private DataViewer(String PlotName,boolean initflag){
|
||||
if (TRACE) {
|
||||
System.out.println("Constructor DataViewer");
|
||||
}
|
||||
m_Name = PlotName;
|
||||
if(initflag) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getName () {
|
||||
return m_Name;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Graph getNewGraph(String InfoString) {
|
||||
m_GraphCounter++;
|
||||
if (TRACE) {
|
||||
System.out.println("Graph.getNewGraph No:"+m_GraphCounter);
|
||||
}
|
||||
return new Graph (InfoString,m_Plot,m_GraphCounter);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
m_Plot = new Plot(m_Name,"x","y", true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private DataViewer(String PlotName, boolean initflag) {
|
||||
if (TRACE) {
|
||||
System.out.println("Constructor DataViewer");
|
||||
}
|
||||
m_Name = PlotName;
|
||||
if (initflag) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Graph getNewGraph(String InfoString) {
|
||||
m_GraphCounter++;
|
||||
if (TRACE) {
|
||||
System.out.println("Graph.getNewGraph No:" + m_GraphCounter);
|
||||
}
|
||||
return new Graph(InfoString, m_Plot, m_GraphCounter);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
m_Plot = new Plot(m_Name, "x", "y", true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ViewContainer extends ArrayList {
|
||||
private DataViewer m_actualPlot;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ViewContainer() {}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean containsName (String name) {
|
||||
DataViewer temp = null;
|
||||
for (int i=0;i<size();i++) {
|
||||
temp = (DataViewer)(get(i));
|
||||
if (name.equals(temp.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private DataViewer m_actualPlot;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ViewContainer() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DataViewer getPlot (String name) {
|
||||
if (m_actualPlot!=null) {
|
||||
if (m_actualPlot.getName().equals(name)) {
|
||||
return m_actualPlot;
|
||||
}
|
||||
}
|
||||
DataViewer temp = null;
|
||||
for (int i=0;i<size();i++) {
|
||||
temp = (DataViewer)(get(i));
|
||||
if (name.equals(temp.getName())) {
|
||||
m_actualPlot = temp;
|
||||
return m_actualPlot;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boolean containsName(String name) {
|
||||
DataViewer temp = null;
|
||||
for (int i = 0; i < size(); i++) {
|
||||
temp = (DataViewer) (get(i));
|
||||
if (name.equals(temp.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DataViewer getPlot(String name) {
|
||||
if (m_actualPlot != null) {
|
||||
if (m_actualPlot.getName().equals(name)) {
|
||||
return m_actualPlot;
|
||||
}
|
||||
}
|
||||
DataViewer temp = null;
|
||||
for (int i = 0; i < size(); i++) {
|
||||
temp = (DataViewer) (get(i));
|
||||
if (name.equals(temp.getName())) {
|
||||
m_actualPlot = temp;
|
||||
return m_actualPlot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,10 @@ package eva2.gui;
|
||||
* $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.server.stat.EvAJob;
|
||||
import eva2.tools.ToolBoxGui;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
@ -28,7 +27,7 @@ import javax.swing.JToolBar;
|
||||
* Contains the GUI elements of start and stop buttons and optionally a help
|
||||
* button.
|
||||
*/
|
||||
public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializable, PanelMaker {
|
||||
public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Serializable, PanelMaker {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(EvAModuleButtonPanelMaker.class.getName());
|
||||
private String m_Name = "undefined";
|
||||
@ -55,20 +54,9 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
|
||||
public JToolBar makePanel() {
|
||||
toolBar = new JToolBar();
|
||||
toolBar.setFloatable(false);
|
||||
|
||||
/* ToDo: This is useless? */
|
||||
if (moduleAdapter.hasConnection()) { // we might be in rmi mode
|
||||
try {
|
||||
String myhostname = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING, "Could not get hostname", e);
|
||||
}
|
||||
}
|
||||
if (!moduleAdapter.hasConnection()) {
|
||||
moduleAdapter.addRemoteStateListener((RemoteStateListener) (this));
|
||||
} else {// there is a network RMI connection
|
||||
moduleAdapter.addRemoteStateListener((RemoteStateListener) RMIProxyLocal.newInstance(this));
|
||||
}
|
||||
|
||||
moduleAdapter.addOptimizationStateListener((OptimizationStateListener) (this));
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
runButton = ToolBoxGui.createIconifiedButton("images/Play24.gif", "Start", true);
|
||||
@ -159,7 +147,6 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
|
||||
}
|
||||
|
||||
private void makeHelpButton() {
|
||||
///////////////////////////////////////////////////////////////
|
||||
if (helpFileName != null && (!helpFileName.equals(""))) {
|
||||
helpButton = new JButton("Description");
|
||||
helpButton.setToolTipText("Description of the current optimization algorithm.");
|
||||
@ -167,7 +154,6 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//System.out.println("Run Opt pressed !!!!!!!!!!!!!!!!======================!!");
|
||||
try {
|
||||
if (helpFileName != null) {
|
||||
HtmlDemo temp = new HtmlDemo(helpFileName);
|
||||
|
@ -4,7 +4,6 @@ import eva2.server.go.tools.FileTools;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.tools.SerializedObject;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@ -65,7 +64,6 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
private GenericObjectEditor genericObjectEditor = null;
|
||||
private boolean withComboBoxToolTips = true; // should tool tips for the combo box be created?
|
||||
private int tipMaxLen = 100; // maximum length of tool tip
|
||||
|
||||
private HashMap<String, String> classNameMap;
|
||||
|
||||
/**
|
||||
@ -99,17 +97,15 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
propertySheetPanel = new PropertySheetPanel();
|
||||
propertySheetPanel.addPropertyChangeListener(
|
||||
new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(final PropertyChangeEvent event) {
|
||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||
}
|
||||
});
|
||||
public void propertyChange(final PropertyChangeEvent event) {
|
||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||
}
|
||||
});
|
||||
openButton = makeIconButton("images/Open16.gif", "Open");
|
||||
openButton.setToolTipText("Load a configured object");
|
||||
openButton.setEnabled(true);
|
||||
openButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
Object object = FileTools.openObject(openButton, genericObjectEditor.getClassType());
|
||||
@ -128,7 +124,6 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
saveButton.setToolTipText("Save the current configured object");
|
||||
saveButton.setEnabled(true);
|
||||
saveButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
FileTools.saveObjectWithFileChooser(saveButton, genericObjectEditor.getValue());
|
||||
@ -138,14 +133,13 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
okayButton = new JButton("OK");
|
||||
okayButton.setEnabled(true);
|
||||
okayButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
backupObject = copyObject(genericObjectEditor.getValue());
|
||||
|
||||
updateClassType();
|
||||
updateChildPropertySheet();
|
||||
|
||||
|
||||
/*
|
||||
* ToDo: This is really ugly. Find a way to make this better.
|
||||
*/
|
||||
@ -160,7 +154,6 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
cancelButton = new JButton("Cancel");
|
||||
cancelButton.setEnabled(true);
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
if (backupObject != null) {
|
||||
@ -223,26 +216,26 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
}
|
||||
objectChooser.addItemListener(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is duplicated from EvAModuleButtonPanelMaker.
|
||||
* ToDo: Refactor this.
|
||||
* This method is duplicated from EvAModuleButtonPanelMaker. ToDo: Refactor
|
||||
* this.
|
||||
*
|
||||
* @param iconSrc
|
||||
* @param title
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
private JButton makeIconButton(final String iconSrc, final String title) {
|
||||
JButton newButton;
|
||||
byte[] bytes;
|
||||
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
|
||||
if (bytes == null) {
|
||||
newButton = new JButton(title);
|
||||
} else {
|
||||
newButton = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
}
|
||||
return newButton;
|
||||
}
|
||||
JButton newButton;
|
||||
byte[] bytes;
|
||||
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
|
||||
if (bytes == null) {
|
||||
newButton = new JButton(title);
|
||||
} else {
|
||||
newButton = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
}
|
||||
return newButton;
|
||||
}
|
||||
|
||||
public void setEnabledOkCancelButtons(boolean enabled) {
|
||||
okayButton.setEnabled(enabled);
|
||||
@ -316,11 +309,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
protected void updateClassType() {
|
||||
List<String> classesLongNames;
|
||||
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5);
|
||||
if (Proxy.isProxyClass(genericObjectEditor.getClassType())) {
|
||||
classesLongNames = GenericObjectEditor.getClassesFromProperties(((RMIProxyLocal) Proxy.getInvocationHandler(((Proxy) genericObjectEditor.getValue()))).getOriginalClass().getName(), null);
|
||||
} else {
|
||||
classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances);
|
||||
}
|
||||
classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances);
|
||||
if (classesLongNames.size() > 1) {
|
||||
classNameMap = new HashMap<String, String>();
|
||||
for (String className : classesLongNames) {
|
||||
@ -396,7 +385,8 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* When the chooser selection is changed, ensures that the Object is changed appropriately.
|
||||
* When the chooser selection is changed, ensures that the Object is changed
|
||||
* appropriately.
|
||||
*
|
||||
* @param e a value of type 'ItemEvent'
|
||||
*/
|
||||
|
@ -7,7 +7,6 @@ package eva2.gui;
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.tools.ReflectPackage;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import java.awt.Component;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
@ -287,14 +286,8 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
}
|
||||
|
||||
Vector<String> v = null;
|
||||
if (Proxy.isProxyClass(classType)) {
|
||||
//if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName());
|
||||
v = new Vector<String>(getClassesFromProperties(((RMIProxyLocal) Proxy.getInvocationHandler(((Proxy) m_Object))).getOriginalClass().getName(), null));
|
||||
} else {
|
||||
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
||||
}
|
||||
|
||||
// v = new Vector<String>(getClassesFromProperties(m_ClassType.getName()));
|
||||
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
||||
|
||||
try {
|
||||
if (v.size() > 0) {
|
||||
setObject((Object) Class.forName((String) v.get(0)).newInstance());
|
||||
|
@ -1,503 +0,0 @@
|
||||
package eva2.gui;
|
||||
|
||||
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.io.*;
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 14.12.2004
|
||||
* Time: 11:33:43
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
public class GenericRemoteServersEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
/** Handles property change notification */
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
/** The label for when we can't edit that type */
|
||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
||||
/** The FilePath that is to be edited*/
|
||||
private PropertyRemoteServers m_RemoteServers;
|
||||
|
||||
/** The gaphix stuff */
|
||||
private JComponent m_Editor;
|
||||
private JPanel m_ParameterPanel;
|
||||
private JTextField m_Login;
|
||||
private JPasswordField m_Password;
|
||||
private JPanel m_ServerList;
|
||||
private JButton[] m_Status;
|
||||
private JTextField[] m_Names;
|
||||
private JComboBox[] m_CPUs;
|
||||
private JButton[] m_Delete;
|
||||
private int prefEditorHeight = 200;
|
||||
|
||||
public GenericRemoteServersEditor() {
|
||||
|
||||
}
|
||||
|
||||
/** This method will init the CustomEditor Panel
|
||||
*/
|
||||
private void initCustomEditor() {
|
||||
this.m_Editor = new JPanel();
|
||||
// This is the upper panel
|
||||
this.m_ParameterPanel = new JPanel();
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 0, 0, 1);
|
||||
this.m_ParameterPanel.setLayout(new GridBagLayout());
|
||||
this.m_ParameterPanel.add(new JLabel("Login: "), gbc);
|
||||
this.m_Login = new JTextField(""+this.m_RemoteServers.getLogin());
|
||||
this.m_Login.addKeyListener(loginListener);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 2, 1, 0, 100);
|
||||
this.m_ParameterPanel.add(this.m_Login, gbc);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 3, 0, 1);
|
||||
this.m_ParameterPanel.add(new JLabel("Password: "), gbc);
|
||||
this.m_Password = new JPasswordField(""+this.m_RemoteServers.getPassword());
|
||||
this.m_Password.addKeyListener(passwordListener);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 2, 4, 0, 100);
|
||||
this.m_ParameterPanel.add(this.m_Password, gbc);
|
||||
|
||||
JButton tmpB;
|
||||
tmpB = makeButtonWith("images/Add24.gif", "add");
|
||||
tmpB.addActionListener(addServer);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
tmpB = makeButtonWith("images/Export24.gif", "Load");
|
||||
tmpB.addActionListener(loadServers);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
tmpB = makeButtonWith("images/Import24.gif", "Save");
|
||||
tmpB.addActionListener(saveServers);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 2, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
tmpB = makeButtonWith("images/Refresh24.gif", "Update Status");
|
||||
tmpB.addActionListener(updateServers);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 3, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
tmpB = makeButtonWith("images/Play24.gif", "Start Server");
|
||||
tmpB.addActionListener(startServers);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 4, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
tmpB = makeButtonWith("images/Stop24.gif", "Stop Server");
|
||||
tmpB.addActionListener(killServers);
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, 1, 5, 1, 1);
|
||||
this.m_ParameterPanel.add(tmpB, gbc);
|
||||
|
||||
this.m_ServerList = new JPanel();
|
||||
this.updateServerList();
|
||||
JScrollPane scrollServer = new JScrollPane(this.m_ServerList);
|
||||
scrollServer.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollServer.setPreferredSize(new Dimension(200,prefEditorHeight));
|
||||
|
||||
this.m_Editor.setLayout(new BorderLayout());
|
||||
this.m_Editor.add(this.m_ParameterPanel, BorderLayout.NORTH);
|
||||
this.m_Editor.add(scrollServer, BorderLayout.CENTER);
|
||||
this.updateEditor();
|
||||
}
|
||||
|
||||
private JButton makeButtonWith(String iconSrc, String title) {
|
||||
JButton tmpB;
|
||||
byte[] bytes;
|
||||
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
|
||||
if (bytes!=null) {
|
||||
tmpB = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
}
|
||||
else {
|
||||
tmpB = new JButton(title);
|
||||
}
|
||||
return tmpB;
|
||||
}
|
||||
|
||||
/** This method updates the server list
|
||||
*
|
||||
*/
|
||||
private void updateServerList() {
|
||||
byte[] bytes;
|
||||
ServerNode t;
|
||||
this.m_ServerList.removeAll();
|
||||
this.m_ServerList.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
this.m_Status = new JButton[this.m_RemoteServers.size()];
|
||||
this.m_Names = new JTextField[this.m_RemoteServers.size()];
|
||||
this.m_CPUs = new JComboBox[this.m_RemoteServers.size()];
|
||||
this.m_Delete = new JButton[this.m_RemoteServers.size()];
|
||||
String[] cups = new String[8];
|
||||
for (int i = 0; i < cups.length; i++) {
|
||||
cups[i] = ""+(i+1);
|
||||
}
|
||||
// The head title
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 0, 1);
|
||||
this.m_ServerList.add(new JLabel("Status"), gbc);
|
||||
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 1, 80);
|
||||
this.m_ServerList.add(new JLabel("Server Name"), gbc);
|
||||
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 2, 10);
|
||||
this.m_ServerList.add(new JLabel("CPUs"), gbc);
|
||||
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.REMAINDER, 3, 10);
|
||||
this.m_ServerList.add(new JLabel("Remove"), gbc);
|
||||
|
||||
for (int i = 0; i < this.m_RemoteServers.size(); i++) {
|
||||
t = this.m_RemoteServers.get(i);
|
||||
// the status indicator
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 0, 1);
|
||||
this.m_Status[i] = new JButton(" ");
|
||||
this.m_Status[i].setEnabled(false);
|
||||
if (this.m_RemoteServers.isServerOnline(t.m_ServerName)) {
|
||||
this.m_Status[i].setBackground(Color.GREEN);
|
||||
}
|
||||
else {
|
||||
this.m_Status[i].setBackground(Color.RED);
|
||||
}
|
||||
this.m_ServerList.add(this.m_Status[i], gbc);
|
||||
// the server name
|
||||
gbc = new GridBagConstraints();
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 1, 80);
|
||||
this.m_Names[i] = new JTextField(""+t.m_ServerName);
|
||||
this.m_Names[i].addKeyListener(serverNameListener);
|
||||
this.m_ServerList.add(this.m_Names[i], gbc);
|
||||
// the number of CPUs
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 2, 10);
|
||||
this.m_CPUs[i] = new JComboBox(cups);
|
||||
this.m_CPUs[i].setSelectedIndex(t.m_CPUs-1);
|
||||
this.m_CPUs[i].addItemListener(cpuStateListener);
|
||||
this.m_ServerList.add(this.m_CPUs[i], gbc);
|
||||
// The delete button
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.REMAINDER, 3, 10);
|
||||
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation("images/Sub24.gif", true);
|
||||
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
this.m_Delete[i].addActionListener(deleteServer);
|
||||
this.m_ServerList.add(this.m_Delete[i], gbc);
|
||||
}
|
||||
String[] h = this.m_RemoteServers.getCheckedServerNodes();
|
||||
// System.out.println("My active nodes: ");
|
||||
// for (int i = 0; i < h.length; i++) {
|
||||
// System.out.println(""+h[i]);
|
||||
// }
|
||||
this.m_ServerList.repaint();
|
||||
this.m_ServerList.validate();
|
||||
}
|
||||
|
||||
private void setGBC(GridBagConstraints gbc, int anchor, int fill, int gridx, int weightx) {
|
||||
gbc.anchor = anchor;
|
||||
gbc.fill = fill;
|
||||
gbc.gridx = gridx;
|
||||
gbc.weightx = weightx;
|
||||
}
|
||||
|
||||
private void setGBC(GridBagConstraints gbc, int anchor, int fill, int gridwidth, int gridx, int gridy, int weightx) {
|
||||
setGBC(gbc, anchor, fill, gridx, weightx);
|
||||
gbc.gridwidth = gridwidth;
|
||||
gbc.gridy = gridy;
|
||||
}
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener saveServers = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String text = m_RemoteServers.writeToText();
|
||||
JFileChooser saver = new JFileChooser();
|
||||
int option = saver.showSaveDialog(m_Editor);
|
||||
if (option == JFileChooser.APPROVE_OPTION) {
|
||||
// now save the stuff to the file
|
||||
File file = saver.getSelectedFile();
|
||||
try {
|
||||
BufferedWriter OutputFile = new BufferedWriter(new OutputStreamWriter (new FileOutputStream (file.getAbsolutePath())));
|
||||
OutputFile.write(text);
|
||||
OutputFile.close();
|
||||
} catch (FileNotFoundException t) {
|
||||
System.err.println("Could not open output file! Filename: " + file.getName());
|
||||
} catch (java.io.IOException t) {
|
||||
System.err.println("Could not write to output file! Filename: " + file.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener killServers = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_RemoteServers.killServers();
|
||||
updateServerList();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener startServers = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_RemoteServers.startServers();
|
||||
updateServerList();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener updateServers = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
updateServerList();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener addServer = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_RemoteServers.addServerNode("noname-"+m_RemoteServers.size(), 1);
|
||||
updateServerList();
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener deleteServer = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
for (int i = 0; i < m_Delete.length; i++) {
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_RemoteServers.removeServerNode(m_RemoteServers.get(i).m_ServerName);
|
||||
}
|
||||
}
|
||||
updateServerList();
|
||||
updateEditor();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener,...
|
||||
*/
|
||||
ActionListener loadServers = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String text = "";
|
||||
JFileChooser reader = new JFileChooser();
|
||||
int option = reader.showOpenDialog(m_Editor);
|
||||
if (option == JFileChooser.APPROVE_OPTION) {
|
||||
// now save the stuff to the file
|
||||
File file = reader.getSelectedFile();
|
||||
try {
|
||||
BufferedReader inputFile = new BufferedReader(new FileReader(file.getAbsolutePath()));
|
||||
String line;
|
||||
while ((line = inputFile.readLine()) != null) {
|
||||
text += line +"\n";
|
||||
}
|
||||
inputFile.close();
|
||||
m_RemoteServers.readFromText(text);
|
||||
// text = inputFile.readLine().read();
|
||||
// OutputFile.close();
|
||||
} catch (FileNotFoundException t) {
|
||||
System.out.println("Could not open output file! Filename: " + file.getName());
|
||||
} catch (java.io.IOException t) {
|
||||
System.out.println("Could not write to output file! Filename: " + file.getName());
|
||||
}
|
||||
}
|
||||
updateServerList();
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener reads all values
|
||||
*/
|
||||
KeyListener loginListener = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyTyped(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
m_RemoteServers.setLogin(m_Login.getText());
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener reads all values
|
||||
*/
|
||||
KeyListener passwordListener = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyTyped(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
m_RemoteServers.setPassword(m_Password.getPassword());
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener reads all values
|
||||
*/
|
||||
KeyListener serverNameListener = new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyTyped(KeyEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
for (int i = 0; i < m_Names.length; i++) {
|
||||
if (event.getSource().equals(m_Names[i])) {
|
||||
m_RemoteServers.setNameFor(i, m_Names[i].getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener adds an element to DoubleArray
|
||||
*/
|
||||
ItemListener cpuStateListener = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
for (int i = 0; i < m_CPUs.length; i++) {
|
||||
if (event.getSource().equals(m_CPUs[i])) {
|
||||
m_RemoteServers.setCPUsFor(i, m_CPUs[i].getSelectedIndex()+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** The object may have changed update the editor.
|
||||
*/
|
||||
private void updateEditor() {
|
||||
if (this.m_Editor != null) {
|
||||
this.m_Editor.validate();
|
||||
this.m_Editor.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** This method will set the value of object that is to be edited.
|
||||
* @param o an object that must be an array.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
if (o instanceof PropertyRemoteServers) {
|
||||
this.m_RemoteServers = (PropertyRemoteServers) o;
|
||||
this.updateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the current object.
|
||||
* @return the current object
|
||||
*/
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return this.m_RemoteServers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJavaInitializationString() {
|
||||
return "TEST";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException(text);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
/** This is used to hook an action listener to the ok button
|
||||
* @param a The action listener.
|
||||
*/
|
||||
public void addOkListener(ActionListener a) {
|
||||
//m_OKButton.addActionListener(a);
|
||||
}
|
||||
|
||||
/** This is used to remove an action listener from the ok button
|
||||
* @param a The action listener
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
//m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/** Returns true since the Object can be shown
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Paints a representation of the current classifier.
|
||||
*
|
||||
* @param gfx the graphics context to use
|
||||
* @param box the area we are allowed to paint into
|
||||
*/
|
||||
@Override
|
||||
public void paintValue(Graphics gfx, Rectangle box) {
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent()) / 2;
|
||||
String rep = "Remote Servers";
|
||||
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 );
|
||||
}
|
||||
|
||||
/** Returns true because we do support a custom editor.
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns the array editing component.
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_Editor;
|
||||
}
|
||||
}
|
@ -5,9 +5,6 @@ package eva2.gui;
|
||||
* $ $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIProxyRemote;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@ -18,14 +15,13 @@ public class GraphWindow {
|
||||
public static boolean TRACE = false;
|
||||
static private int graphCounter = -1;
|
||||
static private PlotContainer plotContainer;
|
||||
private MainAdapterClient mainAdapterClient;
|
||||
private PlotInterface plotter;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static GraphWindow getInstance(MainAdapterClient client, String graphWindowName,
|
||||
public static GraphWindow getInstance(String graphWindowName,
|
||||
String strx, String stry) {
|
||||
if (plotContainer == null) {
|
||||
plotContainer = new PlotContainer();
|
||||
@ -39,7 +35,7 @@ public class GraphWindow {
|
||||
if (ret != null) {
|
||||
plotContainer.remove(ret); // remove if not valid any more
|
||||
}
|
||||
ret = new GraphWindow(client, graphWindowName, strx, stry);
|
||||
ret = new GraphWindow(graphWindowName, strx, stry);
|
||||
plotContainer.add(ret);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
@ -60,28 +56,12 @@ public class GraphWindow {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private GraphWindow(MainAdapterClient client, String plotName, String strx, String stry) {
|
||||
private GraphWindow(String plotName, String strx, String stry) {
|
||||
if (TRACE) {
|
||||
System.out.println("Constructor GraphWindow");
|
||||
}
|
||||
mainAdapterClient = client;
|
||||
name = plotName;
|
||||
try {
|
||||
if ((client == null) || client.getHostName().equals(InetAddress.getLocalHost().getHostName())) {
|
||||
if (TRACE) {
|
||||
System.out.println("no RMI");
|
||||
}
|
||||
plotter = new Plot(plotName, strx, stry, true);
|
||||
} else {
|
||||
plotter = (PlotInterface) RMIProxyRemote.newInstance(new Plot(plotName, strx, stry, false), mainAdapterClient);
|
||||
plotter.init();
|
||||
if (TRACE) {
|
||||
System.out.println("with RMI");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage());
|
||||
}
|
||||
plotter = new Plot(plotName, strx, stry, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +226,6 @@ public class PropertyEditorProvider {
|
||||
PropertyEditorManager.registerEditor(PropertyWeightedLPTchebycheff.class, GenericWeigthedLPTchebycheffEditor.class);
|
||||
// PropertyEditorManager.registerEditor(PropertyStringList.class , GenericStringListSelectionEditor.class);
|
||||
PropertyEditorManager.registerEditor(PropertyFilePath.class , GenericFilePathEditor.class);
|
||||
PropertyEditorManager.registerEditor(PropertyRemoteServers.class , GenericRemoteServersEditor.class);
|
||||
PropertyEditorManager.registerEditor(PropertyOptimizationObjectives.class , GenericOptimizationObjectivesEditor.class);
|
||||
PropertyEditorManager.registerEditor(PropertyOptimizationObjectivesWithParam.class , GenericOptimizationObjectivesWithParamEditor.class);
|
||||
PropertyEditorManager.registerEditor(eva2.gui.MultiLineString.class, eva2.gui.MultiLineStringEditor.class);
|
||||
|
@ -1,312 +0,0 @@
|
||||
package eva2.gui;
|
||||
|
||||
import eva2.tools.jproxy.RMIInvocationHandler;
|
||||
import java.rmi.Naming;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 14.12.2004
|
||||
* Time: 11:33:10
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
class ServerNode implements java.io.Serializable {
|
||||
public String m_ServerName;
|
||||
public int m_CPUs;
|
||||
|
||||
public ServerNode(String name, int cpus) {
|
||||
m_ServerName = name;
|
||||
m_CPUs = cpus;
|
||||
}
|
||||
public ServerNode(ServerNode a) {
|
||||
this.m_CPUs = a.m_CPUs;
|
||||
this.m_ServerName = a.m_ServerName;
|
||||
}
|
||||
@Override
|
||||
public Object clone() {
|
||||
return (Object) new ServerNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class PropertyRemoteServers implements java.io.Serializable {
|
||||
|
||||
private ServerNode[] m_AvailableNodes=null;
|
||||
// private String m_ClassToStart = "eva2.tools.jproxy.RMIServer";
|
||||
private transient String m_password = "";
|
||||
private String m_Login = "";
|
||||
// private boolean m_DeployJar = true;
|
||||
// private String m_JarToDeploy = "JOpt.jar";
|
||||
|
||||
public PropertyRemoteServers() {
|
||||
this.m_AvailableNodes = new ServerNode[0];
|
||||
this.addServerNode("exampleNode.uni-tuebingen.de", 2);
|
||||
this.setLogin("username");
|
||||
this.setPassword("");
|
||||
}
|
||||
|
||||
public PropertyRemoteServers(PropertyRemoteServers e) {
|
||||
this();
|
||||
if (e.m_AvailableNodes != null) {
|
||||
this.m_AvailableNodes = new ServerNode[e.m_AvailableNodes.length];
|
||||
for (int i = 0; i < e.m_AvailableNodes.length; i++) {
|
||||
this.m_AvailableNodes[i] = (ServerNode)e.m_AvailableNodes[i].clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return (Object) new PropertyRemoteServers(this);
|
||||
}
|
||||
|
||||
/** This method adds a server to the server nodes list
|
||||
* It will check whether or not the given name is already
|
||||
* in the current list of nodes is so it breaks.
|
||||
* @param name The name of the server
|
||||
* @param cpus The number of cpus on the server
|
||||
*/
|
||||
|
||||
public void addServerNode(String name, int cpus) {
|
||||
// first check for double instances
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
if (this.m_AvailableNodes[i].m_ServerName.equalsIgnoreCase(name)) {
|
||||
if (cpus > this.m_AvailableNodes[i].m_CPUs) {
|
||||
this.m_AvailableNodes[i].m_CPUs = cpus;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// now add the guy
|
||||
ServerNode[] newList = new ServerNode[this.m_AvailableNodes.length+1];
|
||||
ServerNode newNode = new ServerNode(name, cpus);
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
newList[i] = this.m_AvailableNodes[i];
|
||||
}
|
||||
newList[this.m_AvailableNodes.length] = newNode;
|
||||
this.m_AvailableNodes = newList;
|
||||
}
|
||||
|
||||
/** This method removes a surplus node from the current list
|
||||
* @param name The name of the server to remove
|
||||
*/
|
||||
public void removeServerNode(String name) {
|
||||
ArrayList newList = new ArrayList();
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
if (!this.m_AvailableNodes[i].m_ServerName.equalsIgnoreCase(name)) {
|
||||
newList.add(this.m_AvailableNodes[i]);
|
||||
} else {
|
||||
this.killServer(this.m_AvailableNodes[i].m_ServerName);
|
||||
}
|
||||
}
|
||||
this.m_AvailableNodes = new ServerNode[newList.size()];
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
this.m_AvailableNodes[i] = (ServerNode)newList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method removes and deactivates all servers
|
||||
*
|
||||
*/
|
||||
public void removeAll() {
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
this.killServer(this.m_AvailableNodes[i].m_ServerName);
|
||||
}
|
||||
this.m_AvailableNodes = new ServerNode[0];
|
||||
}
|
||||
|
||||
/** This method returns an unchecked list of server instances
|
||||
* an server with n nodes will occur n times in the returned
|
||||
* server list
|
||||
* @return A list of server instances, with double instances.
|
||||
*/
|
||||
public String[] getServerNodes() {
|
||||
String[] result;
|
||||
ArrayList<String> tmpList = new ArrayList<String>();
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
for (int j = 0; j < this.m_AvailableNodes[i].m_CPUs; j++) {
|
||||
tmpList.add(this.m_AvailableNodes[i].m_ServerName);
|
||||
}
|
||||
}
|
||||
result = new String[tmpList.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = (String) tmpList.get(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method returns an checked list of server instances
|
||||
* an server with n nodes will occur n times in the returned
|
||||
* server list
|
||||
* @return A list of server instances, with double instances.
|
||||
*/
|
||||
public String[] getCheckedServerNodes() {
|
||||
String[] result;
|
||||
ArrayList tmpList = new ArrayList();
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
if (this.isServerOnline(this.m_AvailableNodes[i].m_ServerName)) {
|
||||
for (int j = 0; j < this.m_AvailableNodes[i].m_CPUs; j++) {
|
||||
tmpList.add(this.m_AvailableNodes[i].m_ServerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
result = new String[tmpList.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = (String) tmpList.get(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method will check whether or not a given server is online
|
||||
* @param name The name of the server to check
|
||||
* @return true if server is online, false else
|
||||
*/
|
||||
public boolean isServerOnline(String name) {
|
||||
try {
|
||||
String[] list = Naming.list("rmi://" + name + ":" + 1099);
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception et) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will try to start all server in the current list
|
||||
*/
|
||||
public void startServers() {
|
||||
/* ServerStarter serverstarter;
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
if (!this.isServerOnline(this.m_AvailableNodes[i].m_ServerName)) {
|
||||
serverstarter = new ServerStarter();
|
||||
serverstarter.setPasswd(this.m_password);
|
||||
serverstarter.setClass2Run(this.m_ClassToStart);
|
||||
serverstarter.setDeployJarFile(this.m_DeployJar);
|
||||
serverstarter.setJarfilename(this.m_JarToDeploy);
|
||||
serverstarter.setHostname(this.m_AvailableNodes[i].m_ServerName);
|
||||
serverstarter.setLogin(this.m_Login);
|
||||
try {
|
||||
serverstarter.startServer();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Problems starting the server: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/** This method kills the servers
|
||||
* previously started
|
||||
*/
|
||||
public void killServers() {
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
this.killServer(this.m_AvailableNodes[i].m_ServerName);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method kills a single server
|
||||
* @param name The name of the server to kill
|
||||
*/
|
||||
public void killServer(String name) {
|
||||
if (this.isServerOnline(name)) {
|
||||
try {
|
||||
String[] list = Naming.list("rmi://" + name + ":" + 1099);
|
||||
for (int j = 0; j < list.length; j++) {
|
||||
System.out.println(""+list[j]);
|
||||
if (list[j].indexOf(this.m_Login) > 0) {
|
||||
RMIInvocationHandler x = (RMIInvocationHandler) Naming.lookup("rmi:"+list[j]);
|
||||
//x.invoke("killThread", null);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error : "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** This method returns the number of servers
|
||||
* @return the size
|
||||
*/
|
||||
public int size() {
|
||||
return this.m_AvailableNodes.length;
|
||||
}
|
||||
|
||||
public ServerNode get(int i) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
return this.m_AvailableNodes[i];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String writeToText() {
|
||||
String result = "";
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
result += this.m_AvailableNodes[i].m_ServerName +"\t"+this.m_AvailableNodes[i].m_CPUs+"\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setNameFor(int i, String name) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
this.m_AvailableNodes[i].m_ServerName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCPUsFor(int i, int c) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
this.m_AvailableNodes[i].m_CPUs = c;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromText(String text) {
|
||||
String[] lines = text.split("\n");
|
||||
this.removeAll();
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] rickel = lines[i].split("\t");
|
||||
this.addServerNode(rickel[0].trim(), new Integer(rickel[1].trim()).intValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
PropertyRemoteServers test = new PropertyRemoteServers();
|
||||
test.m_password = "";
|
||||
test.addServerNode("raold1.informatik.uni-tuebingen.de", 2);
|
||||
//test.addServerNode("raold2.informatik.uni-tuebingen.de", 2);
|
||||
System.out.println(" Getting running Servers:");
|
||||
String[] servers = test.getCheckedServerNodes();
|
||||
for (int i = 0; i < servers.length; i++) {
|
||||
System.out.println("Server "+i+": "+servers[i]);
|
||||
}
|
||||
System.out.println("\n Starting Servers: ");
|
||||
test.startServers();
|
||||
System.out.println(" Getting running Servers:");
|
||||
servers = test.getCheckedServerNodes();
|
||||
for (int i = 0; i < servers.length; i++) {
|
||||
System.out.println("Server "+i+": "+servers[i]);
|
||||
}
|
||||
test.killServers();
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return this.m_Login;
|
||||
}
|
||||
public void setLogin(String l) {
|
||||
this.m_Login = l;
|
||||
}
|
||||
public String getPassword() {
|
||||
return this.m_password;
|
||||
}
|
||||
public void setPassword(String l) {
|
||||
this.m_password = l;
|
||||
}
|
||||
public void setPassword(char[] l) {
|
||||
this.m_password = new String(l);
|
||||
}
|
||||
}
|
16
src/eva2/optimization/OptimizationStateListener.java
Normal file
16
src/eva2/optimization/OptimizationStateListener.java
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package eva2.optimization;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author becker
|
||||
*/
|
||||
public interface OptimizationStateListener {
|
||||
void performedStop();
|
||||
void performedStart(String infoString);
|
||||
void performedRestart(String infoString);
|
||||
void updateProgress(final int percent, String msg);
|
||||
}
|
@ -10,25 +10,15 @@ package eva2.server;
|
||||
*/
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.tools.jproxy.MainAdapter;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface EvAMainAdapter extends MainAdapter {
|
||||
public interface EvAMainAdapter {
|
||||
|
||||
public String[] getModuleNameList();
|
||||
// returns the corresponding ModuleAdapter
|
||||
|
||||
public ModuleAdapter getModuleAdapter(String selectedModuleName,
|
||||
boolean withoutRMI,
|
||||
String hostAddress,
|
||||
MainAdapterClient client);
|
||||
ModuleAdapter getModuleAdapter(String selectedModuleName);
|
||||
|
||||
public ModuleAdapter getModuleAdapter(String selectedModuleName,
|
||||
boolean withoutRMI,
|
||||
String hostAddress,
|
||||
InterfaceGOParameters goParams,
|
||||
String noGuiStatsFile,
|
||||
MainAdapterClient client);
|
||||
ModuleAdapter getModuleAdapter(String selectedModuleName, InterfaceGOParameters goParams, String noGuiStatsFile);
|
||||
}
|
||||
|
@ -12,12 +12,10 @@ package eva2.server;
|
||||
import eva2.EvAInfo;
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.MainAdapterImpl;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EvAMainAdapterImpl extends MainAdapterImpl implements EvAMainAdapter {
|
||||
public class EvAMainAdapterImpl implements EvAMainAdapter {
|
||||
|
||||
private ModuleServer moduleServer = null;
|
||||
|
||||
@ -32,13 +30,13 @@ public class EvAMainAdapterImpl extends MainAdapterImpl implements EvAMainAdapte
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleAdapter getModuleAdapter(String selectedModule, boolean withoutRMI, String hostAddress, MainAdapterClient client) {
|
||||
return getModuleAdapter(selectedModule, withoutRMI, hostAddress, null, null, client);
|
||||
public ModuleAdapter getModuleAdapter(String selectedModule) {
|
||||
return getModuleAdapter(selectedModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleAdapter getModuleAdapter(String selectedModule, boolean withoutRMI, String hostAddress, InterfaceGOParameters goParams, String noGuiStatsFile, MainAdapterClient client) {
|
||||
return moduleServer.createModuleAdapter(selectedModule, client, withoutRMI, hostAddress, goParams, noGuiStatsFile);
|
||||
public ModuleAdapter getModuleAdapter(String selectedModule, InterfaceGOParameters goParams, String noGuiStatsFile) {
|
||||
return moduleServer.createModuleAdapter(selectedModule, goParams, noGuiStatsFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,144 +0,0 @@
|
||||
package eva2.server;
|
||||
/*
|
||||
* Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of
|
||||
* Tuebingen, Computer Architecture @author Holger Ulmer, Felix Streichert,
|
||||
* Hannes Planatscher @version: $Revision: 320 $ $Date: 2007-12-06 16:05:11
|
||||
* +0100 (Thu, 06 Dec 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EvAServer {
|
||||
/*
|
||||
* MainAdapterImp object. This is need for the first connection between the
|
||||
* server and the client program.
|
||||
*/
|
||||
private EvAMainAdapter mainRemoteObject;
|
||||
//private EvAComAdapter m_ComAdapter;
|
||||
private static String userName;
|
||||
private RMIServerEvA rmiServer;
|
||||
private static final Logger LOGGER = Logger.getLogger(EvAServer.class.getName());
|
||||
|
||||
/**
|
||||
* Constructor of EvAServer. Calls RMIConnection().
|
||||
*/
|
||||
public EvAServer(boolean insideClient, boolean restart) {
|
||||
LOGGER.log(Level.INFO, "Number of CPUs :{0}", Runtime.getRuntime().availableProcessors());
|
||||
LOGGER.log(Level.INFO, "This is EvA Server Version: {0}", EvAInfo.getVersion());
|
||||
LOGGER.log(Level.INFO, "Java Version: {0}", System.getProperty("java.version"));
|
||||
try {
|
||||
userName = System.getProperty("user.name");
|
||||
} catch (SecurityException ex) {
|
||||
/*
|
||||
* This exception is expected to happen in Java WebStart
|
||||
*/
|
||||
LOGGER.log(Level.WARNING, "Could not fetch username property. Setting username to 'WebStart'", ex);
|
||||
userName = "WebStart";
|
||||
}
|
||||
|
||||
rmiServer = RMIServerEvA.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method of this class. Is the starting point of the server
|
||||
* application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
boolean restart = false;
|
||||
boolean noMulti = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("args = " + args[i]);
|
||||
if (args[i].equals("restart")) {
|
||||
restart = true;
|
||||
}
|
||||
if (args[i].equals("nomulti")) {
|
||||
noMulti = true;
|
||||
}
|
||||
|
||||
}
|
||||
//Runtime.getRuntime().addShutdownHook(new ExitThread());
|
||||
if (restart == true) {
|
||||
String hostName = "Host";
|
||||
try {
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
System.out.println("ERROR getting HostName (EvAServer.main) " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
|
||||
try {
|
||||
System.setOut(new PrintStream(
|
||||
new FileOutputStream(hostName + "_server.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("System.setOut" + e.getMessage());
|
||||
}
|
||||
}
|
||||
EvAServer evaServer = new EvAServer(false, restart); // false => started not inside the client, solo server
|
||||
// if (nomulti==false)
|
||||
// evaServer.multiServers(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void multiServers(int size) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
try {
|
||||
String cmd = "java -cp \".\" eva2.server.EvAServer nomulti";
|
||||
System.out.println("Calling the command:" + cmd);
|
||||
Process pro = Runtime.getRuntime().exec(cmd);
|
||||
//Process pro = Runtime.getRuntime().exec("server");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
|
||||
//pro
|
||||
String line = null;
|
||||
while (true) {
|
||||
while ((line = in.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
//System.out.println("");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in calling the command:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RMIServerEvA getRMIServer() {
|
||||
return rmiServer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int getNumberOfVM(String[] list) {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (list[i].indexOf(EvAMainAdapterImpl.MAIN_ADAPTER_NAME) != -1) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -15,8 +15,6 @@ import eva2.server.modules.GOModuleAdapter;
|
||||
import eva2.server.modules.ModuleAdapter;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.ReflectPackage;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -29,50 +27,50 @@ import java.util.logging.Logger;
|
||||
* Collect available ModuleAdapter implementations and load them on request.
|
||||
*/
|
||||
public class ModuleServer {
|
||||
private static final Logger LOGGER = Logger.getLogger(ModuleServer.class.getName());
|
||||
private static int instanceCounter = 0;
|
||||
private List<Class<?>> moduleClassList;
|
||||
private ModuleAdapter moduleAdapter;
|
||||
private int moduleAdapterCounter = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ModuleServer(Properties EvAProps) {
|
||||
if (instanceCounter > 0) {
|
||||
EVAERROR.EXIT("ModuleServer created twice");
|
||||
}
|
||||
moduleClassList = new ArrayList<Class<?>>();
|
||||
private static final Logger LOGGER = Logger.getLogger(ModuleServer.class.getName());
|
||||
private static int instanceCounter = 0;
|
||||
private List<Class<?>> moduleClassList;
|
||||
private ModuleAdapter moduleAdapter;
|
||||
private int moduleAdapterCounter = 0;
|
||||
|
||||
String modulePckg = null;
|
||||
Class<?> filterBy = null;
|
||||
try {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ModuleServer(Properties EvAProps) {
|
||||
if (instanceCounter > 0) {
|
||||
EVAERROR.EXIT("ModuleServer created twice");
|
||||
}
|
||||
moduleClassList = new ArrayList<Class<?>>();
|
||||
|
||||
String modulePckg = null;
|
||||
Class<?> filterBy = null;
|
||||
try {
|
||||
/* Fetch the name of the package containing the modules */
|
||||
modulePckg = EvAProps.getProperty("ModulePackage");
|
||||
modulePckg = EvAProps.getProperty("ModulePackage");
|
||||
/* Fetch the the super class for all modules */
|
||||
filterBy = Class.forName(EvAProps.getProperty("ModuleFilterClass"));
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Creating ModuleServer failed: couldnt load modules:" + ex.getMessage());
|
||||
System.err.println("module path was " + modulePckg + ", is it valid?");
|
||||
System.err.println("filter class path was " + ((filterBy == null) ? "null" : filterBy.getName()));
|
||||
}
|
||||
filterBy = Class.forName(EvAProps.getProperty("ModuleFilterClass"));
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Creating ModuleServer failed: couldnt load modules:" + ex.getMessage());
|
||||
System.err.println("module path was " + modulePckg + ", is it valid?");
|
||||
System.err.println("filter class path was " + ((filterBy == null) ? "null" : filterBy.getName()));
|
||||
}
|
||||
|
||||
// this gets a list of all valid modules from the package
|
||||
Class<?>[] classes = ReflectPackage.getAssignableClassesInPackage(modulePckg, filterBy, true, true);
|
||||
for (Object cls : classes) {
|
||||
moduleClassList.add((Class<?>) cls);
|
||||
}
|
||||
// this gets a list of all valid modules from the package
|
||||
Class<?>[] classes = ReflectPackage.getAssignableClassesInPackage(modulePckg, filterBy, true, true);
|
||||
for (Object cls : classes) {
|
||||
moduleClassList.add((Class<?>) cls);
|
||||
}
|
||||
|
||||
instanceCounter++;
|
||||
}
|
||||
instanceCounter++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over the list of available modules and fetches
|
||||
* the name of the module by calling the static getName()
|
||||
* method.
|
||||
*
|
||||
/**
|
||||
* Iterates over the list of available modules and fetches the name of the
|
||||
* module by calling the static getName() method.
|
||||
*
|
||||
* @return Array of available modules
|
||||
*/
|
||||
*/
|
||||
public String[] getModuleNameList() {
|
||||
List<String> moduleNameList = new ArrayList<String>();
|
||||
for (Class<?> module : moduleClassList) {
|
||||
@ -113,86 +111,71 @@ public class ModuleServer {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the module indicated by the selectedModuleName from all available
|
||||
* module classes; if necessary through a remote proxy. Try to load a given
|
||||
* parameter file in case its a GOModuleAdapter.
|
||||
*
|
||||
* @return the loaded module adapter instance
|
||||
*/
|
||||
public ModuleAdapter createModuleAdapter(String selectedModuleName,
|
||||
MainAdapterClient Client, boolean runWithoutRMI,
|
||||
String hostAddress, InterfaceGOParameters goParams, String noGuiLogFile) {
|
||||
moduleAdapterCounter++;
|
||||
String adapterName = "ERROR MODULADAPTER !!";
|
||||
String moduleName = null;
|
||||
Method[] methods;
|
||||
/**
|
||||
* Load the module indicated by the selectedModuleName from all available
|
||||
* module classes; if necessary through a remote proxy. Try to load a given
|
||||
* parameter file in case its a GOModuleAdapter.
|
||||
*
|
||||
* @return the loaded module adapter instance
|
||||
*/
|
||||
public ModuleAdapter createModuleAdapter(String selectedModuleName, InterfaceGOParameters goParams, String noGuiLogFile) {
|
||||
moduleAdapterCounter++;
|
||||
String adapterName = "ERROR MODULADAPTER !!";
|
||||
String moduleName = null;
|
||||
Method[] methods;
|
||||
for (Class<?> module : moduleClassList) {
|
||||
try {
|
||||
methods = module.getDeclaredMethods();
|
||||
try {
|
||||
methods = module.getDeclaredMethods();
|
||||
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals("getName")) {
|
||||
moduleName = (String) method.invoke((Object[]) null, (Object[]) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
if ((moduleName != null) && (selectedModuleName.equals(moduleName))) {
|
||||
try {
|
||||
adapterName = moduleAdapterCounter + "_Running_" + selectedModuleName;
|
||||
if (method.getName().equals("getName")) {
|
||||
moduleName = (String) method.invoke((Object[]) null, (Object[]) null);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
if ((moduleName != null) && (selectedModuleName.equals(moduleName))) {
|
||||
try {
|
||||
adapterName = moduleAdapterCounter + "_Running_" + selectedModuleName;
|
||||
|
||||
Constructor<?>[] constructorArr = module.getConstructors();
|
||||
/* create a module instance */
|
||||
int constrIndex = 0;
|
||||
|
||||
if ((goParams==null && noGuiLogFile==null) || !module.equals(GOModuleAdapter.class)) {
|
||||
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)");
|
||||
}
|
||||
Object[] Para = new Object[2];
|
||||
while ((constructorArr[constrIndex].getParameterTypes().length!=2) && (constrIndex < constructorArr.length)) {
|
||||
constrIndex++;
|
||||
}
|
||||
Class<?> paramTypes[] = (constructorArr[constrIndex]).getParameterTypes();
|
||||
Para[0] = paramTypes[0].cast(adapterName);
|
||||
Para[1] = paramTypes[1].cast(Client);
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para);
|
||||
} else {
|
||||
Object[] param = new Object[4];
|
||||
param[0] = (String) adapterName;
|
||||
param[1] = (InterfaceGOParameters) goParams;
|
||||
param[2] = (String) noGuiLogFile;
|
||||
param[3] = (MainAdapterClient) Client;
|
||||
while ((constructorArr[constrIndex].getParameterTypes().length!=4) && (constrIndex < constructorArr.length)) {
|
||||
constrIndex++;
|
||||
}
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||
}
|
||||
if (!runWithoutRMI) {
|
||||
/* if we're using RMI, send the object to a remote server
|
||||
* for this to work the class of moduleAdapter itself must
|
||||
* implement the ModuleAdapter interface for a strange reason,
|
||||
* it is _not_ enough if a superclass implements the same interface!
|
||||
*/
|
||||
moduleAdapter = (ModuleAdapter) RMIProxyLocal.newInstance(moduleAdapter, adapterName);
|
||||
(moduleAdapter).setRemoteThis(moduleAdapter);
|
||||
}
|
||||
// m_RunnungModules.add(m_ModuleAdapter);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
||||
EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
return (ModuleAdapter) moduleAdapter;
|
||||
}
|
||||
}
|
||||
Constructor<?>[] constructorArr = module.getConstructors();
|
||||
/* create a module instance */
|
||||
int constrIndex = 0;
|
||||
|
||||
if ((goParams == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) {
|
||||
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)");
|
||||
}
|
||||
Object[] Para = new Object[1];
|
||||
while ((constructorArr[constrIndex].getParameterTypes().length != 1) && (constrIndex < constructorArr.length)) {
|
||||
constrIndex++;
|
||||
}
|
||||
Class<?> paramTypes[] = (constructorArr[constrIndex]).getParameterTypes();
|
||||
Para[0] = paramTypes[0].cast(adapterName);
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para);
|
||||
} else {
|
||||
Object[] param = new Object[4];
|
||||
param[0] = (String) adapterName;
|
||||
param[1] = (InterfaceGOParameters) goParams;
|
||||
param[2] = (String) noGuiLogFile;
|
||||
while ((constructorArr[constrIndex].getParameterTypes().length != 4) && (constrIndex < constructorArr.length)) {
|
||||
constrIndex++;
|
||||
}
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||
}
|
||||
// m_RunnungModules.add(m_ModuleAdapter);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
||||
EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
return (ModuleAdapter) moduleAdapter;
|
||||
}
|
||||
}
|
||||
// // @todo running modules sind gerade noch abgeschaltet
|
||||
// for (int i = 0; i < m_RunnungModules.size(); i++) {
|
||||
// try {
|
||||
@ -209,7 +192,7 @@ public class ModuleServer {
|
||||
// }
|
||||
// }
|
||||
|
||||
LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName);
|
||||
return null;
|
||||
}
|
||||
LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName);
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package eva2.server;
|
||||
/**
|
||||
* Title: The JProxy Framework
|
||||
* Description: API for distributed and parallel computing.
|
||||
* Copyright: Copyright (c) 2004
|
||||
* Company: University of Tuebingen
|
||||
* @version: $Revision: 250 $
|
||||
* $Date: 2007-11-13 10:32:19 +0100 (Tue, 13 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import eva2.tools.jproxy.RMIServer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class RMIServerEvA extends RMIServer {
|
||||
|
||||
public static RMIServerEvA getInstance() {
|
||||
if (instance==null) {
|
||||
instance = new RMIServerEvA();
|
||||
}
|
||||
return (RMIServerEvA)instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMainRemoteObject(String mainAdapterName) {
|
||||
try {
|
||||
mainRemoteObject = new EvAMainAdapterImpl();
|
||||
mainRemoteObject =
|
||||
(EvAMainAdapter) RMIProxyLocal.newInstance(
|
||||
mainRemoteObject,
|
||||
mainAdapterName + "_" + numberOfVM);
|
||||
mainRemoteObject.setRemoteThis(mainRemoteObject);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.WARNING, "Could not create main remote object!", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ import eva2.server.go.strategies.EvolutionStrategies;
|
||||
import eva2.server.go.strategies.GeneticAlgorithm;
|
||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||
import eva2.server.modules.GOParameters;
|
||||
import eva2.tools.jproxy.ThreadProxy;
|
||||
import eva2.tools.math.RNG;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.List;
|
||||
@ -34,60 +33,54 @@ import java.util.Date;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* Created by IntelliJ IDEA. User: streiche 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 $
|
||||
* @version: $Revision: 306 $ $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopulationChangedEventListener, java.io.Serializable {
|
||||
|
||||
// Interface GUI Stuff
|
||||
transient private JFrame m_Frame;
|
||||
transient private JPanel m_MainPanel;
|
||||
transient private JPanel m_ButtonPanel;
|
||||
transient private JButton m_RunButton, m_StopButton, m_Continue, m_ShowSolution;
|
||||
transient private JComponent m_OptionsPanel, m_O1, m_O2;
|
||||
transient private JComponent m_StatusPanel;
|
||||
transient private JLabel m_StatusField;
|
||||
transient private JProgressBar m_ProgressBar;
|
||||
transient private SwingWorker worker;
|
||||
transient private boolean show = false;
|
||||
transient private JFrame m_Frame;
|
||||
transient private JPanel m_MainPanel;
|
||||
transient private JPanel m_ButtonPanel;
|
||||
transient private JButton m_RunButton, m_StopButton, m_Continue, m_ShowSolution;
|
||||
transient private JComponent m_OptionsPanel, m_O1, m_O2;
|
||||
transient private JComponent m_StatusPanel;
|
||||
transient private JLabel m_StatusField;
|
||||
transient private JProgressBar m_ProgressBar;
|
||||
transient private SwingWorker worker;
|
||||
transient private boolean show = false;
|
||||
// transient private InterfaceTest test = new Test1();
|
||||
|
||||
// Opt. Algorithms and Parameters
|
||||
//transient private InterfaceOptimizer m_Optimizer = new EvolutionaryMultiObjectiveOptimization();
|
||||
//transient private InterfaceOptimizationProblem m_Problem = new TF1Problem();
|
||||
//transient private int m_FunctionCalls = 1000;
|
||||
private GOParameters m_GO;
|
||||
transient private int m_MultiRuns = 1;
|
||||
transient private int m_RecentFC;
|
||||
transient private int currentExperiment = 0;
|
||||
transient private int currentRun;
|
||||
transient private int currentProgress;
|
||||
transient private String m_ExperimentName;
|
||||
transient private String m_OutputPath = "";
|
||||
transient private String m_OutputFileName = "none";
|
||||
private GOParameters m_GO;
|
||||
transient private int m_MultiRuns = 1;
|
||||
transient private int m_RecentFC;
|
||||
transient private int currentExperiment = 0;
|
||||
transient private int currentRun;
|
||||
transient private int currentProgress;
|
||||
transient private String m_ExperimentName;
|
||||
transient private String m_OutputPath = "";
|
||||
transient private String m_OutputFileName = "none";
|
||||
// transient private GOStandaloneVersion m_yself;
|
||||
|
||||
// these parameters are for the continue option
|
||||
transient private Population m_Backup;
|
||||
transient private boolean m_ContinueFlag;
|
||||
|
||||
transient private Population m_Backup;
|
||||
transient private boolean m_ContinueFlag;
|
||||
// Plot Panel stuff
|
||||
transient private eva2.gui.Plot m_Plot;
|
||||
transient private ArrayList m_PerformedRuns = new ArrayList();
|
||||
transient private ArrayList m_TmpData;
|
||||
transient private BufferedWriter m_OutputFile;
|
||||
|
||||
transient private eva2.gui.Plot m_Plot;
|
||||
transient private ArrayList m_PerformedRuns = new ArrayList();
|
||||
transient private ArrayList m_TmpData;
|
||||
transient private BufferedWriter m_OutputFile;
|
||||
// Test
|
||||
transient private List m_List;
|
||||
transient private List m_List;
|
||||
|
||||
|
||||
/** Create a new EALectureGUI.
|
||||
/**
|
||||
* Create a new EALectureGUI.
|
||||
*/
|
||||
public GOStandaloneVersion() {
|
||||
// this.m_List = new List();
|
||||
@ -95,25 +88,27 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// this.m_List.add("Test2");
|
||||
// this.m_List.add("Test3");
|
||||
// this.m_yself = this;
|
||||
this.m_GO = GOParameters.getInstance();
|
||||
this.m_ExperimentName = this.m_GO.getOptimizer().getName()+"-"+this.m_PerformedRuns.size();
|
||||
this.m_GO = GOParameters.getInstance();
|
||||
this.m_ExperimentName = this.m_GO.getOptimizer().getName() + "-" + this.m_PerformedRuns.size();
|
||||
this.m_GO.addPopulationChangedEventListener(this);
|
||||
RNG.setRandomSeed(m_GO.getSeed());
|
||||
}
|
||||
|
||||
/** This method allows you to get the current GO parameters
|
||||
/**
|
||||
* This method allows you to get the current GO parameters
|
||||
*
|
||||
*/
|
||||
public GOParameters getGOParameters() {
|
||||
return this.m_GO;
|
||||
}
|
||||
|
||||
/** This method will generate a Plot Frame and a main Editing Frame
|
||||
/**
|
||||
* This method will generate a Plot Frame and a main Editing Frame
|
||||
*/
|
||||
public void initFrame() {
|
||||
this.m_ProgressBar = new JProgressBar();
|
||||
// init the main frame
|
||||
this.m_Frame = new JFrame();
|
||||
this.m_Frame = new JFrame();
|
||||
this.m_Frame.setTitle("Genetic Optimizing");
|
||||
this.m_Frame.setSize(500, 400);
|
||||
this.m_Frame.setLocation(530, 50);
|
||||
@ -124,7 +119,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
});
|
||||
// build the main panel
|
||||
this.m_MainPanel = new JPanel();
|
||||
this.m_MainPanel = new JPanel();
|
||||
this.m_Frame.getContentPane().add(this.m_MainPanel);
|
||||
this.m_MainPanel.setLayout(new BorderLayout());
|
||||
// build the button panel
|
||||
@ -157,13 +152,13 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
String tmp = "eva2.server.oa.go.Tools.InterfaceTest";
|
||||
try {
|
||||
object = Class.forName(tmp);
|
||||
} catch(java.lang.ClassNotFoundException e) {
|
||||
} catch (java.lang.ClassNotFoundException e) {
|
||||
System.out.println("No Class found for " + tmp);
|
||||
}
|
||||
tmp = "eva2.gui.GenericObjectEditor";
|
||||
try {
|
||||
editor = Class.forName(tmp);
|
||||
} catch(java.lang.ClassNotFoundException e) {
|
||||
} catch (java.lang.ClassNotFoundException e) {
|
||||
System.out.println("No Class found for " + tmp);
|
||||
}
|
||||
if ((object != null) && (editor != null)) {
|
||||
@ -175,8 +170,8 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.m_OptionsPanel = new JTabbedPane();
|
||||
JParaPanel paraPanel2 = new JParaPanel(this.m_GO, "MyGUI");
|
||||
this.m_O2 = (paraPanel2.makePanel());
|
||||
((JTabbedPane)this.m_OptionsPanel).addTab("GO Parameters", this.m_O2);
|
||||
((JTabbedPane)this.m_OptionsPanel).addTab("GO Statistics", this.m_O1);
|
||||
((JTabbedPane) this.m_OptionsPanel).addTab("GO Parameters", this.m_O2);
|
||||
((JTabbedPane) this.m_OptionsPanel).addTab("GO Statistics", this.m_O1);
|
||||
this.m_MainPanel.add(this.m_OptionsPanel, BorderLayout.CENTER);
|
||||
|
||||
// build the Status Panel
|
||||
@ -196,8 +191,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.m_Frame.validate();
|
||||
this.m_Frame.setVisible(true);
|
||||
}
|
||||
|
||||
/** This action listener, called by the "Run/Restart" button, will init the problem and start the computation.
|
||||
/**
|
||||
* This action listener, called by the "Run/Restart" button, will init the
|
||||
* problem and start the computation.
|
||||
*/
|
||||
ActionListener runListener = new ActionListener() {
|
||||
@Override
|
||||
@ -207,12 +203,13 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
public Object construct() {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finished() {
|
||||
m_RunButton.setEnabled(true);
|
||||
m_Continue.setEnabled(true);
|
||||
m_StopButton.setEnabled(false);
|
||||
m_Backup = (Population) m_GO.getOptimizer().getPopulation().clone();
|
||||
m_Backup = (Population) m_GO.getOptimizer().getPopulation().clone();
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
@ -221,10 +218,10 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
m_StopButton.setEnabled(true);
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener, called by the "Cancel" button, interrupts
|
||||
* the worker thread which is running this.doWork(). Note that
|
||||
* the doWork() method handles InterruptedExceptions cleanly.
|
||||
/**
|
||||
* This action listener, called by the "Cancel" button, interrupts the
|
||||
* worker thread which is running this.doWork(). Note that the doWork()
|
||||
* method handles InterruptedExceptions cleanly.
|
||||
*/
|
||||
ActionListener stopListener = new ActionListener() {
|
||||
@Override
|
||||
@ -234,14 +231,14 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
m_StopButton.setEnabled(false);
|
||||
worker.interrupt();
|
||||
for (int i = 0; i < m_MultiRuns; i++) {
|
||||
m_Plot.clearGraph(1000 +i);
|
||||
m_Plot.clearGraph(1000 + i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener, called by the "Cancel" button, interrupts
|
||||
* the worker thread which is running this.doWork(). Note that
|
||||
* the doWork() method handles InterruptedExceptions cleanly.
|
||||
/**
|
||||
* This action listener, called by the "Cancel" button, interrupts the
|
||||
* worker thread which is running this.doWork(). Note that the doWork()
|
||||
* method handles InterruptedExceptions cleanly.
|
||||
*/
|
||||
ActionListener continueListener = new ActionListener() {
|
||||
@Override
|
||||
@ -252,34 +249,35 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
public Object construct() {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finished() {
|
||||
m_RunButton.setEnabled(true);
|
||||
m_Continue.setEnabled(true);
|
||||
m_StopButton.setEnabled(false);
|
||||
m_Backup = (Population) m_GO.getOptimizer().getPopulation().clone();
|
||||
m_ContinueFlag = false;
|
||||
m_Backup = (Population) m_GO.getOptimizer().getPopulation().clone();
|
||||
m_ContinueFlag = false;
|
||||
}
|
||||
};
|
||||
// also mal ganz anders ich gehe davon aus, dass der Benutzer das Ding parametrisiert hat
|
||||
// setze einfach die Backup population ein...
|
||||
m_ContinueFlag = true;
|
||||
m_MultiRuns = 1; // multiruns machen bei continue einfach keinen Sinn...
|
||||
m_ContinueFlag = true;
|
||||
m_MultiRuns = 1; // multiruns machen bei continue einfach keinen Sinn...
|
||||
worker.start();
|
||||
m_RunButton.setEnabled(false);
|
||||
m_Continue.setEnabled(false);
|
||||
m_StopButton.setEnabled(true);
|
||||
}
|
||||
};
|
||||
|
||||
/** This action listener, called by the "show" button will show the
|
||||
* currently best solution in a frame.
|
||||
/**
|
||||
* This action listener, called by the "show" button will show the currently
|
||||
* best solution in a frame.
|
||||
*/
|
||||
ActionListener showSolListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("The current best solution for "+m_GO.getProblem().getName());
|
||||
frame.setTitle("The current best solution for " + m_GO.getProblem().getName());
|
||||
frame.setSize(400, 300);
|
||||
frame.setLocation(450, 250);
|
||||
Population pop = m_GO.getOptimizer().getPopulation();
|
||||
@ -289,7 +287,8 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
};
|
||||
|
||||
/** This method gives the experimental settings and starts the work.
|
||||
/**
|
||||
* This method gives the experimental settings and starts the work.
|
||||
*/
|
||||
@Override
|
||||
public void startExperiment() {
|
||||
@ -299,21 +298,21 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
EvaluationTerminator terminator = new EvaluationTerminator();
|
||||
terminator.setFitnessCalls(50000);
|
||||
this.m_GO.setTerminator(terminator);
|
||||
this.m_MultiRuns = 10;
|
||||
int experimentType = 0;
|
||||
this.m_ExperimentName = "InferringGRN";
|
||||
this.m_MultiRuns = 10;
|
||||
int experimentType = 0;
|
||||
this.m_ExperimentName = "InferringGRN";
|
||||
this.m_OutputFileName = "Result";
|
||||
this.m_OutputPath = "results/";
|
||||
this.m_OutputPath = "results/";
|
||||
// These are some tmp Variables
|
||||
InterfaceDataTypeDouble tmpIndy = new ESIndividualDoubleData();
|
||||
InterfaceMutation tmpMut = new MutateESFixedStepSize();
|
||||
InterfaceDataTypeDouble tmpIndy = new ESIndividualDoubleData();
|
||||
InterfaceMutation tmpMut = new MutateESFixedStepSize();
|
||||
|
||||
switch (experimentType) {
|
||||
case 0 : {
|
||||
case 0: {
|
||||
// use the Struture Skeletalizing with GA
|
||||
this.m_OutputFileName = "Prim4_StructSkelGATESTIT";
|
||||
GeneticAlgorithm ga = new GeneticAlgorithm();
|
||||
SelectTournament tour = new SelectTournament();
|
||||
GeneticAlgorithm ga = new GeneticAlgorithm();
|
||||
SelectTournament tour = new SelectTournament();
|
||||
tour.setTournamentSize(10);
|
||||
ga.setParentSelection(tour);
|
||||
ga.setPartnerSelection(tour);
|
||||
@ -321,26 +320,26 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.m_GO.getOptimizer().getPopulation().setTargetSize(100);
|
||||
F1Problem problem = new F1Problem();
|
||||
tmpIndy = new GAIndividualDoubleData();
|
||||
((GAIndividualDoubleData)tmpIndy).setCrossoverOperator(new CrossoverGAGINPoint());
|
||||
((GAIndividualDoubleData)tmpIndy).setCrossoverProbability(1.0);
|
||||
((GAIndividualDoubleData)tmpIndy).setMutationProbability(1.0);
|
||||
((F1Problem)problem).setEAIndividual(tmpIndy);
|
||||
((GAIndividualDoubleData) tmpIndy).setCrossoverOperator(new CrossoverGAGINPoint());
|
||||
((GAIndividualDoubleData) tmpIndy).setCrossoverProbability(1.0);
|
||||
((GAIndividualDoubleData) tmpIndy).setMutationProbability(1.0);
|
||||
((F1Problem) problem).setEAIndividual(tmpIndy);
|
||||
//((FGRNInferringProblem)this.m_Problem).setStructreSkelInterval(1);
|
||||
this.m_GO.getOptimizer().setProblem(problem);
|
||||
this.m_GO.getOptimizer().addPopulationChangedEventListener(this);
|
||||
this.doWork();
|
||||
break;
|
||||
}
|
||||
case 1 : {
|
||||
case 1: {
|
||||
// use the simple ES Local
|
||||
this.m_OutputFileName = "X360_StandardES";
|
||||
this.m_OutputFileName = "X360_StandardES";
|
||||
EvolutionStrategies es = new EvolutionStrategies();
|
||||
this.m_GO.setOptimizer(es);
|
||||
this.m_GO.getOptimizer().getPopulation().setTargetSize(50);
|
||||
F1Problem problem = new F1Problem();
|
||||
tmpIndy = new ESIndividualDoubleData();
|
||||
((AbstractEAIndividual)tmpIndy).setMutationOperator(new MutateESLocal());
|
||||
((F1Problem)problem).setEAIndividual(tmpIndy);
|
||||
((AbstractEAIndividual) tmpIndy).setMutationOperator(new MutateESLocal());
|
||||
((F1Problem) problem).setEAIndividual(tmpIndy);
|
||||
//((FGRNInferringProblem)this.m_Problem).setUseHEigenMatrix(true);
|
||||
//((FGRNInferringProblem)this.m_Problem).setUseOnlyPositiveNumbers(true);
|
||||
this.m_GO.getOptimizer().setProblem(problem);
|
||||
@ -360,15 +359,14 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
|
||||
/**
|
||||
* This method represents the application code that we'd like to
|
||||
* run on a separate thread. It simulates slowly computing
|
||||
* a value, in this case just a string 'All Done'. It updates the
|
||||
* progress bar every half second to remind the user that
|
||||
* we're still busy.
|
||||
* This method represents the application code that we'd like to run on a
|
||||
* separate thread. It simulates slowly computing a value, in this case just
|
||||
* a string 'All Done'. It updates the progress bar every half second to
|
||||
* remind the user that we're still busy.
|
||||
*/
|
||||
public Object doWork() {
|
||||
try {
|
||||
this.m_GO.saveInstance();
|
||||
this.m_GO.saveInstance();
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Optimizing...");
|
||||
}
|
||||
@ -379,9 +377,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
String name = "";
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss");
|
||||
String m_StartDate = formatter.format(new Date());
|
||||
name = this.m_OutputPath + this.m_OutputFileName +"_"+this.m_ExperimentName+"_"+m_StartDate+".dat";
|
||||
name = this.m_OutputPath + this.m_OutputFileName + "_" + this.m_ExperimentName + "_" + m_StartDate + ".dat";
|
||||
try {
|
||||
this.m_OutputFile = new BufferedWriter(new OutputStreamWriter (new FileOutputStream (name)));
|
||||
this.m_OutputFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("Could not open output file! Filename: " + name);
|
||||
}
|
||||
@ -405,10 +403,10 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
|
||||
for (int j = 0; j < this.m_MultiRuns; j++) {
|
||||
this.m_GO.getProblem().initProblem(); // in the loop as well, dynamic probs may need that (MK)
|
||||
this.m_TmpData = new ArrayList();
|
||||
this.m_TmpData = new ArrayList();
|
||||
this.currentRun = j;
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Optimizing Run " + (j+1) + " of " + this.m_MultiRuns + " Multi Runs...");
|
||||
this.m_StatusField.setText("Optimizing Run " + (j + 1) + " of " + this.m_MultiRuns + " Multi Runs...");
|
||||
}
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
@ -448,9 +446,8 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
if (this.show) {
|
||||
this.draw();
|
||||
}
|
||||
this.m_ExperimentName = this.m_GO.getOptimizer().getName()+"-"+this.m_PerformedRuns.size();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
this.m_ExperimentName = this.m_GO.getOptimizer().getName() + "-" + this.m_PerformedRuns.size();
|
||||
} catch (InterruptedException e) {
|
||||
updateStatus(0);
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Interrupted...");
|
||||
@ -466,8 +463,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
if (this.show) {
|
||||
for (int i = 0; i < this.m_MultiRuns; i++) {
|
||||
this.m_Plot.clearGraph(1000 +i);
|
||||
} }
|
||||
this.m_Plot.clearGraph(1000 + i);
|
||||
}
|
||||
}
|
||||
updateStatus(0);
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Finished...");
|
||||
@ -475,20 +473,21 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
return "All Done";
|
||||
}
|
||||
|
||||
/** This method refreshes the plot
|
||||
/**
|
||||
* This method refreshes the plot
|
||||
*/
|
||||
private void draw() {
|
||||
ArrayList multiRuns, singleRun;
|
||||
Double[] tmpD;
|
||||
double[][] data;
|
||||
ArrayList multiRuns, singleRun;
|
||||
Double[] tmpD;
|
||||
double[][] data;
|
||||
// Color tmpColor;
|
||||
|
||||
for (int i = this.m_PerformedRuns.size()-1; i < this.m_PerformedRuns.size(); i++) {
|
||||
multiRuns = (ArrayList)this.m_PerformedRuns.get(i);
|
||||
for (int i = this.m_PerformedRuns.size() - 1; i < this.m_PerformedRuns.size(); i++) {
|
||||
multiRuns = (ArrayList) this.m_PerformedRuns.get(i);
|
||||
// determine minimum run length
|
||||
int minRunLen = Integer.MAX_VALUE;
|
||||
for (int j = 0; j < multiRuns.size(); j++) {
|
||||
singleRun = (ArrayList)multiRuns.get(j);
|
||||
singleRun = (ArrayList) multiRuns.get(j);
|
||||
// tmpD = (Double[])singleRun.get(singleRun.size()-1);
|
||||
minRunLen = Math.min(minRunLen, singleRun.size());
|
||||
}
|
||||
@ -496,19 +495,19 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
data = new double[minRunLen][3];
|
||||
// First run to determine mean
|
||||
for (int j = 0; j < multiRuns.size(); j++) {
|
||||
singleRun = (ArrayList)multiRuns.get(j);
|
||||
singleRun = (ArrayList) multiRuns.get(j);
|
||||
for (int p = 0; p < data.length; p++) {
|
||||
tmpD = (Double[])singleRun.get(p);
|
||||
tmpD = (Double[]) singleRun.get(p);
|
||||
data[p][0] = tmpD[0].doubleValue();
|
||||
data[p][1] += tmpD[1].doubleValue()/multiRuns.size();
|
||||
data[p][1] += tmpD[1].doubleValue() / multiRuns.size();
|
||||
}
|
||||
}
|
||||
// Second run to determine variance
|
||||
for (int j = 0; j < multiRuns.size(); j++) {
|
||||
singleRun = (ArrayList)multiRuns.get(j);
|
||||
singleRun = (ArrayList) multiRuns.get(j);
|
||||
for (int p = 0; p < data.length; p++) {
|
||||
tmpD = (Double[])singleRun.get(p);
|
||||
data[p][2] += Math.pow(data[p][1] - tmpD[1].doubleValue(),2)/multiRuns.size();
|
||||
tmpD = (Double[]) singleRun.get(p);
|
||||
data[p][2] += Math.pow(data[p][1] - tmpD[1].doubleValue(), 2) / multiRuns.size();
|
||||
}
|
||||
}
|
||||
// Now enter this stuff into the graph
|
||||
@ -524,9 +523,8 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
if (this.m_ContinueFlag) {
|
||||
this.m_Plot.setConnectedPoint(data[j][0]+this.m_RecentFC, data[j][1], this.currentExperiment);
|
||||
}
|
||||
else {
|
||||
this.m_Plot.setConnectedPoint(data[j][0] + this.m_RecentFC, data[j][1], this.currentExperiment);
|
||||
} else {
|
||||
this.m_Plot.setConnectedPoint(data[j][0], data[j][1], this.currentExperiment);
|
||||
}
|
||||
}
|
||||
@ -535,10 +533,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
|
||||
/**
|
||||
* When the worker needs to update the GUI we do so by queuing
|
||||
* a Runnable for the event dispatching thread with
|
||||
* SwingUtilities.invokeLater(). In this case we're just
|
||||
* changing the progress bars value.
|
||||
* When the worker needs to update the GUI we do so by queuing a Runnable
|
||||
* for the event dispatching thread with SwingUtilities.invokeLater(). In
|
||||
* this case we're just changing the progress bars value.
|
||||
*/
|
||||
void updateStatus(final int i) {
|
||||
if (this.m_ProgressBar != null) {
|
||||
@ -552,21 +549,17 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will create a new instance of LectureGUI and will call show() to create
|
||||
* the necessary frames. This method will ignore all arguments.
|
||||
/**
|
||||
* This method will create a new instance of LectureGUI and will call show()
|
||||
* to create the necessary frames. This method will ignore all arguments.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (false) {
|
||||
InterfaceGOStandalone app = (InterfaceGOStandalone)ThreadProxy.newInstance(new GOStandaloneVersion());
|
||||
app.startExperiment();
|
||||
app.setShow(false);
|
||||
} else {
|
||||
GOStandaloneVersion program = new GOStandaloneVersion();
|
||||
RNG.setRandomSeed(1);
|
||||
program.initFrame();
|
||||
program.setShow(true);
|
||||
}
|
||||
GOStandaloneVersion program = new GOStandaloneVersion();
|
||||
RNG.setRandomSeed(1);
|
||||
program.initFrame();
|
||||
program.setShow(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -574,59 +567,62 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.show = t;
|
||||
}
|
||||
|
||||
/** This method allows an optimizer to register a change in the optimizer.
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
/**
|
||||
* This method allows an optimizer to register a change in the optimizer.
|
||||
*
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
Population population = ((InterfaceOptimizer)source).getPopulation();
|
||||
double x = 100/this.m_MultiRuns;
|
||||
if (this.m_GO.getTerminator() instanceof EvaluationTerminator) {
|
||||
double y = x/(double)((EvaluationTerminator)this.m_GO.getTerminator()).getFitnessCalls();
|
||||
currentProgress = (int)(this.currentRun * x + population.getFunctionCalls()*y);
|
||||
} else {
|
||||
currentProgress = (int)(this.currentRun * x);
|
||||
}
|
||||
updateStatus(currentProgress);
|
||||
|
||||
// data to be stored in file
|
||||
double tmpd = 0;
|
||||
StringBuffer tmpLine = new StringBuffer("");
|
||||
tmpLine.append(population.getFunctionCalls());
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(population.getBestEAIndividual().getFitness(0));
|
||||
tmpLine.append("\t");
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
tmpd += ((AbstractEAIndividual)population.get(i)).getFitness(0)/(double)population.size();
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
Population population = ((InterfaceOptimizer) source).getPopulation();
|
||||
double x = 100 / this.m_MultiRuns;
|
||||
if (this.m_GO.getTerminator() instanceof EvaluationTerminator) {
|
||||
double y = x / (double) ((EvaluationTerminator) this.m_GO.getTerminator()).getFitnessCalls();
|
||||
currentProgress = (int) (this.currentRun * x + population.getFunctionCalls() * y);
|
||||
} else {
|
||||
currentProgress = (int) (this.currentRun * x);
|
||||
}
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(tmpd);
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(population.getWorstEAIndividual().getFitness(0));
|
||||
//tmpLine.append("\t");
|
||||
//tmpLine.append(this.m_GO.getProblem().getAdditionalDataValue(population));
|
||||
this.writeToFile(tmpLine.toString());
|
||||
updateStatus(currentProgress);
|
||||
|
||||
Double[] tmpData = new Double[2];
|
||||
tmpData[0] = new Double(population.getFunctionCalls());
|
||||
// instead of adding simply the best fitness value i'll ask the problem what to show
|
||||
tmpData[1] = this.m_GO.getProblem().getDoublePlotValue(population);
|
||||
if (this.m_Plot != null) {
|
||||
if (this.m_ContinueFlag) {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue()+this.m_RecentFC, tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
}
|
||||
else {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
}
|
||||
}
|
||||
this.m_TmpData.add(tmpData);
|
||||
}
|
||||
// data to be stored in file
|
||||
double tmpd = 0;
|
||||
StringBuffer tmpLine = new StringBuffer("");
|
||||
tmpLine.append(population.getFunctionCalls());
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(population.getBestEAIndividual().getFitness(0));
|
||||
tmpLine.append("\t");
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
tmpd += ((AbstractEAIndividual) population.get(i)).getFitness(0) / (double) population.size();
|
||||
}
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(tmpd);
|
||||
tmpLine.append("\t");
|
||||
tmpLine.append(population.getWorstEAIndividual().getFitness(0));
|
||||
//tmpLine.append("\t");
|
||||
//tmpLine.append(this.m_GO.getProblem().getAdditionalDataValue(population));
|
||||
this.writeToFile(tmpLine.toString());
|
||||
|
||||
Double[] tmpData = new Double[2];
|
||||
tmpData[0] = new Double(population.getFunctionCalls());
|
||||
// instead of adding simply the best fitness value i'll ask the problem what to show
|
||||
tmpData[1] = this.m_GO.getProblem().getDoublePlotValue(population);
|
||||
if (this.m_Plot != null) {
|
||||
if (this.m_ContinueFlag) {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue() + this.m_RecentFC, tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
} else {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
}
|
||||
}
|
||||
this.m_TmpData.add(tmpData);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method writes Data to file.
|
||||
* @param line The line that is to be added to the file
|
||||
/**
|
||||
* This method writes Data to file.
|
||||
*
|
||||
* @param line The line that is to be added to the file
|
||||
*/
|
||||
private void writeToFile(String line) {
|
||||
String write = line + "\n";
|
||||
@ -641,41 +637,51 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the name to
|
||||
* the current object.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
public String getName() {
|
||||
return "EA Lecture GUI";
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a simple example framework for Evolutionary Algorithms.";
|
||||
}
|
||||
|
||||
/** This method allows you to set the number of mulitruns that are to be performed,
|
||||
* necessary for stochastic optimizers to ensure reliable results.
|
||||
/**
|
||||
* This method allows you to set the number of mulitruns that are to be
|
||||
* performed, necessary for stochastic optimizers to ensure reliable
|
||||
* results.
|
||||
*
|
||||
* @param multiruns The number of multiruns that are to be performed
|
||||
*/
|
||||
public void setMultiRuns(int multiruns) {
|
||||
this.m_MultiRuns = multiruns;
|
||||
}
|
||||
|
||||
public int getMultiRuns() {
|
||||
return this.m_MultiRuns;
|
||||
}
|
||||
|
||||
public String multiRunsTipText() {
|
||||
return "Multiple runs may be necessary to produce reliable results for stochastic optimizing algorithms.";
|
||||
}
|
||||
|
||||
/** This method allows you to set the seed for the random number
|
||||
* generator.
|
||||
/**
|
||||
* This method allows you to set the seed for the random number generator.
|
||||
*
|
||||
* @param seed The seed for the random number generator
|
||||
*/
|
||||
// MK: These methods have nothing to do with the seed parameter from the m_GO object which is actually used, so I comment them out
|
||||
@ -688,47 +694,57 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// public String seedTipText() {
|
||||
// return "Choose the seed for the random number generator.";
|
||||
// }
|
||||
|
||||
/** This method sets the name of the current experiment as it will occur in the
|
||||
* plot legend.
|
||||
/**
|
||||
* This method sets the name of the current experiment as it will occur in
|
||||
* the plot legend.
|
||||
*
|
||||
* @param experimentName The experiment name
|
||||
*/
|
||||
public void setExpName(String experimentName) {
|
||||
this.m_ExperimentName = experimentName;
|
||||
}
|
||||
|
||||
public String getExpName() {
|
||||
return this.m_ExperimentName;
|
||||
}
|
||||
|
||||
public String expNameTipText() {
|
||||
return "Set the name of the experiment as it will occur in the legend.";
|
||||
}
|
||||
|
||||
/** This method will set the output filename
|
||||
/**
|
||||
* This method will set the output filename
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setOutputFileName (String name) {
|
||||
public void setOutputFileName(String name) {
|
||||
this.m_OutputFileName = name;
|
||||
}
|
||||
public String getOutputFileName () {
|
||||
|
||||
public String getOutputFileName() {
|
||||
return this.m_OutputFileName;
|
||||
}
|
||||
|
||||
public String outputFileNameTipText() {
|
||||
return "Set the name for the output file, if 'none' no output file will be created.";
|
||||
}
|
||||
|
||||
/** This method will set the output filename
|
||||
/**
|
||||
* This method will set the output filename
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setList (List name) {
|
||||
public void setList(List name) {
|
||||
this.m_List = name;
|
||||
}
|
||||
public List getListe () {
|
||||
|
||||
public List getListe() {
|
||||
return this.m_List;
|
||||
}
|
||||
|
||||
public String listTipText() {
|
||||
return "Set the name for the output file, if 'none' no output file will be created.";
|
||||
}
|
||||
|
||||
// /** This method allows you to set the number of functions calls that are to
|
||||
// * be evaluated. Note generational optimizers may exceed this number since
|
||||
// * they allways evaluate the complete population
|
||||
@ -759,7 +775,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// public String optimizerTipText() {
|
||||
// return "Choose a optimizing strategies.";
|
||||
// }
|
||||
|
||||
// /** This method will set the problem that is to be optimized
|
||||
// * @param problem
|
||||
// */
|
||||
@ -773,8 +788,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// public String problemTipText() {
|
||||
// return "Choose the problem that is to optimize and the EA individual parameters.";
|
||||
// }
|
||||
|
||||
|
||||
// public void setTest(InterfaceTest v) {
|
||||
// this.test = v;
|
||||
// }
|
||||
|
@ -1,17 +1,7 @@
|
||||
package eva2.server.go;
|
||||
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
|
||||
/*
|
||||
* 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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for Optimization Processor.
|
||||
@ -34,11 +24,11 @@ public interface InterfaceProcessor {
|
||||
void stopOpt();
|
||||
|
||||
/**
|
||||
* Adds a new RemoteStateListener.
|
||||
* Adds a new OptimizationStateListener.
|
||||
*
|
||||
* @param module The module to add.
|
||||
*/
|
||||
void addListener(RemoteStateListener module);
|
||||
void addListener(OptimizationStateListener module);
|
||||
|
||||
/**
|
||||
* Get Info String about the Optimization.
|
||||
|
@ -3,7 +3,6 @@ package eva2.server.go.mocco;
|
||||
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.gui.PropertyEditorProvider;
|
||||
import eva2.gui.PropertyRemoteServers;
|
||||
import eva2.server.go.InterfaceTerminator;
|
||||
import eva2.server.go.MOCCOStandalone;
|
||||
import eva2.server.go.operators.migration.SOBestMigration;
|
||||
@ -240,12 +239,13 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
}
|
||||
// then set the values
|
||||
// if (!m_Island.getLocalOnly()) {
|
||||
PropertyRemoteServers t = m_Island.getServers();
|
||||
// ToDo: Think of new ways to do this!
|
||||
/*PropertyRemoteServers t = m_Island.getServers();
|
||||
String[] servers = t.getServerNodes();
|
||||
if (servers.length != m_Perturbations) {
|
||||
System.out.println("Warning: Number of servers overrides number of perturbations!");
|
||||
m_Perturbations = servers.length;
|
||||
}
|
||||
}*/
|
||||
// } else {
|
||||
// m_Island.setNumberLocalCPUs(m_Perturbations);
|
||||
// }
|
||||
|
@ -3,7 +3,6 @@ package eva2.server.go.mocco;
|
||||
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.gui.PropertyEditorProvider;
|
||||
import eva2.gui.PropertyRemoteServers;
|
||||
import eva2.server.go.InterfaceTerminator;
|
||||
import eva2.server.go.MOCCOStandalone;
|
||||
import eva2.server.go.operators.migration.SOBestMigration;
|
||||
@ -241,12 +240,13 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
}
|
||||
// then set the values
|
||||
// if (!m_Island.getLocalOnly()) {
|
||||
PropertyRemoteServers servs = m_Island.getServers();
|
||||
// ToDo: Think of new ways to do this!
|
||||
/* PropertyRemoteServers servs = m_Island.getServers();
|
||||
String[] servers = servs.getServerNodes();
|
||||
if (servers.length != m_Perturbations) {
|
||||
System.out.println("Warning: Number of servers overrides number of perturbations!");
|
||||
m_Perturbations = servers.length;
|
||||
}
|
||||
}*/
|
||||
// } else {
|
||||
// m_Island.setNumberLocalCPUs(m_Perturbations);
|
||||
// }
|
||||
|
@ -1,8 +1,5 @@
|
||||
package eva2.server.go.problems;
|
||||
|
||||
import eva2.gui.PropertyRemoteServers;
|
||||
import eva2.tools.jproxy.RMIProxyRemoteThread;
|
||||
|
||||
/**
|
||||
* This class is under construction.
|
||||
*
|
||||
@ -14,14 +11,14 @@ import eva2.tools.jproxy.RMIProxyRemoteThread;
|
||||
*/
|
||||
public abstract class AbstractParallelOptimizationProblem extends AbstractOptimizationProblem {
|
||||
|
||||
private PropertyRemoteServers m_Servers = new PropertyRemoteServers();
|
||||
// private PropertyRemoteServers m_Servers = new PropertyRemoteServers();
|
||||
private int m_LocalCPUs = 4;
|
||||
private boolean m_Parallelize = false;
|
||||
private AbstractOptimizationProblem[] m_Slaves;
|
||||
|
||||
@Override
|
||||
public void initProblem() {
|
||||
if (this.m_Parallelize) {
|
||||
/* if (this.m_Parallelize) {
|
||||
// this is running on remote maschines
|
||||
String[] nodesList = this.m_Servers.getCheckedServerNodes();
|
||||
if ((nodesList == null) || (nodesList.length == 0)) {
|
||||
@ -37,23 +34,9 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi
|
||||
for (int i = 0; i < this.m_LocalCPUs; i++) {
|
||||
this.m_Slaves[i] = (AbstractOptimizationProblem) this.clone();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// /** This method evaluates a given population and set the fitness values
|
||||
// * accordingly
|
||||
// * @param population The population that is to be evaluated.
|
||||
// */
|
||||
// public void evaluate(Population population) {
|
||||
// AbstractEAIndividual tmpIndy;
|
||||
// int curIndex = 0;
|
||||
//
|
||||
// while (curIndex < population.size()) {
|
||||
// what the ?? is this??
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
@ -88,7 +71,7 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi
|
||||
/** This method allows you to managae the available servers
|
||||
* @return The current servers
|
||||
*/
|
||||
public PropertyRemoteServers getServers() {
|
||||
/* public PropertyRemoteServers getServers() {
|
||||
return this.m_Servers;
|
||||
}
|
||||
public void setServers(PropertyRemoteServers b){
|
||||
@ -97,7 +80,7 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi
|
||||
public String serversTipText() {
|
||||
return "Choose and manage the servers (only active in parallelized mode).";
|
||||
}
|
||||
|
||||
*/
|
||||
/** This method allows you to set the number of processors in local mode
|
||||
* @param n Number of processors.
|
||||
*/
|
||||
|
@ -2,7 +2,6 @@ package eva2.server.go.strategies;
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.gui.Plot;
|
||||
import eva2.gui.PropertyRemoteServers;
|
||||
import eva2.server.go.InterfacePopulationChangedEventListener;
|
||||
import eva2.server.go.individuals.ESIndividualDoubleData;
|
||||
import eva2.server.go.operators.migration.InterfaceMigration;
|
||||
@ -17,9 +16,6 @@ import eva2.server.go.problems.F1Problem;
|
||||
import eva2.server.go.problems.F8Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import eva2.server.go.problems.TF1Problem;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import eva2.tools.jproxy.RMIProxyRemoteThread;
|
||||
import eva2.tools.jproxy.RMIServer;
|
||||
|
||||
/** The one and only island model for parallelization. Since parallelization based
|
||||
* on the RMIProxyRemoteThread is on the one hand much slower than benchmark function
|
||||
@ -41,6 +37,7 @@ import eva2.tools.jproxy.RMIServer;
|
||||
* Time: 14:48:20
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
public class IslandModelEA implements InterfacePopulationChangedEventListener, InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
private Population m_Population = new Population();
|
||||
@ -50,14 +47,12 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
// private String[] m_NodesList;
|
||||
private int m_MigrationRate = 10;
|
||||
private boolean m_HeterogenuousProblems = false;
|
||||
private PropertyRemoteServers m_Servers = new PropertyRemoteServers();
|
||||
|
||||
// These are the processor to run on
|
||||
private int m_numLocalCPUs = 1;
|
||||
private boolean m_localOnly = false;
|
||||
transient private InterfaceOptimizer[] m_Islands;
|
||||
transient private RMIServer m_LocalServer = null;
|
||||
|
||||
|
||||
// This is for debugging
|
||||
private boolean m_LogLocalChanges = true;
|
||||
private boolean m_Show = false;
|
||||
@ -76,7 +71,6 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.m_Problem = (InterfaceOptimizationProblem)a.m_Problem.clone();
|
||||
this.m_Optimizer = (InterfaceOptimizer)a.m_Optimizer.clone();
|
||||
this.m_Migration = (InterfaceMigration)a.m_Migration.clone();
|
||||
this.m_Servers = (PropertyRemoteServers)a.m_Servers.clone();
|
||||
this.m_MigrationRate = a.m_MigrationRate;
|
||||
this.m_HeterogenuousProblems = a.m_HeterogenuousProblems;
|
||||
this.m_numLocalCPUs = a.m_numLocalCPUs;
|
||||
@ -119,7 +113,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
} else {
|
||||
// this is running on remote machines
|
||||
if (this.m_LocalServer == null) {
|
||||
// ToDo: Parallelize with Threads?!?
|
||||
/*if (this.m_LocalServer == null) {
|
||||
this.m_LocalServer = RMIServer.getInstance();
|
||||
}
|
||||
try {
|
||||
@ -139,7 +134,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
if (this.m_LogLocalChanges) {
|
||||
this.m_Islands[i].addPopulationChangedEventListener(myLocal);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
this.m_Migration.initMigration(this.m_Islands);
|
||||
@ -193,6 +188,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
} else {
|
||||
// this is running on remote machines
|
||||
// ToDo: Parallellize with threads?!?
|
||||
/*
|
||||
if (this.m_LocalServer == null) {
|
||||
this.m_LocalServer = RMIServer.getInstance();
|
||||
}
|
||||
@ -213,7 +210,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
if (this.m_LogLocalChanges) {
|
||||
this.m_Islands[i].addPopulationChangedEventListener(myLocal);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
this.m_Migration.initMigration(this.m_Islands);
|
||||
@ -282,7 +279,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
}
|
||||
this.m_Population.clear();
|
||||
this.m_Population.SetFunctionCalls(0);
|
||||
this.m_Population.setFunctionCalls(0);
|
||||
Population pop;
|
||||
for (int i = 0; i < this.m_Islands.length; i++) {
|
||||
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
||||
@ -372,16 +369,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
public static void main(String[] args) {
|
||||
// @todo die ServerStarter muss ich noch hin kriegen
|
||||
// @todo Wichtig ich brauche den eva2.tools.jproxy.RMIServer!
|
||||
PropertyRemoteServers s = new PropertyRemoteServers();
|
||||
s.addServerNode("raold1.informatik.uni-tuebingen.de", 2);
|
||||
s.addServerNode("raold2.informatik.uni-tuebingen.de", 2);
|
||||
s.addServerNode("raold3.informatik.uni-tuebingen.de", 2);
|
||||
s.setPassword("KozeOpL;");
|
||||
s.startServers();
|
||||
IslandModelEA imea = new IslandModelEA();
|
||||
imea.m_Show = true;
|
||||
imea.m_localOnly = false;
|
||||
imea.setServers(s);
|
||||
if (false) {
|
||||
imea.m_Optimizer = new MultiObjectiveEA();
|
||||
((MultiObjectiveEA)imea.m_Optimizer).setArchiveSize(25);
|
||||
@ -565,15 +555,6 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
return "Set the migration rate for communication between islands.";
|
||||
}
|
||||
|
||||
/** This method allows you to managae the available servers
|
||||
* @return The current servers
|
||||
*/
|
||||
public PropertyRemoteServers getServers() {
|
||||
return this.m_Servers;
|
||||
}
|
||||
public void setServers(PropertyRemoteServers b){
|
||||
this.m_Servers = b;
|
||||
}
|
||||
public String serversTipText() {
|
||||
return "Choose and manage the servers (only active in parallelized mode).";
|
||||
}
|
||||
|
@ -11,10 +11,8 @@ package eva2.server.modules;
|
||||
*/
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.server.go.InterfaceProcessor;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -32,39 +30,20 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
protected String hostName = "not defined";
|
||||
protected boolean hasConnection = true;
|
||||
protected ModuleAdapter remoteModuleAdapter = null;
|
||||
protected boolean useRMI = true;
|
||||
protected MainAdapterClient mainAdapterClient; // connection to client
|
||||
private List<RemoteStateListener> remoteStateListeners;
|
||||
private List<OptimizationStateListener> optimizationStateListeners;
|
||||
|
||||
protected AbstractModuleAdapter(MainAdapterClient client) {
|
||||
protected AbstractModuleAdapter() {
|
||||
instanceCounter++;
|
||||
instanceNumber = instanceCounter;
|
||||
|
||||
if (client != null) {
|
||||
try {
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
System.out.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
hostName = "localhost";
|
||||
}
|
||||
|
||||
if ((client == null) || client.getHostName().equals(hostName)) {
|
||||
useRMI = false;
|
||||
} else {
|
||||
/* we use RMI */
|
||||
useRMI = true;
|
||||
}
|
||||
remoteStateListeners = new ArrayList<RemoteStateListener>();
|
||||
optimizationStateListeners = new ArrayList<OptimizationStateListener>();
|
||||
}
|
||||
|
||||
/**
|
||||
* From the interface RemoteStateListener. Added this method to make progress bar possible.
|
||||
* From the interface OptimizationStateListener. Added this method to make progress bar possible.
|
||||
*/
|
||||
@Override
|
||||
public void updateProgress(final int percent, String msg) {
|
||||
for (RemoteStateListener listener : remoteStateListeners) {
|
||||
for (OptimizationStateListener listener : optimizationStateListeners) {
|
||||
listener.updateProgress(percent, msg);
|
||||
}
|
||||
}
|
||||
@ -155,8 +134,8 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
* Adds a remote state listener.
|
||||
*/
|
||||
@Override
|
||||
public void addRemoteStateListener(RemoteStateListener remoteListener) {
|
||||
remoteStateListeners.add(remoteListener);
|
||||
public void addOptimizationStateListener(OptimizationStateListener remoteListener) {
|
||||
optimizationStateListeners.add(remoteListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,21 +179,21 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
||||
*/
|
||||
@Override
|
||||
public void performedStop() {
|
||||
for (RemoteStateListener listener : remoteStateListeners) {
|
||||
for (OptimizationStateListener listener : optimizationStateListeners) {
|
||||
listener.performedStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performedStart(String infoString) {
|
||||
for (RemoteStateListener listener : remoteStateListeners) {
|
||||
for (OptimizationStateListener listener : optimizationStateListeners) {
|
||||
listener.performedStart(infoString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performedRestart(String infoString) {
|
||||
for (RemoteStateListener listener : remoteStateListeners) {
|
||||
for (OptimizationStateListener listener : optimizationStateListeners) {
|
||||
listener.performedRestart(infoString);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
|
||||
/**
|
||||
* This the DE module adapter necessary to access this implementation from the EvA top level.
|
||||
*/
|
||||
@ -10,8 +7,8 @@ public class DEModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
|
||||
private static final String moduleName = "Differential_Evolution";
|
||||
|
||||
public DEModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "DE.html", client, DEParameters.getInstance(), true);
|
||||
public DEModuleAdapter(String adapterName) {
|
||||
super(adapterName, "DE.html", DEParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the EP module adapter necessary to access this implementation from the EvA top level.
|
||||
*/
|
||||
@ -9,8 +7,8 @@ public class EPModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
|
||||
private static final String moduleName = "Evolutionary_Programming";
|
||||
|
||||
public EPModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "EP.html", client, EPParameters.getInstance(), true);
|
||||
public EPModuleAdapter(String adapterName) {
|
||||
super(adapterName, "EP.html", EPParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the GA module adapter necessary to access this implementation from the EvA top level.
|
||||
@ -9,8 +8,8 @@ public class GAModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
|
||||
private static final String moduleName = "Genetic_Algorithm";
|
||||
|
||||
public GAModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "GA.html", client, GAParameters.getInstance(), true);
|
||||
public GAModuleAdapter(String adapterName) {
|
||||
super(adapterName, "GA.html", GAParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.server.go.InterfaceGOParameters;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@ -25,8 +24,8 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
* @param AdapterName the title of the ModulAdapter
|
||||
* @param Client the client instance
|
||||
*/
|
||||
public GOModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "", client, GOParameters.getInstance(), false);
|
||||
public GOModuleAdapter(String adapterName) {
|
||||
super(adapterName, "", GOParameters.getInstance(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,9 +34,8 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
* @param AdapterName the title of the ModulAdapter
|
||||
* @param Client the client instance
|
||||
*/
|
||||
public GOModuleAdapter(String adapterName, InterfaceGOParameters goParams, String noGuiLogFile, MainAdapterClient client) {
|
||||
//super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false);
|
||||
super(adapterName, "", client, goParams, false, noGuiLogFile);
|
||||
public GOModuleAdapter(String adapterName, InterfaceGOParameters goParams, String noGuiLogFile) {
|
||||
super(adapterName, "", goParams, false, noGuiLogFile);
|
||||
}
|
||||
// /**
|
||||
// * Starts a statistics GUI and the GOProcessor thread with a given GOParameters file.
|
||||
|
@ -12,8 +12,6 @@ import eva2.server.stat.EvAJobList;
|
||||
import eva2.server.stat.InterfaceStatisticsParameter;
|
||||
import eva2.server.stat.StatisticsStandalone;
|
||||
import eva2.server.stat.StatisticsWithGUI;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
@ -29,22 +27,19 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
*
|
||||
* @param adapterName The AdapterName
|
||||
* @param helperFName Name of a HTML help file name
|
||||
* @param adapterClient The client to serve
|
||||
* @param params A parameter set describing the optimizer module
|
||||
* @param optimizerExpert Set to true if setting the optimizer is an expert option being hidden
|
||||
* from the gui
|
||||
* @param noGUIStatOut If null, statistics with GUI are used, else the standalone statistics
|
||||
* with given output filename.
|
||||
*/
|
||||
public GenericModuleAdapter(String adapterName, String helperFName, MainAdapterClient adapterClient, InterfaceGOParameters params, boolean optimizerExpert, String noGUIStatOut) {
|
||||
super(adapterClient);
|
||||
public GenericModuleAdapter(String adapterName, String helperFName, InterfaceGOParameters params, boolean optimizerExpert, String noGUIStatOut) {
|
||||
remoteModuleAdapter = this;
|
||||
this.adapterName = adapterName;
|
||||
mainAdapterClient = adapterClient;
|
||||
helperFilename = helperFName;
|
||||
|
||||
if (noGUIStatOut==null) {
|
||||
statisticsModule = new StatisticsWithGUI(adapterClient);
|
||||
statisticsModule = new StatisticsWithGUI();
|
||||
} else {
|
||||
statisticsModule = new StatisticsStandalone(noGUIStatOut);
|
||||
}
|
||||
@ -69,8 +64,8 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
* @param params a parameter set describing the optimizer module
|
||||
* @param optimizerExpert set to true if setting the optimizer is an expert option being hidden from the gui
|
||||
*/
|
||||
public GenericModuleAdapter(String adapterName, String helperFName, MainAdapterClient Client, InterfaceGOParameters params, boolean optimizerExpert) {
|
||||
this(adapterName, helperFName, Client, params, optimizerExpert, null);
|
||||
public GenericModuleAdapter(String adapterName, String helperFName, InterfaceGOParameters params, boolean optimizerExpert) {
|
||||
this(adapterName, helperFName, params, optimizerExpert, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,27 +93,17 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
ButtonPanel.setHelperFilename(helperFilename);
|
||||
frmMkr.addPanelMaker(ButtonPanel);
|
||||
InterfaceGOParameters goParams = ((Processor) processor).getGOParams();
|
||||
// TODO do we really need proxies here?
|
||||
if (useRMI && !Proxy.isProxyClass(goParams.getClass())) {
|
||||
frmMkr.addPanelMaker(paramPanel = new JParaPanel(RMIProxyLocal.newInstance(goParams), goParams.getName()));
|
||||
} else {
|
||||
|
||||
frmMkr.addPanelMaker(paramPanel = new JParaPanel(goParams, goParams.getName()));
|
||||
}
|
||||
if (useRMI && !Proxy.isProxyClass(Stat.getClass())) {
|
||||
frmMkr.addPanelMaker(new JParaPanel(RMIProxyLocal.newInstance(Stat), Stat.getName()));
|
||||
} else {
|
||||
|
||||
frmMkr.addPanelMaker(new JParaPanel(Stat, Stat.getName()));
|
||||
}
|
||||
|
||||
jobList = new EvAJobList(new EvAJob[]{});
|
||||
jobList.setModule(this);
|
||||
jobList.addTextListener((AbstractStatistics) ((Processor) processor).getStatistics());
|
||||
|
||||
if (useRMI && !Proxy.isProxyClass(Stat.getClass())) {
|
||||
jobPanel = new JParaPanel(RMIProxyLocal.newInstance(jobList), jobList.getName());
|
||||
} else {
|
||||
|
||||
jobPanel = new JParaPanel(jobList, jobList.getName());
|
||||
}
|
||||
|
||||
frmMkr.addPanelMaker(jobPanel);
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the HC module adapter necessary to access this implementation from the EvA top level.
|
||||
*/
|
||||
@ -15,8 +13,8 @@ public class HCModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public HCModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "HC.html", client, HCParameters.getInstance(), true);
|
||||
public HCModuleAdapter(String adapterName) {
|
||||
super(adapterName, "HC.html", HCParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the MC module adapter necessary to access this implementation from the EvA top level.
|
||||
*/
|
||||
@ -15,8 +13,8 @@ public class MCModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
|
||||
* @param adapterName The AdapterName
|
||||
* @param client The client to serve
|
||||
*/
|
||||
public MCModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "MC.html", client, MCParameters.getInstance(), true);
|
||||
public MCModuleAdapter(String adapterName) {
|
||||
super(adapterName, "MC.html", MCParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@ -12,13 +11,13 @@ public class MOEAModuleAdapter extends GenericModuleAdapter implements Serializa
|
||||
private static final String moduleName = "Multi-Objective_Evolutionary_Algorithms";
|
||||
|
||||
/**
|
||||
* Constructor of the ModuleAdapter
|
||||
* Constructor of the ModuleAdapter.
|
||||
*
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public MOEAModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "MOEA.html", client, MOEAParameters.getInstance(), true);
|
||||
public MOEAModuleAdapter(String adapterName) {
|
||||
super(adapterName, "MOEA.html", MOEAParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,12 +10,12 @@ package eva2.server.modules;
|
||||
* $Author: mkron $
|
||||
*/
|
||||
import eva2.gui.EvATabbedFrameMaker;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.server.stat.EvAJob;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface ModuleAdapter extends RemoteStateListener {
|
||||
public interface ModuleAdapter extends OptimizationStateListener {
|
||||
|
||||
EvATabbedFrameMaker getModuleFrame();
|
||||
|
||||
@ -48,7 +48,7 @@ public interface ModuleAdapter extends RemoteStateListener {
|
||||
*/
|
||||
boolean startPostProcessing();
|
||||
|
||||
void addRemoteStateListener(RemoteStateListener x);
|
||||
void addOptimizationStateListener(OptimizationStateListener x);
|
||||
|
||||
String getAdapterName();
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the PBIL module adapter necessary to access this implementation from the EvA top level.
|
||||
@ -15,8 +14,8 @@ public class PBILModuleAdapter extends GenericModuleAdapter implements ModuleAda
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public PBILModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "PBIL.html", client, PBILParameters.getInstance(), true);
|
||||
public PBILModuleAdapter(String adapterName) {
|
||||
super(adapterName, "PBIL.html", PBILParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the PSO module adapter necessary to access this implementation from the EvA top level.
|
||||
@ -10,13 +9,13 @@ public class PSOModuleAdapter extends GenericModuleAdapter implements ModuleAdap
|
||||
private static final String moduleName = "Particle_Swarm_Optimization";
|
||||
|
||||
/**
|
||||
* Constructor of the Moduladapter
|
||||
* Constructor of the ModulAdapter.
|
||||
*
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public PSOModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "PSO.html", client, PSOParameters.getInstance(), true);
|
||||
public PSOModuleAdapter(String adapterName) {
|
||||
super(adapterName, "PSO.html", PSOParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.server.go.*;
|
||||
import eva2.server.go.operators.paramcontrol.ConstantParameters;
|
||||
import eva2.server.go.operators.paramcontrol.InterfaceParameterControl;
|
||||
@ -19,7 +20,6 @@ import eva2.server.stat.StatisticsWithGUI;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.tools.StringTools;
|
||||
import eva2.tools.jproxy.RemoteStateListener;
|
||||
import eva2.tools.math.RNG;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -28,15 +28,16 @@ import java.util.logging.Logger;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
* The Processor may run as a thread permanently (GenericModuleAdapter) and is then stopped and started
|
||||
* by a switch in startOpt/stopOpt.
|
||||
*
|
||||
* Processor also handles adaptive parameter control by checking for the method getParamControl in (so far)
|
||||
* Optimizer and Problem instances. The return-value may be InterfaceParameterControl or an array of Objects.
|
||||
* If it is a control interface, it is applied to the instance that returned it directly. For arrays of objects
|
||||
* each array entry is again handled by checking for getParamControl, thus recursive controllable structures
|
||||
* are possible.
|
||||
*
|
||||
* The Processor may run as a thread permanently (GenericModuleAdapter) and is
|
||||
* then stopped and started by a switch in startOpt/stopOpt.
|
||||
*
|
||||
* Processor also handles adaptive parameter control by checking for the method
|
||||
* getParamControl in (so far) Optimizer and Problem instances. The return-value
|
||||
* may be InterfaceParameterControl or an array of Objects. If it is a control
|
||||
* interface, it is applied to the instance that returned it directly. For
|
||||
* arrays of objects each array entry is again handled by checking for
|
||||
* getParamControl, thus recursive controllable structures are possible.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
@ -48,32 +49,32 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
private InterfaceGOParameters goParams;
|
||||
private boolean m_createInitialPopulations = true;
|
||||
private boolean saveParams = true;
|
||||
private RemoteStateListener remoteStateListener;
|
||||
private OptimizationStateListener optimizationStateListener;
|
||||
private boolean wasRestarted = false;
|
||||
private int runCounter = 0;
|
||||
private Population resPop = null;
|
||||
private boolean userAborted = false;
|
||||
|
||||
@Override
|
||||
public void addListener(RemoteStateListener module) {
|
||||
public void addListener(OptimizationStateListener module) {
|
||||
LOGGER.log(
|
||||
Level.FINEST,
|
||||
"Processor: setting module as listener: " + ((module == null)
|
||||
? "null" : module.toString()));
|
||||
|
||||
remoteStateListener = module;
|
||||
optimizationStateListener = module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Processor instance and make statistics instance informable of the parameters,
|
||||
* such they can by dynamically show additional information.
|
||||
*
|
||||
* 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 moduleAdapter, InterfaceGOParameters params) {
|
||||
goParams = params;
|
||||
m_Statistics = Stat;
|
||||
remoteStateListener = moduleAdapter;
|
||||
optimizationStateListener = moduleAdapter;
|
||||
|
||||
// the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change.
|
||||
if (Stat != null && (params != null)) {
|
||||
@ -94,7 +95,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
|
||||
/**
|
||||
* If set to true, before every run the parameters will be stored to a file.
|
||||
*
|
||||
*
|
||||
* @param doSave
|
||||
*/
|
||||
public void setSaveParams(boolean doSave) {
|
||||
@ -106,7 +107,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
*/
|
||||
@Override
|
||||
public void startOpt() {
|
||||
m_createInitialPopulations = true;
|
||||
m_createInitialPopulations = true;
|
||||
if (isOptRunning()) {
|
||||
LOGGER.log(Level.SEVERE, "Processor is already running.");
|
||||
return;
|
||||
@ -118,9 +119,9 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the optimization was stopped by the user instead of
|
||||
* the termination criterion.
|
||||
*
|
||||
* Return true if the optimization was stopped by the user instead of the
|
||||
* termination criterion.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean wasAborted() {
|
||||
@ -132,7 +133,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
*/
|
||||
@Override
|
||||
public void restartOpt() {
|
||||
m_createInitialPopulations = false;
|
||||
m_createInitialPopulations = false;
|
||||
if (isOptRunning()) {
|
||||
LOGGER.log(Level.SEVERE, "Processor is already running.");
|
||||
return;
|
||||
@ -195,17 +196,17 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
//m_Statistics.stopOptPerformed(false);
|
||||
setOptRunning(false); // normal finish
|
||||
if (remoteStateListener != null) {
|
||||
remoteStateListener.performedStop(); // is only needed in client server mode
|
||||
remoteStateListener.updateProgress(0, errMsg);
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.performedStop(); // is only needed in client server mode
|
||||
optimizationStateListener.updateProgress(0, errMsg);
|
||||
}
|
||||
}
|
||||
return resPop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main optimization loop.
|
||||
* Return a population containing the solutions of the last run if there were multiple.
|
||||
* Main optimization loop. Return a population containing the solutions of
|
||||
* the last run if there were multiple.
|
||||
*/
|
||||
protected Population optimize(String infoString) {
|
||||
Population resultPop = null;
|
||||
@ -217,11 +218,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
|
||||
RNG.setRandomSeed(goParams.getSeed());
|
||||
|
||||
if (remoteStateListener != null) {
|
||||
if (optimizationStateListener != null) {
|
||||
if (wasRestarted) {
|
||||
remoteStateListener.performedRestart(getInfoString());
|
||||
optimizationStateListener.performedRestart(getInfoString());
|
||||
} else {
|
||||
remoteStateListener.performedStart(getInfoString());
|
||||
optimizationStateListener.performedStart(getInfoString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,8 +243,8 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
|
||||
//m_Statistics.createNextGenerationPerformed((PopulationInterface)this.m_ModulParameter.getOptimizer().getPopulation());
|
||||
if (remoteStateListener != null) {
|
||||
remoteStateListener.updateProgress(getStatusPercent(goParams.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()), null);
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.updateProgress(getStatusPercent(goParams.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()), null);
|
||||
}
|
||||
if (popLog != null) {
|
||||
EVAHELP.clearLog(popLog);
|
||||
@ -278,11 +279,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
|
||||
}
|
||||
setOptRunning(false); // normal finish
|
||||
if (remoteStateListener != null) {
|
||||
remoteStateListener.performedStop(); // is only needed in client server mode
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.performedStop(); // is only needed in client server mode
|
||||
}
|
||||
if (remoteStateListener != null) {
|
||||
remoteStateListener.updateProgress(0, null);
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.updateProgress(0, null);
|
||||
}
|
||||
goParams.getOptimizer().removePopulationChangedEventListener(this);
|
||||
return resultPop;
|
||||
@ -331,14 +332,13 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
InterfaceOptimizer optimizer = goParams.getOptimizer();
|
||||
if (terminator instanceof GenerationTerminator) {
|
||||
args = new Object[]{optimizer, optimizer.getPopulation(), optimizer.getPopulation().getGeneration(), ((GenerationTerminator) terminator).getGenerations()};
|
||||
} // ((InterfaceParameterControl)paramCtrl).updateParameters(optimizer, optimizer.getPopulation().getGeneration(), ((GenerationTerminator)terminator).getGenerations());
|
||||
}
|
||||
else if (terminator instanceof EvaluationTerminator) {
|
||||
args = new Object[]{optimizer, optimizer.getPopulation(), optimizer.getPopulation().getFunctionCalls(), ((EvaluationTerminator) terminator).getFitnessCalls()};
|
||||
} // ((InterfaceParameterControl)paramCtrl).updateParameters(optimizer, optimizer.getPopulation().getFunctionCalls(), ((EvaluationTerminator)terminator).getFitnessCalls());
|
||||
}
|
||||
else {
|
||||
args = new Object[]{optimizer};
|
||||
}
|
||||
// ((InterfaceParameterControl)paramCtrl).updateParameters(optimizer);
|
||||
|
||||
if (args != null) { // only if iteration counting is available
|
||||
iterateParamCtrl(optimizer, "updateParameters", args);
|
||||
@ -348,9 +348,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the percentage of current (multi-)run already performed, based on evaluations/generations
|
||||
* for the EvaluationTerminator/GenerationTerminator or multi-runs only.
|
||||
*
|
||||
* Calculate the percentage of current (multi-)run already performed, based
|
||||
* on evaluations/generations for the
|
||||
* EvaluationTerminator/GenerationTerminator or multi-runs only.
|
||||
*
|
||||
* @param pop
|
||||
* @param currentRun
|
||||
* @param multiRuns
|
||||
@ -371,22 +372,22 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
return curProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This method allows an optimizer to register a change in the optimizer.
|
||||
* Send some information to the statistics module and update the progress.
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
if (name.equals(Population.nextGenerationPerformed)) {
|
||||
// System.out.println(getGOParams().getOptimizer().getPopulation().getFunctionCalls() + " " + getGOParams().getOptimizer().getPopulation().getBestFitness()[0]);
|
||||
m_Statistics.createNextGenerationPerformed(
|
||||
(PopulationInterface) this.goParams.getOptimizer().getPopulation(),
|
||||
this.goParams.getOptimizer(),
|
||||
getInformerList());
|
||||
if (remoteStateListener != null) {
|
||||
remoteStateListener.updateProgress(
|
||||
if (optimizationStateListener != null) {
|
||||
optimizationStateListener.updateProgress(
|
||||
getStatusPercent(
|
||||
goParams.getOptimizer().getPopulation(),
|
||||
runCounter,
|
||||
@ -405,8 +406,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
return informerList;
|
||||
}
|
||||
|
||||
/** This method writes Data to file.
|
||||
* @param line The line that is to be added to the file
|
||||
/**
|
||||
* This method writes Data to file.
|
||||
*
|
||||
* @param line The line that is to be added to the file
|
||||
*/
|
||||
// private void writeToFile(String line) {
|
||||
// //String write = line + "\n";
|
||||
@ -433,14 +436,14 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This method return the Statistics object.
|
||||
*/
|
||||
public InterfaceStatistics getStatistics() {
|
||||
return m_Statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* These methods allow you to get and set the Module Parameters.
|
||||
*/
|
||||
public InterfaceGOParameters getGOParams() {
|
||||
@ -455,9 +458,9 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the last solution population or null if there is none available.
|
||||
*
|
||||
*
|
||||
* @return the last solution population or null
|
||||
*/
|
||||
public Population getResultPopulation() {
|
||||
@ -469,9 +472,10 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a post processing step with given parameters, based on all solutions found by the optimizer.
|
||||
* Use getResultPopulation() to retrieve results.
|
||||
*
|
||||
* Perform a post processing step with given parameters, based on all
|
||||
* solutions found by the optimizer. Use getResultPopulation() to retrieve
|
||||
* results.
|
||||
*
|
||||
* @param ppp
|
||||
* @param listener
|
||||
*/
|
||||
@ -487,7 +491,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
Population resultPop = (Population) (goParams.getOptimizer().getAllSolutions().getSolutions().clone());
|
||||
if (resultPop.getFunctionCalls() != goParams.getOptimizer().getPopulation().getFunctionCalls()) {
|
||||
// System.err.println("bad case in Processor::performNewPostProcessing ");
|
||||
resultPop.SetFunctionCalls(goParams.getOptimizer().getPopulation().getFunctionCalls());
|
||||
resultPop.setFunctionCalls(goParams.getOptimizer().getPopulation().getFunctionCalls());
|
||||
}
|
||||
// if (!resultPop.contains(m_Statistics.getBestSolution())) {
|
||||
// resultPop.add(m_Statistics.getBestSolution());
|
||||
|
@ -1,25 +1,26 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the SA module adapter necessary to access this implementation from the EvA top level.
|
||||
* This the SA module adapter necessary to access this implementation from the
|
||||
* EvA top level.
|
||||
*/
|
||||
public class SAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
|
||||
|
||||
private static final String moduleName = "Simulated_Annealing";
|
||||
|
||||
/** Constructor of the Moduladapter
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
|
||||
public SAModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super (adapterName, "SA.html", client, SAParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Constructor of the ModulAdapter.
|
||||
*
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public SAModuleAdapter(String adapterName) {
|
||||
super(adapterName, "SA.html", SAParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the name of the ModulAdapter
|
||||
*
|
||||
* @return The name
|
||||
*/
|
||||
public static String getName() {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package eva2.server.modules;
|
||||
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
|
||||
/**
|
||||
* This the SSGA module adapter necessary to access this implementation from the EvA top level.
|
||||
* This the SSGA module adapter necessary to access this implementation from the
|
||||
* EvA top level.
|
||||
*/
|
||||
public class SSGAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
|
||||
|
||||
private static final String moduleName = "Steady_State_Genetic_Algorithm";
|
||||
|
||||
/**
|
||||
* Constructor of the ModuleAdapter
|
||||
* Constructor of the ModuleAdapter.
|
||||
*
|
||||
* @param AdapterName The AdapterName
|
||||
* @param Client The client to serve
|
||||
*/
|
||||
public SSGAModuleAdapter(String adapterName, MainAdapterClient client) {
|
||||
super(adapterName, "SSGA.html", client, SSGAParameters.getInstance(), true);
|
||||
public SSGAModuleAdapter(String adapterName) {
|
||||
super(adapterName, "SSGA.html", SSGAParameters.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,13 +9,9 @@ package eva2.server.stat;
|
||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import eva2.gui.DataViewer;
|
||||
import eva2.gui.DataViewerInterface;
|
||||
import eva2.gui.Graph;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.logging.Logger;
|
||||
@ -33,14 +29,6 @@ public class GenericStatistics implements Serializable {
|
||||
private transient Field[] fields;
|
||||
private DataViewerInterface viewer;
|
||||
private Graph graph;
|
||||
private static MainAdapterClient mainAdapterClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void setMainAdapterClient(MainAdapterClient adapter) {
|
||||
mainAdapterClient = adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -131,7 +119,7 @@ public class GenericStatistics implements Serializable {
|
||||
*
|
||||
*/
|
||||
public void initViewer() {
|
||||
viewer = DataViewer.getInstance(mainAdapterClient, "test");
|
||||
viewer = DataViewer.getInstance("test");
|
||||
graph = viewer.getNewGraph("test");
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,6 @@ package eva2.server.stat;
|
||||
* $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.gui.Graph;
|
||||
import eva2.gui.GraphWindow;
|
||||
@ -24,9 +21,6 @@ import eva2.server.go.PopulationInterface;
|
||||
import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
import eva2.tools.EVAERROR;
|
||||
import eva2.tools.Pair;
|
||||
import eva2.tools.jproxy.MainAdapterClient;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
import eva2.tools.jproxy.RMIProxyRemote;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
@ -35,10 +29,10 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A statistics class to plot fitness curves in client-server mode. Mainly, arrays of GraphWindows
|
||||
* and Graphs are managed and the selected data fields are plotted.
|
||||
* TODO: this could finally be cleanly reduced to an InterfaceStatisticsListener - without inheriting
|
||||
* from AbstractStatistics.
|
||||
* A statistics class to plot fitness curves in client-server mode. Mainly,
|
||||
* arrays of GraphWindows and Graphs are managed and the selected data fields
|
||||
* are plotted. TODO: this could finally be cleanly reduced to an
|
||||
* InterfaceStatisticsListener - without inheriting from AbstractStatistics.
|
||||
*/
|
||||
public class StatisticsWithGUI extends AbstractStatistics implements Serializable, InterfaceStatistics {
|
||||
|
||||
@ -50,7 +44,6 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
private Graph[][] statGraph;
|
||||
private String graphInfoString;
|
||||
protected int plotCounter;
|
||||
private MainAdapterClient mainAdapterClient; // the connection to the client MainAdapter
|
||||
private JTextoutputFrameInterface proxyPrinter;
|
||||
/*
|
||||
* List of descriptor strings and optional indices. strictly its redundant
|
||||
@ -63,35 +56,9 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public MainAdapterClient getMainAdapterClient() {
|
||||
return mainAdapterClient;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StatisticsWithGUI(MainAdapterClient client) {
|
||||
mainAdapterClient = client;
|
||||
if (client != null) { // We are probably in rmi mode
|
||||
try {
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.WARNING, "Could not retrieve hostname.", ex);
|
||||
}
|
||||
} else {
|
||||
hostName = "localhost";
|
||||
}
|
||||
|
||||
|
||||
if ((client == null) || client.getHostName().equals(hostName)) {
|
||||
m_StatsParams = StatisticsParameter.getInstance(true);
|
||||
proxyPrinter = new JTextoutputFrame("TextOutput of " + hostName);
|
||||
} else { // we use RMI
|
||||
m_StatsParams = (InterfaceStatisticsParameter) RMIProxyLocal.newInstance(
|
||||
StatisticsParameter.getInstance(true));
|
||||
proxyPrinter = (JTextoutputFrameInterface) RMIProxyRemote.newInstance(new JTextoutputFrame("TextOutput " + hostName),
|
||||
mainAdapterClient);
|
||||
}
|
||||
public StatisticsWithGUI() {
|
||||
m_StatsParams = StatisticsParameter.getInstance(true);
|
||||
proxyPrinter = new JTextoutputFrame("TextOutput of " + hostName);
|
||||
addTextListener(proxyPrinter);
|
||||
}
|
||||
|
||||
@ -170,10 +137,9 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
maybeShowProxyPrinter();
|
||||
int windowCount = 1; // TODO this was earlier description.length for the 2-D String-Array returned by m_StatsParams.getPlotDescriptions, which however always returned an array of length 1 (in the first dim).
|
||||
int graphCount = graphDesc.size();
|
||||
// System.out.println("Initializing " + graphCount + " plots (StatisticsWithGUI)");
|
||||
fitnessFrame = new GraphWindow[windowCount];
|
||||
for (int i = 0; i < fitnessFrame.length; i++) {
|
||||
fitnessFrame[i] = GraphWindow.getInstance(mainAdapterClient, "Optimization " + i + " " + " on " + hostName, "function calls", "fitness");
|
||||
fitnessFrame[i] = GraphWindow.getInstance("Optimization " + i, "function calls", "fitness");
|
||||
}
|
||||
|
||||
fitnessGraph = new Graph[windowCount][];
|
||||
|
@ -1,70 +0,0 @@
|
||||
package eva2.tools;
|
||||
|
||||
import eva2.server.EvAMainAdapter;
|
||||
import eva2.server.EvAMainAdapterImpl;
|
||||
import eva2.tools.jproxy.RMIInvocationHandler;
|
||||
import java.rmi.Naming;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* <p>Title: EvA2</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author planatsc
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ServerPingThread extends Thread {
|
||||
|
||||
boolean isServerAlive;
|
||||
String hostname;
|
||||
|
||||
public ServerPingThread(String hostname) {
|
||||
this.isServerAlive = false;
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
isServerAlive = rmiPing(hostname);
|
||||
this.sleep(3000);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
public boolean rmiPing(String testurl) {
|
||||
EvAMainAdapter Test = null;
|
||||
String SEP = "_";
|
||||
int len = testurl.indexOf(SEP);
|
||||
String Host = testurl;
|
||||
String Number = "_0";
|
||||
if (len != -1) {
|
||||
StringTokenizer st = new StringTokenizer(testurl, SEP);
|
||||
Host = st.nextToken().trim();
|
||||
Number = SEP + st.nextToken().trim();
|
||||
}
|
||||
String UserName = System.getProperty("user.name");
|
||||
String MainAdapterName = UserName + EvAMainAdapterImpl.MAIN_ADAPTER_NAME + Number;
|
||||
try {
|
||||
RMIInvocationHandler x = (RMIInvocationHandler) Naming.lookup("rmi://" + Host + ":" + EvAMainAdapterImpl.PORT + "/" + MainAdapterName); // attention !!
|
||||
Test = (EvAMainAdapter) x.getWrapper();
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isServerAlive() {
|
||||
return isServerAlive;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user