New statistics look, IslandModel and Client-Server mode should work again.
This commit is contained in:
parent
963cf2d89d
commit
7c5363cae8
@ -16,6 +16,7 @@ package javaeva.client;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Event;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@ -24,8 +25,6 @@ import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@ -77,12 +76,14 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
public static final String EVA_PROPERTY_FILE = "resources/JavaEvA.props";
|
||||
private static Properties EVA_PROPERTIES;
|
||||
public static final String iconLocation = "resources/images/JavaEvAIcon_3.gif";
|
||||
|
||||
private static final String splashLocation = "resources/images/JavaEvA2SplashScreen.png";
|
||||
// private static final String splashLocation = "resources/images/JavaEvA2SplashScreen.jpg";
|
||||
final int splashScreenTime = 1500;
|
||||
|
||||
public static boolean TRACE = false;
|
||||
private static String m_ProductName = "JavaEvA";
|
||||
private static String m_ProductName = "JavaEvA 2";
|
||||
// private int PREFERRED_WIDTH = 680;
|
||||
// private int PREFERRED_HEIGHT = 550;
|
||||
private JWindow m_splashScreen;
|
||||
public JEFrame m_Frame;
|
||||
|
||||
private EvAComAdapter m_ComAdapter;
|
||||
@ -158,31 +159,28 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
* Works as client for the JavaEva server.
|
||||
*
|
||||
*/
|
||||
public EvAClient(String hostName) {
|
||||
createSplashScreen();
|
||||
public EvAClient(final String hostName) {
|
||||
final SplashScreen fSplashScreen = new SplashScreen(splashLocation);
|
||||
|
||||
fSplashScreen.splash();
|
||||
|
||||
currentModule = null;
|
||||
|
||||
m_ComAdapter = EvAComAdapter.getInstance();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (m_splashScreen != null) m_splashScreen.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
//init();
|
||||
|
||||
SwingUtilities.invokeLater( new Runnable() {
|
||||
public void run(){
|
||||
long startTime = System.currentTimeMillis();
|
||||
init(hostName); // this takes a bit
|
||||
long wait = System.currentTimeMillis() - startTime;
|
||||
try {
|
||||
Thread.sleep(6000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("error" + e.getMessage());
|
||||
}
|
||||
if (m_splashScreen != null) m_splashScreen.setVisible(false);
|
||||
m_splashScreen = null;
|
||||
}
|
||||
// if splashScreenTime has not passed, sleep some more
|
||||
if (wait < splashScreenTime) Thread.sleep(splashScreenTime - wait);
|
||||
} catch (Exception e) {}
|
||||
// close splash screen
|
||||
fSplashScreen.dispose();
|
||||
}
|
||||
});
|
||||
init(hostName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,27 +256,27 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
m_Frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the JavaEvA splash screen.
|
||||
*/
|
||||
public void createSplashScreen() {
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation("resources/images/JavaEvaSplashScreen.png");
|
||||
try {
|
||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
JLabel splashLabel = new JLabel(ii);
|
||||
m_splashScreen = new JWindow();
|
||||
m_splashScreen.getContentPane().add(splashLabel);
|
||||
m_splashScreen.pack();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
//splashScreen.setSize(screenSize);
|
||||
m_splashScreen.setLocation(screenSize.width / 2 - m_splashScreen.getSize().width / 2, screenSize.height / 2 - m_splashScreen.getSize().height / 2);
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
System.err.println("Could not find JavaEvA splash screen, please move rescoure folder to working directory!");
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * Create the JavaEvA splash screen.
|
||||
// */
|
||||
// public void createSplashScreen() {
|
||||
// BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
// byte[] bytes = loader.getBytesFromResourceLocation("resources/images/JavaEvA2SplashScreen.jpg");
|
||||
// try {
|
||||
// ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
// JLabel splashLabel = new JLabel(ii);
|
||||
// m_splashScreen = new JWindow();
|
||||
// m_splashScreen.getContentPane().add(splashLabel);
|
||||
// m_splashScreen.pack();
|
||||
// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
// //splashScreen.setSize(screenSize);
|
||||
// m_splashScreen.setLocation(screenSize.width / 2 - m_splashScreen.getSize().width / 2, screenSize.height / 2 - m_splashScreen.getSize().height / 2);
|
||||
// } catch (java.lang.NullPointerException e) {
|
||||
// System.err.println("Could not find JavaEvA splash screen, please move rescoure folder to working directory!");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* The one and only main of the client program.
|
||||
@ -415,7 +413,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
try {
|
||||
UIManager.setLookAndFeel(e.getActionCommand());
|
||||
SwingUtilities.updateComponentTreeUI(m_Frame);
|
||||
// hier noch reinhacken dass alle frame geupdated werden.
|
||||
// TODO hier noch reinhacken dass alle frame geupdated werden.
|
||||
m_Frame.pack();
|
||||
// m_Frame.setSize(new Dimension(900, 700));
|
||||
// m_Frame.setVisible(true);
|
||||
@ -431,7 +429,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
try {
|
||||
UIManager.setLookAndFeel(LAF);
|
||||
SwingUtilities.updateComponentTreeUI(m_Frame);
|
||||
m_Frame.pack();
|
||||
// m_Frame.pack();
|
||||
// m_Frame.setSize(new Dimension(900, 700));
|
||||
// m_Frame.setVisible(true);
|
||||
} catch (ClassNotFoundException exc) {} catch (InstantiationException exc) {} catch (UnsupportedLookAndFeelException exc) {} catch (
|
||||
@ -461,15 +459,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
);
|
||||
m_mnuWindow.add(act);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void menuCanceled(MenuEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void menuDeselected(MenuEvent e) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -677,8 +670,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
JOptionPane.showMessageDialog
|
||||
(m_Frame,
|
||||
m_ProductName +
|
||||
"\n University of Tuebingen\n Computer Architecture\n Holger Ulmer & Felix Streichert & Hannes Planatscher \n Prof. Dr. Andreas Zell \n (c) 2007 \n Version " +
|
||||
EvAServer.Version + " \n http://www-ra.informatik.uni-tuebingen.de/software/JavaEvA/", "JavaEvA Information", 1);
|
||||
"\n University of Tuebingen\n Computer Architecture\n H. Ulmer & F. Streichert & H. Planatscher & M. de Paly & M. Kronfeld\n Prof. Dr. Andreas Zell \n (c) 2008 \n Version " +
|
||||
EvAServer.Version + " \n http://www.ra.cs.uni-tuebingen.de/software/JavaEvA", "JavaEvA Information", 1);
|
||||
}
|
||||
|
||||
private void showNoHostFoundDialog() {
|
||||
@ -755,3 +748,38 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
// System.out.println("object gives " + o);
|
||||
// }
|
||||
}
|
||||
|
||||
final class SplashScreen extends Frame {
|
||||
private static final long serialVersionUID = 1281793825850423095L;
|
||||
String imgLocation;
|
||||
|
||||
public SplashScreen(String imgLoc) {
|
||||
imgLocation = imgLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the splash screen to the end user.
|
||||
*
|
||||
* <P>Once this method returns, the splash screen is realized, which means
|
||||
* that almost all work on the splash screen should proceed through the event
|
||||
* dispatch thread. In particular, any call to <code>dispose</code> for the
|
||||
* splash screen must be performed in the event dispatch thread.
|
||||
*/
|
||||
public void splash(){
|
||||
JWindow splashWindow = new JWindow(this);
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation);
|
||||
try {
|
||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
JLabel splashLabel = new JLabel(ii);
|
||||
splashWindow.add(splashLabel);
|
||||
splashWindow.pack();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
|
||||
splashWindow.setVisible(true);
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
System.err.println("Could not find JavaEvA splash screen, please move rescoure folder to working directory!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javaeva.server.go.populations.Population;
|
||||
import javaeva.tools.SelectedTag;
|
||||
import javaeva.tools.Tag;
|
||||
|
||||
@ -132,6 +133,9 @@ public class BeanInspector {
|
||||
|
||||
/**
|
||||
* Collect the accessible properties of an object and their values in a string.
|
||||
* Special cases: Arrays and Lists are concatenations of their elements, Population is excepted from lists.
|
||||
* If the object has its own toString method, this one is preferred. Hidden or expert properties are not
|
||||
* shown.
|
||||
*
|
||||
* @param Target Description of the Parameter
|
||||
* @return Description of the Return Value
|
||||
@ -154,7 +158,7 @@ public class BeanInspector {
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
if (Target instanceof List) { // handle the list case
|
||||
if (Target instanceof List && !(Target instanceof Population)) { // handle the list case
|
||||
StringBuffer sbuf = new StringBuffer("[ ");
|
||||
List<?> lst = (List<?>)Target;
|
||||
for (Object o : lst) {
|
||||
|
@ -11,45 +11,53 @@ package javaeva.gui;
|
||||
*/
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.MethodDescriptor;
|
||||
import java.beans.PropertyDescriptor;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.io.File;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import wsi.ra.jproxy.RMIProxyLocal;
|
||||
|
||||
//import wsi.ra.tool.DummyCategory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import javaeva.client.EvAClient;
|
||||
import javaeva.tools.CompileAndLoad;
|
||||
import javaeva.tools.EVAHELP;
|
||||
import javaeva.tools.ReflectPackage;
|
||||
import javaeva.tools.Tag;
|
||||
import javaeva.tools.SelectedTag;
|
||||
import javaeva.tools.Serializer;
|
||||
import javaeva.server.stat.StatisticsParameter;
|
||||
import javaeva.server.stat.StatisticsParameterImpl;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import wsi.ra.jproxy.RMIProxyLocal;
|
||||
|
||||
|
||||
/*==========================================================================*
|
||||
@ -61,7 +69,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
private Object m_Object;
|
||||
private Object m_Backup;
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private Class m_ClassType;
|
||||
private Class<?> m_ClassType;
|
||||
private GOEPanel m_EditorComponent;
|
||||
private boolean m_Enabled = true;
|
||||
/**
|
||||
@ -501,7 +509,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
System.err.println("warning: " + className + " is not a package!");
|
||||
} else {
|
||||
String pckg = className.substring(0, className.lastIndexOf('.'));
|
||||
Class[] clsArr;
|
||||
Class<?>[] clsArr;
|
||||
try {
|
||||
clsArr = ReflectPackage.getAssignableClassesInPackage(pckg, Class.forName(className), true, true);
|
||||
} catch (ClassNotFoundException e) {
|
||||
@ -513,11 +521,20 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
+EvAClient.EVA_PROPERTY_FILE + " "+"for "+className);
|
||||
classes.add(className);
|
||||
} else {
|
||||
for (Class class1 : clsArr) {
|
||||
for (Class<?> class1 : clsArr) {
|
||||
int m = class1.getModifiers();
|
||||
try {
|
||||
// a field allowing a class to indicate it doesnt want to be displayed
|
||||
Field f = class1.getDeclaredField("hideFromGOE");
|
||||
if (f.getBoolean(class1) == true) {
|
||||
if (TRACE) System.out.println("Class " + class1 + " wants to be hidden from GOE, skipping...");
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
// if (f)
|
||||
if (!Modifier.isAbstract(m) && !class1.isInterface()) { // dont take abstract classes or interfaces
|
||||
try {
|
||||
Class[] params = new Class[0];
|
||||
Class<?>[] params = new Class[0];
|
||||
class1.getConstructor(params);
|
||||
classes.add(class1.getName());
|
||||
} catch (NoSuchMethodException e) {
|
||||
@ -543,7 +560,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @return false, if an error occurs, else true
|
||||
*/
|
||||
public static boolean setExpertProperty(Class cls, String property, boolean expertValue) {
|
||||
public static boolean setExpertProperty(Class<?> cls, String property, boolean expertValue) {
|
||||
try {
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
@ -572,16 +589,20 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param hide desired value to set, true for hidden, false for visible
|
||||
* @return false, if an error occurs, else true
|
||||
*/
|
||||
public static boolean setHideProperty(Class cls, String property, boolean hide) {
|
||||
public static boolean setHideProperty(Class<?> cls, String property, boolean hide) {
|
||||
try {
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
for (int i=0; i<props.length; i++) {
|
||||
if ((props[i].getName().equals(property))) {
|
||||
if (hide != props[i].isHidden()) props[i].setHidden(hide);
|
||||
if (hide != props[i].isHidden()) {
|
||||
props[i].setHidden(hide);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
System.err.println("Error: property " + property + " not found!");
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
System.err.println("exception in setHideProperty: " + e.getMessage());
|
||||
return false;
|
||||
@ -596,7 +617,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param show
|
||||
* @return
|
||||
*/
|
||||
public static boolean setShowProperty(Class cls, String property, boolean show) {
|
||||
public static boolean setShowProperty(Class<?> cls, String property, boolean show) {
|
||||
return GenericObjectEditor.setHideProperty(cls, property, !show);
|
||||
}
|
||||
|
||||
@ -617,7 +638,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*
|
||||
* @param type a value of type 'Class'
|
||||
*/
|
||||
public void setClassType(Class type) {
|
||||
public void setClassType(Class<?> type) {
|
||||
if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
|
||||
m_ClassType = type;
|
||||
if (m_EditorComponent != null)
|
||||
|
@ -12,124 +12,207 @@ package javaeva.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.Serializable;
|
||||
import wsi.ra.tool.BasicResourceLoader;
|
||||
|
||||
import javaeva.client.EvAClient;
|
||||
import javaeva.tools.MultirunRefiner;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import wsi.ra.tool.BasicResourceLoader;
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JTextoutputFrame implements JTextoutputFrameInterface,
|
||||
Serializable {
|
||||
public static boolean TRACE = false;
|
||||
protected String m_Name ="undefined";
|
||||
private transient JTextArea m_TextArea;
|
||||
private boolean m_firstprint = true;
|
||||
private final JFrame frame;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JTextoutputFrame(String Title) {
|
||||
if (TRACE) System.out.println("JTextoutputFrame Constructor");
|
||||
m_Name = Title;
|
||||
frame = new JEFrame(m_Name);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void print(String Text) {
|
||||
//System.out.println("Print:"+Text);
|
||||
if (m_firstprint==true) {
|
||||
m_firstprint = false;
|
||||
createFrame();
|
||||
}
|
||||
m_TextArea.append(Text);
|
||||
m_TextArea.repaint();
|
||||
}
|
||||
|
||||
public void println(String txt) {
|
||||
print(txt+'\n');
|
||||
}
|
||||
|
||||
public void setShow(boolean bShow) {
|
||||
if (frame.isVisible() != bShow) {
|
||||
if (frame.isVisible()) {
|
||||
frame.dispose();
|
||||
m_TextArea.setText(null);
|
||||
} else {
|
||||
if (m_firstprint) createFrame();
|
||||
else frame.setVisible(true);
|
||||
ActionListener,
|
||||
Serializable {
|
||||
public static boolean TRACE = false;
|
||||
protected String m_Name ="undefined";
|
||||
private transient JTextArea m_TextArea = null;
|
||||
// private boolean m_firstprint = true;
|
||||
private final JFrame frame;
|
||||
|
||||
JPopupMenu popup;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JTextoutputFrame(String Title) {
|
||||
if (TRACE) System.out.println("JTextoutputFrame Constructor");
|
||||
m_Name = Title;
|
||||
frame = new JEFrame(m_Name);
|
||||
m_TextArea = null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void print(String Text) {
|
||||
//System.out.println("Print:"+Text);
|
||||
if (m_TextArea == null) {
|
||||
createFrame();
|
||||
}
|
||||
m_TextArea.append(Text);
|
||||
m_TextArea.repaint();
|
||||
}
|
||||
|
||||
public void println(String txt) {
|
||||
print(txt+'\n');
|
||||
}
|
||||
|
||||
public void setShow(boolean bShow) {
|
||||
if (frame.isVisible() != bShow) {
|
||||
if (frame.isVisible()) {
|
||||
frame.dispose();
|
||||
m_TextArea.setText(null);
|
||||
} else {
|
||||
if (m_TextArea == null) createFrame();
|
||||
else frame.setVisible(true);
|
||||
frame.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void createFrame() {
|
||||
if (TRACE) System.out.println("JTextoutputFrame createFrame");
|
||||
m_TextArea = new JTextArea(10,80);
|
||||
m_TextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
m_TextArea.setLineWrap(true);
|
||||
m_TextArea.setWrapStyleWord(true);
|
||||
m_TextArea.setEditable(false);
|
||||
m_TextArea.setCaretPosition(0);
|
||||
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAClient.iconLocation);
|
||||
try {
|
||||
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
System.out.println("Could not find JavaEvA icon, please move resource folder to working directory!");
|
||||
}
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
frame.getContentPane().setLayout(new BorderLayout());
|
||||
//frame.getContentPane().add(new JScrollPane(m_TextArea), BorderLayout.CENTER);
|
||||
final JScrollPane scrollpane = new JScrollPane(m_TextArea);
|
||||
frame.getContentPane().add(scrollpane, BorderLayout.CENTER);
|
||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||
private int lastHeight;
|
||||
//
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JViewport viewport = (JViewport)e.getSource();
|
||||
int Height = viewport.getViewSize().height;
|
||||
if (Height != lastHeight) {
|
||||
lastHeight = Height;
|
||||
int x = Height - viewport.getExtentSize().height;
|
||||
viewport.setViewPosition(new Point(0, x));
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void createFrame() {
|
||||
if (TRACE) System.out.println("JTextoutputFrame createFrame");
|
||||
m_TextArea = new JTextArea(10,80);
|
||||
m_TextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
m_TextArea.setLineWrap(true);
|
||||
m_TextArea.setWrapStyleWord(true);
|
||||
m_TextArea.setEditable(false);
|
||||
m_TextArea.setCaretPosition(0);
|
||||
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(EvAClient.iconLocation);
|
||||
try {
|
||||
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
System.out.println("Could not find JavaEvA icon, please move resource folder to working directory!");
|
||||
}
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
frame.dispose();
|
||||
frame.setEnabled(false);
|
||||
}
|
||||
});
|
||||
frame.getContentPane().setLayout(new BorderLayout());
|
||||
//frame.getContentPane().add(new JScrollPane(m_TextArea), BorderLayout.CENTER);
|
||||
final JScrollPane scrollpane = new JScrollPane(m_TextArea);
|
||||
frame.getContentPane().add(scrollpane, BorderLayout.CENTER);
|
||||
scrollpane.getViewport().addChangeListener(new ChangeListener() {
|
||||
private int lastHeight;
|
||||
//
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JViewport viewport = (JViewport)e.getSource();
|
||||
int Height = viewport.getViewSize().height;
|
||||
if (Height != lastHeight) {
|
||||
lastHeight = Height;
|
||||
int x = Height - viewport.getExtentSize().height;
|
||||
viewport.setViewPosition(new Point(0, x));
|
||||
}
|
||||
}
|
||||
});
|
||||
makePopupMenu();
|
||||
frame.pack();
|
||||
frame.setSize(800, 400);
|
||||
frame.setVisible(true);
|
||||
frame.setState(Frame.ICONIFIED);
|
||||
}
|
||||
|
||||
/**
|
||||
*output
|
||||
*/
|
||||
public static void main( String[] args ){
|
||||
JTextoutputFrame test = new JTextoutputFrame("hi");
|
||||
while (test.frame.isEnabled()) {
|
||||
test.print("Test 12345");
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("Done!");
|
||||
}
|
||||
|
||||
|
||||
void makePopupMenu() {
|
||||
//Create the popup menu.
|
||||
popup = new JPopupMenu();
|
||||
JMenuItem menuItem = new JMenuItem("Clear");
|
||||
menuItem.addActionListener(this);
|
||||
popup.add(menuItem);
|
||||
// menuItem = new JMenuItem("Refine Multiruns");
|
||||
// menuItem.addActionListener(this);
|
||||
// popup.add(menuItem);
|
||||
|
||||
//Add listener to components that can bring up popup menus.
|
||||
MouseListener popupListener = new PopupListener(popup);
|
||||
// frame.addMouseListener(popupListener);
|
||||
m_TextArea.addMouseListener(popupListener);
|
||||
// menuBar.addMouseListener(popupListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == popup.getComponent(0)) {
|
||||
m_TextArea.setText(null);
|
||||
}
|
||||
// else if (e.getSource() == popup.getComponent(1)) {
|
||||
// m_TextArea.append(MultirunRefiner.refineToText(m_TextArea.getText()));
|
||||
// }
|
||||
else System.out.println("no popup component!");
|
||||
}
|
||||
}
|
||||
});
|
||||
frame.pack();
|
||||
frame.setSize(800, 400);
|
||||
frame.setVisible(true);
|
||||
frame.setState(Frame.ICONIFIED);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void main( String[] args ){
|
||||
JTextoutputFrame test = new JTextoutputFrame("hi");
|
||||
while(true)
|
||||
test.print("Test 12345");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A popup listener opening a popup menu on right clicks.
|
||||
*
|
||||
* @author mkron
|
||||
*/
|
||||
class PopupListener extends MouseAdapter {
|
||||
JPopupMenu popup;
|
||||
|
||||
public PopupListener(JPopupMenu pm) {
|
||||
popup = pm;
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
maybeShowPopup(e);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
maybeShowPopup(e);
|
||||
}
|
||||
|
||||
private void maybeShowPopup(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
popup.show(e.getComponent(),
|
||||
e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,10 @@
|
||||
package javaeva.gui;
|
||||
|
||||
//import javaeva.tools.ServerStarter;
|
||||
import javaeva.server.go.strategies.GeneticAlgorithm;
|
||||
import javaeva.server.go.strategies.InterfaceOptimizer;
|
||||
import javaeva.server.EvAMainAdapterImpl;
|
||||
import javaeva.server.EvAMainAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.rmi.Naming;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wsi.ra.jproxy.RMIProxyRemoteThread;
|
||||
import wsi.ra.jproxy.RMIInvocationHandler;
|
||||
import wsi.ra.jproxy.RMIServer;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@ -41,18 +34,17 @@ class ServerNode implements java.io.Serializable {
|
||||
public class PropertyRemoteServers implements java.io.Serializable {
|
||||
|
||||
private ServerNode[] m_AvailableNodes;
|
||||
private String m_ClassToStart = "wsi.ra.jproxy.RMIServer";
|
||||
// private String m_ClassToStart = "wsi.ra.jproxy.RMIServer";
|
||||
private transient String m_password = "";
|
||||
private String m_Login = "streiche";
|
||||
private boolean m_DeployJar = true;
|
||||
private String m_JarToDeploy = "JOpt.jar";
|
||||
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("raold1.informatik.uni-tuebingen.de", 2);
|
||||
this.addServerNode("raold2.informatik.uni-tuebingen.de", 2);
|
||||
this.setLogin("streiche");
|
||||
this.setPassword("Kuskus");
|
||||
this.addServerNode("exampleNode.uni-tuebingen.de", 2);
|
||||
this.setLogin("username");
|
||||
this.setPassword("");
|
||||
}
|
||||
|
||||
public PropertyRemoteServers(PropertyRemoteServers e) {
|
||||
|
@ -12,15 +12,40 @@ package javaeva.gui;
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.lang.reflect.*;
|
||||
import javax.swing.*;
|
||||
import sun.beans.editors.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.Beans;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.MethodDescriptor;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javaeva.tools.EVAHELP;
|
||||
import javaeva.tools.SelectedTag;
|
||||
import javaeva.tools.StringTools;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingConstants;
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
@ -53,6 +78,8 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
private JButton m_HelpBut;
|
||||
/** A count of the number of properties we have an editor for */
|
||||
private int m_NumEditable = 0;
|
||||
/** How long should a tip text line be (translated to HTML) */
|
||||
private int tipTextLineLen = 50;
|
||||
/** A support object for handling property change listeners */
|
||||
private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
|
||||
/** set true to use the GOE by default if no other editor is registered **/
|
||||
@ -249,34 +276,8 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
continue;
|
||||
}
|
||||
editor.setValue(value);
|
||||
|
||||
// now look for a TipText method for this property
|
||||
String tipName = name + "TipText";
|
||||
for (int j = 0; j < m_Methods.length; j++) {
|
||||
String mname = m_Methods[j].getDisplayName();
|
||||
Method meth = m_Methods[j].getMethod();
|
||||
if (mname.equals(tipName)) {
|
||||
if (meth.getReturnType().equals(String.class)) {
|
||||
try {
|
||||
String tempTip = (String)(meth.invoke(m_Target, args));
|
||||
int ci = tempTip.indexOf('.');
|
||||
if (ci < 0) m_TipTexts[i] = tempTip;
|
||||
else m_TipTexts[i] = tempTip.substring(0, ci);
|
||||
// if (m_HelpText != null) {
|
||||
// if (firstTip) {
|
||||
// m_HelpText.append("OPTIONS\n");
|
||||
// firstTip = false;
|
||||
// }
|
||||
// m_HelpText.append(name).append(" -- ");
|
||||
// m_HelpText.append(tempTip).append("\n\n");
|
||||
// //jt.setText(m_HelpText.toString());
|
||||
// }
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // end searching for (int j = 0; j < m_Methods.length; j++) {
|
||||
|
||||
m_TipTexts[i] = getToolTipText(name, m_Methods, m_Target, tipTextLineLen);
|
||||
|
||||
// Now figure out how to display it...
|
||||
if (editor instanceof sun.beans.editors.BoolEditor) {
|
||||
@ -445,7 +446,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
validate();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the html help file name.
|
||||
*
|
||||
@ -713,8 +714,8 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
* @param target The target object
|
||||
* @return String for the tooltip.
|
||||
*/
|
||||
private String getToolTipText(String name, MethodDescriptor[] methods, Object target) {
|
||||
String result = "No tooltip available.";
|
||||
private String getToolTipText(String name, MethodDescriptor[] methods, Object target, int toHTMLLen) {
|
||||
String result = "";
|
||||
String tipName = name + "TipText";
|
||||
for (int j = 0; j < methods.length; j++) {
|
||||
String mname = methods[j].getDisplayName();
|
||||
@ -729,12 +730,14 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
|
||||
else result = tempTip.substring(0, ci);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // end for looking for tiptext
|
||||
return result;
|
||||
if (toHTMLLen > 0) return StringTools.toHTML(result, toHTMLLen);
|
||||
else return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,9 +139,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* @return boolean if equal fitness true else false.
|
||||
*/
|
||||
public boolean equalFitness(AbstractEAIndividual indy) {
|
||||
if (this.m_Fitness.length != indy.m_Fitness.length) return false;
|
||||
for (int i = 0; i < this.m_Fitness.length; i++) {
|
||||
if (this.m_Fitness[i] != indy.m_Fitness[i]) return false;
|
||||
double[] myF = getFitness();
|
||||
double[] oF = indy.getFitness();
|
||||
if (myF.length != oF.length) return false;
|
||||
for (int i = 0; i < oF.length; i++) {
|
||||
if (myF[i] != oF[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -374,7 +376,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
public boolean isDominating(AbstractEAIndividual indy) {
|
||||
if (this.m_AreaConst4ParallelViolated) return false;
|
||||
if (indy.m_AreaConst4ParallelViolated) return true;
|
||||
return isDominatingFitness(m_Fitness, indy.getFitness());
|
||||
return isDominatingFitness(getFitness(), indy.getFitness());
|
||||
// for (int i = 0; (i < this.m_Fitness.length) && (i < tmpFitness.length); i++) {
|
||||
// if (this.m_Fitness[i] <= tmpFitness[i]) result &= true;
|
||||
// else result &= false;
|
||||
@ -433,7 +435,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
if (this.m_ConstraintViolation > indy.m_ConstraintViolation) return false;
|
||||
else return true;
|
||||
}
|
||||
return isDominatingFitness(m_Fitness, tmpFitness);
|
||||
return isDominatingFitness(getFitness(), tmpFitness);
|
||||
// for (int i = 0; (i < this.m_Fitness.length) && (i < tmpFitness.length); i++) {
|
||||
// if (this.m_Fitness[i] <= tmpFitness[i]) result &= true;
|
||||
// else result &= false;
|
||||
@ -451,7 +453,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
// TODO: should this method really be called "..Equal"?
|
||||
if (this.m_AreaConst4ParallelViolated) return false;
|
||||
if (indy.m_AreaConst4ParallelViolated) return true;
|
||||
return isDominatingFitnessNotEqual(m_Fitness, indy.getFitness());
|
||||
return isDominatingFitnessNotEqual(getFitness(), indy.getFitness());
|
||||
}
|
||||
|
||||
/** This method will allow you to compare two individuals regarding the dominance.
|
||||
@ -475,7 +477,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
// if (this.m_Fitness[i] < tmpFitness[i]) result &= true;
|
||||
// else result &= false;
|
||||
// }
|
||||
return isDominatingFitnessNotEqual(m_Fitness, indy.getFitness());
|
||||
return isDominatingFitnessNotEqual(getFitness(), indy.getFitness());
|
||||
}
|
||||
|
||||
/** This method can be used to read the current selection probability of the individual.
|
||||
|
@ -1,24 +1,21 @@
|
||||
package javaeva.server.go.mocco;
|
||||
|
||||
import javaeva.server.go.MOCCOStandalone;
|
||||
import javaeva.server.go.problems.InterfaceMultiObjectiveDeNovoProblem;
|
||||
import javaeva.server.go.problems.InterfaceOptimizationObjective;
|
||||
import javaeva.server.go.tools.GeneralGOEProperty;
|
||||
import javaeva.client.EvAClient;
|
||||
import javaeva.tools.CompileAndLoad;
|
||||
import javaeva.tools.ReflectPackage;
|
||||
import javaeva.gui.PropertyBoolSelector;
|
||||
import javaeva.gui.PropertyText;
|
||||
import javaeva.gui.PropertyPanel;
|
||||
import javaeva.gui.PropertyValueSelector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.*;
|
||||
import java.util.Vector;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javaeva.gui.PropertyBoolSelector;
|
||||
import javaeva.gui.PropertyPanel;
|
||||
import javaeva.gui.PropertyText;
|
||||
import javaeva.gui.PropertyValueSelector;
|
||||
import javaeva.server.go.MOCCOStandalone;
|
||||
import javaeva.server.go.tools.GeneralGOEProperty;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
|
@ -15,6 +15,7 @@ import javaeva.server.go.operators.mutation.InterfaceMutation;
|
||||
import javaeva.server.go.operators.mutation.MutateESFixedStepSize;
|
||||
import javaeva.server.go.operators.terminators.EvaluationTerminator;
|
||||
import javaeva.server.go.populations.Population;
|
||||
import javaeva.server.go.problems.AbstractMultiModalProblemKnown;
|
||||
import javaeva.server.go.problems.AbstractOptimizationProblem;
|
||||
import javaeva.server.go.problems.FM0Problem;
|
||||
import javaeva.server.go.problems.InterfaceMultimodalProblemKnown;
|
||||
@ -476,12 +477,13 @@ public class PostProcess {
|
||||
public static void procMultiModalKnown(Population solutions, InterfaceMultimodalProblemKnown mmkProb, InterfaceTextListener listener) {
|
||||
// Population found = getFoundOptima(solutions, mmkProb.getRealOptima(), mmkProb.getEpsilon(), true);
|
||||
if (listener != null) {
|
||||
listener.println("number of known optima is " + mmkProb.getRealOptima().size());
|
||||
listener.println("default epsilon is " + mmkProb.getEpsilon());
|
||||
listener.println("max peak ratio is " + mmkProb.getMaximumPeakRatio(getFoundOptima(solutions, mmkProb.getRealOptima(), mmkProb.getEpsilon(), true)));
|
||||
}
|
||||
for (double epsilon=0.1; epsilon > 0.00000001; epsilon/=10.) {
|
||||
// out.println("no optima found: " + ((InterfaceMultimodalProblemKnown)mmProb).getNumberOfFoundOptima(pop));
|
||||
if (listener != null) listener.println("found " + getFoundOptima(solutions, mmkProb.getRealOptima(), epsilon, true).size() + " for epsilon = " + epsilon);
|
||||
if (listener != null) listener.println("found " + getFoundOptima(solutions, mmkProb.getRealOptima(), epsilon, true).size() + " for epsilon = " + epsilon + ", maxPeakRatio: " + ((AbstractMultiModalProblemKnown)mmkProb).getMaximumPeakRatio(solutions, epsilon));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
|
||||
this.m_Generation = 0;
|
||||
this.m_FunctionCalls = 0;
|
||||
if (!(this.get(0) instanceof InterfaceGAIndividual)) {
|
||||
System.out.println("Members of the population are not instance of InterfaceGAIndividual!");
|
||||
System.err.println("Members of the population are not instance of InterfaceGAIndividual!");
|
||||
return;
|
||||
}
|
||||
this.m_ProbabilityVector = new double[((InterfaceGAIndividual)this.get(0)).getGenotypeLength()];
|
||||
@ -63,9 +63,9 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
|
||||
public void learnFrom (Population examples, double learnRate) {
|
||||
InterfaceGAIndividual tmpIndy;
|
||||
BitSet tmpBitSet;
|
||||
|
||||
|
||||
for (int i = 0; i < examples.size(); i++) {
|
||||
tmpIndy = (InterfaceGAIndividual)((AbstractEAIndividual)examples.get(i)).clone();
|
||||
tmpIndy = (InterfaceGAIndividual)(examples.getEAIndividual(i)).clone();
|
||||
tmpBitSet = tmpIndy.getBGenotype();
|
||||
for (int j = 0; j < this.m_ProbabilityVector.length; j++) {
|
||||
this.m_ProbabilityVector[j] = this.m_ProbabilityVector[j] * (1.0 - learnRate);
|
||||
|
@ -229,8 +229,12 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
* @return double
|
||||
*/
|
||||
public double getMaximumPeakRatio(Population pop) {
|
||||
return getMaximumPeakRatio(pop, m_Epsilon);
|
||||
}
|
||||
|
||||
public double getMaximumPeakRatio(Population pop, double epsilon) {
|
||||
double optimaInvertedSum = 0, foundInvertedSum = 0;
|
||||
AbstractEAIndividual[] optsFound = PostProcess.getFoundOptimaArray(pop, m_Optima, m_Epsilon, true);
|
||||
AbstractEAIndividual[] optsFound = PostProcess.getFoundOptimaArray(pop, m_Optima, epsilon, true);
|
||||
|
||||
for (int i=0; i<m_Optima.size(); i++) {
|
||||
// sum up known optimal fitness values
|
||||
|
@ -20,10 +20,10 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
||||
// }
|
||||
|
||||
protected void initTemplate() {
|
||||
this.m_Template = new ESIndividualDoubleData();
|
||||
if (m_Template == null) m_Template = new ESIndividualDoubleData();
|
||||
if (getProblemDimension() > 0) { // avoid evil case setting dim to 0 during object init
|
||||
((ESIndividualDoubleData)this.m_Template).setDoubleDataLength(getProblemDimension());
|
||||
((ESIndividualDoubleData)this.m_Template).SetDoubleRange(makeRange());
|
||||
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(getProblemDimension());
|
||||
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(makeRange());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
|
||||
boolean forwardStatisticsOutput = false;
|
||||
private MatlabEvalMediator handler = null;
|
||||
|
||||
public static boolean hideFromGOE = true;
|
||||
|
||||
private F1Problem f1 = new F1Problem(); // TODO
|
||||
|
||||
|
@ -832,7 +832,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_ShowCycle = b;
|
||||
}
|
||||
public String showCycleTipText() {
|
||||
return "Determines how often show is performed.";
|
||||
return "Determines how often show is performed (generations); set to zero to deactivate.";
|
||||
}
|
||||
/** Determines the size of the initial population.
|
||||
* @return This number gives initial population size.
|
||||
|
@ -1,5 +1,6 @@
|
||||
package javaeva.server.go.strategies;
|
||||
|
||||
import javaeva.gui.BeanInspector;
|
||||
import javaeva.server.go.InterfacePopulationChangedEventListener;
|
||||
import javaeva.server.go.individuals.AbstractEAIndividual;
|
||||
import javaeva.server.go.operators.mutation.InterfaceMutation;
|
||||
@ -87,7 +88,9 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
if (((AbstractEAIndividual)original.get(i)).isDominatingDebConstraints(((AbstractEAIndividual)this.m_Population.get(i)))) {
|
||||
this.m_Population.remove(i);
|
||||
this.m_Population.add(i, original.get(i));
|
||||
} // else: mutation improved the individual
|
||||
} else {
|
||||
// else: mutation improved the individual
|
||||
}
|
||||
}
|
||||
this.m_Population.incrGeneration();
|
||||
// for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
|
@ -26,6 +26,12 @@ import wsi.ra.jproxy.RMIServer;
|
||||
* island-model has been implemented too to allow fast and reliabel computation.
|
||||
* This is still usefull, since it is less prone to premature convergence and also
|
||||
* an heterogenuous island model can be used.
|
||||
*
|
||||
* A population of the same size is sent to all nodes and evaluated there independently
|
||||
* for a cycle (more precisely: for MigrationRate generations) after which a communication
|
||||
* step is performed according to the migration model. Only after migration is a main
|
||||
* cycle complete, the statistics updated etc.
|
||||
*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 12.09.2004
|
||||
@ -91,7 +97,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.m_Optimizer.SetProblem(this.m_Problem);
|
||||
InterfacePopulationChangedEventListener myLocal = null;
|
||||
if (this.m_Parallelize) {
|
||||
// this is running on remote maschines
|
||||
// this is running on remote machines
|
||||
if (this.m_LocalServer == null) this.m_LocalServer = RMIServer.getInstance();
|
||||
try {
|
||||
myLocal = (InterfacePopulationChangedEventListener) RMIProxyLocal.newInstance(this);
|
||||
|
@ -2,10 +2,12 @@ package javaeva.server.go.strategies;
|
||||
|
||||
import javaeva.server.go.InterfacePopulationChangedEventListener;
|
||||
import javaeva.server.go.individuals.AbstractEAIndividual;
|
||||
import javaeva.server.go.individuals.InterfaceGAIndividual;
|
||||
import javaeva.server.go.operators.selection.InterfaceSelection;
|
||||
import javaeva.server.go.operators.selection.SelectBestIndividuals;
|
||||
import javaeva.server.go.populations.PBILPopulation;
|
||||
import javaeva.server.go.populations.Population;
|
||||
import javaeva.server.go.problems.AbstractOptimizationProblem;
|
||||
import javaeva.server.go.problems.B1Problem;
|
||||
import javaeva.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
@ -64,6 +66,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
public void initByPopulation(Population pop, boolean reset) {
|
||||
if (!(pop.getEAIndividual(0) instanceof InterfaceGAIndividual)) {
|
||||
System.err.println("Error: PBIL only works with GAIndividuals!");
|
||||
}
|
||||
this.m_Population = new PBILPopulation();
|
||||
if (reset) this.m_Population.init();
|
||||
this.m_Population.addPopulation((Population)pop.clone());
|
||||
@ -120,6 +125,11 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
*/
|
||||
public void SetProblem (InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
if (m_Problem instanceof AbstractOptimizationProblem) {
|
||||
if (!(((AbstractOptimizationProblem)m_Problem).getIndividualTemplate() instanceof InterfaceGAIndividual)) {
|
||||
System.err.println("Error: PBIL only works with GAIndividuals!");
|
||||
}
|
||||
}
|
||||
}
|
||||
public InterfaceOptimizationProblem getProblem () {
|
||||
return this.m_Problem;
|
||||
|
@ -723,16 +723,13 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
public String globalInfo() {
|
||||
return "TRIBES: a parameter free PSO implementation by Maurice Clerc.";
|
||||
}
|
||||
|
||||
public void incEvalCnt(int k) {
|
||||
population.incrFunctionCallsby(k);
|
||||
if (notifyAfter(population.getFunctionCalls())) {
|
||||
firePropertyChangedEvent("NextGenerationPerformed");
|
||||
}
|
||||
}
|
||||
|
||||
public void incEvalCnt() {
|
||||
incEvalCnt(1);
|
||||
population.incrFunctionCalls();
|
||||
if (notifyAfter(population.getFunctionCalls())) {
|
||||
// System.out.println("Notifying after " + population.getFunctionCalls());
|
||||
firePropertyChangedEvent("NextGenerationPerformed");
|
||||
}
|
||||
}
|
||||
|
||||
public double getObjectiveFirstDim() {
|
||||
|
@ -2,12 +2,13 @@ package javaeva.server.go.strategies.tribes;
|
||||
|
||||
import javaeva.server.go.individuals.AbstractEAIndividual;
|
||||
import javaeva.server.go.individuals.InterfaceDataTypeDouble;
|
||||
import javaeva.server.go.individuals.InterfaceESIndividual;
|
||||
import javaeva.server.go.populations.Population;
|
||||
import javaeva.server.go.problems.InterfaceOptimizationProblem;
|
||||
import javaeva.server.go.strategies.Tribes;
|
||||
import javaeva.server.go.tools.RandomNumberGenerator;
|
||||
|
||||
public class TribesExplorer extends AbstractEAIndividual implements InterfaceDataTypeDouble {
|
||||
public class TribesExplorer extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeDouble {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -82,11 +83,11 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
||||
// }
|
||||
|
||||
public double[] getFitness() {
|
||||
return position.fitness;
|
||||
return position.getFitness();
|
||||
}
|
||||
|
||||
public double getFitness(int index) {
|
||||
return position.fitness[index];
|
||||
return position.getFitness()[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,6 +96,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
||||
*/
|
||||
public void SetFitness(double[] fitness) {
|
||||
position.fitness = fitness;
|
||||
super.SetFitness(fitness);
|
||||
fitness[0] -= objectiveValueFirstDim;
|
||||
position.setTotalError();
|
||||
}
|
||||
@ -104,6 +106,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
||||
* by reducing the fitness (in the first dimension).
|
||||
*/
|
||||
public void SetFitness(int index, double fitness) {
|
||||
super.SetFitness(index, fitness);
|
||||
if (index > position.fitness.length) {
|
||||
double[] newFit = new double[index+1];
|
||||
System.arraycopy(position.fitness, 0, newFit, 0, position.fitness.length);
|
||||
@ -440,11 +443,11 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
||||
// pb.fitnessSize, eval);
|
||||
} else { // Artificial fitness by using penalties
|
||||
for (n = 0; n < position.fitness.length; n++) {
|
||||
position.fitness[n] = swarm.tribes[fromTribe].memory[
|
||||
SetFitness(n, swarm.tribes[fromTribe].memory[
|
||||
contact].
|
||||
getPos().
|
||||
fitness[n] +
|
||||
keepInPenalty(range, position);
|
||||
keepInPenalty(range, position));
|
||||
}
|
||||
// position.totalError(position.fitness); // MK: this wont actually do anything
|
||||
}
|
||||
@ -1016,4 +1019,20 @@ v[d] = cmin * v[d];
|
||||
public int size() {
|
||||
return position.x.length;
|
||||
}
|
||||
|
||||
public void SetDGenotype(double[] b) {
|
||||
position.setDoubleArray(b);
|
||||
}
|
||||
|
||||
public void defaultInit() {
|
||||
System.err.println("defaultInit not available for TribesExplorer!");
|
||||
}
|
||||
|
||||
public void defaultMutate() {
|
||||
System.err.println("defaultMutate not available for TribesExplorer!");
|
||||
}
|
||||
|
||||
public double[] getDGenotype() {
|
||||
return position.getDoubleArray().clone();
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class TribesMemory implements java.io.Serializable {
|
||||
si la valeur de la position a diminué
|
||||
*/
|
||||
|
||||
if (position.firstIsBetter(position.fitness,positionPrev.fitness)) {
|
||||
if (position.firstIsBetter(position.getFitness(),positionPrev.getFitness())) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -54,10 +54,22 @@ public class TribesPosition implements java.io.Serializable {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* This one makes a deep copy.
|
||||
* @param vals
|
||||
*/
|
||||
public void setDoubleArray(double[] vals) {
|
||||
x = vals.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* This one makes a shallow copy.
|
||||
* @param fit
|
||||
*/
|
||||
public void setFitness(double[] fit) {
|
||||
fitness = fit;
|
||||
}
|
||||
|
||||
public int getMaxDimension() {
|
||||
return x.length;
|
||||
}
|
||||
|
@ -105,11 +105,11 @@ public class TribesSwarm implements java.io.Serializable{
|
||||
// swarmInitOption -> param option Options: 0 - random, 1 - on the bounds, 2 - sunny spell, 3 - around a center
|
||||
// rangeInitType -> initType: for options 0,1: 1 means use initRange, 0 use default range
|
||||
explorer[n] = generateExplorer(null, -1, swarmInitOption, -1, rangeInitType, prob, false);
|
||||
|
||||
masterTribe.incEvalCnt();
|
||||
// Note : le contact sera défini durant la génération de la tribu
|
||||
|
||||
}
|
||||
masterTribe.incEvalCnt(initNb);
|
||||
// masterTribe.incEvalCnt(initNb);
|
||||
addTribe(initNb, explorer);
|
||||
}
|
||||
|
||||
@ -141,8 +141,8 @@ public class TribesSwarm implements java.io.Serializable{
|
||||
updateQueen(range, prob); // this costs an evaluation
|
||||
// evals++;
|
||||
|
||||
if (queen.position.firstIsBetter(queen.position.fitness,
|
||||
bestMem.getPos().fitness)) {
|
||||
if (queen.position.firstIsBetter(queen.position.getFitness(),
|
||||
bestMem.getPos().getFitness())) {
|
||||
|
||||
int[] worst = findWorst();
|
||||
|
||||
@ -176,14 +176,14 @@ public class TribesSwarm implements java.io.Serializable{
|
||||
int[] found = new int[2];
|
||||
found[0] = 0;
|
||||
found[1] = 0;
|
||||
double[] f = tribes[found[0]].memory[found[1]].getPos().fitness;
|
||||
double[] f = tribes[found[0]].memory[found[1]].getPos().getFitness();
|
||||
double[] f2;
|
||||
|
||||
for (n = 0; n < tribeNb; n++) {
|
||||
for (m = 0; m < tribes[n].memoryNb; m++) {
|
||||
// System.arraycopy(tribes[n].memory[m].position.fitness, 0, f2,
|
||||
// 0, fitnessSize);
|
||||
f2 = tribes[n].memory[m].getPos().fitness;
|
||||
f2 = tribes[n].memory[m].getPos().getFitness();
|
||||
// this is not XOR! (for multi-objective fitness, betterThan is not symmetrical)
|
||||
if ((switchBest && tribes[n].memory[m].getPos().firstIsBetter(f2, f))
|
||||
|| (!switchBest && tribes[n].memory[m].getPos().firstIsBetter(f, f2))) {
|
||||
|
@ -2,7 +2,7 @@ package javaeva.server.modules;
|
||||
|
||||
import javaeva.server.go.InterfaceGOParameters;
|
||||
import javaeva.server.stat.StatisticsWithGUI;
|
||||
import javaeva.server.stat.StatisticsParameter;
|
||||
import javaeva.server.stat.InterfaceStatisticsParameter;
|
||||
import javaeva.server.EvAServer;
|
||||
import javaeva.gui.GenericObjectEditor;
|
||||
import javaeva.gui.JTabbedModuleFrame;
|
||||
@ -53,7 +53,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
|
||||
public JTabbedModuleFrame getModuleFrame() {
|
||||
if (TRACE) System.out.println("GenericModulAdapter.getModuleFrame");
|
||||
ArrayList<Object> GUIContainer = new ArrayList<Object>();
|
||||
StatisticsParameter Stat = ((StatisticsWithGUI)m_StatisticsModul).getStatisticsParameter();
|
||||
InterfaceStatisticsParameter Stat = ((StatisticsWithGUI)m_StatisticsModul).getStatisticsParameter();
|
||||
JModuleGeneralPanel ButtonPanel = new JModuleGeneralPanel(m_RemoteThis,((Processor)m_Processor).isOptRunning());
|
||||
ButtonPanel.setHelperFilename(helperFilename);
|
||||
GUIContainer.add(ButtonPanel);
|
||||
|
@ -2,7 +2,7 @@ package javaeva.server.modules;
|
||||
|
||||
import javaeva.server.go.InterfaceGOParameters;
|
||||
import javaeva.server.stat.StatisticsWithGUI;
|
||||
import javaeva.server.stat.StatisticsParameter;
|
||||
import javaeva.server.stat.InterfaceStatisticsParameter;
|
||||
import javaeva.server.EvAServer;
|
||||
import javaeva.gui.JTabbedModuleFrame;
|
||||
import javaeva.gui.JModuleGeneralPanel;
|
||||
|
@ -8,6 +8,7 @@ import javaeva.server.go.PopulationInterface;
|
||||
import javaeva.server.go.operators.postprocess.PostProcess;
|
||||
import javaeva.server.go.operators.postprocess.PostProcessParams;
|
||||
import javaeva.server.go.operators.terminators.EvaluationTerminator;
|
||||
import javaeva.server.go.operators.terminators.GenerationTerminator;
|
||||
import javaeva.server.go.populations.Population;
|
||||
import javaeva.server.go.problems.AbstractOptimizationProblem;
|
||||
import javaeva.server.go.tools.RandomNumberGenerator;
|
||||
@ -29,7 +30,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
// private volatile boolean m_doRunScript;
|
||||
private InterfaceStatistics m_Statistics;
|
||||
private InterfaceGOParameters goParams;
|
||||
private boolean m_createInitialPopulations=true;
|
||||
private boolean m_createInitialPopulations = true;
|
||||
private boolean saveParams = true;
|
||||
private RemoteStateListener m_ListenerModule;
|
||||
private boolean wasRestarted = false;
|
||||
@ -167,38 +168,13 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
if (wasRestarted) m_ListenerModule.performedRestart(getInfoString());
|
||||
else m_ListenerModule.performedStart(getInfoString());
|
||||
}
|
||||
|
||||
// if (this.show) this.m_StatusField.setText("Optimizing...");
|
||||
|
||||
// opening output file...
|
||||
// String name = this.m_ModulParameter.getOutputFileName();
|
||||
// if (!name.equalsIgnoreCase("none") && !name.equals("")) {
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss");
|
||||
// String m_StartDate = formatter.format(new Date());
|
||||
// name = this.m_OutputPath + name +"_"+this.m_ModulParameter.getOptimizer().getName()+"_"+m_StartDate+".dat";
|
||||
// try {
|
||||
// this.m_OutputFile = new BufferedWriter(new OutputStreamWriter (new FileOutputStream (name)));
|
||||
// } catch (FileNotFoundException e) {
|
||||
// System.err.println("Could not open output file! Filename: " + name);
|
||||
// }
|
||||
// //this.writeToFile(" FitnessCalls\t Best\t Mean\t Worst \t" + this.m_ModulParameter.getProblem().getAdditionalFileStringHeader(this.m_ModulParameter.getOptimizer().getPopulation()));
|
||||
// } else {
|
||||
// this.m_OutputFile = null;
|
||||
// }
|
||||
|
||||
|
||||
goParams.getOptimizer().addPopulationChangedEventListener(this);
|
||||
|
||||
runCounter = 0;
|
||||
|
||||
while (isOptRunning() && (runCounter<m_Statistics.getStatisticsParameter().getMultiRuns())) {
|
||||
// for (int runCounter = 0; runCounter<m_Statistics.getStatisticsParameter().getMultiRuns(); runCounter++) {
|
||||
m_Statistics.startOptPerformed(getInfoString(),runCounter);
|
||||
m_Statistics.printToTextListener("\n****** Multirun "+runCounter);
|
||||
//m_Statistics.startOptPerformed(infoString,runCounter);
|
||||
m_Statistics.printToTextListener("\nModule parameters: ");
|
||||
m_Statistics.printToTextListener(BeanInspector.toString(goParams));
|
||||
m_Statistics.printToTextListener("\nStatistics parameters: ");
|
||||
m_Statistics.printToTextListener(BeanInspector.toString(m_Statistics.getStatisticsParameter()) + '\n');
|
||||
m_Statistics.startOptPerformed(getInfoString(),runCounter, goParams);
|
||||
|
||||
this.goParams.getProblem().initProblem();
|
||||
this.goParams.getOptimizer().SetProblem(this.goParams.getProblem());
|
||||
@ -210,8 +186,8 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
|
||||
do { // main loop
|
||||
this.goParams.getOptimizer().optimize();
|
||||
// m_Statistics.createNextGenerationPerformed((PopulationInterface)this.m_ModulParameter.getOptimizer().getPopulation());
|
||||
// m_ListenerModule.updateProgress(getStatusPercent(m_ModulParameter.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()));
|
||||
// registerPopulationStateChanged *SHOULD* be fired by the optimizer or resp. the population
|
||||
// as we are event listener
|
||||
} while (isOptRunning() && !this.goParams.getTerminator().isTerminated(this.goParams.getOptimizer().getPopulation()));
|
||||
runCounter++;
|
||||
|
||||
@ -230,46 +206,46 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
||||
return resultPop;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return the percentage of current (multi-)run already performed
|
||||
*/
|
||||
private int getStatusPercent(Population pop, int currentRun, int multiRuns) {
|
||||
double x = 100/multiRuns;
|
||||
double percentPerRun = 100/multiRuns;
|
||||
int curProgress;
|
||||
if (this.goParams.getTerminator() instanceof EvaluationTerminator) {
|
||||
double y = x/(double)((EvaluationTerminator)this.goParams.getTerminator()).getFitnessCalls();
|
||||
curProgress = (int)(currentRun * x + pop.getFunctionCalls()*y);
|
||||
} else {
|
||||
curProgress = (int)(currentRun * x);
|
||||
}
|
||||
double curRunPerf = pop.getFunctionCalls()*percentPerRun/(double)((EvaluationTerminator)this.goParams.getTerminator()).getFitnessCalls();
|
||||
curProgress = (int)(currentRun * percentPerRun + curRunPerf);
|
||||
} else if (this.goParams.getTerminator() instanceof GenerationTerminator) {
|
||||
double curRunPerf = pop.getGeneration()*percentPerRun/(double)((GenerationTerminator)this.goParams.getTerminator()).getGenerations();
|
||||
curProgress = (int)(currentRun * percentPerRun + curRunPerf);
|
||||
} else curProgress = (int)(currentRun * percentPerRun);
|
||||
return curProgress;
|
||||
}
|
||||
|
||||
/** This method allows an optimizer to register a change in the optimizer.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
// Population population = ((InterfaceOptimizer)source).getPopulation();
|
||||
|
||||
m_Statistics.createNextGenerationPerformed((PopulationInterface)this.goParams.getOptimizer().getPopulation(), this.goParams.getProblem());
|
||||
if (m_ListenerModule != null) m_ListenerModule.updateProgress(getStatusPercent(goParams.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()), null);
|
||||
|
||||
// if (this.m_OutputFile != null) {
|
||||
// // data to be stored in file
|
||||
//// double tmpd = 0;
|
||||
// StringBuffer tmpLine = new StringBuffer("");
|
||||
// tmpLine.append(population.getFunctionCalls());
|
||||
// tmpLine.append("\t");
|
||||
// tmpLine.append(BeanInspector.toString(population.getBestEAIndividual().getFitness()));
|
||||
// tmpLine.append("\t");
|
||||
// double[] fit = population.getMeanFitness();
|
||||
// //for (int i = 0; i < population.size(); i++) tmpd += ((AbstractEAIndividual)population.get(i)).getFitness(0)/(double)population.size();
|
||||
// tmpLine.append(BeanInspector.toString(fit));
|
||||
// tmpLine.append("\t");
|
||||
// tmpLine.append(BeanInspector.toString(population.getWorstEAIndividual().getFitness()));
|
||||
// tmpLine.append("\t");
|
||||
// //tmpLine.append(population.getBestEAIndividual().getStringRepresentation());
|
||||
// tmpLine.append(this.m_ModulParameter.getProblem().getAdditionalFileStringValue(population));
|
||||
// //this.writeToFile(tmpLine.toString());
|
||||
// }
|
||||
m_Statistics.createNextGenerationPerformed(
|
||||
(PopulationInterface)this.goParams.getOptimizer().getPopulation(),
|
||||
this.goParams.getProblem());
|
||||
if (m_ListenerModule != null) {
|
||||
m_ListenerModule.updateProgress(
|
||||
getStatusPercent(
|
||||
goParams.getOptimizer().getPopulation(),
|
||||
runCounter,
|
||||
m_Statistics.getStatisticsParameter().getMultiRuns()),
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method writes Data to file.
|
||||
|
@ -17,13 +17,29 @@ import wsi.ra.tool.StatisticUtils;
|
||||
public abstract class AbstractStatistics implements InterfaceTextListener, InterfaceStatistics {
|
||||
private PrintWriter resultOut;
|
||||
public final static boolean TRACE = false;
|
||||
protected StatisticsParameter m_StatisticsParameter;
|
||||
protected InterfaceStatisticsParameter m_StatsParams;
|
||||
protected String startDate;
|
||||
protected long startTime;
|
||||
|
||||
|
||||
/**
|
||||
* Keep track of all intermediate fitness values, best, avg. and worst, averaging over all runs
|
||||
* for final output, "refining" the multi run data.
|
||||
* If the runs have different lengths, the shortest of all defines the length
|
||||
* of averaged data to be displayed. This mechanism expects that createNextGenerationPerformed
|
||||
* comes in regular intervals (in terms of function calls performed). This needs to be emulated
|
||||
* by dynamic population optimizers, also due to the graph output.
|
||||
*/
|
||||
private boolean refineMultiRuns = true;
|
||||
private ArrayList<double[][]> meanCollection;
|
||||
|
||||
// say whether the object should be written to a file every time
|
||||
private boolean saveParams = true;
|
||||
private boolean firstPlot = true;
|
||||
private int runIterCnt = 0;
|
||||
// show this many iterations of the averaged performance after a full multi-run
|
||||
private int showAvgIntervals = 9;
|
||||
|
||||
// collect data
|
||||
protected int functionCalls;
|
||||
protected int functionCallSum;
|
||||
protected int convergenceCnt;
|
||||
@ -42,7 +58,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
functionCallSum = 0;
|
||||
convergenceCnt = 0;
|
||||
optRunsPerformed = 0;
|
||||
|
||||
runIterCnt = 0;
|
||||
textListeners = new ArrayList<InterfaceTextListener>();
|
||||
}
|
||||
|
||||
@ -60,8 +76,10 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
startDate = formatter.format(new Date());
|
||||
startTime = System.currentTimeMillis();
|
||||
// open the result file:
|
||||
String resFName = m_StatisticsParameter.getResultFileName();
|
||||
if (!resFName.equalsIgnoreCase("none") && !resFName.equals("")) {
|
||||
String resFName = m_StatsParams.getResultFileName();
|
||||
if ((m_StatsParams.getOutputTo().getSelectedTagID()!=1) // not "text only"
|
||||
&& (m_StatsParams.getOutputVerbosity().getSelectedTagID() > StatsParameter.VERBOSITY_NONE)) { // verbosity accordingly high
|
||||
//!resFName.equalsIgnoreCase("none") && !resFName.equals("")) {
|
||||
String name = resFName + "_" + startDate + ".txt";
|
||||
if (TRACE) System.out.println("FileName =" + name);
|
||||
try {
|
||||
@ -76,7 +94,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
/**
|
||||
* If set to true, before every run the parameters will be stored to a file.
|
||||
* If set to true, before every run the parameters will be stored to a file at the start
|
||||
* of each run. Default is true.
|
||||
*
|
||||
* @param doSave
|
||||
*/
|
||||
@ -84,46 +103,64 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
saveParams = doSave;
|
||||
}
|
||||
|
||||
public void startOptPerformed(String infoString, int runNumber) {
|
||||
public void startOptPerformed(String infoString, int runNumber, Object params) {
|
||||
if (TRACE) System.out.println("AbstractStatistics.startOptPerformed " + runNumber);
|
||||
if (runNumber == 0) {
|
||||
functionCallSum = 0;
|
||||
firstPlot = true;
|
||||
optRunsPerformed = 0;
|
||||
convergenceCnt = 0;
|
||||
if (saveParams) m_StatisticsParameter.saveInstance();
|
||||
if (saveParams) m_StatsParams.saveInstance();
|
||||
initOutput();
|
||||
bestCurrentIndividual = null;
|
||||
bestIndivdualAllover = null;
|
||||
if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
|
||||
else meanCollection = null;
|
||||
}
|
||||
runIterCnt = 0;
|
||||
if (printRunIntroVerbosity()) printToTextListener("\n****** Multirun "+runNumber);
|
||||
if (params != null) {
|
||||
if (printRunIntroVerbosity()) printToTextListener("\nModule parameters: ");
|
||||
if (printRunIntroVerbosity()) printToTextListener(BeanInspector.toString(params));
|
||||
}
|
||||
if (printRunIntroVerbosity()) printToTextListener("\nStatistics parameters: ");
|
||||
if (printRunIntroVerbosity()) printToTextListener(BeanInspector.toString(getStatisticsParameter()) + '\n');
|
||||
functionCalls = 0;
|
||||
}
|
||||
|
||||
public void stopOptPerformed(boolean normal) {
|
||||
if (TRACE) System.out.println("AbstractStatistics.stopOptPerformed");
|
||||
if (runIterCnt < meanCollection.size()) {
|
||||
// no good: later run was shorter than the first one. What to do? Discard the longer one:
|
||||
if (TRACE) System.err.println("Error in AbstractStatistics: later run was shorter than earlier one... discarding rest...");
|
||||
for (int i=meanCollection.size()-1; i>=runIterCnt; i--) meanCollection.remove(i);
|
||||
}
|
||||
optRunsPerformed++;
|
||||
functionCallSum += functionCalls;
|
||||
// check for convergence
|
||||
if (bestCurrentIndividual != null) {
|
||||
if (StatisticUtils.norm(bestCurrentIndividual.getFitness()) < this.m_StatisticsParameter.getConvergenceRateThreshold()) {
|
||||
if (StatisticUtils.norm(bestCurrentIndividual.getFitness()) < this.m_StatsParams.getConvergenceRateThreshold()) {
|
||||
convergenceCnt++;
|
||||
}
|
||||
printToTextListener(" Best solution: " + BeanInspector.toString(bestCurrentIndividual) + "\n");
|
||||
printToTextListener(AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
|
||||
if (printRunStoppedVerbosity()) printToTextListener(" Best solution: " + BeanInspector.toString(bestCurrentIndividual) + "\n");
|
||||
if (printRunStoppedVerbosity()) printToTextListener(AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
|
||||
}
|
||||
if (currentBestFit!= null) {
|
||||
printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
||||
if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
||||
}
|
||||
if (optRunsPerformed == m_StatisticsParameter.getMultiRuns()) finalizeOutput();
|
||||
if (optRunsPerformed == m_StatsParams.getMultiRuns()) finalizeOutput();
|
||||
}
|
||||
|
||||
protected void finalizeOutput() {
|
||||
printToTextListener("*******\n Reached target " + convergenceCnt + " times with threshold " + m_StatisticsParameter.getConvergenceRateThreshold() + ", rate " + convergenceCnt/(double)m_StatisticsParameter.getMultiRuns() + '\n');
|
||||
printToTextListener("Best overall individual: " + BeanInspector.toString(bestIndivdualAllover) + '\n');
|
||||
printToTextListener(" solution : " + AbstractEAIndividual.getDefaultDataString(bestIndivdualAllover) + '\n');
|
||||
printToTextListener(" fitness : " + BeanInspector.toString(bestIndivdualAllover.getFitness()) + '\n');
|
||||
if (TRACE)
|
||||
System.out.println("stopOptPerformed");
|
||||
if (printFinalVerbosity()) printToTextListener("*******\n Runs performed: " + optRunsPerformed + ", reached target " + convergenceCnt + " times with threshold " + m_StatsParams.getConvergenceRateThreshold() + ", rate " + convergenceCnt/(double)m_StatsParams.getMultiRuns() + '\n');
|
||||
if (printFinalVerbosity()) printToTextListener("Best overall individual: " + BeanInspector.toString(bestIndivdualAllover) + '\n');
|
||||
if (printFinalVerbosity()) printToTextListener(" solution : " + AbstractEAIndividual.getDefaultDataString(bestIndivdualAllover) + '\n');
|
||||
if (printFinalVerbosity()) printToTextListener(" fitness : " + BeanInspector.toString(bestIndivdualAllover.getFitness()) + '\n');
|
||||
if (refineMultiRuns && (optRunsPerformed>1) && (meanCollection != null)) {
|
||||
if (printFinalVerbosity()) printToTextListener("Averaged performance:\n");
|
||||
for (int i=0; i<meanCollection.size(); i++) divideMean(meanCollection.get(i), optRunsPerformed);
|
||||
if (printFinalVerbosity()) printToTextListener(refineToText(meanCollection, showAvgIntervals));
|
||||
}
|
||||
if (TRACE)
|
||||
System.out.println("End of run");
|
||||
if (resultOut != null) {
|
||||
@ -135,12 +172,39 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
}
|
||||
|
||||
public static String refineToText(ArrayList<double[][]> result, int iterationsToShow) {
|
||||
double[][] mean;
|
||||
StringBuffer sbuf = new StringBuffer("Iteration\tFun.Calls\tBest\tMean\tWorst\n");
|
||||
double step = result.size()/(iterationsToShow-1.);
|
||||
int printedIteration=0;
|
||||
|
||||
for(int i = 1; i < result.size()+1; i++) {
|
||||
// print the first, last and intermediate iterations requested by the integer parameter
|
||||
// first one is printed always, as printedIteration=0
|
||||
if ((i==result.size()) || ((i-1)==Math.round(printedIteration*step))) {
|
||||
printedIteration++;
|
||||
mean = result.get(i-1);
|
||||
sbuf.append(i);
|
||||
sbuf.append("\t");
|
||||
sbuf.append(BeanInspector.toString(mean[0]));
|
||||
sbuf.append("\t");
|
||||
sbuf.append(BeanInspector.toString(mean[1]));
|
||||
sbuf.append("\t");
|
||||
sbuf.append(BeanInspector.toString(mean[2]));
|
||||
sbuf.append("\t");
|
||||
sbuf.append(BeanInspector.toString(mean[3]));
|
||||
sbuf.append("\n");
|
||||
}
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
public abstract String getHostName();
|
||||
|
||||
public void printToTextListener(String s) {
|
||||
if ((resultOut != null)) resultOut.print(s);
|
||||
for (InterfaceTextListener l : textListeners) {
|
||||
if (m_StatisticsParameter.isShowTextOutput()) l.print(s);
|
||||
if (m_StatsParams.getOutputTo().getSelectedTagID() >= 1) l.print(s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +218,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
printToTextListener("\n");
|
||||
}
|
||||
|
||||
public StatisticsParameter getStatisticsParameter() {
|
||||
return m_StatisticsParameter;
|
||||
public InterfaceStatisticsParameter getStatisticsParameter() {
|
||||
return m_StatsParams;
|
||||
}
|
||||
|
||||
protected boolean doTextOutput() {
|
||||
@ -164,33 +228,27 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
|
||||
protected String getOutputHeader(InterfaceAdditionalPopulationInformer informer, PopulationInterface pop) {
|
||||
String headline = "Fit.-calls \t Best \t Mean \t Worst ";
|
||||
if (informer == null)
|
||||
if ((informer == null) || !m_StatsParams.isOutputAdditionalInfo()) {
|
||||
return headline;
|
||||
else return headline + "\t " + informer.getAdditionalFileStringHeader(pop);
|
||||
} else return headline + "\t " + informer.getAdditionalFileStringHeader(pop);
|
||||
}
|
||||
|
||||
protected String getOutputLine(InterfaceAdditionalPopulationInformer informer, PopulationInterface pop) {
|
||||
StringBuffer sbuf = new StringBuffer(Integer.toString(functionCalls));
|
||||
sbuf.append("\t");
|
||||
sbuf.append(" \t ");
|
||||
sbuf.append(BeanInspector.toString(currentBestFit));
|
||||
sbuf.append("\t");
|
||||
if (meanFitness != null) {
|
||||
sbuf.append(" \t ");
|
||||
sbuf.append(BeanInspector.toString(meanFitness));
|
||||
sbuf.append(" \t ");
|
||||
} else sbuf.append("- \t ");
|
||||
} else sbuf.append(" \t #");
|
||||
if (currentWorstFit != null) {
|
||||
sbuf.append(BeanInspector.toString(currentWorstFit));
|
||||
sbuf.append(" \t ");
|
||||
} else sbuf.append(" - \t ");
|
||||
if (informer != null) {
|
||||
sbuf.append(BeanInspector.toString(currentWorstFit));
|
||||
} else sbuf.append(" # \t");
|
||||
if (informer != null && m_StatsParams.isOutputAdditionalInfo()) {
|
||||
sbuf.append(" \t ");
|
||||
sbuf.append(informer.getAdditionalFileStringValue(pop));
|
||||
}
|
||||
// if (m_BestIndividual instanceof AbstractEAIndividual) {
|
||||
// sbuf.append(((AbstractEAIndividual)m_BestIndividual).getStringRepresentation());
|
||||
// } else {
|
||||
// sbuf.append(m_BestIndividual.toString());
|
||||
// }
|
||||
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
@ -205,13 +263,15 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
meanFitness = null;
|
||||
|
||||
if (firstPlot) {
|
||||
initPlots(m_StatisticsParameter.getPlotDescriptions());
|
||||
if (doTextOutput()) printToTextListener(getOutputHeader(null, null)+'\n');
|
||||
initPlots(m_StatsParams.getPlotDescriptions());
|
||||
// if (doTextOutput()) printToTextListener(getOutputHeader(null, null)+'\n');
|
||||
firstPlot = false;
|
||||
}
|
||||
if ((runIterCnt == 0) && printHeaderByVerbosity()) printToTextListener(getOutputHeader(null, null)+'\n');
|
||||
|
||||
if (doTextOutput()) printToTextListener(getOutputLine(null, null)+'\n');
|
||||
if (doTextOutput() && printLineByVerbosity(calls)) printToTextListener(getOutputLine(null, null)+'\n');
|
||||
plotCurrentResults();
|
||||
runIterCnt++;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,10 +295,11 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
public synchronized void createNextGenerationPerformed(PopulationInterface
|
||||
pop, InterfaceAdditionalPopulationInformer informer) {
|
||||
if (firstPlot) {
|
||||
initPlots(m_StatisticsParameter.getPlotDescriptions());
|
||||
if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
||||
initPlots(m_StatsParams.getPlotDescriptions());
|
||||
// if (doTextOutput()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
||||
firstPlot = false;
|
||||
}
|
||||
if ((runIterCnt==0) && printHeaderByVerbosity()) printToTextListener(getOutputHeader(informer, pop)+'\n');
|
||||
|
||||
if (pop.getSpecificData() != null) {
|
||||
plotSpecificData(pop, informer);
|
||||
@ -263,9 +324,73 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
meanFitness = pop.getMeanFitness().clone();
|
||||
currentWorstFit = pop.getWorstIndividual().getFitness().clone();
|
||||
functionCalls = pop.getFunctionCalls();
|
||||
|
||||
if (doTextOutput()) printToTextListener(getOutputLine(informer, pop)+'\n');
|
||||
|
||||
if (meanCollection != null) {
|
||||
// Collect average data
|
||||
double[][] means = null;
|
||||
if ((optRunsPerformed==0) && (meanCollection.size()<=runIterCnt)) {
|
||||
// in the first run, newly allocate the arrays
|
||||
means = new double[4][currentBestFit.length];
|
||||
meanCollection.add(means);
|
||||
} else {
|
||||
if (meanCollection.size()<=runIterCnt) {// bad case!
|
||||
// may happen for dynamic pop-sizes, e.g. in Tribe, when runs do not necessarily send the
|
||||
// "generation performed" event the same number of times.
|
||||
// thus: dont do an update for events that are "too late"
|
||||
means = null;
|
||||
} else means = meanCollection.get(runIterCnt);
|
||||
}
|
||||
if (means != null) updateMeans(means, functionCalls, currentBestFit, meanFitness, currentWorstFit);
|
||||
}
|
||||
// meanCollection.set(pop.getGenerations()-1, means);
|
||||
|
||||
if (doTextOutput() && printLineByVerbosity(runIterCnt)) printToTextListener(getOutputLine(informer, pop)+'\n');
|
||||
plotCurrentResults();
|
||||
|
||||
runIterCnt++;
|
||||
}
|
||||
|
||||
private boolean printLineByVerbosity(int iteration) {
|
||||
return (m_StatsParams.getOutputVerbosity().getSelectedTagID() > StatsParameter.VERBOSITY_KTH_IT)
|
||||
|| ((m_StatsParams.getOutputVerbosity().getSelectedTagID() == StatsParameter.VERBOSITY_KTH_IT)
|
||||
&& (isKthRun(iteration, m_StatsParams.getOutputVerbosityK())));
|
||||
}
|
||||
|
||||
private boolean printRunIntroVerbosity() {
|
||||
return (m_StatsParams.getOutputVerbosity().getSelectedTagID() >= StatsParameter.VERBOSITY_KTH_IT);
|
||||
}
|
||||
|
||||
private boolean printRunStoppedVerbosity() {
|
||||
return (m_StatsParams.getOutputVerbosity().getSelectedTagID() >= StatsParameter.VERBOSITY_KTH_IT);
|
||||
}
|
||||
|
||||
private boolean printFinalVerbosity() {
|
||||
return (m_StatsParams.getOutputVerbosity().getSelectedTagID() > StatsParameter.VERBOSITY_NONE);
|
||||
}
|
||||
|
||||
private boolean isKthRun(int i, int k) {
|
||||
return (i % k) == 0;
|
||||
}
|
||||
|
||||
private boolean printHeaderByVerbosity() {
|
||||
return (m_StatsParams.getOutputVerbosity().getSelectedTagID() >= StatsParameter.VERBOSITY_KTH_IT);
|
||||
}
|
||||
|
||||
private void updateMeans(double[][] means, double funCalls, double[] bestFit, double[] meanFit, double[] worstFit) {
|
||||
means[0][0]+=funCalls;
|
||||
addMean(means[1], bestFit);
|
||||
addMean(means[2], meanFit);
|
||||
addMean(means[3], worstFit);
|
||||
}
|
||||
|
||||
private static void divideMean(double[][] mean, double d) {
|
||||
for (int i=0; i<mean.length; i++) {
|
||||
for (int j=0; j<mean[i].length; j++) mean[i][j] /= d;
|
||||
}
|
||||
}
|
||||
|
||||
private void addMean(double[] mean, double[] fit) {
|
||||
for (int i=0; i<mean.length; i++) mean[i] += fit[i];
|
||||
}
|
||||
|
||||
private boolean secondIsBetter(IndividualInterface indy1, IndividualInterface indy2) {
|
||||
|
@ -13,6 +13,7 @@ package javaeva.server.stat;
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import javaeva.server.go.IndividualInterface;
|
||||
import javaeva.server.go.InterfaceGOParameters;
|
||||
import javaeva.server.go.PopulationInterface;
|
||||
import javaeva.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
/*==========================================================================*
|
||||
@ -25,7 +26,7 @@ public interface InterfaceStatistics {
|
||||
/**
|
||||
* Initialize statistics computations.
|
||||
*/
|
||||
public void startOptPerformed(String InfoString,int runnumber); // called from processor
|
||||
public void startOptPerformed(String InfoString,int runnumber, Object params); // called from processor
|
||||
/**
|
||||
* Finalize statistics computations.
|
||||
*/
|
||||
@ -35,7 +36,7 @@ public interface InterfaceStatistics {
|
||||
public void printToTextListener(String s);
|
||||
public void createNextGenerationPerformed(PopulationInterface Pop, InterfaceAdditionalPopulationInformer informer);
|
||||
public void createNextGenerationPerformed(double[] bestfit,double[] worstfit,int calls);
|
||||
public StatisticsParameter getStatisticsParameter(); // called from moduleadapter
|
||||
public InterfaceStatisticsParameter getStatisticsParameter(); // called from moduleadapter
|
||||
public IndividualInterface getBestSolution(); // returns the best overall solution
|
||||
public double[] getBestFitness(); // returns the best overall fitness
|
||||
}
|
@ -21,7 +21,7 @@ import javaeva.tools.SelectedTag;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface StatisticsParameter {
|
||||
public interface InterfaceStatisticsParameter {
|
||||
public String getName();
|
||||
public void saveInstance();
|
||||
public String globalInfo();
|
||||
@ -47,12 +47,23 @@ public interface StatisticsParameter {
|
||||
public void setPlotFitness(SelectedTag newMethod);
|
||||
|
||||
public String getResultFileName();
|
||||
public void setResultFileName(String x);
|
||||
public void SetResultFileName(String x);
|
||||
|
||||
public void setConvergenceRateThreshold(double x);
|
||||
public double getConvergenceRateThreshold();
|
||||
|
||||
|
||||
public void SetShowTextOutput(boolean show);
|
||||
public boolean isShowTextOutput();
|
||||
public void setShowTextOutput(boolean bShow);
|
||||
// public String showTextOutputTipText();
|
||||
|
||||
public boolean isOutputAdditionalInfo();
|
||||
public void setOutputAdditionalInfo(boolean bShowAdd);
|
||||
|
||||
public void setOutputVerbosity(SelectedTag sTag);
|
||||
public SelectedTag getOutputVerbosity();
|
||||
|
||||
public int getOutputVerbosityK();
|
||||
public void setOutputVerbosityK(int k);
|
||||
|
||||
public void setOutputTo(SelectedTag sTag);
|
||||
public SelectedTag getOutputTo();
|
||||
}
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javaeva.server.go.InterfaceGOParameters;
|
||||
import javaeva.server.go.PopulationInterface;
|
||||
import javaeva.server.go.problems.InterfaceAdditionalPopulationInformer;
|
||||
|
||||
@ -54,9 +55,9 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StatisticsStandalone(StatisticsParameter statParams) {
|
||||
public StatisticsStandalone(InterfaceStatisticsParameter statParams) {
|
||||
super();
|
||||
m_StatisticsParameter = statParams;
|
||||
m_StatsParams = statParams;
|
||||
try {
|
||||
m_MyHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
@ -68,15 +69,15 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
*
|
||||
*/
|
||||
public StatisticsStandalone(String resultFileName) {
|
||||
this(new StatisticsParameterImpl());
|
||||
m_StatisticsParameter.setResultFileName(resultFileName);
|
||||
this(new StatsParameter());
|
||||
m_StatsParams.SetResultFileName(resultFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StatisticsStandalone() {
|
||||
this(new StatisticsParameterImpl());
|
||||
this(new StatsParameter());
|
||||
}
|
||||
|
||||
protected void initPlots(List<String[]> description) {
|
||||
@ -103,19 +104,19 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
*/
|
||||
private void initContainer(String[] description) {
|
||||
for (int i = 0; i < description.length; i++) {
|
||||
m_Result.add(new ArrayList[m_StatisticsParameter.getMultiRuns()]);
|
||||
m_Result.add(new ArrayList[m_StatsParams.getMultiRuns()]);
|
||||
m_ResultString.add(description[i]);
|
||||
}
|
||||
for (int i = 0; i < m_Result.size(); i++)
|
||||
((ArrayList[]) m_Result.get(i))[optRunsPerformed] = new ArrayList<double[]>();
|
||||
}
|
||||
|
||||
public void startOptPerformed(String infoString, int runNumber) {
|
||||
super.startOptPerformed(infoString, runNumber);
|
||||
public void startOptPerformed(String infoString, int runNumber, Object params) {
|
||||
super.startOptPerformed(infoString, runNumber, params);
|
||||
if (runNumber == 0) {
|
||||
m_Result = new ArrayList<ArrayList<double[]>[]>();
|
||||
m_ResultString = new ArrayList<String>();
|
||||
m_BestFitnessAtEnd = new double[this.m_StatisticsParameter.getMultiRuns()];
|
||||
m_BestFitnessAtEnd = new double[this.m_StatsParams.getMultiRuns()];
|
||||
} else {
|
||||
for (int i = 0; i < m_Result.size(); i++)
|
||||
((ArrayList[]) m_Result.get(i))[optRunsPerformed] = new ArrayList<ArrayList<double[]>[]>();
|
||||
@ -132,7 +133,7 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
}
|
||||
|
||||
//System.out.println("stopOptPerformed :"+m_OptRunsPerformed);
|
||||
if (optRunsPerformed == m_StatisticsParameter.getMultiRuns()) {
|
||||
if (optRunsPerformed == m_StatsParams.getMultiRuns()) {
|
||||
m_FitnessMeanofALL = m_SumOfBestFit / ((double) optRunsPerformed);
|
||||
//System.out.println("m_FitnessMeanofALL "+m_FitnessMeanofALL);
|
||||
m_FitnessMedianofALL = getMedian(m_BestFitnessAtEnd);
|
||||
|
@ -82,11 +82,11 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
|
||||
|
||||
if ((Client == null) || Client.getHostName().equals(m_MyHostName)) {
|
||||
m_StatisticsParameter = StatisticsParameterImpl.getInstance();
|
||||
m_StatsParams = StatsParameter.getInstance();
|
||||
m_ProxyPrinter = new JTextoutputFrame("TextOutput of " + m_MyHostName);
|
||||
} else { // we use RMI
|
||||
m_StatisticsParameter = (StatisticsParameter) RMIProxyLocal.newInstance(
|
||||
StatisticsParameterImpl.getInstance());
|
||||
m_StatsParams = (InterfaceStatisticsParameter)RMIProxyLocal.newInstance(
|
||||
StatsParameter.getInstance());
|
||||
m_ProxyPrinter = (JTextoutputFrameInterface) RMIProxyRemote.newInstance(new
|
||||
JTextoutputFrame("TextOutput " + m_MyHostName),
|
||||
m_MainAdapterClient);
|
||||
@ -98,21 +98,21 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public synchronized void startOptPerformed(String infoString, int runNumber) {
|
||||
super.startOptPerformed(infoString, runNumber);
|
||||
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams) {
|
||||
super.startOptPerformed(infoString, runNumber, goParams);
|
||||
|
||||
m_GraphInfoString = infoString;
|
||||
|
||||
// m_TextCounter = m_StatisticsParameter.GetTextoutput();
|
||||
m_PlotCounter = m_StatisticsParameter.GetPlotoutput();
|
||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||
}
|
||||
|
||||
public void stopOptPerformed(boolean normal) {
|
||||
super.stopOptPerformed(normal);
|
||||
|
||||
if (optRunsPerformed > m_StatisticsParameter.getMultiRuns()) System.err.println("error: this shouldnt happen (StatisticsWithGUI::stopOptPerformed)");
|
||||
if (optRunsPerformed > m_StatsParams.getMultiRuns()) System.err.println("error: this shouldnt happen (StatisticsWithGUI::stopOptPerformed)");
|
||||
// unite the graphs only if the break was "normal"
|
||||
if (normal && (m_StatisticsParameter.getMultiRuns() > 1) && (m_StatGraph != null)) {
|
||||
if (normal && (m_StatsParams.getMultiRuns() > 1) && (m_StatGraph != null)) {
|
||||
// unite the point sets for a multirun
|
||||
for (int i = 0; i < m_FitnessGraph.length; i++) {
|
||||
for (int j = 0; j < m_FitnessGraph[i].length; j++) {
|
||||
@ -120,8 +120,8 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
m_StatGraph[i][j].addGraph(m_FitnessGraph[i][j]);
|
||||
m_StatGraph[i][j].setInfoString(
|
||||
(m_FitnessGraph[i][j].getInfo().length() > 0 ? (m_FitnessGraph[i][j].getInfo() + "_") : "" )
|
||||
+ (m_StatisticsParameter.GetInfoString().length() > 0 ? (m_StatisticsParameter.GetInfoString() + "_") : "" )
|
||||
+ m_StatisticsParameter.GetInfoString()
|
||||
+ (m_StatsParams.GetInfoString().length() > 0 ? (m_StatsParams.GetInfoString() + "_") : "" )
|
||||
+ m_StatsParams.GetInfoString()
|
||||
+ "Mean_of_" + optRunsPerformed + " ",
|
||||
(float) 2.0);
|
||||
m_FitnessGraph[i][j].clear();
|
||||
@ -140,7 +140,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
protected void initPlots(List<String[]> description) {
|
||||
if (TRACE) System.out.println("initPlots");
|
||||
|
||||
if (m_ProxyPrinter != null) m_ProxyPrinter.setShow(m_StatisticsParameter.isShowTextOutput());
|
||||
if (m_ProxyPrinter != null) m_ProxyPrinter.setShow((m_StatsParams).isShowTextOutput());
|
||||
|
||||
m_FitnessFrame = new GraphWindow[description.size()];
|
||||
for (int i = 0; i < m_FitnessFrame.length; i++) {
|
||||
@ -158,14 +158,14 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
// this is where the column string for ascii export is created!
|
||||
m_FitnessGraph[i][j] =
|
||||
m_FitnessFrame[i].getNewGraph(d[j] + "_" +
|
||||
m_StatisticsParameter.GetInfoString() +
|
||||
m_StatsParams.GetInfoString() +
|
||||
m_GraphInfoString);
|
||||
m_FitnessGraph[i][j].jump();
|
||||
}
|
||||
}
|
||||
if (m_StatisticsParameter.getMultiRuns() > 1 &&
|
||||
m_StatisticsParameter.GetuseStatPlot() == true) {
|
||||
String Info = m_StatisticsParameter.GetInfoString();
|
||||
if (m_StatsParams.getMultiRuns() > 1 &&
|
||||
m_StatsParams.GetuseStatPlot() == true) {
|
||||
String Info = m_StatsParams.GetInfoString();
|
||||
m_StatGraph = new Graph[description.size()][];
|
||||
for (int i = 0; i < m_StatGraph.length; i++) {
|
||||
m_StatGraph[i] = new Graph[((String[]) description.get(i)).length];
|
||||
@ -201,20 +201,20 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
// Plots
|
||||
m_PlotCounter--;
|
||||
|
||||
int fitnessplot_setting = m_StatisticsParameter.getPlotFitness().getSelectedTag().getID();
|
||||
int fitnessplot_setting = m_StatsParams.getPlotFitness().getSelectedTag().getID();
|
||||
|
||||
if (m_PlotCounter == 0) {
|
||||
m_PlotCounter = m_StatisticsParameter.GetPlotoutput();
|
||||
boolean doPlotBest = (fitnessplot_setting == StatisticsParameterImpl.PLOT_BEST)
|
||||
|| (fitnessplot_setting == StatisticsParameterImpl.PLOT_BEST_AND_WORST);
|
||||
boolean doPlotWorst = (fitnessplot_setting == StatisticsParameterImpl.PLOT_WORST)
|
||||
|| (fitnessplot_setting == StatisticsParameterImpl.PLOT_BEST_AND_WORST);
|
||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||
boolean doPlotBest = (fitnessplot_setting == StatsParameter.PLOT_BEST)
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
||||
boolean doPlotWorst = (fitnessplot_setting == StatsParameter.PLOT_WORST)
|
||||
|| (fitnessplot_setting == StatsParameter.PLOT_BEST_AND_WORST);
|
||||
if (doPlotBest) {
|
||||
plotFitnessPoint(0, 0, functionCalls, currentBestFit[0]);
|
||||
}
|
||||
if (doPlotWorst) {
|
||||
// schlechteste Fitness plotten
|
||||
m_PlotCounter = m_StatisticsParameter.GetPlotoutput();
|
||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||
if (currentWorstFit == null) {
|
||||
System.err.println("m_WorstFitness==null in plotStatisticsPerformed");
|
||||
return;
|
||||
@ -261,7 +261,7 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
||||
|
||||
m_PlotCounter--;
|
||||
if (m_PlotCounter == 0) {
|
||||
m_PlotCounter = m_StatisticsParameter.GetPlotoutput();
|
||||
m_PlotCounter = m_StatsParams.GetPlotoutput();
|
||||
int index = 0;
|
||||
for (int i = 0; i < m_FitnessGraph.length; i++) {
|
||||
for (int j = 0; j < m_FitnessGraph[i].length; j++) {
|
||||
|
@ -16,6 +16,7 @@ package javaeva.server.stat;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javaeva.gui.GenericObjectEditor;
|
||||
import javaeva.tools.Serializer;
|
||||
import javaeva.tools.Tag;
|
||||
import javaeva.tools.SelectedTag;
|
||||
@ -26,41 +27,52 @@ import javaeva.tools.SelectedTag;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class StatisticsParameterImpl implements StatisticsParameter, Serializable {
|
||||
public class StatsParameter implements InterfaceStatisticsParameter, Serializable {
|
||||
public final static int PLOT_BEST = 0;
|
||||
public final static int PLOT_WORST = 1;
|
||||
public final static int PLOT_BEST_AND_WORST = 2;
|
||||
public final static Tag[] TAGS_PLOT_FITNESS = {
|
||||
new Tag(PLOT_BEST, "plot best of population"),
|
||||
new Tag(PLOT_WORST, "plot worst of population"),
|
||||
new Tag(PLOT_BEST_AND_WORST, "plot best and worst of population")
|
||||
new Tag(PLOT_BEST, "plot best"),
|
||||
new Tag(PLOT_WORST, "plot worst"),
|
||||
new Tag(PLOT_BEST_AND_WORST, "both best and worst")
|
||||
};
|
||||
private int m_PlotFitness = PLOT_BEST;
|
||||
|
||||
public final static int VERBOSITY_NONE = 0;
|
||||
public final static int VERBOSITY_FINAL = 1;
|
||||
public final static int VERBOSITY_KTH_IT = 2;
|
||||
public final static int VERBOSITY_ALL = 3;
|
||||
SelectedTag outputVerbosity = new SelectedTag("No output", "Results", "K-th iteration", "All iterations");
|
||||
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
||||
private int verboK = 10;
|
||||
|
||||
private int m_PlotFitness = PLOT_BEST;
|
||||
private int m_Textoutput = 0;
|
||||
private int m_Plotoutput = 1;
|
||||
private int m_MultiRuns = 1;
|
||||
private String m_ResultFileName = "none";
|
||||
private String m_ResultFilePrefix = "JE2";
|
||||
protected String m_Name = "not defined";
|
||||
protected String m_InfoString = "";
|
||||
private boolean m_useStatPlot = true;
|
||||
private boolean showAdditionalProblemInfo = false;
|
||||
private double m_ConvergenceRateThreshold=0.001;
|
||||
private boolean showTextOutput = true;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static StatisticsParameterImpl getInstance() {
|
||||
StatisticsParameterImpl Instance = (StatisticsParameterImpl) Serializer.loadObject("Statistics.ser");
|
||||
public static StatsParameter getInstance() {
|
||||
StatsParameter Instance = (StatsParameter) Serializer.loadObject("Statistics.ser");
|
||||
if (Instance == null)
|
||||
Instance = new StatisticsParameterImpl();
|
||||
Instance = new StatsParameter();
|
||||
return Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public StatisticsParameterImpl() {
|
||||
public StatsParameter() {
|
||||
m_Name = "Statistics";
|
||||
outputVerbosity.setSelectedTag(2);
|
||||
outputTo.setSelectedTag(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,13 +94,13 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
public ArrayList<String[]> getPlotDescriptions() {
|
||||
ArrayList<String[]> desc = new ArrayList<String[]>();
|
||||
switch (getPlotFitness().getSelectedTagID()) {
|
||||
case StatisticsParameterImpl.PLOT_BEST_AND_WORST:
|
||||
case StatsParameter.PLOT_BEST_AND_WORST:
|
||||
desc.add(new String[] {"Best", "Worst"});
|
||||
break;
|
||||
case StatisticsParameterImpl.PLOT_BEST:
|
||||
case StatsParameter.PLOT_BEST:
|
||||
desc.add(new String[] {"Best"});
|
||||
break;
|
||||
case StatisticsParameterImpl.PLOT_WORST:
|
||||
case StatsParameter.PLOT_WORST:
|
||||
desc.add(new String[] {"Worst"});
|
||||
break;
|
||||
}
|
||||
@ -105,21 +117,21 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private StatisticsParameterImpl(StatisticsParameterImpl Source) {
|
||||
private StatsParameter(StatsParameter Source) {
|
||||
m_ConvergenceRateThreshold = Source.m_ConvergenceRateThreshold;
|
||||
m_useStatPlot = Source.m_useStatPlot;
|
||||
m_Textoutput = Source.m_Textoutput;
|
||||
m_Plotoutput = Source.m_Plotoutput;
|
||||
m_PlotFitness = Source.m_PlotFitness;
|
||||
m_MultiRuns = Source.m_MultiRuns;
|
||||
m_ResultFileName = Source.m_ResultFileName;
|
||||
m_ResultFilePrefix = Source.m_ResultFilePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Object getClone() {
|
||||
return new StatisticsParameterImpl(this);
|
||||
return new StatsParameter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +142,7 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
}
|
||||
|
||||
public String globalInfo() {
|
||||
return "Set of parameter describing the statistics which logs the state of the optimization.";
|
||||
return "Configure statistics and output of the optimization run.";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,12 +166,12 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
// return "Frequency how often the fitness plot gets an update. plotoutput=1 -> there is a output every generation. plotoutput<0 -> there is no plot output";
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String printMeanTipText() {
|
||||
return "Prints the mean of the fitness plot. Makes only sense when multiRuns > 1;";
|
||||
}
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// public String printMeanTipText() {
|
||||
// return "Prints the mean of the fitness plot. Makes only sense when multiRuns > 1;";
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
@ -182,14 +194,6 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
return "Number of independent optimization runs to evaluate.";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setResultFileName(String x) {
|
||||
if (x==null) m_ResultFileName = "";
|
||||
else m_ResultFileName = x;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -260,19 +264,39 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
return "The individual of which the objectives are plotted.";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getResultFileName() {
|
||||
return m_ResultFileName;
|
||||
public void SetResultFileName(String x) {
|
||||
if (x==null) m_ResultFilePrefix = "";
|
||||
else m_ResultFilePrefix = x;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String resultFileNameTipText() {
|
||||
return "File name for the result file. If empty or 'none', no output file will be created.";
|
||||
public String getResultFileName() {
|
||||
return m_ResultFilePrefix;
|
||||
}
|
||||
|
||||
public void SetShowTextOutput(boolean show) {
|
||||
// activate if not activated
|
||||
if (show && outputTo.getSelectedTagID() == 0) outputTo.setSelectedTag(2);
|
||||
// deactivate if activated
|
||||
else if (!show && outputTo.getSelectedTagID()>0) outputTo.setSelectedTag(0);
|
||||
}
|
||||
|
||||
public boolean isShowTextOutput() {
|
||||
return outputTo.getSelectedTagID()>0;
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// public String resultFileNameTipText() {
|
||||
// return "File name for the result file. If empty or 'none', no output file will be created.";
|
||||
// }
|
||||
|
||||
public String convergenceRateThresholdTipText() {
|
||||
return "Provided the optimal fitness is at zero, give the threshold below which it is considered as 'reached'";
|
||||
@ -293,22 +317,74 @@ public class StatisticsParameterImpl implements StatisticsParameter, Serializabl
|
||||
return m_ConvergenceRateThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the showOutputData
|
||||
*/
|
||||
public boolean isShowTextOutput() {
|
||||
return showTextOutput;
|
||||
// /**
|
||||
// * @return the showOutputData
|
||||
// */
|
||||
// public boolean isShowTextOutput() {
|
||||
// return showTextOutput;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @param showOutputData the showOutputData to set
|
||||
// */
|
||||
// public void setShowTextOutput(boolean bShow) {
|
||||
// this.showTextOutput = bShow;
|
||||
// }
|
||||
//
|
||||
// public String showTextOutputTipText() {
|
||||
// return "Indicates whether further text output should be printed";
|
||||
// }
|
||||
|
||||
public boolean isOutputAdditionalInfo() {
|
||||
return showAdditionalProblemInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param showOutputData the showOutputData to set
|
||||
*/
|
||||
public void setShowTextOutput(boolean bShow) {
|
||||
this.showTextOutput = bShow;
|
||||
public void setOutputAdditionalInfo(boolean showAdd) {
|
||||
showAdditionalProblemInfo = showAdd;
|
||||
}
|
||||
|
||||
public String showTextOutputTipText() {
|
||||
return "Indicates whether further text output should be printed";
|
||||
public String outputAdditionalInfoTipText() {
|
||||
return "Activate to output additional problem information per iteration, such as the current solution representation.";
|
||||
}
|
||||
|
||||
public void hideHideable() {
|
||||
setOutputVerbosity(getOutputVerbosity());
|
||||
}
|
||||
public void setOutputVerbosity(SelectedTag sTag) {
|
||||
outputVerbosity = sTag;
|
||||
GenericObjectEditor.setHideProperty(this.getClass(), "outputVerbosityK", sTag.getSelectedTagID() != VERBOSITY_KTH_IT);
|
||||
}
|
||||
public SelectedTag getOutputVerbosity() {
|
||||
return outputVerbosity;
|
||||
}
|
||||
|
||||
public String outputVerbosityTipText() {
|
||||
return "Set the data output level.";
|
||||
}
|
||||
|
||||
public int getOutputVerbosityK() {
|
||||
return verboK;
|
||||
}
|
||||
|
||||
public void setOutputVerbosityK(int k) {
|
||||
verboK = k;
|
||||
}
|
||||
|
||||
public String outputVerbosityKTipText() {
|
||||
return "Set the interval of data output for intermediate verbosity (in generations).";
|
||||
}
|
||||
|
||||
public SelectedTag getOutputTo() {
|
||||
return outputTo;
|
||||
}
|
||||
|
||||
public void setOutputTo(SelectedTag tag) {
|
||||
outputTo = tag;
|
||||
}
|
||||
|
||||
public String outputToTipText() {
|
||||
return "Set the output destination; to deactivate output, set verbosity to none.";
|
||||
}
|
||||
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
package javaeva.tools;
|
||||
/*
|
||||
* Title: JavaEvA
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 235 $
|
||||
* $Date: 2007-11-08 13:53:51 +0100 (Thu, 08 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
*
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class CompileAndLoad {
|
||||
/**
|
||||
* muss weg . wird ersetzt. hannes
|
||||
*/
|
||||
static public Object getInstance (String path, String fullclassname, Object[] paraforconstructor) {
|
||||
System.out.println("CompileAndLoad getInstancee");
|
||||
Object Instance = null;
|
||||
try {
|
||||
String base = System.getProperty("user.dir");
|
||||
// System.out.println("getInstance base = " + base + "path=" + path);
|
||||
// System.out.println("base="+base);
|
||||
// System.out.println("fullclassname = " + fullclassname);
|
||||
String classname = EVAHELP.cutClassName(fullclassname);
|
||||
//JavaCompiler.compile(base + "\\" + path + "\\" + classname + ".java");
|
||||
//JavacWrapper jwc = new JavacWrapper();
|
||||
JavacWrapper.compile(base + "\\" + path + "\\" + classname + ".java");
|
||||
System.out.println("Error: " + JavacWrapper.m_error);
|
||||
URL[] serverURLs = null;
|
||||
try {
|
||||
//System.out.println("!!!!!!!!!!!getInstance base =" + base + " path =" +path);
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
String s = "file:"+base+"/"+JavacWrapper.m_userdefclasses+"/";
|
||||
serverURLs = new URL[] {
|
||||
// new URL("file:Z:/work/JOptStudent/userdefinedclasses/")
|
||||
new URL(s)
|
||||
};
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("Invalid URL:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
ClassLoader loader = new URLClassLoader(serverURLs);
|
||||
Class[] classes = new Class[paraforconstructor.length];
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (paraforconstructor[i].getClass() == Double.class)
|
||||
classes[i] = double.class;
|
||||
else if (paraforconstructor[i].getClass() == Integer.class)
|
||||
classes[i] = int.class;
|
||||
else if (paraforconstructor[i].getClass() == Boolean.class)
|
||||
classes[i] = boolean.class;
|
||||
else
|
||||
classes[i] = paraforconstructor[i].getClass();
|
||||
}
|
||||
System.out.println("fullclassname: " + fullclassname);
|
||||
Constructor[] constructors = loader.loadClass(fullclassname).getConstructors();
|
||||
Constructor constructor = loader.loadClass(fullclassname).getConstructor(classes);
|
||||
Instance = constructor.newInstance(paraforconstructor);
|
||||
} catch (Exception e) {
|
||||
System.out.println("CompileAndLoad.getInstance() : " + e + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Instance;
|
||||
}
|
||||
|
||||
static public Object getInstanceFull (String path, String fullclassname, Object[] paraforconstructor) {
|
||||
// System.out.println("CompileAndLoad getInstancee");
|
||||
Object Instance = null;
|
||||
try {
|
||||
String base = System.getProperty("user.dir");
|
||||
// System.out.println("getInstance base = " + base + "path=" + path);
|
||||
// System.out.println("base="+base);
|
||||
// System.out.println("fullclassname = " + fullclassname);
|
||||
String classname = EVAHELP.cutClassName(fullclassname);
|
||||
//JavaCompiler.compile(base + "\\" + path + "\\" + classname + ".java");
|
||||
//JavacWrapper jwc = new JavacWrapper();
|
||||
JavacWrapper.compile(base + "\\" + path);
|
||||
// System.out.println("Error (CompileAndLoad): " + JavacWrapper.m_error);
|
||||
URL[] serverURLs = null;
|
||||
try {
|
||||
//System.out.println("!!!!!!!!!!!getInstance base =" + base + " path =" +path);
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
String s = "file:"+base+"/"+JavacWrapper.m_userdefclasses+"/";
|
||||
// System.out.println("LADE: " + s );
|
||||
serverURLs = new URL[] {
|
||||
// new URL("file:Z:/work/JOptStudent/userdefinedclasses/")
|
||||
new URL(s)
|
||||
};
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("Invalid URL:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
URLClassLoader loader = new URLClassLoader(serverURLs);
|
||||
|
||||
Class[] classes = new Class[paraforconstructor.length];
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (paraforconstructor[i].getClass() == Double.class)
|
||||
classes[i] = double.class;
|
||||
else if (paraforconstructor[i].getClass() == Integer.class)
|
||||
classes[i] = int.class;
|
||||
else if (paraforconstructor[i].getClass() == Boolean.class)
|
||||
classes[i] = boolean.class;
|
||||
else
|
||||
classes[i] = paraforconstructor[i].getClass();
|
||||
}
|
||||
//System.out.println("fullclassname: " + fullclassname);
|
||||
Constructor[] constructors = loader.loadClass(fullclassname).getConstructors();
|
||||
Constructor constructor = loader.loadClass(fullclassname).getConstructor(classes);
|
||||
Instance = constructor.newInstance(paraforconstructor);
|
||||
/*URL[] testu = loader.getURLs();
|
||||
for (int i = 0; i < testu.length; i++) {
|
||||
System.out.println("URL:" + testu[i]);
|
||||
}*/
|
||||
|
||||
// System.out.println("OK INSTANCE CREATED");
|
||||
} catch (Exception e) {
|
||||
System.out.println("CompileAndLoad.getInstance() : " + e + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static public Class getClass (String path, String fullclassname, Object[] paraforconstructor) {
|
||||
System.out.println("CompileAndLoad getClass");
|
||||
Class ret = null;
|
||||
try {
|
||||
String base = System.getProperty("user.dir");
|
||||
System.out.println("getInstance base = " + base + "path=" + path);
|
||||
String classname = EVAHELP.cutClassName(fullclassname);
|
||||
JavacWrapper.compile(base + "\\" + path + "\\" + classname + ".java");
|
||||
URL[] serverURLs = null;
|
||||
try {
|
||||
System.out.println("URLs=" + "file:"); //+classname+".class");
|
||||
System.out.println("!!!!!!!!!!!getInstance base =" + base + "path =" + path);
|
||||
serverURLs = new URL[] {
|
||||
// new URL("file:Z:/work/JOptStudent/userdefinedclasses/")
|
||||
new URL("file:"+base+"/userdefinedclasses/")
|
||||
};
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("Invalid URL:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
ClassLoader loader = new URLClassLoader(serverURLs);
|
||||
} catch (Exception e) {
|
||||
System.out.println("CompileAndLoad:G : " + e + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// Object[] para = new Object[] {};
|
||||
// AbstractESProblem first = (AbstractESProblem) CompileAndLoad.getInstanceFull("/usersrc/src1/javaeva/server/problems/bench/UserProblem.java","javaeva.server.problems.bench.UserProblem",para);
|
||||
// //first = (AbstractESProblem) CompileAndLoad.getInstanceFull("/usersrc/src2/javaeva/server/problems/bench/UserProblem.java","javaeva.server.problems.bench.UserProblem",para);
|
||||
// first = (AbstractESProblem) CompileAndLoad.getInstanceFull("/usersrc/src2/javaeva/server/problems/bench/UserProblem.java","javaeva.server.problems.bench.UserProblem",para);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,98 +0,0 @@
|
||||
package javaeva.tools;
|
||||
/*
|
||||
* Title: JavaEvA
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 10 $
|
||||
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
|
||||
* $Author: streiche $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.File;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JavacWrapper {
|
||||
static final public String m_userdefclasses = "userdefclasses";
|
||||
static StringBuffer m_error = new StringBuffer();
|
||||
static StringBuffer m_output = new StringBuffer();
|
||||
static boolean compiling = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JavacWrapper() {}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static String getErrors() {
|
||||
return m_error.toString();
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static boolean compiling() {
|
||||
return compiling;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void compile(final String javafile) {
|
||||
compiling = true;
|
||||
m_error.delete(0,m_error.length());
|
||||
m_output.delete(0,m_error.length());
|
||||
String base = System.getProperty("user.dir");
|
||||
String m_ClassPath = System.getProperty("java.class.path");
|
||||
String target = base+"/"+m_userdefclasses+"/";
|
||||
|
||||
String tmpS = javafile.replaceAll("\\/","/");
|
||||
File temp = new File(target);
|
||||
if (temp.isDirectory()==false) temp.mkdir();
|
||||
try {
|
||||
System.out.println("javac -classpath " + m_ClassPath + " -d " + target + " " + tmpS);
|
||||
Process pc = Runtime.getRuntime().exec("javac -classpath " + m_ClassPath + " -d " + target + " " + tmpS);
|
||||
final BufferedReader estream = new BufferedReader(new InputStreamReader(pc.getErrorStream()));
|
||||
Thread errThread = new Thread( new Runnable () {
|
||||
public void run() {
|
||||
try {
|
||||
String outstr = estream.readLine();
|
||||
while (outstr != null) {
|
||||
m_error.append(outstr + "\n");
|
||||
outstr = estream.readLine();
|
||||
}
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
);
|
||||
final BufferedReader ostream = new BufferedReader(new InputStreamReader(pc.getInputStream()));
|
||||
Thread outThread = new Thread( new Runnable () {
|
||||
public void run() {
|
||||
try {
|
||||
String outstr = ostream.readLine();
|
||||
while (outstr != null) {
|
||||
m_output.append(outstr + "\n");
|
||||
outstr = ostream.readLine();
|
||||
}
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
);
|
||||
outThread.start();
|
||||
errThread.start();
|
||||
pc.waitFor();
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
compiling = false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
@ -26,17 +26,36 @@ import java.io.*;
|
||||
public class MultirunRefiner {
|
||||
private JFrame m_Frame;
|
||||
private JPanel myPanel, myJButtonJPanel;
|
||||
private JButton refineJButton, confidenceJButton, exitJButton;
|
||||
private JButton refineJButton, exitJButton;
|
||||
// private JButton confidenceJButton;
|
||||
private JTextArea m_InputText, m_OutputText;
|
||||
private JScrollPane m_SP1, m_SP2;
|
||||
private JMenuBar m_MenuBar;
|
||||
private JMenu m_FileJMenu;
|
||||
private JMenuItem m_LoadExpItem, m_SaveExpItem;
|
||||
private JMenuItem m_ExitItem; /** Creates a new instance of MultirunRefiner */
|
||||
private JMenuItem m_ExitItem;
|
||||
|
||||
/** Creates a new instance of MultirunRefiner */
|
||||
public MultirunRefiner() {
|
||||
|
||||
}
|
||||
|
||||
public MultirunRefiner(File f) {
|
||||
starter();
|
||||
if (!readFile(f)) System.err.println("Error, couldnt open file " + f);
|
||||
}
|
||||
|
||||
public MultirunRefiner(String fileName) {
|
||||
starter();
|
||||
File f=new File(fileName);
|
||||
if (!readFile(f)) System.err.println("Error, couldnt open file " + f);
|
||||
}
|
||||
|
||||
public MultirunRefiner(String text, int numRuns) {
|
||||
starter();
|
||||
m_InputText.setText(text);
|
||||
}
|
||||
|
||||
public void starter() {
|
||||
this.m_Frame = new JFrame("MultirunRefiner\u2122");
|
||||
|
||||
@ -96,15 +115,15 @@ public class MultirunRefiner {
|
||||
refineJButton = new JButton("Refine Multiruns");
|
||||
refineJButton.addMouseListener (new java.awt.event.MouseAdapter () {
|
||||
public void mouseClicked (java.awt.event.MouseEvent evt) {
|
||||
refine();
|
||||
}
|
||||
});
|
||||
confidenceJButton = new JButton("Create Matlab/Confidence");
|
||||
confidenceJButton.addMouseListener (new java.awt.event.MouseAdapter () {
|
||||
public void mouseClicked (java.awt.event.MouseEvent evt) {
|
||||
compute();
|
||||
m_OutputText.setText(refineToText(refine(m_InputText.getText())));
|
||||
}
|
||||
});
|
||||
// confidenceJButton = new JButton("Create Matlab/Confidence");
|
||||
// confidenceJButton.addMouseListener (new java.awt.event.MouseAdapter () {
|
||||
// public void mouseClicked (java.awt.event.MouseEvent evt) {
|
||||
// compute();
|
||||
// }
|
||||
// });
|
||||
exitJButton = new JButton("EXIT");
|
||||
exitJButton.addMouseListener (new java.awt.event.MouseAdapter () {
|
||||
public void mouseClicked (java.awt.event.MouseEvent evt) {
|
||||
@ -112,7 +131,7 @@ public class MultirunRefiner {
|
||||
}
|
||||
});
|
||||
this.myJButtonJPanel.add(refineJButton);
|
||||
this.myJButtonJPanel.add(confidenceJButton);
|
||||
// this.myJButtonJPanel.add(confidenceJButton);
|
||||
this.myJButtonJPanel.add(exitJButton);
|
||||
|
||||
m_Frame.validate();
|
||||
@ -128,22 +147,26 @@ public class MultirunRefiner {
|
||||
fc.setFileFilter(new TXTFileFilter());
|
||||
int returnVal = fc.showDialog(this.m_Frame, "Load Multirun.TXT");
|
||||
if (returnVal == 0) {
|
||||
BufferedReader dis;
|
||||
String tmp, result="";
|
||||
try {
|
||||
this.clearInputText();
|
||||
FileReader fileStream = new FileReader(fc.getSelectedFile());
|
||||
this.m_InputText.read( fileStream, fc.getSelectedFile());
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("FILE " + fc.getSelectedFile() + " NOT FOUND!");
|
||||
} catch (java.lang.NullPointerException npe) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
//this.m_InputText.setText(fc.getSelectedFile().getName());
|
||||
readFile(fc.getSelectedFile());
|
||||
this.m_Frame.validate();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean readFile(File f) {
|
||||
FileReader fileStream;
|
||||
clearInputText();
|
||||
try {
|
||||
fileStream = new FileReader(f);
|
||||
this.m_InputText.read( fileStream, f);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
clearInputText();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearInputText() {
|
||||
this.m_InputText.setText("");
|
||||
}
|
||||
@ -174,73 +197,127 @@ public class MultirunRefiner {
|
||||
}
|
||||
}
|
||||
|
||||
protected static boolean hasNextLine(String txt) {
|
||||
return (txt != null && (txt.length() > 0));
|
||||
}
|
||||
|
||||
protected static String readLine(BufferedReader br) {
|
||||
String line;
|
||||
try {
|
||||
line = br.readLine();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
/** This method will refine multiple run into on mean element
|
||||
*/
|
||||
public void refine() {
|
||||
public static ArrayList<double[]> refine(String text) {
|
||||
double[] tmp;
|
||||
double[] mean = new double[3];
|
||||
int begin, end, numExp = 0;
|
||||
ArrayList result = new ArrayList(), tmpA;
|
||||
int numExp = 0, iteration = 0, lineCnt = 0;
|
||||
ArrayList<double[]> result = new ArrayList<double[]>();
|
||||
String line;
|
||||
String runHeader = "Fit.-calls Best Mean Worst Solution";
|
||||
String runFinalizer = " Best solution: ";
|
||||
boolean readRun = false;
|
||||
|
||||
BufferedReader br = new BufferedReader(new StringReader(text));
|
||||
|
||||
while ((line = readLine(br)) != null) {
|
||||
// Pair<String, String> p = popNextLine(text);
|
||||
lineCnt++;
|
||||
// line = p.car();
|
||||
// text = p.cdr();
|
||||
|
||||
this.clearOutputText();
|
||||
for (int i = 0; i < this.m_InputText.getLineCount(); i++) {
|
||||
try {
|
||||
begin = this.m_InputText.getLineStartOffset(i);
|
||||
end = this.m_InputText.getLineEndOffset(i);
|
||||
tmp = this.parseStringForDouble(this.m_InputText.getText(begin, end-begin));
|
||||
if (tmp.length > 3) {
|
||||
if (((int)(tmp[0])) == 1) numExp++;
|
||||
if (result.size()-1 < ((int)(tmp[0]))) result.add(((int)(tmp[0])), new double[3]);
|
||||
mean = ((double[])(result.get(((int)(tmp[0])))));
|
||||
mean[0] += tmp[1];
|
||||
mean[1] += tmp[2];
|
||||
mean[2] += tmp[3];
|
||||
}
|
||||
} catch (javax.swing.text.BadLocationException ble){}
|
||||
if (line.startsWith(runHeader)) {
|
||||
numExp++;
|
||||
readRun = true;
|
||||
iteration = 0;
|
||||
System.out.println("Experiment starts at line " + lineCnt);
|
||||
continue;
|
||||
} else if (line.startsWith(runFinalizer)) {
|
||||
System.out.println("Experiment ends at line " + lineCnt);
|
||||
readRun = false;
|
||||
continue;
|
||||
}
|
||||
if (readRun) {
|
||||
tmp = parseStringForDouble(line);
|
||||
if (tmp.length > 3) {
|
||||
if (numExp==1) {
|
||||
mean = new double[3];
|
||||
result.add(iteration, mean);
|
||||
} else mean = result.get(iteration);
|
||||
mean[0] += tmp[1];
|
||||
mean[1] += tmp[2];
|
||||
mean[2] += tmp[3];
|
||||
} else System.err.println("Error in MultiRunRefiner!");
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
System.out.println(this.m_InputText.getLineCount() + " lines parsed. " + numExp + " experiments with " + result.size() + " events each.");
|
||||
this.addOutputText("Event\tBest\tMean\tWorst\n");
|
||||
System.out.println(lineCnt + " lines parsed. " + numExp + " experiments with " + result.size() + " events each.");
|
||||
|
||||
for(int i = 0; i < result.size(); i++) {
|
||||
mean = ((double[])(result.get(i)));
|
||||
this.addOutputText(i+"\t"+mean[0]/numExp+"\t"+mean[1]/numExp+"\t"+mean[2]/numExp+"\n");
|
||||
for (int k=0; k<mean.length; k++) mean[k]/=numExp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void compute() {
|
||||
double[] tmp;
|
||||
double[] mean = new double[3];
|
||||
int begin, end, numExp = 0;
|
||||
ArrayList result = new ArrayList(), tmpA;
|
||||
|
||||
this.clearOutputText();
|
||||
for (int i = 0; i < this.m_InputText.getLineCount(); i++) {
|
||||
try {
|
||||
begin = this.m_InputText.getLineStartOffset(i);
|
||||
end = this.m_InputText.getLineEndOffset(i);
|
||||
tmp = this.parseStringForDouble(this.m_InputText.getText(begin, end-begin));
|
||||
if (tmp.length > 3) {
|
||||
if (((int)(tmp[0])) == 1) numExp++;
|
||||
if (result.size()-1 < ((int)(tmp[0]))) result.add(((int)(tmp[0])), new double[3]);
|
||||
mean = ((double[])(result.get(((int)(tmp[0])))));
|
||||
mean[0] += tmp[1];
|
||||
mean[1] += tmp[2];
|
||||
mean[2] += tmp[3];
|
||||
}
|
||||
} catch (javax.swing.text.BadLocationException ble){}
|
||||
}
|
||||
System.out.println(this.m_InputText.getLineCount() + " lines parsed. " + numExp + " experiments with " + result.size() + " events each.");
|
||||
this.addOutputText("Event\tBest\tMean\tWorst\n");
|
||||
/** This method will refine multiple run into on mean element
|
||||
*/
|
||||
public static String refineToText(ArrayList<double[]> result) {
|
||||
double[] mean;
|
||||
StringBuffer sbuf = new StringBuffer("Event\tBest\tMean\tWorst\n");
|
||||
|
||||
for(int i = 0; i < result.size(); i++) {
|
||||
mean = ((double[])(result.get(i)));
|
||||
this.addOutputText(i+"\t"+mean[0]/numExp+"\t"+mean[1]/numExp+"\t"+mean[2]/numExp+"\n");
|
||||
sbuf.append(i+"\t"+mean[0]+"\t"+mean[1]+"\t"+mean[2]+"\n");
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
public static String refineToText(String input) {
|
||||
return refineToText(refine(input));
|
||||
}
|
||||
|
||||
// public void compute() {
|
||||
// double[] tmp;
|
||||
// double[] mean = new double[3];
|
||||
// int begin, end, numExp = 0;
|
||||
// ArrayList result = new ArrayList(), tmpA;
|
||||
//
|
||||
// this.clearOutputText();
|
||||
// for (int i = 0; i < this.m_InputText.getLineCount(); i++) {
|
||||
// try {
|
||||
// begin = this.m_InputText.getLineStartOffset(i);
|
||||
// end = this.m_InputText.getLineEndOffset(i);
|
||||
// tmp = this.parseStringForDouble(this.m_InputText.getText(begin, end-begin));
|
||||
// if (tmp.length > 3) {
|
||||
// if (((int)(tmp[0])) == 1) numExp++;
|
||||
// if (result.size()-1 < ((int)(tmp[0]))) result.add(((int)(tmp[0])), new double[3]);
|
||||
// mean = ((double[])(result.get(((int)(tmp[0])))));
|
||||
// mean[0] += tmp[1];
|
||||
// mean[1] += tmp[2];
|
||||
// mean[2] += tmp[3];
|
||||
// }
|
||||
// } catch (javax.swing.text.BadLocationException ble){}
|
||||
// }
|
||||
// System.out.println(this.m_InputText.getLineCount() + " lines parsed. " + numExp + " experiments with " + result.size() + " events each.");
|
||||
// this.addOutputText("Event\tBest\tMean\tWorst\n");
|
||||
// for(int i = 0; i < result.size(); i++) {
|
||||
// mean = ((double[])(result.get(i)));
|
||||
// this.addOutputText(i+"\t"+mean[0]/numExp+"\t"+mean[1]/numExp+"\t"+mean[2]/numExp+"\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
/** A simple method to read doubles from a string.
|
||||
* @param String The string to be searched.
|
||||
* @return The array of doubles found.
|
||||
*/
|
||||
private double[] parseStringForDouble (String searchme) {
|
||||
public static double[] parseStringForDouble (String searchme) {
|
||||
double [] output;
|
||||
Vector tmpOutput;
|
||||
int positionInString = 0, from, to, i, tmp;
|
||||
|
@ -121,6 +121,13 @@ public class SelectedTag implements java.io.Serializable {
|
||||
public String getSelectedString() {
|
||||
return m_Tags[m_Selected].getString();
|
||||
}
|
||||
|
||||
public int getTagIDByString(String str) {
|
||||
for (int i=0; i<m_Tags.length; i++) {
|
||||
if (m_Tags[i].equals(str)) return m_Tags[i].getID();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* Returns true if the given String is equivalent to the currently selected Tags string component,
|
||||
* else false.
|
||||
|
@ -1,87 +0,0 @@
|
||||
package javaeva.tools;
|
||||
import java.io.Serializable;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileOutputStream;
|
||||
import javaeva.tools.JavacWrapper;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Source implements Serializable {
|
||||
private String m_String = "";
|
||||
private String m_Path = "";
|
||||
private String m_Filename = "";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Source(String path) {
|
||||
System.out.println("Constructor Source "+path);
|
||||
m_Path = path;
|
||||
m_Filename = System.getProperty("user.dir")+path;
|
||||
System.out.println("user.dir " +System.getProperty("user.dir")+ " m_Filename "+m_Filename);
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(m_Filename));
|
||||
while(true) {
|
||||
String s = reader.readLine();
|
||||
if (s==null) break;
|
||||
//System.out.println("s="+s);
|
||||
m_String=m_String+"\n"+s;
|
||||
}
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("e="+e+" "+e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getPath() {
|
||||
return m_Path;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getFilename() {
|
||||
return m_Filename;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setString (String s ) {
|
||||
if (s.equals(m_String)==false) {
|
||||
m_String = s;
|
||||
try {
|
||||
File f = new File (m_Filename);
|
||||
f.createNewFile();
|
||||
PrintWriter writer = new PrintWriter(new FileOutputStream(f));
|
||||
writer.println(m_String);
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("set Source="+e+" "+e.getMessage());}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getString ( ) {
|
||||
return m_String;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void append(String s) {
|
||||
m_String = m_String + "\n"+s;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void compile() {
|
||||
String base = System.getProperty("user.dir");
|
||||
System.out.println("user.dir " + base);
|
||||
JavacWrapper.compile(base + m_Path);
|
||||
}
|
||||
}
|
41
src/javaeva/tools/StringTools.java
Normal file
41
src/javaeva/tools/StringTools.java
Normal file
@ -0,0 +1,41 @@
|
||||
package javaeva.tools;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class StringTools {
|
||||
|
||||
/**
|
||||
* Returns a HTML formated String, in which each line is at most lineBreak
|
||||
* symbols long.
|
||||
*
|
||||
* @param string
|
||||
* @param lineBreak
|
||||
* @return
|
||||
*/
|
||||
public static String toHTML(String string, int lineBreak) {
|
||||
StringTokenizer st = new StringTokenizer(string, " ");
|
||||
if (!st.hasMoreTokens()) return "<html><body></body></html>";
|
||||
StringBuffer sbuf = new StringBuffer(st.nextToken());
|
||||
|
||||
int length = sbuf.length();
|
||||
while (st.hasMoreElements()) {
|
||||
if (length >= lineBreak) {
|
||||
sbuf.append("<br>");
|
||||
length = 0;
|
||||
} else sbuf.append(" ");
|
||||
String tmp = st.nextToken();
|
||||
length += tmp.length() + 1;
|
||||
sbuf.append(tmp);
|
||||
}
|
||||
sbuf.insert(0, "<html><body>");
|
||||
sbuf.append("</body></html>");
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(toHTML("Hallo-asdfsadfsafdsadfo, dies ist ein doller test text!", 15));
|
||||
System.out.println(toHTML("Set the interval of data output for intermediate verbosity (in generations).", 15));
|
||||
System.out.println(toHTML("Set the interval of data output for intermediate verbosity (in generations).", 25));
|
||||
System.out.println(toHTML("Set the interval of data output for intermediate verbosity (in generations).", 30));
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ public class XThread extends Thread implements Serializable {
|
||||
private static XThread[] m_Instances;
|
||||
private static int m_MAXinstances = 10;
|
||||
private static int m_index = 0;
|
||||
public static boolean TRACE = false;
|
||||
|
||||
public static void init(int x) {
|
||||
m_MAXinstances = x;
|
||||
@ -47,7 +48,7 @@ public class XThread extends Thread implements Serializable {
|
||||
*
|
||||
*/
|
||||
public static XThread getXThread(Object x, Method m, Object[] Para, int MAXinstances) {
|
||||
System.out.println("getXThread2 CALLLED");
|
||||
if (TRACE) System.out.println("getXThread2 CALLLED");
|
||||
//System.out.println("waiting "+m_instances+ " on "+x.hashCode()+ " m "+m.getName()+" m_MAXinstances " +MAXinstances);
|
||||
XThread ret = null;
|
||||
if (m_Instances == null)
|
||||
@ -83,7 +84,7 @@ System.out.println("getXThread2 CALLLED");
|
||||
Thread.sleep(w);
|
||||
w = 2 * w; //System.out.println(""+i);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in sleep of XThread");
|
||||
System.err.println("Error in sleep of XThread");
|
||||
}
|
||||
|
||||
} // end of while true
|
||||
@ -112,7 +113,7 @@ System.out.println("getXThread2 CALLLED");
|
||||
*
|
||||
*/
|
||||
public static XThread getXThread(Object x, String m, Object[] Para, int MAXinstances) {
|
||||
System.out.println("getXThread1 CALLLED");
|
||||
if (TRACE) System.out.println("getXThread1 CALLLED");
|
||||
// while (m_instances >= MAXinstances) {
|
||||
// //System.out.println("waiting "+m_instances);
|
||||
// //pleasewait();
|
||||
@ -161,7 +162,7 @@ System.out.println("getXThread2 CALLLED");
|
||||
Thread.sleep(w);
|
||||
w = 2 * w; //System.out.println(""+i);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in sleep of XThread");
|
||||
System.err.println("Error in sleep of XThread");
|
||||
}
|
||||
|
||||
} // end of while true
|
||||
@ -185,14 +186,14 @@ System.out.println("getXThread2 CALLLED");
|
||||
|
||||
private void removemyself() {
|
||||
for (int i = 0; i < m_Instances.length; i++) {
|
||||
System.out.println("TRYING TO REMOVE");
|
||||
if (TRACE) System.out.println("TRYING TO REMOVE");
|
||||
if (this.m_Instances[i] == this) {
|
||||
this.m_Instances[i] = null;
|
||||
System.out.println("REMOVED");
|
||||
System.out.println("REMOVED THREAD");
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("DANGER!!!!!!!!! XTHREAD ->NOT<- REMOVED");
|
||||
System.err.println("DANGER!!!!!!!!! XTHREAD ->NOT<- REMOVED");
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -235,7 +236,7 @@ System.out.println("getXThread2 CALLLED");
|
||||
if (m_Method != null) {
|
||||
//setPriority(Thread.MAX_PRIORITY);
|
||||
try {
|
||||
System.out.println("XTHREAD calling m_Method"+m_Method.getName());
|
||||
System.out.println("XTHREAD calling m_Method "+m_Method.getName());
|
||||
//System.out.print("--->");
|
||||
//this.setPriority(Thread.MAX_PRIORITY);
|
||||
m_Method.invoke(m_Object, m_Para);
|
||||
|
Loading…
x
Reference in New Issue
Block a user