parent
550e9956d8
commit
bcf7a9a8a2
@ -91,7 +91,9 @@ public class EvAInfo {
|
||||
|
||||
public static String getVersion() {
|
||||
String version = getProperty("EvA2Version");
|
||||
if (version==null) System.err.println("ERROR, missing property EvA2Version!");
|
||||
if (version==null) {
|
||||
System.err.println("ERROR, missing property EvA2Version!");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,9 @@ public class OptimizerRunnable implements Runnable {
|
||||
cntID++;
|
||||
|
||||
proc = new Processor(stats, null, params);
|
||||
if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
|
||||
if (proc.getStatistics() instanceof AbstractStatistics) {
|
||||
((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
|
||||
}
|
||||
doRestart = restart;
|
||||
}
|
||||
|
||||
@ -112,20 +114,28 @@ public class OptimizerRunnable implements Runnable {
|
||||
}
|
||||
|
||||
public void setStats(InterfaceStatistics stats) {
|
||||
if (proc.isOptRunning()) throw new RuntimeException("Error - cannot change statistics instance during optimization.");
|
||||
if (proc.isOptRunning()) {
|
||||
throw new RuntimeException("Error - cannot change statistics instance during optimization.");
|
||||
}
|
||||
InterfaceGOParameters params = proc.getGOParams();
|
||||
proc = new Processor(stats, null, params);
|
||||
if (proc.getStatistics() instanceof AbstractStatistics) ((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
|
||||
if (proc.getStatistics() instanceof AbstractStatistics) {
|
||||
((AbstractStatistics)proc.getStatistics()).setSaveParams(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextListener(InterfaceTextListener lsnr) {
|
||||
proc.getStatistics().removeTextListener(listener);
|
||||
this.listener = lsnr;
|
||||
if (listener != null) proc.getStatistics().addTextListener(listener);
|
||||
if (listener != null) {
|
||||
proc.getStatistics().addTextListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void addRemoteStateListener(RemoteStateListener rsl) {
|
||||
if (proc != null) proc.addListener(rsl);
|
||||
if (proc != null) {
|
||||
proc.addListener(rsl);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDoRestart(boolean restart) {
|
||||
@ -140,8 +150,12 @@ public class OptimizerRunnable implements Runnable {
|
||||
if (postProcessOnly) {
|
||||
proc.performPostProcessing((PostProcessParams)proc.getGOParams().getPostProcessParams(), listener);
|
||||
} else {
|
||||
if (doRestart) proc.restartOpt();
|
||||
else proc.startOpt();
|
||||
if (doRestart) {
|
||||
proc.restartOpt();
|
||||
}
|
||||
else {
|
||||
proc.startOpt();
|
||||
}
|
||||
proc.runOptOnce();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
@ -204,28 +218,36 @@ public class OptimizerRunnable implements Runnable {
|
||||
InterfaceTerminator term = proc.getGOParams().getTerminator();
|
||||
return term.lastTerminationMessage();
|
||||
}
|
||||
} else return "Not yet terminated";
|
||||
} else {
|
||||
return "Not yet terminated";
|
||||
}
|
||||
}
|
||||
|
||||
public double[] getDoubleSolution() {
|
||||
IndividualInterface indy = getResult();
|
||||
if (indy instanceof InterfaceDataTypeDouble) {
|
||||
return ((InterfaceDataTypeDouble)indy).getDoubleData();
|
||||
} else return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BitSet getBinarySolution() {
|
||||
IndividualInterface indy = getResult();
|
||||
if (indy instanceof InterfaceDataTypeBinary) {
|
||||
return ((InterfaceDataTypeBinary)indy).getBinaryData();
|
||||
} else return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getIntegerSolution() {
|
||||
IndividualInterface indy = getResult();
|
||||
if (indy instanceof InterfaceDataTypeInteger) {
|
||||
return ((InterfaceDataTypeInteger)indy).getIntegerData();
|
||||
} else return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +259,9 @@ public class OptimizerRunnable implements Runnable {
|
||||
public void setVerbosityLevel(int vLev) {
|
||||
if (vLev >= 0 && vLev < proc.getStatistics().getStatisticsParameter().getOutputVerbosity().getTags().length) {
|
||||
proc.getStatistics().getStatisticsParameter().getOutputVerbosity().setSelectedTag(vLev);
|
||||
} else System.err.println("Invalid verbosity leveln in OptimizerRunnable.setVerbosityLevel!");
|
||||
} else {
|
||||
System.err.println("Invalid verbosity leveln in OptimizerRunnable.setVerbosityLevel!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,9 @@ class RMIConnectionEvA extends RMIConnection {
|
||||
if (m_MainAdapter instanceof EvAMainAdapter) {
|
||||
EvAMainAdapter evaAdapter = (EvAMainAdapter)m_MainAdapter;
|
||||
ModuleAdapter ret = null;
|
||||
if (TRACE) System.out.println("ComAdapter.getModuleAdapter(" + Modul + ")");
|
||||
if (TRACE) {
|
||||
System.out.println("ComAdapter.getModuleAdapter(" + Modul + ")");
|
||||
}
|
||||
String hostAdd = "";
|
||||
try {
|
||||
hostAdd = InetAddress.getLocalHost().getHostAddress();
|
||||
|
@ -98,7 +98,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
this.m_BlackCheck[i].addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
if (actionOnSelect()) m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
|
||||
if (actionOnSelect()) {
|
||||
m_Support.firePropertyChange("AbstractListSelectionEditor", null, this);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.m_NodePanel.add(this.m_BlackCheck[i]);
|
||||
@ -125,7 +127,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object o) {
|
||||
if (setObject(o)) updateEditor();
|
||||
if (setObject(o)) {
|
||||
updateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,13 +161,17 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -202,7 +210,9 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
|
||||
|
@ -146,26 +146,38 @@ public class BeanInspector {
|
||||
* @return Description of the Return Value
|
||||
*/
|
||||
private static String toString(Object obj, char delim, boolean tight, String indentStr, int indentDepth, boolean withNewlines) {
|
||||
if (obj == null) return "null";
|
||||
if (obj == null) {
|
||||
return "null";
|
||||
}
|
||||
// try the object itself
|
||||
if (obj instanceof String) return (String)obj; // directly return a string object
|
||||
if (obj instanceof String) {
|
||||
return (String)obj;
|
||||
} // directly return a string object
|
||||
Class<? extends Object> type = obj.getClass();
|
||||
|
||||
if (type.isArray()) { // handle the array case
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
sbuf.append("[");
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
int len = Array.getLength(obj);
|
||||
for (int i=0; i<len; i++) {
|
||||
// sbuf.append(toString(Array.get(obj, i)));
|
||||
if (withNewlines) sbuf.append('\n');
|
||||
if (withNewlines) {
|
||||
sbuf.append('\n');
|
||||
}
|
||||
sbuf.append(toString(Array.get(obj, i), delim, tight, indentStr, indentDepth, withNewlines));
|
||||
if (i<len-1) {
|
||||
// sbuf.append(delim);
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
sbuf.append("]");
|
||||
return sbuf.toString();
|
||||
}
|
||||
@ -176,17 +188,25 @@ public class BeanInspector {
|
||||
|
||||
if (obj instanceof List && !(obj instanceof Population)) { // handle the list case
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
if (withNewlines) sbuf.append('\n');
|
||||
if (withNewlines) {
|
||||
sbuf.append('\n');
|
||||
}
|
||||
addIndent(sbuf, indentStr, indentDepth);
|
||||
sbuf.append("[");
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
List<?> lst = (List<?>)obj;
|
||||
for (Object o : lst) {
|
||||
sbuf.append(o.toString());
|
||||
sbuf.append(delim);
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
}
|
||||
if (!tight && (sbuf.charAt(sbuf.length()-2) == delim)) sbuf.setCharAt(sbuf.length()-2, ' '); // delete the delim
|
||||
if (!tight && (sbuf.charAt(sbuf.length()-2) == delim)) {
|
||||
sbuf.setCharAt(sbuf.length()-2, ' ');
|
||||
} // delete the delim
|
||||
sbuf.setCharAt(sbuf.length()-1, ']');
|
||||
return sbuf.toString();
|
||||
}
|
||||
@ -198,7 +218,9 @@ public class BeanInspector {
|
||||
//args[0] = obj;
|
||||
try {
|
||||
String ret = (String) methods[ii].invoke(obj, args);
|
||||
if (TRACE) System.out.println("toString on "+ obj.getClass() + " gave me " + ret);
|
||||
if (TRACE) {
|
||||
System.out.println("toString on "+ obj.getClass() + " gave me " + ret);
|
||||
}
|
||||
return makeIndent(indentStr, indentDepth) + ret;
|
||||
} catch (Exception e) {
|
||||
System.err.println(" ERROR +"+ e.getMessage());
|
||||
@ -211,19 +233,25 @@ public class BeanInspector {
|
||||
Pair<String[],Object[]> nameVals = getPublicPropertiesOf(obj, true, true);
|
||||
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
if (withNewlines) sbuf.append('\n');
|
||||
if (withNewlines) {
|
||||
sbuf.append('\n');
|
||||
}
|
||||
addIndent(sbuf, indentStr, indentDepth);
|
||||
sbuf.append(type.getName());
|
||||
sbuf.append("{");
|
||||
for (int i=0; i<nameVals.head.length; i++) {
|
||||
if (nameVals.head[i]!=null) {
|
||||
if (withNewlines) sbuf.append('\n');
|
||||
if (withNewlines) {
|
||||
sbuf.append('\n');
|
||||
}
|
||||
addIndent(sbuf, indentStr, indentDepth);
|
||||
sbuf.append(nameVals.head[i]);
|
||||
sbuf.append("=");
|
||||
sbuf.append(toString(nameVals.tail[i], delim, tight, indentStr, indentDepth+1, withNewlines));
|
||||
sbuf.append(delim);
|
||||
if (!tight) sbuf.append(" ");
|
||||
if (!tight) {
|
||||
sbuf.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +269,9 @@ public class BeanInspector {
|
||||
|
||||
private static String makeIndent(String indentStr, int indentDepth) {
|
||||
if (indentStr!=null) {
|
||||
if (indentDepth<1) return "";
|
||||
if (indentDepth<1) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
StringBuffer sbuf = new StringBuffer(indentStr);
|
||||
for (int i=2; i<=indentDepth; i++) {
|
||||
@ -249,7 +279,9 @@ public class BeanInspector {
|
||||
}
|
||||
return sbuf.toString();
|
||||
}
|
||||
} else return "";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -412,7 +444,9 @@ public class BeanInspector {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,7 +457,9 @@ public class BeanInspector {
|
||||
* @return
|
||||
*/
|
||||
public static Class[] toClassArray(Object[] o) {
|
||||
if (o==null) return null;
|
||||
if (o==null) {
|
||||
return null;
|
||||
}
|
||||
Class[] clz = new Class[o.length];
|
||||
for (int i=0; i<o.length; i++) {
|
||||
clz[i]=o[i].getClass();
|
||||
@ -461,15 +497,21 @@ public class BeanInspector {
|
||||
for (Method method : meths) {
|
||||
if (method.getName().equals(mName)) { // name match
|
||||
Class[] methParamTypes = method.getParameterTypes();
|
||||
if (paramTypes==null && methParamTypes.length==0) return method; // full match
|
||||
if (paramTypes==null && methParamTypes.length==0) {
|
||||
return method;
|
||||
} // full match
|
||||
else {
|
||||
if (paramTypes!=null && (methParamTypes.length==paramTypes.length)) {
|
||||
boolean mismatch = false; int i=0;
|
||||
while ((i<methParamTypes.length) && (!mismatch)) {
|
||||
if (!methParamTypes[i].isAssignableFrom(paramTypes[i]) && !isBoxableFrom(methParamTypes[i], paramTypes[i])) mismatch=true;
|
||||
if (!methParamTypes[i].isAssignableFrom(paramTypes[i]) && !isBoxableFrom(methParamTypes[i], paramTypes[i])) {
|
||||
mismatch=true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!mismatch) return method; // parameter match, otherwise search on
|
||||
if (!mismatch) {
|
||||
return method;
|
||||
} // parameter match, otherwise search on
|
||||
} // parameter mismatch, search on
|
||||
}
|
||||
}
|
||||
@ -488,7 +530,9 @@ public class BeanInspector {
|
||||
Class box = getBoxedType(clz1);
|
||||
if (box!=null && (clz2.isAssignableFrom(box))) {
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,16 +544,36 @@ public class BeanInspector {
|
||||
*/
|
||||
public static Class getBoxedType(Class cls) {
|
||||
if (cls.isPrimitive()) {
|
||||
if (cls == double.class) return Double.class;
|
||||
else if (cls == char.class) return Character.class;
|
||||
else if (cls == int.class) return Integer.class;
|
||||
else if (cls == boolean.class) return Boolean.class;
|
||||
else if (cls == byte.class) return Byte.class;
|
||||
else if (cls == short.class) return Short.class;
|
||||
else if (cls == long.class) return Long.class;
|
||||
else if (cls == float.class) return Float.class;
|
||||
else return Void.class;
|
||||
} else return null;
|
||||
if (cls == double.class) {
|
||||
return Double.class;
|
||||
}
|
||||
else if (cls == char.class) {
|
||||
return Character.class;
|
||||
}
|
||||
else if (cls == int.class) {
|
||||
return Integer.class;
|
||||
}
|
||||
else if (cls == boolean.class) {
|
||||
return Boolean.class;
|
||||
}
|
||||
else if (cls == byte.class) {
|
||||
return Byte.class;
|
||||
}
|
||||
else if (cls == short.class) {
|
||||
return Short.class;
|
||||
}
|
||||
else if (cls == long.class) {
|
||||
return Long.class;
|
||||
}
|
||||
else if (cls == float.class) {
|
||||
return Float.class;
|
||||
}
|
||||
else {
|
||||
return Void.class;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,16 +581,36 @@ public class BeanInspector {
|
||||
* primitive class.
|
||||
**/
|
||||
public static Class getUnboxedType(Class cls) {
|
||||
if (cls == Double.class) return double.class;
|
||||
else if (cls == Character.class) return char.class;
|
||||
else if (cls == Integer.class) return int.class;
|
||||
else if (cls == Boolean.class) return boolean.class;
|
||||
else if (cls == Byte.class) return byte.class;
|
||||
else if (cls == Short.class) return short.class;
|
||||
else if (cls == Long.class) return long.class;
|
||||
else if (cls == Float.class) return float.class;
|
||||
else if (cls == Void.class) return void.class;
|
||||
else return null;
|
||||
if (cls == Double.class) {
|
||||
return double.class;
|
||||
}
|
||||
else if (cls == Character.class) {
|
||||
return char.class;
|
||||
}
|
||||
else if (cls == Integer.class) {
|
||||
return int.class;
|
||||
}
|
||||
else if (cls == Boolean.class) {
|
||||
return boolean.class;
|
||||
}
|
||||
else if (cls == Byte.class) {
|
||||
return byte.class;
|
||||
}
|
||||
else if (cls == Short.class) {
|
||||
return short.class;
|
||||
}
|
||||
else if (cls == Long.class) {
|
||||
return long.class;
|
||||
}
|
||||
else if (cls == Float.class) {
|
||||
return float.class;
|
||||
}
|
||||
else if (cls == Void.class) {
|
||||
return void.class;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -594,15 +678,21 @@ public class BeanInspector {
|
||||
ArrayList<String> memberInfoList = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < m_Properties.length; i++) {
|
||||
if (m_Properties[i].isExpert()) continue;
|
||||
if (m_Properties[i].isExpert()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = m_Properties[i].getDisplayName();
|
||||
if (TRACE) System.out.println("PSP looking at "+ name);
|
||||
if (TRACE) {
|
||||
System.out.println("PSP looking at "+ name);
|
||||
}
|
||||
|
||||
Method getter = m_Properties[i].getReadMethod();
|
||||
Method setter = m_Properties[i].getWriteMethod();
|
||||
// Only display read/write properties.
|
||||
if (getter == null || setter == null) continue;
|
||||
if (getter == null || setter == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Object args[] = { };
|
||||
@ -612,7 +702,9 @@ public class BeanInspector {
|
||||
if (value == null) {
|
||||
// If it's a user-defined property we give a warning.
|
||||
String getterClass = m_Properties[i].getReadMethod().getDeclaringClass().getName();
|
||||
if (getterClass.indexOf("java.") != 0) System.err.println("Warning: Property \"" + name+ "\" has null initial value. Skipping.");
|
||||
if (getterClass.indexOf("java.") != 0) {
|
||||
System.err.println("Warning: Property \"" + name+ "\" has null initial value. Skipping.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -633,10 +725,14 @@ public class BeanInspector {
|
||||
memberInfoBf.append("String in {");
|
||||
for (int k=0; k<tags.length; k++) {
|
||||
memberInfoBf.append(tags[k].getString());
|
||||
if (k+1<tags.length) memberInfoBf.append(", ");
|
||||
if (k+1<tags.length) {
|
||||
memberInfoBf.append(", ");
|
||||
}
|
||||
}
|
||||
memberInfoBf.append("}");
|
||||
} else memberInfoBf.append(typeName);
|
||||
} else {
|
||||
memberInfoBf.append(typeName);
|
||||
}
|
||||
|
||||
if (withValues) {
|
||||
memberInfoBf.append('\t');
|
||||
@ -671,15 +767,33 @@ public class BeanInspector {
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static double toDouble(Object val) throws IllegalArgumentException {
|
||||
if (val instanceof Integer) return ((Integer)val).doubleValue();
|
||||
else if (val instanceof Double) return ((Double)val).doubleValue();
|
||||
else if (val instanceof Boolean) return (((Boolean)val) ? 1. : 0.);
|
||||
else if (val instanceof Character) return ((Character)val).charValue();
|
||||
else if (val instanceof Byte) return ((Byte)val).doubleValue();
|
||||
else if (val instanceof Short) return ((Short)val).doubleValue();
|
||||
else if (val instanceof Long) return ((Long)val).doubleValue();
|
||||
else if (val instanceof Float) return ((Float)val).doubleValue();
|
||||
else if (val instanceof Void) return 0;
|
||||
if (val instanceof Integer) {
|
||||
return ((Integer)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Double) {
|
||||
return ((Double)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Boolean) {
|
||||
return (((Boolean)val) ? 1. : 0.);
|
||||
}
|
||||
else if (val instanceof Character) {
|
||||
return ((Character)val).charValue();
|
||||
}
|
||||
else if (val instanceof Byte) {
|
||||
return ((Byte)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Short) {
|
||||
return ((Short)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Long) {
|
||||
return ((Long)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Float) {
|
||||
return ((Float)val).doubleValue();
|
||||
}
|
||||
else if (val instanceof Void) {
|
||||
return 0;
|
||||
}
|
||||
throw new IllegalArgumentException("Illegal type, cant convert " + val.getClass() + " to double.");
|
||||
}
|
||||
|
||||
@ -691,14 +805,30 @@ public class BeanInspector {
|
||||
* @return
|
||||
*/
|
||||
public static Object stringToPrimitive(String str, Class<?> destType) throws NumberFormatException {
|
||||
if ((destType == Integer.class) || (destType == int.class)) return Integer.valueOf(str);
|
||||
else if ((destType == Double.class) || (destType == double.class)) return Double.valueOf(str);
|
||||
else if ((destType == Boolean.class) || (destType == boolean.class)) return Boolean.valueOf(str);
|
||||
else if ((destType == Byte.class) || (destType == byte.class)) return Byte.valueOf(str);
|
||||
else if ((destType == Short.class) || (destType == short.class)) return Short.valueOf(str);
|
||||
else if ((destType == Long.class) || (destType == long.class)) return Long.valueOf(str);
|
||||
else if ((destType == Float.class) || (destType == float.class)) return Float.valueOf(str);
|
||||
else if ((destType == Character.class) || (destType == char.class)) return str.charAt(0);
|
||||
if ((destType == Integer.class) || (destType == int.class)) {
|
||||
return Integer.valueOf(str);
|
||||
}
|
||||
else if ((destType == Double.class) || (destType == double.class)) {
|
||||
return Double.valueOf(str);
|
||||
}
|
||||
else if ((destType == Boolean.class) || (destType == boolean.class)) {
|
||||
return Boolean.valueOf(str);
|
||||
}
|
||||
else if ((destType == Byte.class) || (destType == byte.class)) {
|
||||
return Byte.valueOf(str);
|
||||
}
|
||||
else if ((destType == Short.class) || (destType == short.class)) {
|
||||
return Short.valueOf(str);
|
||||
}
|
||||
else if ((destType == Long.class) || (destType == long.class)) {
|
||||
return Long.valueOf(str);
|
||||
}
|
||||
else if ((destType == Float.class) || (destType == float.class)) {
|
||||
return Float.valueOf(str);
|
||||
}
|
||||
else if ((destType == Character.class) || (destType == char.class)) {
|
||||
return str.charAt(0);
|
||||
}
|
||||
else {
|
||||
// if (destType == Void.class)
|
||||
System.err.println("warning, value interpreted as void type");
|
||||
@ -714,18 +844,35 @@ public class BeanInspector {
|
||||
* @return
|
||||
*/
|
||||
public static Object doubleToPrimitive(Double d, Class<?> destType) {
|
||||
if ((destType == Double.class) || (destType == double.class)) return d;
|
||||
if ((destType == Integer.class) || (destType == int.class)) return new Integer(d.intValue());
|
||||
else if ((destType == Boolean.class) || (destType == boolean.class)) return (d!=0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
else if ((destType == Byte.class) || (destType == byte.class)) return new Byte(d.byteValue());
|
||||
else if ((destType == Short.class) || (destType == short.class)) return new Short(d.shortValue());
|
||||
else if ((destType == Long.class) || (destType == long.class)) return new Long(d.longValue());
|
||||
else if ((destType == Float.class) || (destType == float.class)) return new Float(d.floatValue());
|
||||
if ((destType == Double.class) || (destType == double.class)) {
|
||||
return d;
|
||||
}
|
||||
if ((destType == Integer.class) || (destType == int.class)) {
|
||||
return new Integer(d.intValue());
|
||||
}
|
||||
else if ((destType == Boolean.class) || (destType == boolean.class)) {
|
||||
return (d!=0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else if ((destType == Byte.class) || (destType == byte.class)) {
|
||||
return new Byte(d.byteValue());
|
||||
}
|
||||
else if ((destType == Short.class) || (destType == short.class)) {
|
||||
return new Short(d.shortValue());
|
||||
}
|
||||
else if ((destType == Long.class) || (destType == long.class)) {
|
||||
return new Long(d.longValue());
|
||||
}
|
||||
else if ((destType == Float.class) || (destType == float.class)) {
|
||||
return new Float(d.floatValue());
|
||||
}
|
||||
else { // this makes hardly sense...
|
||||
System.err.println("warning: converting from double to character or void...");
|
||||
if ((destType == Character.class) || (destType == char.class)) return new Character(d.toString().charAt(0));
|
||||
else //if (destType == Void.class) return 0;
|
||||
return 0;
|
||||
if ((destType == Character.class) || (destType == char.class)) {
|
||||
return new Character(d.toString().charAt(0));
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -737,9 +884,13 @@ public class BeanInspector {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isJavaPrimitive(Class<?> cls) {
|
||||
if (cls.isPrimitive()) return true;
|
||||
if (cls.isPrimitive()) {
|
||||
return true;
|
||||
}
|
||||
if ((cls == Double.class) || (cls == Integer.class) || (cls == Boolean.class) || (cls == Character.class) || (cls == Void.class)
|
||||
|| (cls == Byte.class) || (cls == Short.class) || (cls == Long.class) || (cls == Float.class)) return true;
|
||||
|| (cls == Byte.class) || (cls == Short.class) || (cls == Long.class) || (cls == Float.class)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -751,14 +902,30 @@ public class BeanInspector {
|
||||
* @return
|
||||
*/
|
||||
public static Class getJavaPrimitive(Class<?> cls) {
|
||||
if (cls.isPrimitive()) return cls;
|
||||
if (cls == Double.class) return double.class;
|
||||
else if (cls == Integer.class) return int.class;
|
||||
else if (cls == Boolean.class) return Boolean.class;
|
||||
else if (cls == Byte.class) return byte.class;
|
||||
else if (cls == Short.class) return short.class;
|
||||
else if (cls == Long.class) return long.class;
|
||||
else if (cls == Float.class) return float.class;
|
||||
if (cls.isPrimitive()) {
|
||||
return cls;
|
||||
}
|
||||
if (cls == Double.class) {
|
||||
return double.class;
|
||||
}
|
||||
else if (cls == Integer.class) {
|
||||
return int.class;
|
||||
}
|
||||
else if (cls == Boolean.class) {
|
||||
return Boolean.class;
|
||||
}
|
||||
else if (cls == Byte.class) {
|
||||
return byte.class;
|
||||
}
|
||||
else if (cls == Short.class) {
|
||||
return short.class;
|
||||
}
|
||||
else if (cls == Long.class) {
|
||||
return long.class;
|
||||
}
|
||||
else if (cls == Float.class) {
|
||||
return float.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
@ -776,8 +943,12 @@ public class BeanInspector {
|
||||
return value;
|
||||
}
|
||||
if (destType == String.class || destType == SelectedTag.class) {
|
||||
if (value.getClass() == String.class) return value;
|
||||
else return value.toString();
|
||||
if (value.getClass() == String.class) {
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return value.toString();
|
||||
}
|
||||
} else if (isJavaPrimitive(destType)) {
|
||||
try {
|
||||
if (value.getClass() == String.class) {
|
||||
|
@ -214,13 +214,17 @@ public class BigStringEditor implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,9 @@ public class DPointSetMultiIcon extends DComponent
|
||||
{
|
||||
p = m.getPoint(xMI.getImage(i), yMI.getImage(i));
|
||||
|
||||
if (p==null) continue;
|
||||
if (p==null) {
|
||||
continue;
|
||||
}
|
||||
if (this.m_IconsMI.get(i) != null)
|
||||
{
|
||||
g.setStroke(new BasicStroke());
|
||||
|
@ -37,8 +37,9 @@ public class DataViewer implements DataViewerInterface {
|
||||
*
|
||||
*/
|
||||
public static DataViewerInterface getInstance (MainAdapterClient client,String GraphWindowName) {
|
||||
if (m_ViewContainer == null)
|
||||
m_ViewContainer = new ViewContainer();
|
||||
if (m_ViewContainer == null) {
|
||||
m_ViewContainer = new ViewContainer();
|
||||
}
|
||||
DataViewerInterface ret =null;
|
||||
try {
|
||||
if (!m_ViewContainer.containsName(GraphWindowName)) {
|
||||
@ -50,13 +51,17 @@ public class DataViewer implements DataViewerInterface {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (client != null && client.getHostName().equals(m_MyHostName)== true) {
|
||||
if (TRACE) System.out.println("no RMI");
|
||||
if (TRACE) {
|
||||
System.out.println("no RMI");
|
||||
}
|
||||
ret = new DataViewer(GraphWindowName,true);
|
||||
}
|
||||
else {
|
||||
ret = (DataViewerInterface) RMIProxyRemote.newInstance(new DataViewer(GraphWindowName,false), client);
|
||||
ret.init();
|
||||
if (TRACE) System.out.println("with RMI");
|
||||
if (TRACE) {
|
||||
System.out.println("with RMI");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,10 +81,13 @@ public class DataViewer implements DataViewerInterface {
|
||||
*
|
||||
*/
|
||||
private DataViewer(String PlotName,boolean initflag){
|
||||
if (TRACE) System.out.println("Constructor DataViewer");
|
||||
if (TRACE) {
|
||||
System.out.println("Constructor DataViewer");
|
||||
}
|
||||
m_Name = PlotName;
|
||||
if(initflag)
|
||||
this.init();
|
||||
if(initflag) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -93,7 +101,9 @@ public class DataViewer implements DataViewerInterface {
|
||||
@Override
|
||||
public Graph getNewGraph(String InfoString) {
|
||||
m_GraphCounter++;
|
||||
if (TRACE) System.out.println("Graph.getNewGraph No:"+m_GraphCounter);
|
||||
if (TRACE) {
|
||||
System.out.println("Graph.getNewGraph No:"+m_GraphCounter);
|
||||
}
|
||||
return new Graph (InfoString,m_Plot,m_GraphCounter);
|
||||
}
|
||||
/**
|
||||
@ -131,9 +141,11 @@ class ViewContainer extends ArrayList {
|
||||
*
|
||||
*/
|
||||
public DataViewer getPlot (String name) {
|
||||
if (m_actualPlot!=null)
|
||||
if (m_actualPlot.getName().equals(name))
|
||||
return m_actualPlot;
|
||||
if (m_actualPlot!=null) {
|
||||
if (m_actualPlot.getName().equals(name)) {
|
||||
return m_actualPlot;
|
||||
}
|
||||
}
|
||||
DataViewer temp = null;
|
||||
for (int i=0;i<size();i++) {
|
||||
temp = (DataViewer)(get(i));
|
||||
|
@ -49,7 +49,9 @@ public class EnumEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public String[] getTags() {
|
||||
if (getValue()==null) return null;
|
||||
if (getValue()==null) {
|
||||
return null;
|
||||
}
|
||||
String[] tags = new String[enumConstants.length];
|
||||
for (int i=0; i<tags.length; i++) {
|
||||
tags[i]=enumConstants[i].toString();
|
||||
|
@ -48,7 +48,9 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
childrenNames = PropertySheetPanel.getPropertyNames(target);
|
||||
childrenValues = PropertySheetPanel.getPropertyValues(target, true, true, true);
|
||||
super.removeAllChildren();
|
||||
if (expand) initChildren();
|
||||
if (expand) {
|
||||
initChildren();
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
@ -65,8 +67,9 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
private void initChildren() {
|
||||
for (int i=0; i<childrenValues.length; i++) {
|
||||
if (childrenValues[i]!=null) {
|
||||
if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass())))
|
||||
super.add(new EvATreeNode(childrenNames[i], childrenValues[i]));
|
||||
if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) {
|
||||
super.add(new EvATreeNode(childrenNames[i], childrenValues[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,7 +82,11 @@ public class EvATreeNode extends DefaultMutableTreeNode {
|
||||
} catch (Exception e) {
|
||||
extendedInfo=null;
|
||||
}
|
||||
if (extendedInfo != null) return myName + " - "+ extendedInfo;
|
||||
else return myName;
|
||||
if (extendedInfo != null) {
|
||||
return myName + " - "+ extendedInfo;
|
||||
}
|
||||
else {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,17 +37,24 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
||||
root = rootNode;
|
||||
jtree = jt;
|
||||
|
||||
if (jtree!=null) jtree.addTreeSelectionListener(this); // listen to tree selection changes
|
||||
if (goEditor!=null) goEditor.addPropertyChangeListener(this); // listen to changes to the parameters
|
||||
if (jtree!=null) {
|
||||
jtree.addTreeSelectionListener(this);
|
||||
} // listen to tree selection changes
|
||||
if (goEditor!=null) {
|
||||
goEditor.addPropertyChangeListener(this);
|
||||
} // listen to changes to the parameters
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
if (TRACE) System.out.println("valueChanged to " + BeanInspector.toString(e.getPath()));
|
||||
if (TRACE) {
|
||||
System.out.println("valueChanged to " + BeanInspector.toString(e.getPath()));
|
||||
}
|
||||
TreePath tp = e.getPath();
|
||||
if (TRACE) for (int i=tp.getPathCount()-1; i>=0; i--) {
|
||||
System.out.println("* " + i + " " + tp.getPathComponent(i));
|
||||
}
|
||||
if (TRACE) {
|
||||
for (int i=tp.getPathCount()-1; i>=0; i--) {
|
||||
System.out.println("* " + i + " " + tp.getPathComponent(i));
|
||||
} }
|
||||
EvATreeNode leafNode = (EvATreeNode)tp.getLastPathComponent();
|
||||
// goe.setValue(leafNode.getUserObject());
|
||||
Component editComp = goe.getCustomEditor();
|
||||
@ -61,8 +68,12 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (TRACE) System.out.println("EvATreeNode received change event " + evt);
|
||||
if (TRACE) {
|
||||
System.out.println("EvATreeNode received change event " + evt);
|
||||
}
|
||||
root.setObject(evt.getNewValue(), true);
|
||||
if (jtree !=null) jtree.setModel(new DefaultTreeModel(root)); // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||
if (jtree !=null) {
|
||||
jtree.setModel(new DefaultTreeModel(root));
|
||||
} // TODO this should be done differently so that the tree is not collapsed on each change!
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,12 @@ public class Exp extends DFunction {
|
||||
private double minValue = 1e-10; // think of a minimal value we want to show in case invalid (<=0) values are requested
|
||||
|
||||
public void setMinValue(double v) {
|
||||
if (v>0) minValue = v;
|
||||
else System.err.println("Error, minimal value for Exp must be positive!");
|
||||
if (v>0) {
|
||||
minValue = v;
|
||||
}
|
||||
else {
|
||||
System.err.println("Error, minimal value for Exp must be positive!");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@ -58,6 +62,8 @@ public class Exp extends DFunction {
|
||||
}
|
||||
|
||||
public void updateMinValue(double y) {
|
||||
if (y<minValue && (y>0)) minValue=y;
|
||||
if (y<minValue && (y>0)) {
|
||||
minValue=y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,9 @@ public abstract class ExtAction extends AbstractAction {
|
||||
*/
|
||||
public ExtAction(String s, Icon i, String toolTip, KeyStroke key){
|
||||
this(s, i, toolTip);
|
||||
if (i==null)
|
||||
System.out.println("Icon == null");
|
||||
if (i==null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
putValue(KEYSTROKE, key);
|
||||
}
|
||||
/**
|
||||
@ -47,8 +48,9 @@ public abstract class ExtAction extends AbstractAction {
|
||||
*/
|
||||
public ExtAction(String s, Icon i, String toolTip){
|
||||
super(null, i);
|
||||
if (i==null)
|
||||
System.out.println("Icon == null");
|
||||
if (i==null) {
|
||||
System.out.println("Icon == null");
|
||||
}
|
||||
setValues(s, toolTip);
|
||||
}
|
||||
/**
|
||||
|
@ -52,7 +52,9 @@ public class GenericAreaEditor extends AbstractListSelectionEditor {
|
||||
this.m_AreaObject = (GPArea) o;
|
||||
m_AreaObject.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -290,13 +290,17 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -348,7 +352,9 @@ public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor {
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
}
|
@ -197,13 +197,17 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -255,7 +259,9 @@ public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEd
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
}
|
@ -214,13 +214,17 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -272,7 +276,9 @@ public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEdi
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
}
|
@ -85,13 +85,17 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -156,7 +160,9 @@ public class GenericFilePathEditor extends JPanel implements PropertyEditor {
|
||||
m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath());
|
||||
m_Support.firePropertyChange("", m_FilePath, null);
|
||||
Window w = (Window) m_FileChooser.getTopLevelAncestor();
|
||||
if (w != null) w.dispose();
|
||||
if (w != null) {
|
||||
w.dispose();
|
||||
}
|
||||
m_Panel = null;
|
||||
}
|
||||
}
|
||||
|
@ -173,13 +173,17 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -231,7 +235,9 @@ public class GenericIntArrayEditor extends JPanel implements PropertyEditor {
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
}
|
@ -42,7 +42,9 @@ public class GenericObjectListSelectionEditor extends AbstractListSelectionEdito
|
||||
this.objList = (PropertySelectableList) o;
|
||||
objList.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Retruns the current object.
|
||||
|
@ -80,13 +80,18 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_Editors[i].m_Editor).setClassType(InterfaceOptimizationTarget.class);
|
||||
}
|
||||
this.m_Editors[i].m_Editor.setValue(this.m_Editors[i].m_Value);
|
||||
this.m_Editors[i].m_Editor.addPropertyChangeListener(this);
|
||||
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
|
||||
if (this.m_Editors[i].m_View != null) this.m_Editors[i].m_View.repaint();
|
||||
if (this.m_Editors[i].m_View != null) {
|
||||
this.m_Editors[i].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -217,13 +222,18 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
try {
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
if (newEdit[l].m_Editor == null) newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (newEdit[l].m_Editor instanceof GenericObjectEditor)
|
||||
if (newEdit[l].m_Editor == null) {
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (newEdit[l].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) newEdit[l].m_Editor).setClassType(InterfaceOptimizationTarget.class);
|
||||
}
|
||||
newEdit[l].m_Editor.setValue(newEdit[l].m_Value);
|
||||
newEdit[l].m_Editor.addPropertyChangeListener(m_self);
|
||||
AbstractObjectEditor.findViewFor(newEdit[l]);
|
||||
if (newEdit[l].m_View != null) newEdit[l].m_View.repaint();
|
||||
if (newEdit[l].m_View != null) {
|
||||
newEdit[l].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -240,7 +250,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
int l = m_OptimizationObjectives.getSelectedTargets().length, j = 0;
|
||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1];
|
||||
for (int i = 0; i < m_Delete.length; i++) {
|
||||
if (event.getSource().equals(m_Delete[i])) m_OptimizationObjectives.removeTarget(i);
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_OptimizationObjectives.removeTarget(i);
|
||||
}
|
||||
else {
|
||||
newEdit[j] = m_Editors[i];
|
||||
j++;
|
||||
@ -361,7 +373,9 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) this.initCustomEditor();
|
||||
if (this.m_Editor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_Editor;
|
||||
}
|
||||
|
||||
@ -377,13 +391,17 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
@ -402,13 +420,18 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_Editors[i].m_Editor).setClassType(InterfaceOptimizationTarget.class);
|
||||
}
|
||||
this.m_Editors[i].m_Editor.setValue(this.m_Editors[i].m_Value);
|
||||
this.m_Editors[i].m_Editor.addPropertyChangeListener(this);
|
||||
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
|
||||
if (this.m_Editors[i].m_View != null) this.m_Editors[i].m_View.repaint();
|
||||
if (this.m_Editors[i].m_View != null) {
|
||||
this.m_Editors[i].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
|
@ -83,13 +83,18 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_Editors[i].m_Editor).setClassType(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
this.m_Editors[i].m_Editor.setValue(this.m_Editors[i].m_Value);
|
||||
this.m_Editors[i].m_Editor.addPropertyChangeListener(this);
|
||||
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
|
||||
if (this.m_Editors[i].m_View != null) this.m_Editors[i].m_View.repaint();
|
||||
if (this.m_Editors[i].m_View != null) {
|
||||
this.m_Editors[i].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -242,13 +247,18 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
try {
|
||||
newEdit[l].m_Value = list[l];
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(newEdit[l].m_Value.getClass());
|
||||
if (newEdit[l].m_Editor == null) newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (newEdit[l].m_Editor instanceof GenericObjectEditor)
|
||||
if (newEdit[l].m_Editor == null) {
|
||||
newEdit[l].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (newEdit[l].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) newEdit[l].m_Editor).setClassType(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
newEdit[l].m_Editor.setValue(newEdit[l].m_Value);
|
||||
newEdit[l].m_Editor.addPropertyChangeListener(m_self);
|
||||
AbstractObjectEditor.findViewFor(newEdit[l]);
|
||||
if (newEdit[l].m_View != null) newEdit[l].m_View.repaint();
|
||||
if (newEdit[l].m_View != null) {
|
||||
newEdit[l].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -265,7 +275,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
int l = m_OptimizationObjectivesWithWeights.getSelectedTargets().length, j = 0;
|
||||
GeneralGOEProperty[] newEdit = new GeneralGOEProperty[l-1];
|
||||
for (int i = 0; i < m_Delete.length; i++) {
|
||||
if (event.getSource().equals(m_Delete[i])) m_OptimizationObjectivesWithWeights.removeTarget(i);
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_OptimizationObjectivesWithWeights.removeTarget(i);
|
||||
}
|
||||
else {
|
||||
newEdit[j] = m_Editors[i];
|
||||
j++;
|
||||
@ -432,7 +444,9 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) this.initCustomEditor();
|
||||
if (this.m_Editor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_Editor;
|
||||
}
|
||||
|
||||
@ -448,13 +462,17 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/** This will wait for the GenericObjectEditor to finish
|
||||
@ -473,13 +491,18 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
|
||||
try {
|
||||
this.m_Editors[i].m_Value = list[i];
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(this.m_Editors[i].m_Value.getClass());
|
||||
if (this.m_Editors[i].m_Editor == null) this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_Editors[i].m_Editor == null) {
|
||||
this.m_Editors[i].m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
if (this.m_Editors[i].m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_Editors[i].m_Editor).setClassType(InterfaceOptimizationObjective.class);
|
||||
}
|
||||
this.m_Editors[i].m_Editor.setValue(this.m_Editors[i].m_Value);
|
||||
this.m_Editors[i].m_Editor.addPropertyChangeListener(this);
|
||||
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
|
||||
if (this.m_Editors[i].m_View != null) this.m_Editors[i].m_View.repaint();
|
||||
if (this.m_Editors[i].m_View != null) {
|
||||
this.m_Editors[i].m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
|
@ -107,8 +107,12 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
JButton tmpB;
|
||||
byte[] bytes;
|
||||
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
|
||||
if (bytes!=null) tmpB = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
else tmpB = new JButton(title);
|
||||
if (bytes!=null) {
|
||||
tmpB = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
|
||||
}
|
||||
else {
|
||||
tmpB = new JButton(title);
|
||||
}
|
||||
return tmpB;
|
||||
}
|
||||
|
||||
@ -148,8 +152,12 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.BOTH, 0, 1);
|
||||
this.m_Status[i] = new JButton(" ");
|
||||
this.m_Status[i].setEnabled(false);
|
||||
if (this.m_RemoteServers.isServerOnline(t.m_ServerName)) this.m_Status[i].setBackground(Color.GREEN);
|
||||
else this.m_Status[i].setBackground(Color.RED);
|
||||
if (this.m_RemoteServers.isServerOnline(t.m_ServerName)) {
|
||||
this.m_Status[i].setBackground(Color.GREEN);
|
||||
}
|
||||
else {
|
||||
this.m_Status[i].setBackground(Color.RED);
|
||||
}
|
||||
this.m_ServerList.add(this.m_Status[i], gbc);
|
||||
// the server name
|
||||
gbc = new GridBagConstraints();
|
||||
@ -263,7 +271,9 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
for (int i = 0; i < m_Delete.length; i++) {
|
||||
if (event.getSource().equals(m_Delete[i])) m_RemoteServers.removeServerNode(m_RemoteServers.get(i).m_ServerName);
|
||||
if (event.getSource().equals(m_Delete[i])) {
|
||||
m_RemoteServers.removeServerNode(m_RemoteServers.get(i).m_ServerName);
|
||||
}
|
||||
}
|
||||
updateServerList();
|
||||
updateEditor();
|
||||
@ -343,7 +353,9 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
for (int i = 0; i < m_Names.length; i++) {
|
||||
if (event.getSource().equals(m_Names[i])) m_RemoteServers.setNameFor(i, m_Names[i].getText());
|
||||
if (event.getSource().equals(m_Names[i])) {
|
||||
m_RemoteServers.setNameFor(i, m_Names[i].getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -354,7 +366,9 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
for (int i = 0; i < m_CPUs.length; i++) {
|
||||
if (event.getSource().equals(m_CPUs[i])) m_RemoteServers.setCPUsFor(i, m_CPUs[i].getSelectedIndex()+1);
|
||||
if (event.getSource().equals(m_CPUs[i])) {
|
||||
m_RemoteServers.setCPUsFor(i, m_CPUs[i].getSelectedIndex()+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -419,13 +433,17 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -477,7 +495,9 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_Editor == null) this.initCustomEditor();
|
||||
if (this.m_Editor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_Editor;
|
||||
}
|
||||
}
|
@ -221,13 +221,17 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@ -279,7 +283,9 @@ public class GenericWeigthedLPTchebycheffEditor extends JPanel implements Proper
|
||||
*/
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (this.m_CustomEditor == null) this.initCustomEditor();
|
||||
if (this.m_CustomEditor == null) {
|
||||
this.initCustomEditor();
|
||||
}
|
||||
return m_CustomEditor;
|
||||
}
|
||||
}
|
@ -264,10 +264,11 @@ public class GraphPointSet {
|
||||
int[] GraphSize = new int[m_PointSetContainer.size()];
|
||||
for (int i = 0; i < m_PointSetContainer.size(); i++) {
|
||||
GraphSize[i] = ((PointSet) m_PointSetContainer.get(i)).getSize();
|
||||
if (GraphSize[i] <= 0)
|
||||
System.err.println("Warning: invalid graph size of "
|
||||
+ GraphSize[i] + " at " + i
|
||||
+ "! (GraphPointSet.addGraph)");
|
||||
if (GraphSize[i] <= 0) {
|
||||
System.err.println("Warning: invalid graph size of "
|
||||
+ GraphSize[i] + " at " + i
|
||||
+ "! (GraphPointSet.addGraph)");
|
||||
}
|
||||
}
|
||||
if (Mathematics.sum(GraphSize) == 0) {
|
||||
System.err
|
||||
@ -309,8 +310,9 @@ public class GraphPointSet {
|
||||
y[i] = m_PointSetContainer.get(i).m_Y[index[i]];
|
||||
index[i]++;
|
||||
numberofpoints++;
|
||||
} else
|
||||
y[i] = 0;
|
||||
} else {
|
||||
y[i] = 0;
|
||||
}
|
||||
}
|
||||
double ymean = Mathematics.sum(y) / numberofpoints;
|
||||
// compute median double median = getMedian(y);
|
||||
@ -499,10 +501,12 @@ public class GraphPointSet {
|
||||
}
|
||||
m_ConnectedPointSet.removeAllPoints();
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
if (buf[i].x == x.x && buf[i].y == x.y)
|
||||
System.out.println("point found");
|
||||
else
|
||||
m_ConnectedPointSet.addDPoint(buf[i]);
|
||||
if (buf[i].x == x.x && buf[i].y == x.y) {
|
||||
System.out.println("point found");
|
||||
}
|
||||
else {
|
||||
m_ConnectedPointSet.addDPoint(buf[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -563,7 +567,9 @@ public class GraphPointSet {
|
||||
* @return the median point of this point set or null if it is empty
|
||||
*/
|
||||
public DPoint getMedPoint() {
|
||||
if (m_ConnectedPointSet==null) return null;
|
||||
if (m_ConnectedPointSet==null) {
|
||||
return null;
|
||||
}
|
||||
int medX = m_ConnectedPointSet.getSize()/2;
|
||||
return m_ConnectedPointSet.getDPoint(medX);
|
||||
}
|
||||
|
@ -65,8 +65,12 @@ public class GraphPointSetLegend {
|
||||
GraphPointSet pointset = pointSetContainer.get(i);
|
||||
if (pointset.getPointSet().getSize()>0) {
|
||||
String entryStr;
|
||||
if (appendIndex) entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString();
|
||||
else entryStr = pointset.getInfoString();
|
||||
if (appendIndex) {
|
||||
entryStr = StringTools.expandPrefixZeros(i, pointSetContainer.size()-1) + ": " + pointset.getInfoString();
|
||||
}
|
||||
else {
|
||||
entryStr = pointset.getInfoString();
|
||||
}
|
||||
legendEntries.add(new Pair<String, Color>(entryStr,pointset.getColor()));
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ public abstract class JDocFrame extends JInternalFrame{
|
||||
*
|
||||
*/
|
||||
public void save(){
|
||||
if(m_file != null) save(m_file);
|
||||
if(m_file != null) {
|
||||
save(m_file);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -67,14 +69,20 @@ public abstract class JDocFrame extends JInternalFrame{
|
||||
*/
|
||||
private void setChangedImpl(boolean value){
|
||||
changed = value;
|
||||
if(changed) setTitle(titleStr + " *");
|
||||
else setTitle(titleStr);
|
||||
if(changed) {
|
||||
setTitle(titleStr + " *");
|
||||
}
|
||||
else {
|
||||
setTitle(titleStr);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void setChanged(boolean value){
|
||||
if(changed != value) setChangedImpl(value);
|
||||
if(changed != value) {
|
||||
setChangedImpl(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
@ -31,8 +31,11 @@ public class JExtFileChooser extends JFileChooser{
|
||||
if(getDialogType() == JFileChooser.SAVE_DIALOG && overwriteWarning){
|
||||
File f = getSelectedFile();
|
||||
|
||||
if(f != null && f.exists())
|
||||
if(JOptionPane.showConfirmDialog(this, "Die Datei " + f.getPath() + " existiert bereits.\nSoll sie <20>berschrieben werden?", "Achtung", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) return;
|
||||
if(f != null && f.exists()) {
|
||||
if (JOptionPane.showConfirmDialog(this, "Die Datei " + f.getPath() + " existiert bereits.\nSoll sie <20>berschrieben werden?", "Achtung", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.approveSelection();
|
||||
|
@ -49,11 +49,17 @@ public class JExtMenu extends JMenu{
|
||||
JMenuItem item = super.add(a);
|
||||
Object o;
|
||||
o = a.getValue(ExtAction.MNEMONIC);
|
||||
if(o != null) item.setMnemonic(((Character)o).charValue());
|
||||
if(o != null) {
|
||||
item.setMnemonic(((Character)o).charValue());
|
||||
}
|
||||
o = a.getValue(ExtAction.TOOLTIP);
|
||||
if(o != null) item.setToolTipText((String)o);
|
||||
if(o != null) {
|
||||
item.setToolTipText((String)o);
|
||||
}
|
||||
o = a.getValue(ExtAction.KEYSTROKE);
|
||||
if(o != null) item.setAccelerator((KeyStroke)o);
|
||||
if(o != null) {
|
||||
item.setAccelerator((KeyStroke)o);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
/**
|
||||
@ -65,19 +71,31 @@ public class JExtMenu extends JMenu{
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
JMenuItem menuItem = (JMenuItem)component;
|
||||
if(menuItem == null) return;
|
||||
if(menuItem == null) {
|
||||
return;
|
||||
}
|
||||
String propertyName = e.getPropertyName();
|
||||
if(propertyName.equals(Action.NAME)) menuItem.setText((String)e.getNewValue());
|
||||
else if(propertyName.equals("enabled")) menuItem.setEnabled(((Boolean)e.getNewValue()).booleanValue());
|
||||
if(propertyName.equals(Action.NAME)) {
|
||||
menuItem.setText((String)e.getNewValue());
|
||||
}
|
||||
else if(propertyName.equals("enabled")) {
|
||||
menuItem.setEnabled(((Boolean)e.getNewValue()).booleanValue());
|
||||
}
|
||||
else if(propertyName.equals(Action.SMALL_ICON)){
|
||||
Icon icon = (Icon)e.getNewValue();
|
||||
menuItem.setIcon(icon);
|
||||
menuItem.invalidate();
|
||||
menuItem.repaint();
|
||||
}
|
||||
else if(propertyName.equals(ExtAction.MNEMONIC)) menuItem.setMnemonic(((Character)e.getNewValue()).charValue());
|
||||
else if(propertyName.equals(ExtAction.TOOLTIP)) menuItem.setToolTipText((String)e.getNewValue());
|
||||
else if(propertyName.equals(ExtAction.KEYSTROKE)) menuItem.setAccelerator((KeyStroke)e.getNewValue());
|
||||
else if(propertyName.equals(ExtAction.MNEMONIC)) {
|
||||
menuItem.setMnemonic(((Character)e.getNewValue()).charValue());
|
||||
}
|
||||
else if(propertyName.equals(ExtAction.TOOLTIP)) {
|
||||
menuItem.setToolTipText((String)e.getNewValue());
|
||||
}
|
||||
else if(propertyName.equals(ExtAction.KEYSTROKE)) {
|
||||
menuItem.setAccelerator((KeyStroke)e.getNewValue());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ public class JExtToolBar extends JToolBar{
|
||||
|
||||
if(k != null){
|
||||
int modifiers = k.getModifiers();
|
||||
if(modifiers > 0) result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||
if(modifiers > 0) {
|
||||
result.append(KeyEvent.getKeyModifiersText(modifiers) + "+");
|
||||
}
|
||||
result.append(KeyEvent.getKeyText(k.getKeyCode()));
|
||||
}
|
||||
if(result.length() > 0){
|
||||
|
@ -104,12 +104,18 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
private JToolBar barEdit;
|
||||
@Override
|
||||
public JMenu getMenu(String group){
|
||||
if(GROUP_EDIT.equals(group)) return mnuEdit;
|
||||
else return null;
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
return mnuEdit;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public JToolBar getToolBar(String group){
|
||||
if(GROUP_EDIT.equals(group)) return barEdit;
|
||||
if(GROUP_EDIT.equals(group)) {
|
||||
return barEdit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -156,7 +162,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.cutAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCut.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Ausschneiden");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('a'));
|
||||
@ -166,7 +174,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.copyAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditCopy.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Kopieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('k'));
|
||||
@ -176,7 +186,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.pasteAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(Action.SMALL_ICON, new ImageIcon("images/EditPaste.gif"));
|
||||
a.putValue(ExtAction.CAPTION, "Einf<EFBFBD>gen");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('e'));
|
||||
@ -188,7 +200,9 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
|
||||
a = (Action)hashActions.get(DefaultEditorKit.selectAllAction);
|
||||
keyActions = keys.getKeyStrokesForAction(a);
|
||||
if(keyActions != null && keyActions.length > 0) a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
if(keyActions != null && keyActions.length > 0) {
|
||||
a.putValue(ExtAction.KEYSTROKE, keyActions[0]);
|
||||
}
|
||||
a.putValue(ExtAction.CAPTION, "Alles markieren");
|
||||
a.putValue(ExtAction.MNEMONIC, new Character('m'));
|
||||
a.putValue(ExtAction.TOOLTIP, "Markiert das ganze Dokument");
|
||||
@ -259,10 +273,12 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
}
|
||||
catch(IOException exc){}
|
||||
finally{
|
||||
if(in != null) try{
|
||||
in.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
if(in != null) {
|
||||
try{
|
||||
in.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,10 +295,12 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
}
|
||||
catch(IOException exc){}
|
||||
finally{
|
||||
if(out != null) try{
|
||||
out.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
if(out != null) {
|
||||
try{
|
||||
out.close();
|
||||
}
|
||||
catch(IOException exc){}
|
||||
}
|
||||
}
|
||||
|
||||
super.save(f);
|
||||
@ -292,6 +310,8 @@ public class JTextEditorInternalFrame extends JDocFrame{
|
||||
public void setSelected(boolean value) throws java.beans.PropertyVetoException{
|
||||
super.setSelected(value);
|
||||
|
||||
if(value) textArea.requestFocus();
|
||||
if(value) {
|
||||
textArea.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,13 +73,17 @@ public class MultiLineStringEditor implements PropertyEditor {
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) listeners = new PropertyChangeSupport(this);
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listeners == null) listeners = new PropertyChangeSupport(this);
|
||||
if (listeners == null) {
|
||||
listeners = new PropertyChangeSupport(this);
|
||||
}
|
||||
listeners.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ public class PropertyBoolSelector extends JCheckBox {
|
||||
public PropertyBoolSelector(PropertyEditor pe) {
|
||||
super();
|
||||
m_Editor = pe;
|
||||
if (m_Editor.getAsText().equals("True"))
|
||||
setSelected(true);
|
||||
else
|
||||
setSelected(false);
|
||||
if (m_Editor.getAsText().equals("True")) {
|
||||
setSelected(true);
|
||||
}
|
||||
else {
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
addItemListener(new ItemListener () {
|
||||
@Override
|
||||
|
@ -29,15 +29,21 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
* @param d
|
||||
*/
|
||||
public PropertyDoubleArray(int rows, int cols, double ... d) {
|
||||
if (rows>0 && cols>0) this.m_DoubleArray = new double[rows][cols];
|
||||
else this.m_DoubleArray=null;
|
||||
if (rows>0 && cols>0) {
|
||||
this.m_DoubleArray = new double[rows][cols];
|
||||
}
|
||||
else {
|
||||
this.m_DoubleArray=null;
|
||||
}
|
||||
this.m_numCols=cols;
|
||||
int index=0;
|
||||
for (int i=0; i<rows; i++) {
|
||||
for (int j=0; j<cols; j++) {
|
||||
m_DoubleArray[i][j]=d[index];
|
||||
index++;
|
||||
if (index>=d.length) index=0;
|
||||
if (index>=d.length) {
|
||||
index=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,8 +69,12 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
*/
|
||||
public void setDoubleArray(double[][] d) {
|
||||
this.m_DoubleArray = d;
|
||||
if (d.length>0) m_numCols=d[0].length;
|
||||
else m_numCols=1;
|
||||
if (d.length>0) {
|
||||
m_numCols=d[0].length;
|
||||
}
|
||||
else {
|
||||
m_numCols=1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,8 +119,12 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
double[][] newDD = new double[k][m_numCols];
|
||||
for (int i=0; i<k; i++) {
|
||||
for (int j=0; j<m_numCols; j++) {
|
||||
if (i<m_DoubleArray.length) newDD[i][j]=m_DoubleArray[i][j];
|
||||
else newDD[i][j]=m_DoubleArray[m_DoubleArray.length-1][j];
|
||||
if (i<m_DoubleArray.length) {
|
||||
newDD[i][j]=m_DoubleArray[i][j];
|
||||
}
|
||||
else {
|
||||
newDD[i][j]=m_DoubleArray[m_DoubleArray.length-1][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
setDoubleArray(newDD);
|
||||
@ -118,11 +132,15 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public void deleteRow(int k) {
|
||||
if (k<0 || k>=getNumRows()) throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row.");
|
||||
if (k<0 || k>=getNumRows()) {
|
||||
throw new IllegalArgumentException("Invalid index to deleteRow: " + k + " is not a valid row.");
|
||||
}
|
||||
double[][] newDD = new double[getNumRows()-1][getNumCols()];
|
||||
int inc=0;
|
||||
for (int i = 0; i < newDD.length; i++) {
|
||||
if (i==k) inc=1;
|
||||
if (i==k) {
|
||||
inc=1;
|
||||
}
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[i][j] = m_DoubleArray[i+inc][j];
|
||||
}
|
||||
@ -137,7 +155,9 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
* @param k
|
||||
*/
|
||||
public void addRowCopy(int k) {
|
||||
if (k<0 || k>= getNumRows()) k=getNumRows()-1;
|
||||
if (k<0 || k>= getNumRows()) {
|
||||
k=getNumRows()-1;
|
||||
}
|
||||
double[][] newDD = new double[getNumRows()+1][getNumCols()];
|
||||
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
@ -145,12 +165,14 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
newDD[i][j] = m_DoubleArray[i][j];
|
||||
}
|
||||
}
|
||||
if (k>=0) for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = newDD[k][j];
|
||||
}
|
||||
else for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = 1.;
|
||||
} // if the array was empty
|
||||
if (k>=0) {
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = newDD[k][j];
|
||||
} }
|
||||
else {
|
||||
for (int j=0; j<getNumCols(); j++) {
|
||||
newDD[newDD.length-1][j] = 1.;
|
||||
} } // if the array was empty
|
||||
setDoubleArray(newDD);
|
||||
}
|
||||
|
||||
@ -164,9 +186,10 @@ public class PropertyDoubleArray implements java.io.Serializable {
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
colSum += m_DoubleArray[i][j];
|
||||
}
|
||||
if (colSum!=0) for (int i = 0; i < getNumRows(); i++) {
|
||||
m_DoubleArray[i][j]/=colSum;
|
||||
}
|
||||
if (colSum!=0) {
|
||||
for (int i = 0; i < getNumRows(); i++) {
|
||||
m_DoubleArray[i][j]/=colSum;
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,20 @@ public class PropertyEditorProvider {
|
||||
|
||||
// if (TRACE) System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
||||
if ((editor == null) && useDefaultGOE ) {
|
||||
if (cls.isArray()) editor = new GenericArrayEditor();
|
||||
else if (cls.isEnum()) editor = new EnumEditor();
|
||||
else editor = new GenericObjectEditor();
|
||||
if (cls.isArray()) {
|
||||
editor = new GenericArrayEditor();
|
||||
}
|
||||
else if (cls.isEnum()) {
|
||||
editor = new EnumEditor();
|
||||
}
|
||||
else {
|
||||
editor = new GenericObjectEditor();
|
||||
}
|
||||
// if (TRACE) System.out.println("using GOE/GAE");
|
||||
}
|
||||
if (TRACE) System.out.println("# using "+ editor.getClass().getName() + " for " + cls.getName());
|
||||
if (TRACE) {
|
||||
System.out.println("# using "+ editor.getClass().getName() + " for " + cls.getName());
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
@ -89,47 +97,83 @@ public class PropertyEditorProvider {
|
||||
PropertyEditor editor = null;
|
||||
Class pec = prop.getPropertyEditorClass();
|
||||
Class type = prop.getPropertyType();
|
||||
if (TRACE) System.out.println("PropertyEditorProvider: Searching editor for " + value.getClass());
|
||||
if (TRACE) {
|
||||
System.out.println("PropertyEditorProvider: Searching editor for " + value.getClass());
|
||||
}
|
||||
try {
|
||||
if (pec != null) editor = (PropertyEditor)pec.newInstance();
|
||||
if (pec != null) {
|
||||
editor = (PropertyEditor)pec.newInstance();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
editor = null;
|
||||
}
|
||||
|
||||
if (editor == null) {
|
||||
if (TRACE) System.out.println("PropertySheetPanel.makeEditor(): No editor from PEC.");
|
||||
if (TRACE) {
|
||||
System.out.println("PropertySheetPanel.makeEditor(): No editor from PEC.");
|
||||
}
|
||||
|
||||
//@todo Streiche: Here i'm looking for a specialized editor
|
||||
//if (TRACE) System.out.println("PropertySheetPanel.setTarget(): trying to find specialised editor for "+value.getClass()+".");
|
||||
if (TRACE) System.out.println("A PropertySheetPanel.makeEditor(): checking " + value.getClass());
|
||||
if (value != null) editor = PropertyEditorManager.findEditor(value.getClass());
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
||||
if (TRACE) {
|
||||
System.out.println("A PropertySheetPanel.makeEditor(): checking " + value.getClass());
|
||||
}
|
||||
if (value != null) {
|
||||
editor = PropertyEditorManager.findEditor(value.getClass());
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println((editor == null ) ? "No editor from PEM" : ("Found " + editor.getClass()));
|
||||
}
|
||||
|
||||
if (editor == null && (BeanInspector.isJavaPrimitive(value.getClass()))) {
|
||||
Class<?> prim = BeanInspector.getBoxedType(value.getClass());
|
||||
if (TRACE) System.out.println("B1 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
if (prim!=null) editor = PropertyEditorManager.findEditor(prim);
|
||||
if (TRACE) {
|
||||
System.out.println("B1 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
}
|
||||
if (prim!=null) {
|
||||
editor = PropertyEditorManager.findEditor(prim);
|
||||
}
|
||||
if (editor ==null) {
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by boxed type " : ("Found " + editor.getClass()));
|
||||
if (TRACE) {
|
||||
System.out.println((editor == null ) ? "No editor from PEM by boxed type " : ("Found " + editor.getClass()));
|
||||
}
|
||||
|
||||
prim = BeanInspector.getUnboxedType(value.getClass());
|
||||
if (TRACE) System.out.println("B2 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
if (prim!=null) editor = PropertyEditorManager.findEditor(prim);
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by unboxed type " : ("Found " + editor.getClass()));
|
||||
if (TRACE) {
|
||||
System.out.println("B2 PropertySheetPanel.makeEditor(): checking " + prim);
|
||||
}
|
||||
if (prim!=null) {
|
||||
editor = PropertyEditorManager.findEditor(prim);
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println((editor == null ) ? "No editor from PEM by unboxed type " : ("Found " + editor.getClass()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (editor == null) {
|
||||
if (TRACE) System.out.println("C PropertySheetPanel.makeEditor(): checking " + type);
|
||||
if (TRACE) {
|
||||
System.out.println("C PropertySheetPanel.makeEditor(): checking " + type);
|
||||
}
|
||||
editor = PropertyEditorManager.findEditor(type);
|
||||
if (TRACE) System.out.println((editor == null ) ? "No editor from PEM by type" : ("Found " + editor.getClass()));
|
||||
if (TRACE) {
|
||||
System.out.println((editor == null ) ? "No editor from PEM by type" : ("Found " + editor.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
if ((editor == null) && useDefaultGOE ) {
|
||||
if (type.isArray()) editor = new GenericArrayEditor();
|
||||
else if (type.isEnum()) editor = new EnumEditor();
|
||||
else editor = new GenericObjectEditor();
|
||||
if (TRACE) System.out.println("using GOE/GAE");
|
||||
if (type.isArray()) {
|
||||
editor = new GenericArrayEditor();
|
||||
}
|
||||
else if (type.isEnum()) {
|
||||
editor = new EnumEditor();
|
||||
}
|
||||
else {
|
||||
editor = new GenericObjectEditor();
|
||||
}
|
||||
if (TRACE) {
|
||||
System.out.println("using GOE/GAE");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editor == null) {
|
||||
@ -145,7 +189,9 @@ public class PropertyEditorProvider {
|
||||
// ((GenericObjectEditor) editor).getCustomEditor();
|
||||
((GenericObjectEditor) editor).setClassType(type);
|
||||
}
|
||||
if (TRACE) System.out.println("+ using "+ editor.getClass().getName() + " for " + value.getClass().getName());
|
||||
if (TRACE) {
|
||||
System.out.println("+ using "+ editor.getClass().getName() + " for " + value.getClass().getName());
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,12 @@ public class PropertyFilePath implements java.io.Serializable {
|
||||
*/
|
||||
public static PropertyFilePath getFilePathFromResource(String relPath) {
|
||||
String fName = ReflectPackage.getResourcePathFromCP(relPath);
|
||||
if (fName == null) return null;
|
||||
else return new PropertyFilePath(fName);
|
||||
if (fName == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return new PropertyFilePath(fName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,16 +71,26 @@ public class PropertyFilePath implements java.io.Serializable {
|
||||
|
||||
String old = this.getCompleteFilePath();
|
||||
try {
|
||||
if (trace) System.out.println("Complete Filename: " +s);
|
||||
if (trace) {
|
||||
System.out.println("Complete Filename: " +s);
|
||||
}
|
||||
filesep = System.getProperty("file.separator");
|
||||
if (trace) System.out.println("File.Separator: " +filesep);
|
||||
if (trace) {
|
||||
System.out.println("File.Separator: " +filesep);
|
||||
}
|
||||
this.FileName = s.substring(s.lastIndexOf(filesep)+1);
|
||||
this.FileExtension = this.FileName.substring(this.FileName.lastIndexOf("."));
|
||||
this.FilePath = s.substring(0, s.lastIndexOf(filesep)+1);
|
||||
|
||||
if (trace) System.out.println("FilePath: " +this.FilePath);
|
||||
if (trace) System.out.println("Filename: " + this.FileName);
|
||||
if (trace) System.out.println("Fileext.: " + this.FileExtension);
|
||||
if (trace) {
|
||||
System.out.println("FilePath: " +this.FilePath);
|
||||
}
|
||||
if (trace) {
|
||||
System.out.println("Filename: " + this.FileName);
|
||||
}
|
||||
if (trace) {
|
||||
System.out.println("Fileext.: " + this.FileExtension);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.setCompleteFilePath(old);
|
||||
}
|
||||
|
@ -58,7 +58,9 @@ public class PropertyOptimizationObjectives implements java.io.Serializable {
|
||||
* @param index The index of the target to be removed.
|
||||
*/
|
||||
public void removeTarget(int index) {
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) return;
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
||||
int j = 0;
|
||||
|
@ -59,7 +59,9 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.length == this.m_Weights.length) return;
|
||||
if (d.length == this.m_Weights.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.length > this.m_Weights.length) {
|
||||
double[] newWeights = new double[d.length];
|
||||
@ -134,7 +136,9 @@ public class PropertyOptimizationObjectivesWithParam implements java.io.Serializ
|
||||
* @param index The index of the target to be removed.
|
||||
*/
|
||||
public void removeTarget(int index) {
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) return;
|
||||
if ((index < 0) || (index >= this.m_SelectedObjectives.length)) {
|
||||
return;
|
||||
}
|
||||
|
||||
InterfaceOptimizationObjective[] newList = new InterfaceOptimizationObjective[this.m_SelectedObjectives.length-1];
|
||||
double[] newWeights = new double[this.m_Weights.length - 1];
|
||||
|
@ -73,7 +73,9 @@ public class PropertyRemoteServers implements java.io.Serializable {
|
||||
// first check for double instances
|
||||
for (int i = 0; i < this.m_AvailableNodes.length; i++) {
|
||||
if (this.m_AvailableNodes[i].m_ServerName.equalsIgnoreCase(name)) {
|
||||
if (cpus > this.m_AvailableNodes[i].m_CPUs) this.m_AvailableNodes[i].m_CPUs = cpus;
|
||||
if (cpus > this.m_AvailableNodes[i].m_CPUs) {
|
||||
this.m_AvailableNodes[i].m_CPUs = cpus;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -165,8 +167,12 @@ public class PropertyRemoteServers implements java.io.Serializable {
|
||||
public boolean isServerOnline(String name) {
|
||||
try {
|
||||
String[] list = Naming.list("rmi://" + name + ":" + 1099);
|
||||
if (list == null) return false;
|
||||
else return true;
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception et) {
|
||||
return false;
|
||||
}
|
||||
@ -231,10 +237,12 @@ public class PropertyRemoteServers implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public ServerNode get(int i) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length))
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
return this.m_AvailableNodes[i];
|
||||
else
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String writeToText() {
|
||||
@ -246,11 +254,15 @@ public class PropertyRemoteServers implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public void setNameFor(int i, String name) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) this.m_AvailableNodes[i].m_ServerName = name;
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
this.m_AvailableNodes[i].m_ServerName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCPUsFor(int i, int c) {
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) this.m_AvailableNodes[i].m_CPUs = c;
|
||||
if ((i >= 0) && (i < this.m_AvailableNodes.length)) {
|
||||
this.m_AvailableNodes[i].m_CPUs = c;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromText(String text) {
|
||||
|
@ -48,7 +48,9 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
public void setObjects(T[] o, boolean[] selection) {
|
||||
this.m_Objects = o;
|
||||
this.m_Selection = selection;
|
||||
if (o.length != selection.length) throw new RuntimeException("Error, mismatching length of arrays in " + this.getClass());
|
||||
if (o.length != selection.length) {
|
||||
throw new RuntimeException("Error, mismatching length of arrays in " + this.getClass());
|
||||
}
|
||||
m_Support.firePropertyChange("PropertySelectableList", null, this);
|
||||
}
|
||||
|
||||
@ -63,7 +65,9 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
public T[] getSelectedObjects() {
|
||||
T[] selObjects = getObjects().clone();
|
||||
for (int i=0; i<selObjects.length; i++) {
|
||||
if (!m_Selection[i]) selObjects[i]=null;
|
||||
if (!m_Selection[i]) {
|
||||
selObjects[i]=null;
|
||||
}
|
||||
}
|
||||
return selObjects;
|
||||
}
|
||||
@ -98,8 +102,12 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public int size() {
|
||||
if (m_Objects == null) return 0;
|
||||
else return m_Objects.length;
|
||||
if (m_Objects == null) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return m_Objects.length;
|
||||
}
|
||||
}
|
||||
|
||||
public T get(int i) {
|
||||
@ -138,12 +146,16 @@ public class PropertySelectableList<T> implements java.io.Serializable {
|
||||
// }
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support == null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,9 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||
strs = (StringSelection) o;
|
||||
// m_AreaObject.addPropertyChangeListener(this);
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +64,9 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
|
||||
boolean first = true;
|
||||
for (int i=0; i<getElementCount(); i++) {
|
||||
if (isElementSelected(i)) {
|
||||
if (!first) sbuf.append(", ");
|
||||
if (!first) {
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(getElementName(i));
|
||||
first=false;
|
||||
}
|
||||
|
@ -53,10 +53,12 @@ public class TopoPlot extends Plot {
|
||||
* @param color_scale the topologies color coding. Values (0-3) are valid. @See ColorBarCalculator.
|
||||
*/
|
||||
public void setParams(int gridX, int gridY, int color_scale) {
|
||||
if (gridX>m_Frame.getWidth())
|
||||
gridX = m_Frame.getWidth();
|
||||
if (gridY>m_Frame.getHeight())
|
||||
gridY = m_Frame.getHeight();
|
||||
if (gridX>m_Frame.getWidth()) {
|
||||
gridX = m_Frame.getWidth();
|
||||
}
|
||||
if (gridY>m_Frame.getHeight()) {
|
||||
gridY = m_Frame.getHeight();
|
||||
}
|
||||
gridx = gridX;
|
||||
gridy = gridY;
|
||||
colorScale = color_scale;
|
||||
@ -114,9 +116,15 @@ public class TopoPlot extends Plot {
|
||||
pos[0] = border[0][0]+x*deltaX;
|
||||
pos[1] = border[1][0]+y*deltaY;
|
||||
tmp = (float)(problem.functionValue(pos));
|
||||
if (TRACEMETH) System.out.println(pos[0] + " " + pos[1] + " " + tmp);
|
||||
if (tmp < min) min = tmp;
|
||||
if (tmp > max) max = tmp;
|
||||
if (TRACEMETH) {
|
||||
System.out.println(pos[0] + " " + pos[1] + " " + tmp);
|
||||
}
|
||||
if (tmp < min) {
|
||||
min = tmp;
|
||||
}
|
||||
if (tmp > max) {
|
||||
max = tmp;
|
||||
}
|
||||
if (withGradientsIfAvailable && (problem instanceof InterfaceFirstOrderDerivableProblem)) {
|
||||
double[] deriv = ((InterfaceFirstOrderDerivableProblem)problem).getFirstOrderGradients(problem.project2DPoint(pos));
|
||||
for (int i=0; i<2;i++) {
|
||||
|
@ -166,7 +166,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
} catch(java.lang.ClassNotFoundException e) {
|
||||
System.out.println("No Class found for " + tmp);
|
||||
}
|
||||
if ((object != null) && (editor != null)) paraPanel.registerEditor(object, editor);
|
||||
if ((object != null) && (editor != null)) {
|
||||
paraPanel.registerEditor(object, editor);
|
||||
}
|
||||
this.m_O1 = (paraPanel.makePanel());
|
||||
// TODO this is defunct anyways... (MK, 2010-03)
|
||||
// EvAClient.setProperty("eva2.server.oa.go.Tools.InterfaceTest", "eva2.server.oa.go.Tools.Test1,eva2.server.oa.go.Tools.Test2");
|
||||
@ -367,7 +369,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
public Object doWork() {
|
||||
try {
|
||||
this.m_GO.saveInstance();
|
||||
if (this.show) this.m_StatusField.setText("Optimizing...");
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Optimizing...");
|
||||
}
|
||||
|
||||
RNG.setRandomSeed(m_GO.getSeed());
|
||||
// opening output file...
|
||||
@ -403,10 +407,12 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
this.m_GO.getProblem().initProblem(); // in the loop as well, dynamic probs may need that (MK)
|
||||
this.m_TmpData = new ArrayList();
|
||||
this.currentRun = j;
|
||||
if (this.show)
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Optimizing Run " + (j+1) + " of " + this.m_MultiRuns + " Multi Runs...");
|
||||
if (Thread.interrupted())
|
||||
}
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
// write header to file
|
||||
this.writeToFile(" FitnessCalls\t Best\t Mean\t Worst \t" + BeanInspector.toString(this.m_GO.getProblem().getAdditionalDataHeader(), '\t', false, ""));
|
||||
if ((this.m_ContinueFlag) && (this.m_Backup != null)) {
|
||||
@ -426,7 +432,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
//while (this.m_GO.getOptimizer().getPopulation().getFunctionCalls() < this.m_FunctionCalls) {
|
||||
while (!this.m_GO.getTerminator().isTerminated(this.m_GO.getOptimizer().getPopulation())) {
|
||||
//System.out.println("Simulated Function calls "+ this.m_Optimizer.getPopulation().getFunctionCalls());
|
||||
if (Thread.interrupted()) throw new InterruptedException();
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
m_GO.getOptimizer().optimize();
|
||||
}
|
||||
System.gc();
|
||||
@ -434,13 +442,19 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
//this.writeToFile(this.m_GO.getProblem().getStringRepresentationForProblem(this.m_GO.getOptimizer()));
|
||||
tmpMultiRun.add(this.m_TmpData);
|
||||
}
|
||||
if (this.show) this.m_Plot.setInfoString(this.currentExperiment, this.m_ExperimentName, 0.5f);
|
||||
if (this.show) this.draw();
|
||||
if (this.show) {
|
||||
this.m_Plot.setInfoString(this.currentExperiment, this.m_ExperimentName, 0.5f);
|
||||
}
|
||||
if (this.show) {
|
||||
this.draw();
|
||||
}
|
||||
this.m_ExperimentName = this.m_GO.getOptimizer().getName()+"-"+this.m_PerformedRuns.size();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
updateStatus(0);
|
||||
if (this.show) this.m_StatusField.setText("Interrupted...");
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Interrupted...");
|
||||
}
|
||||
return "Interrupted";
|
||||
}
|
||||
if (this.m_OutputFile != null) {
|
||||
@ -450,11 +464,14 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
System.out.println("Failed to close output file!");
|
||||
}
|
||||
}
|
||||
if (this.show) for (int i = 0; i < this.m_MultiRuns; i++) {
|
||||
this.m_Plot.clearGraph(1000 +i);
|
||||
}
|
||||
if (this.show) {
|
||||
for (int i = 0; i < this.m_MultiRuns; i++) {
|
||||
this.m_Plot.clearGraph(1000 +i);
|
||||
} }
|
||||
updateStatus(0);
|
||||
if (this.show) this.m_StatusField.setText("Finished...");
|
||||
if (this.show) {
|
||||
this.m_StatusField.setText("Finished...");
|
||||
}
|
||||
return "All Done";
|
||||
}
|
||||
|
||||
@ -506,8 +523,12 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// if (this.m_GO.getOptimizer().getName().equalsIgnoreCase("CBN-EA")) tmpColor = Color.black;
|
||||
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
if (this.m_ContinueFlag) this.m_Plot.setConnectedPoint(data[j][0]+this.m_RecentFC, data[j][1], this.currentExperiment);
|
||||
else this.m_Plot.setConnectedPoint(data[j][0], data[j][1], this.currentExperiment);
|
||||
if (this.m_ContinueFlag) {
|
||||
this.m_Plot.setConnectedPoint(data[j][0]+this.m_RecentFC, data[j][1], this.currentExperiment);
|
||||
}
|
||||
else {
|
||||
this.m_Plot.setConnectedPoint(data[j][0], data[j][1], this.currentExperiment);
|
||||
}
|
||||
}
|
||||
this.currentExperiment++;
|
||||
}
|
||||
@ -593,8 +614,12 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
// instead of adding simply the best fitness value i'll ask the problem what to show
|
||||
tmpData[1] = this.m_GO.getProblem().getDoublePlotValue(population);
|
||||
if (this.m_Plot != null) {
|
||||
if (this.m_ContinueFlag) this.m_Plot.setConnectedPoint(tmpData[0].doubleValue()+this.m_RecentFC, tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
else this.m_Plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
if (this.m_ContinueFlag) {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue()+this.m_RecentFC, tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
}
|
||||
else {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000+this.currentRun);
|
||||
}
|
||||
}
|
||||
this.m_TmpData.add(tmpData);
|
||||
}
|
||||
@ -605,7 +630,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu
|
||||
*/
|
||||
private void writeToFile(String line) {
|
||||
String write = line + "\n";
|
||||
if (this.m_OutputFile == null) return;
|
||||
if (this.m_OutputFile == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.m_OutputFile.write(write, 0, write.length());
|
||||
this.m_OutputFile.flush();
|
||||
|
@ -212,15 +212,27 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
private void checkForObjectives(String w) {
|
||||
System.out.println("I'm currently "+w);
|
||||
System.out.print("Original Problem is ");
|
||||
if (this.m_State.m_OriginalProblem.isMultiObjective()) System.out.println("multi-objective.");
|
||||
else System.out.println("single-objective.");
|
||||
if (this.m_State.m_OriginalProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
System.out.print("Current Problem is ");
|
||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) System.out.println("multi-objective.");
|
||||
else System.out.println("single-objective.");
|
||||
if (this.m_State.m_CurrentProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
if (this.m_State.m_BackupProblem != null) {
|
||||
System.out.print("Backup Problem is ");
|
||||
if (this.m_State.m_BackupProblem.isMultiObjective()) System.out.println("multi-objective.");
|
||||
else System.out.println("single-objective.");
|
||||
if (this.m_State.m_BackupProblem.isMultiObjective()) {
|
||||
System.out.println("multi-objective.");
|
||||
}
|
||||
else {
|
||||
System.out.println("single-objective.");
|
||||
}
|
||||
} else {
|
||||
System.out.println("No Backup Problem");
|
||||
}
|
||||
@ -235,7 +247,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
s = "Objectives: {";
|
||||
for (int i = 0; i < obj.length; i++) {
|
||||
s += obj[i].getIdentName();
|
||||
if (i < (obj.length-1)) s += "; ";
|
||||
if (i < (obj.length-1)) {
|
||||
s += "; ";
|
||||
}
|
||||
}
|
||||
s += "}";
|
||||
System.out.println(""+s);
|
||||
@ -244,7 +258,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
s = "Weights : {";
|
||||
for (int i = 0; i < prop.getNumRows(); i++) {
|
||||
s += prop.getValue(i,0);
|
||||
if (i < (prop.getNumRows()-1)) s += "; ";
|
||||
if (i < (prop.getNumRows()-1)) {
|
||||
s += "; ";
|
||||
}
|
||||
}
|
||||
s += "}";
|
||||
System.out.println(""+s);
|
||||
@ -328,10 +344,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
throw new Exception("Object not of type MOCCOState");
|
||||
} return obj;
|
||||
} catch (Exception ex) {
|
||||
if (this.m_JFrame != null)
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||
else
|
||||
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
||||
if (this.m_JFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't read object: " + selected.getName() + "\n" + ex.getMessage(), "Open object file", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
else {
|
||||
System.out.println("Couldn't read object: " + selected.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -346,10 +364,12 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
oo.writeObject(this.m_State);
|
||||
oo.close();
|
||||
} catch (Exception ex) {
|
||||
if (this.m_JFrame != null)
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||
else
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
if (this.m_JFrame != null) {
|
||||
JOptionPane.showMessageDialog(this.m_JFrame, "Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage(), "Save object", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
else {
|
||||
System.out.println("Couldn't write to file: " + sFile.getName() + "\n" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,10 +385,14 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
}
|
||||
this.m_StillWorking = true;
|
||||
this.m_State.m_Optimizer.setProblem(this.m_State.m_CurrentProblem);
|
||||
if (this.m_Debug) System.out.println(""+this.m_State.m_Optimizer.getStringRepresentation());
|
||||
if (this.m_Debug) {
|
||||
System.out.println(""+this.m_State.m_Optimizer.getStringRepresentation());
|
||||
}
|
||||
this.m_State.m_CurrentProblem.evaluate(this.m_State.m_Optimizer.getPopulation());
|
||||
this.m_State.m_Optimizer.getPopulation().SetFunctionCalls(0);
|
||||
if (this.m_State.m_Optimizer.getPopulation().size() == 0) this.m_State.m_Optimizer.init();
|
||||
if (this.m_State.m_Optimizer.getPopulation().size() == 0) {
|
||||
this.m_State.m_Optimizer.init();
|
||||
}
|
||||
this.m_State.m_Optimizer.addPopulationChangedEventListener(this);
|
||||
worker = new SwingWorker() {
|
||||
@Override
|
||||
@ -394,7 +418,9 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
m_State.addPopulation2History(pop[i]);
|
||||
}
|
||||
}
|
||||
if (m_View != null) m_View.problemChanged(true);
|
||||
if (m_View != null) {
|
||||
m_View.problemChanged(true);
|
||||
}
|
||||
m_StillWorking = false;
|
||||
}
|
||||
};
|
||||
@ -427,9 +453,13 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati
|
||||
*/
|
||||
Object doWork() {
|
||||
try {
|
||||
if (Thread.interrupted()) throw new InterruptedException();
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
while (!this.m_State.m_Terminator.isTerminated(this.m_State.m_Optimizer.getPopulation())) {
|
||||
if (Thread.interrupted()) throw new InterruptedException();
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
this.m_State.m_Optimizer.optimize();
|
||||
}
|
||||
System.gc();
|
||||
|
@ -76,7 +76,9 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
if (other instanceof AbstractEAIndividualComparator) {
|
||||
AbstractEAIndividualComparator o = (AbstractEAIndividualComparator)other;
|
||||
if ((indyDataKey==o.indyDataKey) || (indyDataKey!=null && (indyDataKey.equals(o.indyDataKey)))) {
|
||||
if ((fitCriterion == o.fitCriterion) && (preferFeasible == o.preferFeasible)) return true;
|
||||
if ((fitCriterion == o.fitCriterion) && (preferFeasible == o.preferFeasible)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -127,32 +129,48 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
|
||||
if (preferFeasible) { // check constraint violation first?
|
||||
int constrViolComp = ((AbstractEAIndividual) o1).compareConstraintViolation((AbstractEAIndividual) o2);
|
||||
if (constrViolComp>0) return -1;
|
||||
else if (constrViolComp < 0) return 1;
|
||||
if (constrViolComp>0) {
|
||||
return -1;
|
||||
}
|
||||
else if (constrViolComp < 0) {
|
||||
return 1;
|
||||
}
|
||||
// otherwise both do not violate, so regard fitness
|
||||
}
|
||||
if (indyDataKey != null && (indyDataKey.length()>0)) { // check specific key
|
||||
double[] fit1 = (double[])((AbstractEAIndividual)o1).getData(indyDataKey);
|
||||
double[] fit2 = (double[])((AbstractEAIndividual)o2).getData(indyDataKey);
|
||||
if ((fit1==null) || (fit2==null)) throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals ("+this.getClass().getSimpleName()+")");
|
||||
if ((fit1==null) || (fit2==null)) {
|
||||
throw new RuntimeException("Unknown individual data key " + indyDataKey + ", unable to compare individuals ("+this.getClass().getSimpleName()+")");
|
||||
}
|
||||
if (fitCriterion < 0) {
|
||||
o1domO2 = AbstractEAIndividual.isDominatingFitness(fit1, fit2);
|
||||
o2domO1 = AbstractEAIndividual.isDominatingFitness(fit2, fit1);
|
||||
} else {
|
||||
if (fit1[fitCriterion] == fit2[fitCriterion]) return 0;
|
||||
else return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1;
|
||||
if (fit1[fitCriterion] == fit2[fitCriterion]) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return (fit1[fitCriterion] < fit2[fitCriterion]) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (fitCriterion < 0) {
|
||||
o1domO2 = ((AbstractEAIndividual) o1).isDominating((AbstractEAIndividual) o2);
|
||||
o2domO1 = ((AbstractEAIndividual) o2).isDominating((AbstractEAIndividual) o1);
|
||||
} else {
|
||||
if (((AbstractEAIndividual) o1).getFitness()[fitCriterion] == ((AbstractEAIndividual) o2).getFitness()[fitCriterion]) return 0;
|
||||
if (((AbstractEAIndividual) o1).getFitness()[fitCriterion] == ((AbstractEAIndividual) o2).getFitness()[fitCriterion]) {
|
||||
return 0;
|
||||
}
|
||||
return (((AbstractEAIndividual) o1).getFitness()[fitCriterion] < ((AbstractEAIndividual) o2).getFitness()[fitCriterion]) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (o1domO2 ^ o2domO1) return (o1domO2 ? -1 : 1); // they are comparable
|
||||
else return 0; // they are not comparable
|
||||
if (o1domO2 ^ o2domO1) {
|
||||
return (o1domO2 ? -1 : 1);
|
||||
} // they are comparable
|
||||
else {
|
||||
return 0;
|
||||
} // they are not comparable
|
||||
}
|
||||
|
||||
public String getIndyDataKey() {
|
||||
|
@ -36,8 +36,9 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
}
|
||||
|
||||
public ESIndividualBinaryData(ESIndividualBinaryData individual) {
|
||||
if (individual.m_Phenotype != null)
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = (BitSet) individual.m_Phenotype.clone();
|
||||
}
|
||||
this.m_Genotype = new double[individual.m_Genotype.length];
|
||||
this.m_Range = new double[individual.m_Genotype.length][2];
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
@ -77,12 +78,22 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof ESIndividualBinaryData) {
|
||||
ESIndividualBinaryData indy = (ESIndividualBinaryData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -166,11 +177,19 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
this.SetBinaryPhenotype(binaryData);
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_UseHardSwitch) {
|
||||
if (binaryData.get(i)) this.m_Genotype[i] = RNG.randomDouble(0.55,1.0);
|
||||
else this.m_Genotype[i] = RNG.randomDouble(0.0,0.45);
|
||||
if (binaryData.get(i)) {
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.55,1.0);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype[i] = RNG.randomDouble(0.0,0.45);
|
||||
}
|
||||
} else {
|
||||
if (binaryData.get(i)) this.m_Genotype[i] = 0.9;
|
||||
else this.m_Genotype[i] = 0.1;
|
||||
if (binaryData.get(i)) {
|
||||
this.m_Genotype[i] = 0.9;
|
||||
}
|
||||
else {
|
||||
this.m_Genotype[i] = 0.1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,8 +259,12 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public void SetDGenotype(double[] b) {
|
||||
this.m_Genotype = b;
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) this.m_Genotype[i] = this.m_Range[1][0];
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) this.m_Genotype[i] = this.m_Range[1][1];
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Genotype[i] = this.m_Range[1][0];
|
||||
}
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Genotype[i] = this.m_Range[1][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,8 +294,12 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
}
|
||||
else {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
|
@ -79,14 +79,28 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof ESIndividualDoubleData) {
|
||||
ESIndividualDoubleData indy = (ESIndividualDoubleData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) return false;
|
||||
if (this.m_Genotype.length != indy.m_Genotype.length) return false;
|
||||
if (this.m_Range.length != indy.m_Range.length) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Genotype.length != indy.m_Genotype.length) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range.length != indy.m_Range.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -172,7 +186,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public double[] getDoubleData() {
|
||||
// since the phenotype is set to null if the genotype is changed,
|
||||
// it should now be save to only perform the copy if the phenotype is null
|
||||
if (this.m_Phenotype!=null) return m_Phenotype;
|
||||
if (this.m_Phenotype!=null) {
|
||||
return m_Phenotype;
|
||||
}
|
||||
else {
|
||||
this.m_Phenotype = new double[this.m_Genotype.length];
|
||||
System.arraycopy(this.m_Genotype, 0, this.m_Phenotype, 0, this.m_Genotype.length);
|
||||
@ -187,8 +203,12 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
*/
|
||||
@Override
|
||||
public double[] getDoubleDataWithoutUpdate() {
|
||||
if (m_Phenotype==null) return getDoubleData();
|
||||
else return this.m_Phenotype;
|
||||
if (m_Phenotype==null) {
|
||||
return getDoubleData();
|
||||
}
|
||||
else {
|
||||
return this.m_Phenotype;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows you to set the phenotype double data. To change the genotype,
|
||||
@ -222,7 +242,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public void init(InterfaceOptimizationProblem opt) {
|
||||
super.init(opt);
|
||||
// evil operators may not respect the range, so at least give some hint
|
||||
if (!Mathematics.isInRange(m_Genotype, m_Range)) EVAERROR.errorMsgOnce("Warning: Individual out of range after initialization (and potential initial crossover/mutation)!");
|
||||
if (!Mathematics.isInRange(m_Genotype, m_Range)) {
|
||||
EVAERROR.errorMsgOnce("Warning: Individual out of range after initialization (and potential initial crossover/mutation)!");
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will init the individual with a given value for the
|
||||
@ -234,7 +256,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof double[]) {
|
||||
double[] bs = (double[]) obj;
|
||||
if (bs.length != this.m_Genotype.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Genotype.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetDoubleGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -290,8 +314,12 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
this.m_Genotype = b;
|
||||
this.m_Phenotype=null; // mark it as invalid
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) this.m_Genotype[i] = this.m_Range[i][0];
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) this.m_Genotype[i] = this.m_Range[i][1];
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][0];
|
||||
}
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,14 +350,22 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public static void defaultMutate(double[] genotype, double[][] range) {
|
||||
int mutationIndex = RNG.randomInt(0, genotype.length-1);
|
||||
genotype[mutationIndex] += ((range[mutationIndex][1] - range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f);
|
||||
if (genotype[mutationIndex] < range[mutationIndex][0]) genotype[mutationIndex] = range[mutationIndex][0];
|
||||
if (genotype[mutationIndex] > range[mutationIndex][1]) genotype[mutationIndex] = range[mutationIndex][1];
|
||||
if (genotype[mutationIndex] < range[mutationIndex][0]) {
|
||||
genotype[mutationIndex] = range[mutationIndex][0];
|
||||
}
|
||||
if (genotype[mutationIndex] > range[mutationIndex][1]) {
|
||||
genotype[mutationIndex] = range[mutationIndex][1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
|
||||
}
|
||||
else {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
|
||||
}
|
||||
m_Phenotype = null; // mark as invalid
|
||||
}
|
||||
|
||||
|
@ -74,12 +74,22 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof ESIndividualIntegerData) {
|
||||
ESIndividualIntegerData indy = (ESIndividualIntegerData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -156,8 +166,12 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
this.m_Phenotype = new int[this.m_Genotype.length];
|
||||
for (int i = 0; i < this.m_Phenotype.length; i++) {
|
||||
this.m_Phenotype[i] = (int) this.m_Genotype[i];
|
||||
if (this.m_Phenotype[i] < this.m_Range[i][0]) this.m_Phenotype[i] = this.m_Range[i][0];
|
||||
if (this.m_Phenotype[i] > this.m_Range[i][1]) this.m_Phenotype[i] = this.m_Range[i][1];
|
||||
if (this.m_Phenotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Phenotype[i] = this.m_Range[i][0];
|
||||
}
|
||||
if (this.m_Phenotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Phenotype[i] = this.m_Range[i][1];
|
||||
}
|
||||
}
|
||||
return this.m_Phenotype;
|
||||
}
|
||||
@ -204,7 +218,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[]) {
|
||||
int[] bs = (int[]) obj;
|
||||
if (bs.length != this.m_Genotype.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Genotype.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -257,8 +273,12 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void SetDGenotype(double[] b) {
|
||||
this.m_Genotype = b;
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) this.m_Genotype[i] = this.m_Range[i][0];
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) this.m_Genotype[i] = this.m_Range[i][1];
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][0];
|
||||
}
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +288,12 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_Genotype.length-1);
|
||||
this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0])/2)*RNG.gaussianDouble(0.05f);
|
||||
if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0];
|
||||
if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1];
|
||||
if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) {
|
||||
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0];
|
||||
}
|
||||
if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) {
|
||||
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1];
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return the range for all double attributes.
|
||||
@ -288,7 +312,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
int[][] range = m_Range;
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
range = (int[][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
|
||||
}
|
||||
|
@ -92,13 +92,25 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof ESIndividualPermutationData) {
|
||||
ESIndividualPermutationData indy = (ESIndividualPermutationData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) return false;
|
||||
if (this.m_Range.length != indy.m_Range.length) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range.length != indy.m_Range.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -163,8 +175,12 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
int smallest = Integer.MAX_VALUE;
|
||||
this.m_Range[p] = new double[perm[p].length][2];
|
||||
for (int i = 0; i < perm[p].length; i++) {
|
||||
if (perm[p][i] > biggest) biggest = perm[p][i];
|
||||
if (perm[p][i] < smallest) smallest = perm[p][i];
|
||||
if (perm[p][i] > biggest) {
|
||||
biggest = perm[p][i];
|
||||
}
|
||||
if (perm[p][i] < smallest) {
|
||||
smallest = perm[p][i];
|
||||
}
|
||||
this.m_Range[p][i][0] = 0;
|
||||
this.m_Range[p][i][1] = 1;
|
||||
}
|
||||
@ -196,7 +212,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
||||
for (int j = 0; j < this.m_Genotype[p].length; j++) {
|
||||
if (this.m_Genotype[p][i] > this.m_Genotype[p][j]) this.m_Phenotype[p][i]++;
|
||||
if (this.m_Genotype[p][i] > this.m_Genotype[p][j]) {
|
||||
this.m_Phenotype[p][i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,7 +251,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[][]) {
|
||||
int[][] bs = (int[][]) obj;
|
||||
if (bs.length != this.m_Genotype.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Genotype.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetPermutationGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -318,8 +338,12 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation());
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||
if (this.m_Genotype[i][j] < this.m_Range[i][j][0]) this.m_Genotype[i][j] = this.m_Range[i][j][0];
|
||||
if (this.m_Genotype[i][j] > this.m_Range[i][j][1]) this.m_Genotype[i][j] = this.m_Range[i][j][1];
|
||||
if (this.m_Genotype[i][j] < this.m_Range[i][j][0]) {
|
||||
this.m_Genotype[i][j] = this.m_Range[i][j][0];
|
||||
}
|
||||
if (this.m_Genotype[i][j] > this.m_Range[i][j][1]) {
|
||||
this.m_Genotype[i][j] = this.m_Range[i][j][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +362,9 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
double[][][] range = m_Range;
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (double[][][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) {
|
||||
range = (double[][][])((InterfaceHasInitRange)prob).getInitRange();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
ESIndividualDoubleData.defaultInit(m_Genotype[i], range[i]);
|
||||
|
@ -60,8 +60,12 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GAESIndividualBinaryDoubleData) {
|
||||
GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData)individual;
|
||||
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_BitSet).equalGenotypes((AbstractEAIndividual)indy.m_BitSet)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) {
|
||||
return false;
|
||||
}
|
||||
if (!((AbstractEAIndividual)this.m_BitSet).equalGenotypes((AbstractEAIndividual)indy.m_BitSet)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -109,8 +113,12 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
*/
|
||||
@Override
|
||||
public void mutate() {
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_BitSet).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Numbers).mutate();
|
||||
}
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_BitSet).mutate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,11 +37,13 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
}
|
||||
|
||||
public GAIndividualBinaryData(GAIndividualBinaryData individual) {
|
||||
if (individual.m_Phenotype != null)
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = (BitSet) individual.m_Phenotype.clone();
|
||||
}
|
||||
this.m_GenotypeLength = individual.m_GenotypeLength;
|
||||
if (individual.m_Genotype != null)
|
||||
if (individual.m_Genotype != null) {
|
||||
this.m_Genotype = (BitSet)individual.m_Genotype.clone();
|
||||
}
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
this.m_Age = individual.m_Age;
|
||||
@ -73,9 +75,15 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GAIndividualBinaryData) {
|
||||
GAIndividualBinaryData indy = (GAIndividualBinaryData) individual;
|
||||
if (this.m_GenotypeLength != indy.m_GenotypeLength) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) return false;
|
||||
if (this.m_GenotypeLength != indy.m_GenotypeLength) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -89,7 +97,9 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public double defaultEvaulateAsMiniBits() {
|
||||
double result = 0;
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (this.m_Genotype.get(i)) result++;
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -146,9 +156,15 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
result += "})\n Value: ";
|
||||
result += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (i%8==0) result+="|";
|
||||
if (this.m_Genotype.get(i)) result += "1";
|
||||
else result += "0";
|
||||
if (i%8==0) {
|
||||
result+="|";
|
||||
}
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}";
|
||||
result += "\n Mutation ("+this.m_MutationProbability+"):" + this.m_MutationOperator.getStringRepresentation();
|
||||
@ -187,8 +203,12 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) this.m_Genotype.set(i);
|
||||
else this.m_Genotype.clear(i);
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,8 +218,12 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength);
|
||||
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
|
||||
if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex);
|
||||
else this.m_Genotype.set(mutationIndex);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
|
||||
}
|
||||
|
||||
|
@ -86,12 +86,22 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
if (individual instanceof GAIndividualDoubleData) {
|
||||
GAIndividualDoubleData indy = (GAIndividualDoubleData) individual;
|
||||
//@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen
|
||||
if (this.m_GenotypeLength != indy.m_GenotypeLength) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) return false;
|
||||
if (this.m_GenotypeLength != indy.m_GenotypeLength) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -227,7 +237,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof double[]) {
|
||||
double[] bs = (double[]) obj;
|
||||
if (bs.length != this.m_Range.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Range.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetDoubleGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -262,8 +274,12 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
result += "]\n";
|
||||
result += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (this.m_Genotype.get(i)) result += "1";
|
||||
else result += "0";
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}";
|
||||
return result;
|
||||
@ -303,8 +319,12 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) this.m_Genotype.set(i);
|
||||
else this.m_Genotype.clear(i);
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,8 +333,12 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
@Override
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex);
|
||||
else this.m_Genotype.set(mutationIndex);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
|
@ -86,12 +86,22 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
if (individual instanceof GAIndividualIntegerData) {
|
||||
GAIndividualIntegerData indy = (GAIndividualIntegerData) individual;
|
||||
//@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) return false;
|
||||
if (this.m_Range.length != indy.m_Range.length) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range.length != indy.m_Range.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -253,7 +263,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[]) {
|
||||
int[] bs = (int[]) obj;
|
||||
if (bs.length != this.m_Range.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Range.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -302,8 +314,12 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
}
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (this.m_Genotype.get(i)) result += "1";
|
||||
else result += "0";
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}";
|
||||
return result;
|
||||
@ -351,8 +367,12 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
}
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) this.m_Genotype.set(i);
|
||||
else this.m_Genotype.clear(i);
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,8 +385,12 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
}
|
||||
int mutationIndex = RNG.randomInt(0, overallLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex);
|
||||
else this.m_Genotype.set(mutationIndex);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -60,8 +60,12 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GAPIndividualProgramData) {
|
||||
GAPIndividualProgramData indy = (GAPIndividualProgramData)individual;
|
||||
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_Program).equalGenotypes((AbstractEAIndividual)indy.m_Program)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_Numbers).equalGenotypes((AbstractEAIndividual)indy.m_Numbers)) {
|
||||
return false;
|
||||
}
|
||||
if (!((AbstractEAIndividual)this.m_Program).equalGenotypes((AbstractEAIndividual)indy.m_Program)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -109,8 +113,12 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
|
||||
*/
|
||||
@Override
|
||||
public void mutate() {
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Numbers).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Program).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Numbers).mutate();
|
||||
}
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Program).mutate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,8 +58,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
this.m_MaxNumberOfNodes = individual.m_MaxNumberOfNodes;
|
||||
this.m_NumberOfBitPerInt= individual.m_NumberOfBitPerInt;
|
||||
this.m_CurrentIndex = individual.m_CurrentIndex;
|
||||
if (individual.m_Genotype != null)
|
||||
if (individual.m_Genotype != null) {
|
||||
this.m_Genotype = (BitSet)individual.m_Genotype.clone();
|
||||
}
|
||||
if (individual.m_Area != null) {
|
||||
this.m_Area = new GPArea[individual.m_Area.length];
|
||||
for (int i = 0; i < this.m_Area.length; i++) {
|
||||
@ -120,11 +121,21 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GEIndividualProgramData) {
|
||||
GEIndividualProgramData indy = (GEIndividualProgramData) individual;
|
||||
if (this.m_GenotypeLengthPerProgram != indy.m_GenotypeLengthPerProgram) return false;
|
||||
if (this.m_MaxNumberOfNodes != indy.m_MaxNumberOfNodes) return false;
|
||||
if (this.m_NumberOfBitPerInt != indy.m_NumberOfBitPerInt) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) return false;
|
||||
if (this.m_GenotypeLengthPerProgram != indy.m_GenotypeLengthPerProgram) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_MaxNumberOfNodes != indy.m_MaxNumberOfNodes) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_NumberOfBitPerInt != indy.m_NumberOfBitPerInt) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -148,7 +159,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
ArrayList area = this.m_Area[t].getReducedList();
|
||||
for (int i = 0; i < area.size(); i++) {
|
||||
arity = ((AbstractGPNode) area.get(i)).getArity();
|
||||
if (arity > maxArity) maxArity = arity;
|
||||
if (arity > maxArity) {
|
||||
maxArity = arity;
|
||||
}
|
||||
}
|
||||
|
||||
// Now i get a sorted list
|
||||
@ -182,7 +195,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
}
|
||||
}
|
||||
tmpExpr[i] = tmpRule;
|
||||
if (tmpRule != null) numberOfRules++;
|
||||
if (tmpRule != null) {
|
||||
numberOfRules++;
|
||||
}
|
||||
}
|
||||
// Now get rid of the null rules
|
||||
int[][] trueExpr = new int[numberOfRules][];
|
||||
@ -218,11 +233,17 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
// first the Non-Terminals
|
||||
result += "N \t := \t{";
|
||||
for (int i = 0; i < this.m_Rules[t].length; i++) {
|
||||
if (i == 0) result += "expr, ";
|
||||
if (i == 0) {
|
||||
result += "expr, ";
|
||||
}
|
||||
else {
|
||||
if (i == 1) result += "var, ";
|
||||
if (i == 1) {
|
||||
result += "var, ";
|
||||
}
|
||||
else {
|
||||
if (((AbstractGPNode[])this.m_Rules[t][i]).length > 0) result += "op"+(i-1)+", ";
|
||||
if (((AbstractGPNode[])this.m_Rules[t][i]).length > 0) {
|
||||
result += "op"+(i-1)+", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,7 +268,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
int[][] rulz = (int[][])this.m_Rules[t][i];
|
||||
for (int j = 0; j < rulz.length; j++) {
|
||||
result += this.getRuleString(rulz[j]) + "\n";
|
||||
if ((j+1) < rulz.length) result += "\t \t \t \t \t \t";
|
||||
if ((j+1) < rulz.length) {
|
||||
result += "\t \t \t \t \t \t";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// now the rules for the terminals
|
||||
@ -285,9 +308,15 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
String result = "";
|
||||
result += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLengthPerProgram*this.m_Area.length; i++) {
|
||||
if (i % this.m_NumberOfBitPerInt == 0) result += " ";
|
||||
if (this.m_Genotype.get(i)) result += "1";
|
||||
else result += "0";
|
||||
if (i % this.m_NumberOfBitPerInt == 0) {
|
||||
result += " ";
|
||||
}
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}";
|
||||
return result;
|
||||
@ -300,9 +329,15 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
private String getRuleString(int[] rule) {
|
||||
String result ="";
|
||||
for (int k = 0; k < rule.length; k++) {
|
||||
if (rule[k] == 0) result += "<expr> ";
|
||||
if (rule[k] == 1) result += "<var> ";
|
||||
if (rule[k] > 1) result += "<op"+(rule[k]-1)+"> ";
|
||||
if (rule[k] == 0) {
|
||||
result += "<expr> ";
|
||||
}
|
||||
if (rule[k] == 1) {
|
||||
result += "<var> ";
|
||||
}
|
||||
if (rule[k] > 1) {
|
||||
result += "<op"+(rule[k]-1)+"> ";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -326,7 +361,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
this.m_Area[t] = oldArea[oldArea.length-1];
|
||||
}
|
||||
this.m_Rules = new Object[length][];
|
||||
if (oldRulz == null) return;
|
||||
if (oldRulz == null) {
|
||||
return;
|
||||
}
|
||||
for (int t = 0; ((t < this.m_Area.length) && (t < oldArea.length)); t++) {
|
||||
if (oldRulz[t] != null) {
|
||||
this.m_Rules[t] = new Object[oldRulz[t].length];
|
||||
@ -382,10 +419,13 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
private int decodeNextInt(int t) {
|
||||
int result = 0;
|
||||
for (int i = 0; i < this.m_NumberOfBitPerInt; i++) {
|
||||
if (this.m_Genotype.get(this.m_CurrentIndex+(t*this.m_GenotypeLengthPerProgram)))
|
||||
if (this.m_Genotype.get(this.m_CurrentIndex+(t*this.m_GenotypeLengthPerProgram))) {
|
||||
result += Math.pow(2, i);
|
||||
}
|
||||
this.m_CurrentIndex++;
|
||||
if (this.m_CurrentIndex >= (t+1)*this.m_GenotypeLengthPerProgram) this.m_CurrentIndex = t*this.m_GenotypeLengthPerProgram;
|
||||
if (this.m_CurrentIndex >= (t+1)*this.m_GenotypeLengthPerProgram) {
|
||||
this.m_CurrentIndex = t*this.m_GenotypeLengthPerProgram;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -445,7 +485,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
// lets decode the stuff!
|
||||
if (this.m_Rules == null) {
|
||||
this.compileArea();
|
||||
if (this.m_Rules == null) return null;
|
||||
if (this.m_Rules == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
this.m_CurrentIndex = 0;
|
||||
this.m_CurrentNumberOfNodes = 0;
|
||||
@ -491,7 +533,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void SetProgramGenotype(InterfaceProgram[] program) {
|
||||
this.SetProgramPhenotype(program);
|
||||
if (program instanceof AbstractGPNode[]) System.err.println("Warning setProgram() for GEIndividualProgramData not implemented!");
|
||||
if (program instanceof AbstractGPNode[]) {
|
||||
System.err.println("Warning setProgram() for GEIndividualProgramData not implemented!");
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows you to set the function area
|
||||
@ -546,8 +590,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
result += "GEIndividual coding program:\n";
|
||||
result += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLengthPerProgram*this.m_Area.length; i++) {
|
||||
if (this.m_Genotype.get(i)) result += "1";
|
||||
else result += "0";
|
||||
if (this.m_Genotype.get(i)) {
|
||||
result += "1";
|
||||
}
|
||||
else {
|
||||
result += "0";
|
||||
}
|
||||
}
|
||||
result += "}\n";
|
||||
InterfaceProgram[] data = this.getProgramData();
|
||||
@ -591,8 +639,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
for (int i = 0; i < this.m_GenotypeLengthPerProgram*this.m_Area.length; i++) {
|
||||
if (RNG.flipCoin(0.5)) this.m_Genotype.set(i);
|
||||
else this.m_Genotype.clear(i);
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,8 +654,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLengthPerProgram*this.m_Area.length);
|
||||
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
|
||||
if (this.m_Genotype.get(mutationIndex)) this.m_Genotype.clear(mutationIndex);
|
||||
else this.m_Genotype.set(mutationIndex);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
}
|
||||
else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
}
|
||||
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
|
||||
}
|
||||
|
||||
|
@ -85,12 +85,22 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GIIndividualIntegerData) {
|
||||
GIIndividualIntegerData indy = (GIIndividualIntegerData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (this.m_Genotype.length != indy.m_Genotype.length) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Genotype.length != indy.m_Genotype.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) return false;
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) return false;
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) return false;
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -212,7 +222,9 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[]) {
|
||||
int[] bs = (int[]) obj;
|
||||
if (bs.length != this.m_Range.length) System.out.println("Init value and requested length doesn't match!");
|
||||
if (bs.length != this.m_Range.length) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
@ -309,7 +321,9 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
}
|
||||
} else if (rng instanceof int[][]){
|
||||
range = (int[][])rng;
|
||||
} else System.err.println("Error, invalid initial range provided by " + prob + ", expecting int[][] or double[][], disregarding initialization range");
|
||||
} else {
|
||||
System.err.println("Error, invalid initial range provided by " + prob + ", expecting int[][] or double[][], disregarding initialization range");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
|
@ -58,8 +58,12 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof GIOBGAIndividualIntegerPermutationData) {
|
||||
GIOBGAIndividualIntegerPermutationData indy = (GIOBGAIndividualIntegerPermutationData)individual;
|
||||
if (!((AbstractEAIndividual)this.m_Integer).equalGenotypes((AbstractEAIndividual)indy.m_Integer)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_Permutation).equalGenotypes((AbstractEAIndividual)indy.m_Permutation)) return false;
|
||||
if (!((AbstractEAIndividual)this.m_Integer).equalGenotypes((AbstractEAIndividual)indy.m_Integer)) {
|
||||
return false;
|
||||
}
|
||||
if (!((AbstractEAIndividual)this.m_Permutation).equalGenotypes((AbstractEAIndividual)indy.m_Permutation)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -107,8 +111,12 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
*/
|
||||
@Override
|
||||
public void mutate() {
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Integer).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability))((AbstractEAIndividual)this.m_Permutation).mutate();
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Integer).mutate();
|
||||
}
|
||||
if (RNG.flipCoin(this.m_MutationProbability)) {
|
||||
((AbstractEAIndividual)this.m_Permutation).mutate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,9 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = new AbstractGPNode[individual.m_Phenotype.length];
|
||||
for (int i = 0; i < individual.m_Phenotype.length; i++) {
|
||||
if (individual.m_Phenotype[i] != null) this.m_Phenotype[i] = (AbstractGPNode)individual.m_Phenotype[i].clone();
|
||||
if (individual.m_Phenotype[i] != null) {
|
||||
this.m_Phenotype[i] = (AbstractGPNode)individual.m_Phenotype[i].clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (individual.m_Genotype != null) {
|
||||
@ -52,7 +54,9 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
this.m_Genotype[i] = (AbstractGPNode)individual.m_Genotype[i].clone();
|
||||
this.m_Genotype[i].connect(null);
|
||||
}
|
||||
if (individual.m_Area[i] != null) this.m_Area[i] = (GPArea)individual.m_Area[i].clone();
|
||||
if (individual.m_Area[i] != null) {
|
||||
this.m_Area[i] = (GPArea)individual.m_Area[i].clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.m_InitFullGrowRatio = individual.m_InitFullGrowRatio;
|
||||
@ -91,14 +95,17 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
if (individual instanceof GPIndividualProgramData) {
|
||||
GPIndividualProgramData indy = (GPIndividualProgramData) individual;
|
||||
//@todo Eigendlich k<EFBFBD>nnte ich noch die Areas vergleichen
|
||||
if (this.m_maxAllowedDepth != indy.m_maxAllowedDepth)
|
||||
if (this.m_maxAllowedDepth != indy.m_maxAllowedDepth) {
|
||||
return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null))
|
||||
}
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if ((this.m_Genotype[i] == null) || (indy.m_Genotype[i] == null) || (!this.m_Genotype[i].equals(indy.m_Genotype[i])))
|
||||
if ((this.m_Genotype[i] == null) || (indy.m_Genotype[i] == null) || (!this.m_Genotype[i].equals(indy.m_Genotype[i]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -156,8 +163,12 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public InterfaceProgram[] getProgramDataWithoutUpdate() {
|
||||
if (this.m_Phenotype==null) return getProgramData();
|
||||
else return this.m_Phenotype;
|
||||
if (this.m_Phenotype==null) {
|
||||
return getProgramData();
|
||||
}
|
||||
else {
|
||||
return this.m_Phenotype;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows you to set the program phenotype.
|
||||
@ -243,7 +254,9 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
}
|
||||
result += "})\n Value: ";
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] != null) result += this.m_Genotype[i].getStringRepresentation();
|
||||
if (this.m_Genotype[i] != null) {
|
||||
result += this.m_Genotype[i].getStringRepresentation();
|
||||
}
|
||||
result += "\nUsing " + this.m_Genotype[i].getNumberOfNodes() + " nodes.";
|
||||
}
|
||||
return result;
|
||||
@ -321,10 +334,12 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
this.m_Genotype[i] = (AbstractGPNode)(this.m_Area[i].getRandomNonTerminal()).clone();
|
||||
this.m_Genotype[i].setDepth(0);
|
||||
int targetDepth = RNG.randomInt(1, this.m_InitDepth);
|
||||
if (RNG.flipCoin(this.m_InitFullGrowRatio))
|
||||
if (RNG.flipCoin(this.m_InitFullGrowRatio)) {
|
||||
this.m_Genotype[i].initFull(this.m_Area[i], targetDepth);
|
||||
else
|
||||
}
|
||||
else {
|
||||
this.m_Genotype[i].initGrow(this.m_Area[i], targetDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,8 +380,12 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
* @param b The new init Full Grow Ratio of the GP Tree.
|
||||
*/
|
||||
public void setInitFullGrowRatio(double b) {
|
||||
if (b < 0) b = 0;
|
||||
if (b > 1) b = 1;
|
||||
if (b < 0) {
|
||||
b = 0;
|
||||
}
|
||||
if (b > 1) {
|
||||
b = 1;
|
||||
}
|
||||
this.m_InitFullGrowRatio = b;
|
||||
}
|
||||
public double getInitFullGrowRatio() {
|
||||
|
@ -33,9 +33,15 @@ public class IndividualDistanceComparator implements Comparator<Object>, Seriali
|
||||
double d1 = distMetric.distance((AbstractEAIndividual)o1, refIndy);
|
||||
double d2 = distMetric.distance((AbstractEAIndividual)o2, refIndy);
|
||||
|
||||
if (d1==d2) return 0;
|
||||
if (closerMeansLess) return ((d1<d2) ? -1 : 1);
|
||||
else return ((d1<d2) ? 1 : -1);
|
||||
if (d1==d2) {
|
||||
return 0;
|
||||
}
|
||||
if (closerMeansLess) {
|
||||
return ((d1<d2) ? -1 : 1);
|
||||
}
|
||||
else {
|
||||
return ((d1<d2) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,12 +36,18 @@ public class IndividualWeightedFitnessComparator implements Comparator<Object>,
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof IndividualWeightedFitnessComparator) {
|
||||
IndividualWeightedFitnessComparator o = (IndividualWeightedFitnessComparator)obj;
|
||||
if (fitWeights==null && (o.fitWeights==null)) return true;
|
||||
if (fitWeights==null || o.fitWeights==null) return false;
|
||||
if (fitWeights==null && (o.fitWeights==null)) {
|
||||
return true;
|
||||
}
|
||||
if (fitWeights==null || o.fitWeights==null) {
|
||||
return false;
|
||||
}
|
||||
// now both are non null:
|
||||
if (fitWeights.length==o.fitWeights.length) {
|
||||
for (int i=0; i<fitWeights.length; i++) {
|
||||
if (fitWeights[i]!=o.fitWeights[i]) return false;
|
||||
if (fitWeights[i]!=o.fitWeights[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -55,7 +61,9 @@ public class IndividualWeightedFitnessComparator implements Comparator<Object>,
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (fitWeights==null) return super.hashCode();
|
||||
if (fitWeights==null) {
|
||||
return super.hashCode();
|
||||
}
|
||||
int code=0;
|
||||
for (int i=0; i<fitWeights.length; i++) {
|
||||
code+=(int)(fitWeights[i]*10000)%(10000*(i+1));
|
||||
@ -75,9 +83,15 @@ public class IndividualWeightedFitnessComparator implements Comparator<Object>,
|
||||
double score1 = calcScore(f1);
|
||||
double score2 = calcScore(f2);
|
||||
|
||||
if (score1 < score2) return -1;
|
||||
else if (score1 > score2) return 1;
|
||||
else return 0;
|
||||
if (score1 < score2) {
|
||||
return -1;
|
||||
}
|
||||
else if (score1 > score2) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,10 +100,16 @@ public class IndividualWeightedFitnessComparator implements Comparator<Object>,
|
||||
* @return
|
||||
*/
|
||||
private double calcScore(double[] f) {
|
||||
if (f==null || fitWeights==null) throw new RuntimeException("Error, missing information in " + this.getClass());
|
||||
if (f==null || fitWeights==null) {
|
||||
throw new RuntimeException("Error, missing information in " + this.getClass());
|
||||
}
|
||||
if (f.length!=fitWeights.length) {
|
||||
if (f.length<fitWeights.length) EVAERROR.errorMsgOnce("Warning, fitness vector has less dimensions than the weights... some weights are ignored, in " + this.getClass());
|
||||
else EVAERROR.errorMsgOnce("Warning, fitness vector has more dimensions than the weights... some fitness values are ignored, in " + this.getClass());
|
||||
if (f.length<fitWeights.length) {
|
||||
EVAERROR.errorMsgOnce("Warning, fitness vector has less dimensions than the weights... some weights are ignored, in " + this.getClass());
|
||||
}
|
||||
else {
|
||||
EVAERROR.errorMsgOnce("Warning, fitness vector has more dimensions than the weights... some fitness values are ignored, in " + this.getClass());
|
||||
}
|
||||
}
|
||||
double s = 0;
|
||||
for (int i=0; i<Math.min(f.length, fitWeights.length); i++) {
|
||||
|
@ -72,13 +72,20 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof OBGAIndividualPermutationData) {
|
||||
OBGAIndividualPermutationData indy = (OBGAIndividualPermutationData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) return false;
|
||||
if (m_Genotype.length != indy.m_Genotype.length) return false;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (m_Genotype.length != indy.m_Genotype.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i].length != indy.m_Genotype[i].length)
|
||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||
if (this.m_Genotype[i][j] != indy.m_Genotype[i][j]) return false;
|
||||
}
|
||||
if (this.m_Genotype[i].length != indy.m_Genotype[i].length) {
|
||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||
if (this.m_Genotype[i][j] != indy.m_Genotype[i][j]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -42,8 +42,12 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri
|
||||
for (int j = 1; j <= i; j++) {
|
||||
tmpB ^= refBitSet.get(locus[0] + j);
|
||||
}
|
||||
if (tmpB) tmpBitSet.set(i);
|
||||
else tmpBitSet.clear(i);
|
||||
if (tmpB) {
|
||||
tmpBitSet.set(i);
|
||||
}
|
||||
else {
|
||||
tmpBitSet.clear(i);
|
||||
}
|
||||
}
|
||||
return this.m_HelpingHand.decodeValue(tmpBitSet, range, tmpLocus, correction);
|
||||
}
|
||||
@ -66,11 +70,19 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri
|
||||
tmpLocus[1] = locus[1];
|
||||
tmpBitSet = new BitSet(tmpLocus.length);
|
||||
this.m_HelpingHand.codeValue(value, range, tmpBitSet, tmpLocus);
|
||||
if (tmpBitSet.get(0)) refBitSet.set(locus[0]);
|
||||
else refBitSet.clear(locus[0]);
|
||||
if (tmpBitSet.get(0)) {
|
||||
refBitSet.set(locus[0]);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(locus[0]);
|
||||
}
|
||||
for (int i = 1; i < locus[1]; i++) {
|
||||
if (tmpBitSet.get(i)^tmpBitSet.get(i-1)) refBitSet.set(locus[0] + i);
|
||||
else refBitSet.clear(locus[0] + i);
|
||||
if (tmpBitSet.get(i)^tmpBitSet.get(i-1)) {
|
||||
refBitSet.set(locus[0] + i);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(locus[0] + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +127,12 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri
|
||||
String output = "{";
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (b.get(i)) output += "1";
|
||||
else output += "0";
|
||||
if (b.get(i)) {
|
||||
output += "1";
|
||||
}
|
||||
else {
|
||||
output += "0";
|
||||
}
|
||||
}
|
||||
output += "}\n";
|
||||
return output;
|
||||
|
@ -43,8 +43,12 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding,java.io.Ser
|
||||
for (int j = 1; j <= i; j++) {
|
||||
tmpB ^= refBitSet.get(locus[0] + j);
|
||||
}
|
||||
if (tmpB) tmpBitSet.set(i);
|
||||
else tmpBitSet.clear(i);
|
||||
if (tmpB) {
|
||||
tmpBitSet.set(i);
|
||||
}
|
||||
else {
|
||||
tmpBitSet.clear(i);
|
||||
}
|
||||
}
|
||||
return this.m_HelpingHand.decodeValue(tmpBitSet, range, tmpLocus, correction);
|
||||
}
|
||||
@ -74,11 +78,19 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding,java.io.Ser
|
||||
// if (tmpBitSet.get(i)^tmpBitSet.get(i-1)) refBitSet.set(locus[1] + i);
|
||||
// else refBitSet.clear(locus[1] + i);
|
||||
// }
|
||||
if (tmpBitSet.get(0)) refBitSet.set(locus[0]);
|
||||
else refBitSet.clear(locus[0]);
|
||||
if (tmpBitSet.get(0)) {
|
||||
refBitSet.set(locus[0]);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(locus[0]);
|
||||
}
|
||||
for (int i = 1; i < locus[1]; i++) {
|
||||
if (tmpBitSet.get(i)^tmpBitSet.get(i-1)) refBitSet.set(locus[0] + i);
|
||||
else refBitSet.clear(locus[0] + i);
|
||||
if (tmpBitSet.get(i)^tmpBitSet.get(i-1)) {
|
||||
refBitSet.set(locus[0] + i);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(locus[0] + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,8 +118,12 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding,java.io.Ser
|
||||
String output = "{";
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (b.get(i)) output += "1";
|
||||
else output += "0";
|
||||
if (b.get(i)) {
|
||||
output += "1";
|
||||
}
|
||||
else {
|
||||
output += "0";
|
||||
}
|
||||
}
|
||||
output += "}\n";
|
||||
return output;
|
||||
|
@ -83,7 +83,9 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
|
||||
for (int i=1+locus[0]; i<locus[0]+locus[1]; i++) {
|
||||
val *= 2.;
|
||||
if (refBitSet.get(i)) val+=1.;
|
||||
if (refBitSet.get(i)) {
|
||||
val+=1.;
|
||||
}
|
||||
}
|
||||
|
||||
return range[0]+((range[1]-range[0])*val)/lastMaxVal;
|
||||
@ -134,8 +136,12 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
//System.out.print("FLOAT Value coded : " + value + " " + this.printBitSet(tmpBitSet, m_length));
|
||||
//System.out.println(tmpV + "/" + m_max + "*(" + u_max + "-" + u_min + ")+" + u_min +"\n");
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (tmpBitSet.get(i)) refBitSet.set(m_start + m_length - 1 - i);
|
||||
else refBitSet.clear(m_start + m_length - 1 - i);
|
||||
if (tmpBitSet.get(i)) {
|
||||
refBitSet.set(m_start + m_length - 1 - i);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(m_start + m_length - 1 - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,8 +163,12 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
range[0] = -110;
|
||||
range[1] = 1000;
|
||||
for (int i = 0; i < test.length(); i++) {
|
||||
if (test.charAt(i) == '1') tmpBitSet.set(i);
|
||||
else tmpBitSet.clear(i);
|
||||
if (test.charAt(i) == '1') {
|
||||
tmpBitSet.set(i);
|
||||
}
|
||||
else {
|
||||
tmpBitSet.clear(i);
|
||||
}
|
||||
}
|
||||
// value = t.decodeValue(tmpBitSet, range, locus, false);
|
||||
// System.out.println("Value: " + value);
|
||||
@ -195,8 +205,12 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
String output = "{";
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (b.get(i)) output += "1";
|
||||
else output += "0";
|
||||
if (b.get(i)) {
|
||||
output += "1";
|
||||
}
|
||||
else {
|
||||
output += "0";
|
||||
}
|
||||
}
|
||||
output += "}\n";
|
||||
return output;
|
||||
|
@ -91,8 +91,12 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
m_min = 0;
|
||||
tmpV = value - u_min;
|
||||
long tmpOut = tmpV;// damit ist tmpV im range m_Min m_Max
|
||||
if (tmpV > m_max) tmpV = m_max;
|
||||
if (tmpV < m_min) tmpV = m_min;
|
||||
if (tmpV > m_max) {
|
||||
tmpV = m_max;
|
||||
}
|
||||
if (tmpV < m_min) {
|
||||
tmpV = m_min;
|
||||
}
|
||||
tmpBitSet = new BitSet(m_length);
|
||||
while (tmpV >= 1) {
|
||||
//System.out.println(tmpV);
|
||||
@ -111,12 +115,20 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
//System.out.println("tmpV " + tmpOut + " Range("+m_min+";"+m_max+") "+m_length+" "+this.printBitSet(tmpBitSet,m_length));
|
||||
// Das sieht bis hierher richtig toll aus, nur jetzt wirds scheisse m_Length war im Arsch
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (tmpBitSet.get(i)) refBitSet.set(m_start + m_length - 1 - i);
|
||||
else refBitSet.clear(m_start + m_length - 1 - i);
|
||||
if (tmpBitSet.get(i)) {
|
||||
refBitSet.set(m_start + m_length - 1 - i);
|
||||
}
|
||||
else {
|
||||
refBitSet.clear(m_start + m_length - 1 - i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (refBitSet.get(m_start + m_length - 1 - i)) tmpBitSet.set(m_length - 1 - i);
|
||||
else tmpBitSet.clear(m_start + m_length - 1 - i);
|
||||
if (refBitSet.get(m_start + m_length - 1 - i)) {
|
||||
tmpBitSet.set(m_length - 1 - i);
|
||||
}
|
||||
else {
|
||||
tmpBitSet.clear(m_start + m_length - 1 - i);
|
||||
}
|
||||
}
|
||||
//System.out.println("INT Value coded : " + value + " " + this.printBitSet(tmpBitSet, m_length));
|
||||
}
|
||||
@ -150,8 +162,12 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
String output = "{";
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (b.get(i)) output += "1";
|
||||
else output += "0";
|
||||
if (b.get(i)) {
|
||||
output += "1";
|
||||
}
|
||||
else {
|
||||
output += "0";
|
||||
}
|
||||
}
|
||||
output += "}\n";
|
||||
return output;
|
||||
|
@ -80,7 +80,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
sbuf.append("(");
|
||||
for (int i = 0; i < node.m_Nodes.length; i++) {
|
||||
sbuf.append(node.m_Nodes[i].getStringRepresentation());
|
||||
if (i<node.m_Nodes.length-1) sbuf.append(", ");
|
||||
if (i<node.m_Nodes.length-1) {
|
||||
sbuf.append(", ");
|
||||
}
|
||||
}
|
||||
sbuf.append(")");
|
||||
}
|
||||
@ -119,10 +121,14 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
System.err.println("String has unknown prefix: " + str);
|
||||
}
|
||||
}
|
||||
else if (matchSet.size()>1) System.err.println("String has ambiguous prefix: " + str + " -- " + BeanInspector.toString(matchSet));
|
||||
else if (matchSet.size()>1) {
|
||||
System.err.println("String has ambiguous prefix: " + str + " -- " + BeanInspector.toString(matchSet));
|
||||
}
|
||||
else { // exactly one match:
|
||||
AbstractGPNode currentNode = (AbstractGPNode)matchSet.get(0).clone();
|
||||
if (TRACE) System.out.println("Found match: " + currentNode.getOpIdentifier() + "/" + currentNode.getArity());
|
||||
if (TRACE) {
|
||||
System.out.println("Found match: " + currentNode.getOpIdentifier() + "/" + currentNode.getArity());
|
||||
}
|
||||
int cutFront=currentNode.getOpIdentifier().length();
|
||||
String restStr;
|
||||
if (currentNode.getArity()==0) {
|
||||
@ -151,7 +157,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (TRACE) System.out.println("read " + currentNode.getName() + ", rest: " + restStr);
|
||||
if (TRACE) {
|
||||
System.out.println("read " + currentNode.getName() + ", rest: " + restStr);
|
||||
}
|
||||
return new Pair<AbstractGPNode,String>(currentNode, restStr);
|
||||
}
|
||||
}
|
||||
@ -182,18 +190,28 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
private static Pair<Double, String> readDouble(String str, boolean expect) {
|
||||
String firstArg;
|
||||
int argLen = str.indexOf(',');
|
||||
if (argLen<0) argLen = str.indexOf(')');
|
||||
if (argLen<0) {
|
||||
argLen = str.indexOf(')');
|
||||
}
|
||||
else {
|
||||
int firstBrace = str.indexOf(')');
|
||||
if ((firstBrace >= 0) && (firstBrace<argLen)) argLen = firstBrace;
|
||||
if ((firstBrace >= 0) && (firstBrace<argLen)) {
|
||||
argLen = firstBrace;
|
||||
}
|
||||
}
|
||||
if (argLen>0) firstArg=str.substring(0,argLen);
|
||||
else firstArg=str.trim();
|
||||
if (argLen>0) {
|
||||
firstArg=str.substring(0,argLen);
|
||||
}
|
||||
else {
|
||||
firstArg=str.trim();
|
||||
}
|
||||
try {
|
||||
Double d=Double.parseDouble(firstArg);
|
||||
return new Pair<Double,String>(d, str.substring(firstArg.length()));
|
||||
} catch(NumberFormatException e) {
|
||||
if (expect) System.err.println("String has unknown prefix: " + str);
|
||||
if (expect) {
|
||||
System.err.println("String has unknown prefix: " + str);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -203,8 +221,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
* @return string
|
||||
*/
|
||||
public static String makeStringRepresentation(AbstractGPNode[] nodes, String op) {
|
||||
if (nodes.length==0) return op;
|
||||
else if (nodes.length==1) return op+"(" + nodes[0].getStringRepresentation()+")";
|
||||
if (nodes.length==0) {
|
||||
return op;
|
||||
}
|
||||
else if (nodes.length==1) {
|
||||
return op+"(" + nodes[0].getStringRepresentation()+")";
|
||||
}
|
||||
else {
|
||||
String result = "( "+nodes[0].getStringRepresentation();
|
||||
for (int i = 1; i < nodes.length; i++) {
|
||||
@ -229,9 +251,15 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
Vector<AbstractGPNode> matching = new Vector<AbstractGPNode>();
|
||||
for (int i=0; i<nodeTypes.size(); i++) {
|
||||
String reqPrefix=nodeTypes.get(i).getOpIdentifier();
|
||||
if (nodeTypes.get(i).getArity()>0) reqPrefix+="(";
|
||||
if (str.startsWith(reqPrefix)) matching.add(nodeTypes.get(i));
|
||||
else if (ignoreCase && str.toLowerCase().startsWith(reqPrefix.toLowerCase())) matching.add(nodeTypes.get(i));
|
||||
if (nodeTypes.get(i).getArity()>0) {
|
||||
reqPrefix+="(";
|
||||
}
|
||||
if (str.startsWith(reqPrefix)) {
|
||||
matching.add(nodeTypes.get(i));
|
||||
}
|
||||
else if (ignoreCase && str.toLowerCase().startsWith(reqPrefix.toLowerCase())) {
|
||||
matching.add(nodeTypes.get(i));
|
||||
}
|
||||
}
|
||||
if (matching.size()>1 && firstLongestOnly) { // allow only the longest match (or first longest)
|
||||
int maxLen = matching.get(0).getOpIdentifier().length();
|
||||
@ -244,7 +272,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
maxLen = longest.getOpIdentifier().length();
|
||||
longestList.clear();
|
||||
longestList.add(longest);
|
||||
} else if (matching.get(i).getOpIdentifier().length()==maxLen) longestList.add(matching.get(i));
|
||||
} else if (matching.get(i).getOpIdentifier().length()==maxLen) {
|
||||
longestList.add(matching.get(i));
|
||||
}
|
||||
}
|
||||
matching.clear();
|
||||
matching.addAll(longestList);
|
||||
@ -316,7 +346,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
Class<?> cls = AbstractGPNode.class;
|
||||
Class<?>[] nodes = ReflectPackage.getAssignableClassesInPackage(cls.getPackage().getName(), AbstractGPNode.class, true, false);
|
||||
for (Class<?> c : nodes) {
|
||||
if (Modifier.isAbstract(c.getModifiers()) || c.isInterface()) continue;
|
||||
if (Modifier.isAbstract(c.getModifiers()) || c.isInterface()) {
|
||||
continue;
|
||||
}
|
||||
AbstractGPNode node;
|
||||
try {
|
||||
node = (AbstractGPNode)c.newInstance();
|
||||
@ -412,7 +444,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
if (m_Nodes.length>0) {
|
||||
int k=RNG.randomInt(m_Nodes.length);
|
||||
return m_Nodes[k].getRandomLeaf();
|
||||
} else return this;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows you to set the parent of the node
|
||||
@ -433,8 +467,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
*/
|
||||
public void connect(AbstractGPNode parent) {
|
||||
this.m_Parent = parent;
|
||||
if (parent != null) this.m_Depth = this.m_Parent.getDepth()+1;
|
||||
else this.m_Depth = 0;
|
||||
if (parent != null) {
|
||||
this.m_Depth = this.m_Parent.getDepth()+1;
|
||||
}
|
||||
else {
|
||||
this.m_Depth = 0;
|
||||
}
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
this.m_Nodes[i].connect(this);
|
||||
}
|
||||
@ -453,8 +491,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
public void initFull(GPArea area, int depth) {
|
||||
this.m_Nodes = new AbstractGPNode[this.getArity()];
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (this.m_Depth+1 >= depth) this.m_Nodes[i] = (AbstractGPNode)area.getRandomNodeWithArity(0).clone();
|
||||
else this.m_Nodes[i] = (AbstractGPNode)area.getRandomNonTerminal().clone();
|
||||
if (this.m_Depth+1 >= depth) {
|
||||
this.m_Nodes[i] = (AbstractGPNode)area.getRandomNodeWithArity(0).clone();
|
||||
}
|
||||
else {
|
||||
this.m_Nodes[i] = (AbstractGPNode)area.getRandomNonTerminal().clone();
|
||||
}
|
||||
this.m_Nodes[i].setDepth(this.m_Depth+1);
|
||||
this.m_Nodes[i].setParent(this);
|
||||
this.m_Nodes[i].initFull(area, depth);
|
||||
@ -468,8 +510,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
public void initGrow(GPArea area, int depth) {
|
||||
this.m_Nodes = new AbstractGPNode[this.getArity()];
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (this.m_Depth+1 >= depth) this.m_Nodes[i] = (AbstractGPNode)area.getRandomNodeWithArity(0).clone();
|
||||
else this.m_Nodes[i] = (AbstractGPNode)area.getRandomNode().clone();
|
||||
if (this.m_Depth+1 >= depth) {
|
||||
this.m_Nodes[i] = (AbstractGPNode)area.getRandomNodeWithArity(0).clone();
|
||||
}
|
||||
else {
|
||||
this.m_Nodes[i] = (AbstractGPNode)area.getRandomNode().clone();
|
||||
}
|
||||
this.m_Nodes[i].setDepth(this.m_Depth+1);
|
||||
this.m_Nodes[i].setParent(this);
|
||||
this.m_Nodes[i].initGrow(area, depth);
|
||||
@ -494,7 +540,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
public int getMaxDepth() {
|
||||
int result = this.m_Depth;
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (this.m_Nodes[i] != null) result = Math.max(result, this.m_Nodes[i].getMaxDepth());
|
||||
if (this.m_Nodes[i] != null) {
|
||||
result = Math.max(result, this.m_Nodes[i].getMaxDepth());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -514,8 +562,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
* @return True if MaxDepth is violated
|
||||
*/
|
||||
public boolean isMaxDepthViolated(int maxDepth) {
|
||||
if (maxDepth < this.getMaxDepth()) return true;
|
||||
else return false;
|
||||
if (maxDepth < this.getMaxDepth()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
// if (depth > this.m_Depth) return false;
|
||||
// else {
|
||||
// boolean result = true;
|
||||
@ -559,10 +611,16 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
public boolean equals(Object obj) {
|
||||
if (obj.getClass().equals(this.getClass())) {
|
||||
AbstractGPNode node = (AbstractGPNode)obj;
|
||||
if (this.getArity()!=node.getArity()) return false;
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) return false;
|
||||
if (this.getArity()!=node.getArity()) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Nodes.length != node.m_Nodes.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) return false;
|
||||
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -593,7 +651,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
||||
return false;
|
||||
}
|
||||
for (int i=0; i<m_Nodes.length; i++) {
|
||||
if (!m_Nodes[i].checkDepth(myDepth+1)) return false;
|
||||
if (!m_Nodes[i].checkDepth(myDepth+1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -28,12 +28,15 @@ public class GPArea implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public GPArea(GPArea g) {
|
||||
if (g.m_BlackList != null)
|
||||
if (g.m_BlackList != null) {
|
||||
this.m_BlackList = (ArrayList<Boolean>)g.m_BlackList.clone();
|
||||
if (g.m_ReducedList != null)
|
||||
}
|
||||
if (g.m_ReducedList != null) {
|
||||
this.m_ReducedList = (ArrayList<AbstractGPNode>)g.m_ReducedList.clone();
|
||||
if (g.m_CompleteList != null)
|
||||
}
|
||||
if (g.m_CompleteList != null) {
|
||||
this.m_CompleteList = (ArrayList<AbstractGPNode>)g.m_CompleteList.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -118,17 +121,27 @@ public class GPArea implements java.io.Serializable {
|
||||
public AbstractGPNode getRandomNodeWithArity(int targetarity) {
|
||||
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>();
|
||||
for (int i = 0; i < this.m_ReducedList.size(); i++) {
|
||||
if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() == targetarity) tmpArray.add(this.m_ReducedList.get(i));
|
||||
if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() == targetarity) {
|
||||
tmpArray.add(this.m_ReducedList.get(i));
|
||||
}
|
||||
}
|
||||
if (tmpArray.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1));
|
||||
}
|
||||
if (tmpArray.size() == 0) return null;
|
||||
else return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1));
|
||||
}
|
||||
|
||||
/** This method will return a random node.
|
||||
*/
|
||||
public AbstractGPNode getRandomNode() {
|
||||
if (this.m_ReducedList.size() == 0) return null;
|
||||
else return (AbstractGPNode)this.m_ReducedList.get(RNG.randomInt(0, this.m_ReducedList.size()-1));
|
||||
if (this.m_ReducedList.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return (AbstractGPNode)this.m_ReducedList.get(RNG.randomInt(0, this.m_ReducedList.size()-1));
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a non terminal
|
||||
@ -136,10 +149,16 @@ public class GPArea implements java.io.Serializable {
|
||||
public AbstractGPNode getRandomNonTerminal() {
|
||||
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>();
|
||||
for (int i = 0; i < this.m_ReducedList.size(); i++) {
|
||||
if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() > 0) tmpArray.add(this.m_ReducedList.get(i));
|
||||
if (((AbstractGPNode)this.m_ReducedList.get(i)).getArity() > 0) {
|
||||
tmpArray.add(this.m_ReducedList.get(i));
|
||||
}
|
||||
}
|
||||
if (tmpArray.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1));
|
||||
}
|
||||
if (tmpArray.size() == 0) return null;
|
||||
else return (AbstractGPNode)tmpArray.get(RNG.randomInt(0, tmpArray.size()-1));
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
@ -154,14 +173,18 @@ public class GPArea implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support==null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support==null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support==null) m_Support = new PropertyChangeSupport(this);
|
||||
if (m_Support==null) {
|
||||
m_Support = new PropertyChangeSupport(this);
|
||||
}
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,17 @@ public class GPNodeAbs extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 0;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result += ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result += ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
Double ret = new Double(result);
|
||||
|
||||
if (ret<0) return -ret;
|
||||
else return ret;
|
||||
if (ret<0) {
|
||||
return -ret;
|
||||
}
|
||||
else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,9 @@ public class GPNodeAdd extends AbstractGPNode implements java.io.Serializable {
|
||||
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result += ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result += ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ public class GPNodeConst extends AbstractGPNode implements java.io.Serializable
|
||||
if (obj instanceof GPNodeConst) {
|
||||
GPNodeConst node = (GPNodeConst)obj;
|
||||
return (node.value==this.value);
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will be used to identify the node in the GPAreaEditor
|
||||
|
@ -50,7 +50,9 @@ public class GPNodeCos extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.sin(((Double)tmpObj).doubleValue());
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.sin(((Double)tmpObj).doubleValue());
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,21 @@ public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
|
||||
double tmpValue = 0;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result = ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
for (int i = 1; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof Double)
|
||||
if (tmpObj instanceof Double) {
|
||||
tmpValue = ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
if (Math.abs(tmpValue) < this.m_LowerBorderForSec) {
|
||||
if (tmpValue < 0) tmpValue = -this.m_LowerBorderForSec;
|
||||
else tmpValue = this.m_LowerBorderForSec;
|
||||
if (tmpValue < 0) {
|
||||
tmpValue = -this.m_LowerBorderForSec;
|
||||
}
|
||||
else {
|
||||
tmpValue = this.m_LowerBorderForSec;
|
||||
}
|
||||
}
|
||||
result /= tmpValue;
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ public class GPNodeExp extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.exp(((Double)tmpObj).doubleValue());
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.exp(((Double)tmpObj).doubleValue());
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,9 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeInput) {
|
||||
GPNodeInput node = (GPNodeInput)obj;
|
||||
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) return false;
|
||||
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -85,13 +87,17 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public String getOpIdentifier() {
|
||||
if (this.lastValue == null) return this.m_Identifier;
|
||||
if (this.lastValue == null) {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
else {
|
||||
if (this.lastValue instanceof Double) {
|
||||
double tmpD = ((Double)this.lastValue).doubleValue();
|
||||
tmpD = ((long)(tmpD*10000.0 + ((tmpD>=0.0)?0.5:-0.5)))/10000.0;
|
||||
return ("S:" +this.m_Identifier + " = " + tmpD);
|
||||
} else return ("S:" +this.m_Identifier + " = " + this.lastValue.toString());
|
||||
} else {
|
||||
return ("S:" +this.m_Identifier + " = " + this.lastValue.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,12 @@ public class GPNodeMult extends AbstractGPNode implements java.io.Serializable {
|
||||
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result *= ((Double)tmpObj).doubleValue();
|
||||
else System.err.println("Unexpected type returned in evaluate for "+this.getClass().getSimpleName());
|
||||
if (tmpObj instanceof Double) {
|
||||
result *= ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
else {
|
||||
System.err.println("Unexpected type returned in evaluate for "+this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -51,10 +51,14 @@ public class GPNodeNeg extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 0;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result += ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result += ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
for (int i = 1; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result -= ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result -= ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GPNodeOutput) {
|
||||
GPNodeOutput node = (GPNodeOutput)obj;
|
||||
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) return false;
|
||||
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -50,7 +50,9 @@ public class GPNodePow2 extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.pow(((Double)tmpObj).doubleValue(), 2);
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.pow(((Double)tmpObj).doubleValue(), 2);
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,9 @@ public class GPNodePow3 extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.pow(((Double)tmpObj).doubleValue(), 3);
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.pow(((Double)tmpObj).doubleValue(), 3);
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,17 @@ public class GPNodeProd extends AbstractGPNode implements java.io.Serializable {
|
||||
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof double[]) result*=Mathematics.product((double[])tmpObj);
|
||||
if (tmpObj instanceof double[]) {
|
||||
result*=Mathematics.product((double[])tmpObj);
|
||||
}
|
||||
else if (tmpObj instanceof Double[]) {
|
||||
Double[] vals = (Double[])tmpObj;
|
||||
for (int j=0; j<vals.length; j++) {
|
||||
result*=vals[j];
|
||||
}
|
||||
} else if (tmpObj instanceof Double) result=(Double)tmpObj;
|
||||
} else if (tmpObj instanceof Double) {
|
||||
result=(Double)tmpObj;
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ public class GPNodeSin extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.sin(((Double)tmpObj).doubleValue());
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.sin(((Double)tmpObj).doubleValue());
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,9 @@ public class GPNodeSqrt extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 1;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result = Math.sqrt(Math.abs(((Double)tmpObj).doubleValue()));
|
||||
if (tmpObj instanceof Double) {
|
||||
result = Math.sqrt(Math.abs(((Double)tmpObj).doubleValue()));
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,14 @@ public class GPNodeSub extends AbstractGPNode implements java.io.Serializable {
|
||||
double result = 0;
|
||||
|
||||
tmpObj = this.m_Nodes[0].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result += ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result += ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
for (int i = 1; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof Double) result -= ((Double)tmpObj).doubleValue();
|
||||
if (tmpObj instanceof Double) {
|
||||
result -= ((Double)tmpObj).doubleValue();
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -51,13 +51,17 @@ public class GPNodeSum extends AbstractGPNode implements java.io.Serializable {
|
||||
|
||||
for (int i = 0; i < this.m_Nodes.length; i++) {
|
||||
tmpObj = this.m_Nodes[i].evaluate(environment);
|
||||
if (tmpObj instanceof double[]) result+=Mathematics.sum((double[])tmpObj);
|
||||
if (tmpObj instanceof double[]) {
|
||||
result+=Mathematics.sum((double[])tmpObj);
|
||||
}
|
||||
else if (tmpObj instanceof Double[]) {
|
||||
Double[] vals = (Double[])tmpObj;
|
||||
for (int j=0; j<vals.length; j++) {
|
||||
result+=vals[j];
|
||||
}
|
||||
} else if (tmpObj instanceof Double) result=(Double)tmpObj;
|
||||
} else if (tmpObj instanceof Double) {
|
||||
result=(Double)tmpObj;
|
||||
}
|
||||
}
|
||||
return new Double(result);
|
||||
}
|
||||
|
@ -92,8 +92,12 @@ public class MOCCOChooseReferenceSolution extends MOCCOPhase implements Interfac
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = i+1;
|
||||
gbc.weightx = 1;
|
||||
if (obj[i].is2BMinimized()) textA = new JTextField("min");
|
||||
else textA = new JTextField("max");
|
||||
if (obj[i].is2BMinimized()) {
|
||||
textA = new JTextField("min");
|
||||
}
|
||||
else {
|
||||
textA = new JTextField("max");
|
||||
}
|
||||
textA.setEditable(false);
|
||||
tmpP.add(textA, gbc);
|
||||
gbc.gridx = 2;
|
||||
|
@ -97,8 +97,12 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
this.m_TradeOff[i][j] = new JTextField("");
|
||||
if (i == j) {
|
||||
this.m_TradeOff[i][j].setBackground(Color.WHITE);
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) this.m_TradeOff[i][j].setEditable(true);
|
||||
else this.m_TradeOff[i][j].setEditable(false);
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
this.m_TradeOff[i][j].setEditable(true);
|
||||
}
|
||||
else {
|
||||
this.m_TradeOff[i][j].setEditable(false);
|
||||
}
|
||||
this.m_TradeOff[i][j].setText("1.0");
|
||||
this.m_TradeOff[i][j].addActionListener(weightListener);
|
||||
} else {
|
||||
@ -130,12 +134,17 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
try {
|
||||
this.m_EOpt.m_Value = this.m_Opt;
|
||||
this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(this.m_EOpt.m_Value.getClass());
|
||||
if (this.m_EOpt.m_Editor == null) this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
if (this.m_EOpt.m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_EOpt.m_Editor == null) {
|
||||
this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (this.m_EOpt.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EOpt.m_Editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
this.m_EOpt.m_Editor.setValue(this.m_EOpt.m_Value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EOpt);
|
||||
if (this.m_EOpt.m_View != null) this.m_EOpt.m_View.repaint();
|
||||
if (this.m_EOpt.m_View != null) {
|
||||
this.m_EOpt.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -153,12 +162,17 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -190,7 +204,9 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
w[i] = new Double(m_TradeOff[i][i].getText()).doubleValue();
|
||||
sum += w[i];
|
||||
}
|
||||
if (new Double(sum).isNaN()) return;
|
||||
if (new Double(sum).isNaN()) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < m_TradeOff.length; i++) {
|
||||
for (int j = 0; j < m_TradeOff.length; j++) {
|
||||
if (i != j) {
|
||||
@ -241,7 +257,9 @@ public class MOCCOParameterizeGDF extends MOCCOPhase implements InterfaceProcess
|
||||
System.out.println("obj.length = " + obj.length);
|
||||
System.out.println("d.length = " + d.length);
|
||||
for (int i = 0; i < obj.length; i++) {
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) tmpA.add(new Double(d[i]));
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
tmpA.add(new Double(d[i]));
|
||||
}
|
||||
}
|
||||
|
||||
double[] result = new double[tmpA.size()];
|
||||
|
@ -87,12 +87,17 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Optimizer;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -110,12 +115,17 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -141,11 +151,15 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE
|
||||
m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem);
|
||||
Population pop = m_Mocco.m_State.m_Optimizer.getPopulation();
|
||||
pop.clear();
|
||||
if (pop.getArchive() != null) pop.getArchive().clear();
|
||||
if (pop.getArchive() != null) {
|
||||
pop.getArchive().clear();
|
||||
}
|
||||
if (m_Mocco.m_State.m_PopulationHistory.length > 0) {
|
||||
pop = m_Mocco.m_State.getSelectedPopulations();
|
||||
m_Mocco.m_State.m_Optimizer.initByPopulation(pop, false);
|
||||
if (pop.size() == 0) m_Mocco.m_State.m_Optimizer.init();
|
||||
if (pop.size() == 0) {
|
||||
m_Mocco.m_State.m_Optimizer.init();
|
||||
}
|
||||
}
|
||||
m_Finished = true;
|
||||
}
|
||||
|
@ -111,12 +111,17 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
try {
|
||||
this.m_EMOSO.m_Value = this.m_LpMetric;
|
||||
this.m_EMOSO.m_Editor = PropertyEditorProvider.findEditor(this.m_EMOSO.m_Value.getClass());
|
||||
if (this.m_EMOSO.m_Editor == null) this.m_EMOSO.m_Editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class);
|
||||
if (this.m_EMOSO.m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_EMOSO.m_Editor == null) {
|
||||
this.m_EMOSO.m_Editor = PropertyEditorProvider.findEditor(MOSOLpMetric.class);
|
||||
}
|
||||
if (this.m_EMOSO.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EMOSO.m_Editor).setClassType(MOSOLpMetric.class);
|
||||
}
|
||||
this.m_EMOSO.m_Editor.setValue(this.m_EMOSO.m_Value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EMOSO);
|
||||
if (this.m_EMOSO.m_View != null) this.m_EMOSO.m_View.repaint();
|
||||
if (this.m_EMOSO.m_View != null) {
|
||||
this.m_EMOSO.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -142,12 +147,17 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
try {
|
||||
this.m_EIMEA.m_Value = this.m_Island;
|
||||
this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(this.m_EIMEA.m_Value.getClass());
|
||||
if (this.m_EIMEA.m_Editor == null) this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
if (this.m_EIMEA.m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_EIMEA.m_Editor == null) {
|
||||
this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
}
|
||||
if (this.m_EIMEA.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EIMEA.m_Editor).setClassType(IslandModelEA.class);
|
||||
}
|
||||
this.m_EIMEA.m_Editor.setValue(this.m_EIMEA.m_Value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EIMEA);
|
||||
if (this.m_EIMEA.m_View != null) this.m_EIMEA.m_View.repaint();
|
||||
if (this.m_EIMEA.m_View != null) {
|
||||
this.m_EIMEA.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -165,12 +175,17 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -242,8 +257,12 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr
|
||||
for (int i = 0; i < m_Perturbations; i++) {
|
||||
tmpD = new double[m_RefPoint.length];
|
||||
for (int j = 0; j < tmpD.length; j++) {
|
||||
if (i > 0) tmpD[j] = m_RefPoint[j] + RNG.gaussianDouble(m_Perturbation);
|
||||
else tmpD[j] = m_RefPoint[j];
|
||||
if (i > 0) {
|
||||
tmpD[j] = m_RefPoint[j] + RNG.gaussianDouble(m_Perturbation);
|
||||
}
|
||||
else {
|
||||
tmpD[j] = m_RefPoint[j];
|
||||
}
|
||||
}
|
||||
tmpLPs[i] = (MOSOLpMetric)m_LpMetric.clone();
|
||||
// I've to set this before I change the parameters, because the problem sets the
|
||||
|
@ -80,12 +80,17 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Optimizer;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -103,12 +108,17 @@ public class MOCCOParameterizeSO extends MOCCOPhase implements InterfaceProcessE
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
|
@ -129,8 +129,12 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = i+1;
|
||||
gbc.weightx = 1;
|
||||
if (obj[i].is2BMinimized()) panelSTEP.add(new JLabel("min"), gbc);
|
||||
else panelSTEP.add(new JLabel("max"), gbc);
|
||||
if (obj[i].is2BMinimized()) {
|
||||
panelSTEP.add(new JLabel("min"), gbc);
|
||||
}
|
||||
else {
|
||||
panelSTEP.add(new JLabel("max"), gbc);
|
||||
}
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = i+1;
|
||||
this.m_RefSol[i] = new JTextField(""+((Double)m_RefSolution.getData(obj[i].getIdentName())).doubleValue());
|
||||
@ -144,8 +148,12 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
gbc.gridx = 4;
|
||||
gbc.gridy = i+1;
|
||||
this.m_Weight[i] = new JTextField("1.0");
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) this.m_Weight[i].setEditable(true);
|
||||
else this.m_Weight[i].setEditable(false);
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
this.m_Weight[i].setEditable(true);
|
||||
}
|
||||
else {
|
||||
this.m_Weight[i].setEditable(false);
|
||||
}
|
||||
//this.m_Satisfied[i].addActionListener(valueChanged);
|
||||
panelSTEP.add(this.m_Weight[i], gbc);
|
||||
gbc.gridx = 5;
|
||||
@ -172,12 +180,17 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
try {
|
||||
this.m_EOpt.m_Value = this.m_Opt;
|
||||
this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(this.m_EOpt.m_Value.getClass());
|
||||
if (this.m_EOpt.m_Editor == null) this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
if (this.m_EOpt.m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_EOpt.m_Editor == null) {
|
||||
this.m_EOpt.m_Editor = PropertyEditorProvider.findEditor(InterfaceOptimizer.class);
|
||||
}
|
||||
if (this.m_EOpt.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EOpt.m_Editor).setClassType(InterfaceOptimizer.class);
|
||||
}
|
||||
this.m_EOpt.m_Editor.setValue(this.m_EOpt.m_Value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EOpt);
|
||||
if (this.m_EOpt.m_View != null) this.m_EOpt.m_View.repaint();
|
||||
if (this.m_EOpt.m_View != null) {
|
||||
this.m_EOpt.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -195,12 +208,17 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -318,7 +336,9 @@ public class MOCCOParameterizeSTEP extends MOCCOPhase implements InterfaceProces
|
||||
System.out.println("obj.length = " + obj.length);
|
||||
System.out.println("d.length = " + d.length);
|
||||
for (int i = 0; i < obj.length; i++) {
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) tmpA.add(new Double(d[i]));
|
||||
if (obj[i].getOptimizationMode().contains("Objective")) {
|
||||
tmpA.add(new Double(d[i]));
|
||||
}
|
||||
}
|
||||
|
||||
double[] result = new double[tmpA.size()];
|
||||
|
@ -119,12 +119,17 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
try {
|
||||
this.m_EIMEA.m_Value = this.m_Island;
|
||||
this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(this.m_EIMEA.m_Value.getClass());
|
||||
if (this.m_EIMEA.m_Editor == null) this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
if (this.m_EIMEA.m_Editor instanceof GenericObjectEditor)
|
||||
if (this.m_EIMEA.m_Editor == null) {
|
||||
this.m_EIMEA.m_Editor = PropertyEditorProvider.findEditor(IslandModelEA.class);
|
||||
}
|
||||
if (this.m_EIMEA.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) this.m_EIMEA.m_Editor).setClassType(IslandModelEA.class);
|
||||
}
|
||||
this.m_EIMEA.m_Editor.setValue(this.m_EIMEA.m_Value);
|
||||
AbstractObjectEditor.findViewFor(this.m_EIMEA);
|
||||
if (this.m_EIMEA.m_View != null) this.m_EIMEA.m_View.repaint();
|
||||
if (this.m_EIMEA.m_View != null) {
|
||||
this.m_EIMEA.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -142,12 +147,17 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
try {
|
||||
editor.m_Value = this.m_Mocco.m_State.m_Terminator;
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(editor.m_Value.getClass());
|
||||
if (editor.m_Editor == null) editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
if (editor.m_Editor instanceof GenericObjectEditor)
|
||||
if (editor.m_Editor == null) {
|
||||
editor.m_Editor = PropertyEditorProvider.findEditor(InterfaceTerminator.class);
|
||||
}
|
||||
if (editor.m_Editor instanceof GenericObjectEditor) {
|
||||
((GenericObjectEditor) editor.m_Editor).setClassType(InterfaceTerminator.class);
|
||||
}
|
||||
editor.m_Editor.setValue(editor.m_Value);
|
||||
AbstractObjectEditor.findViewFor(editor);
|
||||
if (editor.m_View != null) editor.m_View.repaint();
|
||||
if (editor.m_View != null) {
|
||||
editor.m_View.repaint();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Darn can't read the value...");
|
||||
}
|
||||
@ -256,17 +266,29 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac
|
||||
try {
|
||||
u = new Double(m_UpperLimit[j].getText()).doubleValue();
|
||||
} catch (NumberFormatException e) {}
|
||||
if (l < 0) l = 0;
|
||||
if (u > 1) u = 1;
|
||||
if (u < 0) u = 0;
|
||||
if (l > 1) l = 1;
|
||||
if (l < 0) {
|
||||
l = 0;
|
||||
}
|
||||
if (u > 1) {
|
||||
u = 1;
|
||||
}
|
||||
if (u < 0) {
|
||||
u = 0;
|
||||
}
|
||||
if (l > 1) {
|
||||
l = 1;
|
||||
}
|
||||
if (u < l) {
|
||||
double t = u;
|
||||
u = l; l = t;
|
||||
}
|
||||
|
||||
if (i > 0) tmpD[j] = RNG.randomDouble(l,u);
|
||||
else tmpD[j] = 1;
|
||||
if (i > 0) {
|
||||
tmpD[j] = RNG.randomDouble(l,u);
|
||||
}
|
||||
else {
|
||||
tmpD[j] = 1;
|
||||
}
|
||||
sum += tmpD[j];
|
||||
}
|
||||
for (int j = 0; j < tmpD.length; j++) {
|
||||
|
@ -118,7 +118,9 @@ public class MOCCOState {
|
||||
fitness.add(((AbstractEAIndividual)newPop[newPop.length-1].get(j)).getFitness());
|
||||
constraint.add(new Double(((AbstractEAIndividual)newPop[newPop.length-1].get(j)).getConstraintViolation()));
|
||||
}
|
||||
if (this.m_ObjectiveCache != null) this.m_ObjectiveCache.add(objectives);
|
||||
if (this.m_ObjectiveCache != null) {
|
||||
this.m_ObjectiveCache.add(objectives);
|
||||
}
|
||||
this.m_FitnessCache.add(fitness);
|
||||
this.m_ConstraintCache.add(constraint);
|
||||
}
|
||||
@ -153,7 +155,9 @@ public class MOCCOState {
|
||||
public Population getSelectedPopulations() {
|
||||
Population result = new Population();
|
||||
for (int i = 0; i < this.m_PopulationHistory.length; i++) {
|
||||
if (this.m_Use[i]) result.addPopulation(this.m_PopulationHistory[i]);
|
||||
if (this.m_Use[i]) {
|
||||
result.addPopulation(this.m_PopulationHistory[i]);
|
||||
}
|
||||
}
|
||||
this.m_CurrentProblem.evaluate(result);
|
||||
return result;
|
||||
@ -201,8 +205,12 @@ public class MOCCOState {
|
||||
if (tmpObj != null) {
|
||||
double[] tmoF = new double[tmpObj.length];
|
||||
for (int k = 0; k < tmpObj.length; k++) {
|
||||
if (this.m_PopulationHistory[i].get(j) == null) System.out.println("Individual "+i+" == null!");
|
||||
if (tmpObj[k] == null) System.out.println("Objective "+k+" == null!");
|
||||
if (this.m_PopulationHistory[i].get(j) == null) {
|
||||
System.out.println("Individual "+i+" == null!");
|
||||
}
|
||||
if (tmpObj[k] == null) {
|
||||
System.out.println("Objective "+k+" == null!");
|
||||
}
|
||||
if (((AbstractEAIndividual)this.m_PopulationHistory[i].get(j)).getData(tmpObj[k].getIdentName()) == null) {
|
||||
System.out.println("User Data "+k+" "+tmpObj[k].getIdentName()+" == null!");
|
||||
}
|
||||
@ -213,7 +221,9 @@ public class MOCCOState {
|
||||
fitness.add(((AbstractEAIndividual)this.m_PopulationHistory[i].get(j)).getFitness());
|
||||
constraint.add(new Double(((AbstractEAIndividual)this.m_PopulationHistory[i].get(j)).getConstraintViolation()));
|
||||
}
|
||||
if (this.m_ObjectiveCache != null) this.m_ObjectiveCache.add(objectives);
|
||||
if (this.m_ObjectiveCache != null) {
|
||||
this.m_ObjectiveCache.add(objectives);
|
||||
}
|
||||
this.m_FitnessCache.add(fitness);
|
||||
this.m_ConstraintCache.add(constraint);
|
||||
}
|
||||
|
@ -373,7 +373,9 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
public void plot1DFitnessPlot() {
|
||||
double xmin = 0, ymin = Double.POSITIVE_INFINITY, xmax = Double.NEGATIVE_INFINITY, ymax = Double.NEGATIVE_INFINITY, fitness;
|
||||
Population[] pops = this.m_MOCCO.m_State.m_PopulationHistory;
|
||||
if ((pops == null) || (pops.length < 1)) return;
|
||||
if ((pops == null) || (pops.length < 1)) {
|
||||
return;
|
||||
}
|
||||
GraphPointSet mySet;
|
||||
DPoint myPoint;
|
||||
DPointIcon icon;
|
||||
@ -390,13 +392,19 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
((InterfaceDPointWithContent)icon).setEAIndividual(pops[i].getBestEAIndividual());
|
||||
myPoint.setIcon(icon);
|
||||
mySet.addDPoint(myPoint);
|
||||
if (fitness < ymin) ymin = fitness;
|
||||
if (fitness > ymax) ymax = fitness;
|
||||
if (fitness < ymin) {
|
||||
ymin = fitness;
|
||||
}
|
||||
if (fitness > ymax) {
|
||||
ymax = fitness;
|
||||
}
|
||||
}
|
||||
mySet = new GraphPointSet(2, this.m_1DView);
|
||||
mySet.setConnectedMode(false);
|
||||
double yrange = ymax - ymin;
|
||||
if (yrange < 0.00001) yrange = 0.00001;
|
||||
if (yrange < 0.00001) {
|
||||
yrange = 0.00001;
|
||||
}
|
||||
mySet.addDPoint(0, ymin - 0.1 * yrange);
|
||||
mySet.addDPoint(pops.length+2, ymax + 0.1 * yrange);
|
||||
this.m_ViewPanel.validate();
|
||||
@ -413,13 +421,19 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
*/
|
||||
@Override
|
||||
public void individualSelected(AbstractEAIndividual indy) {
|
||||
if (indy.isMarked()) indy.unmark();
|
||||
if (indy.isMarked()) {
|
||||
indy.unmark();
|
||||
}
|
||||
else {
|
||||
if (this.m_SelectUniqueSolution) this.m_MOCCO.m_State.m_ParetoFront.unmarkAllIndividuals();
|
||||
if (this.m_SelectUniqueSolution) {
|
||||
this.m_MOCCO.m_State.m_ParetoFront.unmarkAllIndividuals();
|
||||
}
|
||||
indy.mark();
|
||||
}
|
||||
this.m_View.updateView();
|
||||
if (this.m_RefSolutionListener != null) this.m_RefSolutionListener.individualSelected(indy);
|
||||
if (this.m_RefSolutionListener != null) {
|
||||
this.m_RefSolutionListener.individualSelected(indy);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows to toggle unique selection mode
|
||||
@ -468,7 +482,9 @@ public class MOCCOViewer extends JPanel implements InterfaceRefSolutionListener,
|
||||
@Override
|
||||
public void refPointGiven(double[] point) {
|
||||
this.m_ReferencePoint = point;
|
||||
if (this.m_RefPointListener != null) this.m_RefPointListener.refPointGiven(point);
|
||||
if (this.m_RefPointListener != null) {
|
||||
this.m_RefPointListener.refPointGiven(point);
|
||||
}
|
||||
this.m_View.updateView();
|
||||
}
|
||||
|
||||
|
@ -157,12 +157,18 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
this.m_Area.removeAll();
|
||||
// first set the names of the objectives
|
||||
String[] tmpS = this.getAvailableObjectiveNames();
|
||||
if (tmpS.length != this.m_JCObjective1.getItemCount()) updateObjectiveComboBoxes();
|
||||
if (tmpS.length != this.m_JCObjective1.getItemCount()) {
|
||||
updateObjectiveComboBoxes();
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < tmpS.length; i++) {
|
||||
if (!tmpS[i].equalsIgnoreCase((String)this.m_JCObjective1.getItemAt(i))) equal = false;
|
||||
if (!tmpS[i].equalsIgnoreCase((String)this.m_JCObjective1.getItemAt(i))) {
|
||||
equal = false;
|
||||
}
|
||||
}
|
||||
if (!equal) {
|
||||
updateObjectiveComboBoxes();
|
||||
}
|
||||
if (!equal) updateObjectiveComboBoxes();
|
||||
if (this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem instanceof InterfaceMultiObjectiveDeNovoProblem) {
|
||||
//InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
String[] objectives = this.getAvailableObjectiveNames();
|
||||
@ -201,29 +207,49 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
for (int j = 0; j < ((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).size(); j++) {
|
||||
fitness = (double[])((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_FitnessCache.get(i)).get(j);
|
||||
myPoint = new DPoint(fitness[indexX], fitness[indexY]);
|
||||
if (((Double)((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0)
|
||||
if (((Double)((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0) {
|
||||
myPoint.setIcon(new Chart2DDPointIconCross());
|
||||
else
|
||||
}
|
||||
else {
|
||||
myPoint.setIcon(new Chart2DDPointIconPoint());
|
||||
}
|
||||
mySet.addDPoint(myPoint);
|
||||
if (fitness[indexX] < xmin) xmin = fitness[indexX];
|
||||
if (fitness[indexX] > xmax) xmax = fitness[indexX];
|
||||
if (fitness[indexY] < ymin) ymin = fitness[indexY];
|
||||
if (fitness[indexY] > ymax) ymax = fitness[indexY];
|
||||
if (fitness[indexX] < xmin) {
|
||||
xmin = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexX] > xmax) {
|
||||
xmax = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexY] < ymin) {
|
||||
ymin = fitness[indexY];
|
||||
}
|
||||
if (fitness[indexY] > ymax) {
|
||||
ymax = fitness[indexY];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < ((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).size(); j++) {
|
||||
fitness = (double[])((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ObjectiveCache.get(i)).get(j);
|
||||
myPoint = new DPoint(fitness[indexX], fitness[indexY]);
|
||||
if (((Double)((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0)
|
||||
if (((Double)((ArrayList)this.m_MOCCOViewer.m_MOCCO.m_State.m_ConstraintCache.get(i)).get(j)).doubleValue() == 0) {
|
||||
myPoint.setIcon(new Chart2DDPointIconCross());
|
||||
else
|
||||
}
|
||||
else {
|
||||
myPoint.setIcon(new Chart2DDPointIconPoint());
|
||||
}
|
||||
mySet.addDPoint(myPoint);
|
||||
if (fitness[indexX] < xmin) xmin = fitness[indexX];
|
||||
if (fitness[indexX] > xmax) xmax = fitness[indexX];
|
||||
if (fitness[indexY] < ymin) ymin = fitness[indexY];
|
||||
if (fitness[indexY] > ymax) ymax = fitness[indexY];
|
||||
if (fitness[indexX] < xmin) {
|
||||
xmin = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexX] > xmax) {
|
||||
xmax = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexY] < ymin) {
|
||||
ymin = fitness[indexY];
|
||||
}
|
||||
if (fitness[indexY] > ymax) {
|
||||
ymax = fitness[indexY];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,15 +275,25 @@ public class ParetoFrontView2D extends JPanel implements InterfaceParetoFrontVie
|
||||
}
|
||||
point = new DPoint(fitness[indexX], fitness[indexY]);
|
||||
icon = new Chart2DDPointContentSelectable();
|
||||
if (this.m_MOCCOViewer.m_RefSolutionSelectable) ((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_MOCCOViewer);
|
||||
if (this.m_MOCCOViewer.m_RefSolutionSelectable) {
|
||||
((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_MOCCOViewer);
|
||||
}
|
||||
((InterfaceDPointWithContent)icon).setProblem(this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem);
|
||||
((InterfaceDPointWithContent)icon).setEAIndividual((AbstractEAIndividual)pf.get(i));
|
||||
point.setIcon(icon);
|
||||
mySet.addDPoint(point);
|
||||
if (fitness[indexX] < xmin) xmin = fitness[indexX];
|
||||
if (fitness[indexX] > xmax) xmax = fitness[indexX];
|
||||
if (fitness[indexY] < ymin) ymin = fitness[indexY];
|
||||
if (fitness[indexY] > ymax) ymax = fitness[indexY];
|
||||
if (fitness[indexX] < xmin) {
|
||||
xmin = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexX] > xmax) {
|
||||
xmax = fitness[indexX];
|
||||
}
|
||||
if (fitness[indexY] < ymin) {
|
||||
ymin = fitness[indexY];
|
||||
}
|
||||
if (fitness[indexY] > ymax) {
|
||||
ymax = fitness[indexY];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,9 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
} else {
|
||||
int index = 0;
|
||||
for (int i = 0; i < this.m_Obj1; i++) {
|
||||
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) index++;
|
||||
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
// System.out.println("obj 1 is accessing fitness of " + tmpObj[this.m_Obj1].getIdentName() + " using " +index);
|
||||
@ -81,7 +83,9 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
} else {
|
||||
int index = 0;
|
||||
for (int i = 0; i < this.m_Obj2; i++) {
|
||||
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) index++;
|
||||
if (!tmpObj[i].getOptimizationMode().equalsIgnoreCase("Constraint")) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// System.out.println("obj 2 is accessing fitness of " + tmpObj[this.m_Obj2].getIdentName() + " using " +index);
|
||||
// System.out.println(" fitness.length = " + indy.getFitness().length);
|
||||
@ -123,21 +127,35 @@ class SimpleView extends JComponent implements InterfaceRefPointListener {
|
||||
plotValue = this.fetchPlotValueFor((AbstractEAIndividual)pf.get(i));
|
||||
point = new DPoint(plotValue[0], plotValue[1]);
|
||||
icon = new Chart2DDPointContentSelectable();
|
||||
if (this.m_Dad.m_MOCCOViewer.m_RefSolutionSelectable) ((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_Dad.m_MOCCOViewer);
|
||||
if (this.m_Dad.m_MOCCOViewer.m_RefSolutionSelectable) {
|
||||
((Chart2DDPointContentSelectable)icon).addSelectionListener(this.m_Dad.m_MOCCOViewer);
|
||||
}
|
||||
((InterfaceDPointWithContent)icon).setProblem(this.m_Dad.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem);
|
||||
((InterfaceDPointWithContent)icon).setEAIndividual((AbstractEAIndividual)pf.get(i));
|
||||
point.setIcon(icon);
|
||||
mySet.addDPoint(point);
|
||||
if (plotValue[0] < xmin) xmin = plotValue[0];
|
||||
if (plotValue[0] > xmax) xmax = plotValue[0];
|
||||
if (plotValue[1] < ymin) ymin = plotValue[1];
|
||||
if (plotValue[1] > ymax) ymax = plotValue[1];
|
||||
if (plotValue[0] < xmin) {
|
||||
xmin = plotValue[0];
|
||||
}
|
||||
if (plotValue[0] > xmax) {
|
||||
xmax = plotValue[0];
|
||||
}
|
||||
if (plotValue[1] < ymin) {
|
||||
ymin = plotValue[1];
|
||||
}
|
||||
if (plotValue[1] > ymax) {
|
||||
ymax = plotValue[1];
|
||||
}
|
||||
}
|
||||
mySet = new GraphPointSet(0, this.m_Area);
|
||||
mySet.setConnectedMode(false);
|
||||
double xrange = (xmax - xmin), yrange = (ymax - ymin);
|
||||
if (xrange < 0.0000001) xrange = 0.0000001;
|
||||
if (yrange < 0.0000001) yrange = 0.0000001;
|
||||
if (xrange < 0.0000001) {
|
||||
xrange = 0.0000001;
|
||||
}
|
||||
if (yrange < 0.0000001) {
|
||||
yrange = 0.0000001;
|
||||
}
|
||||
if ((new Double(xrange)).isNaN()) {
|
||||
mySet.addDPoint(0, 0);
|
||||
mySet.addDPoint(1, 1);
|
||||
@ -335,8 +353,12 @@ public class ParetoFrontViewScatterPlot extends JPanel implements InterfaceParet
|
||||
|
||||
// first set the names of the objectives
|
||||
InterfaceOptimizationObjective[] tmp = ((InterfaceMultiObjectiveDeNovoProblem)this.m_MOCCOViewer.m_MOCCO.m_State.m_CurrentProblem).getProblemObjectives();
|
||||
if (this.m_Scatter == null) this.makeScatter();
|
||||
if (this.m_Scatter.length != tmp.length) this.makeScatter();
|
||||
if (this.m_Scatter == null) {
|
||||
this.makeScatter();
|
||||
}
|
||||
if (this.m_Scatter.length != tmp.length) {
|
||||
this.makeScatter();
|
||||
}
|
||||
if (this.m_Scatter != null) {
|
||||
for (int i = 0; i < tmp.length; i++) {
|
||||
for (int j = 0; j < tmp.length; j++) {
|
||||
|
@ -39,11 +39,15 @@ public abstract class AbstractArchiving implements InterfaceArchiving, java.io.S
|
||||
public boolean isDominant(AbstractEAIndividual indy, Population pop) {
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
if (!(indy.equals(pop.get(i))) && (((AbstractEAIndividual)pop.get(i)).isDominatingDebConstraints(indy))) return false;
|
||||
if (!(indy.equals(pop.get(i))) && (((AbstractEAIndividual)pop.get(i)).isDominatingDebConstraints(indy))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
if (!(indy.equals(pop.get(i))) && (((AbstractEAIndividual)pop.get(i)).isDominating(indy))) return false;
|
||||
if (!(indy.equals(pop.get(i))) && (((AbstractEAIndividual)pop.get(i)).isDominating(indy))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -63,8 +67,12 @@ public abstract class AbstractArchiving implements InterfaceArchiving, java.io.S
|
||||
tmpFitness = ((AbstractEAIndividual)archive.get(i)).getFitness();
|
||||
try {
|
||||
for (int j = 0; j < indyFitness.length; j++) {
|
||||
if (indyFitness[j] <= tmpFitness[j]) isDominating &= true;
|
||||
else isDominating &= false;
|
||||
if (indyFitness[j] <= tmpFitness[j]) {
|
||||
isDominating &= true;
|
||||
}
|
||||
else {
|
||||
isDominating &= false;
|
||||
}
|
||||
}
|
||||
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||
//System.out.println("-------addIndividualToArchive-------("+indyFitness.length+"/"+tmpFitness.length+")");
|
||||
@ -144,7 +152,9 @@ public abstract class AbstractArchiving implements InterfaceArchiving, java.io.S
|
||||
myPoint.setIcon(icons[index]);
|
||||
mySet.addDPoint(myPoint);
|
||||
}
|
||||
if (lastValue != null) plot.setConnectedPoint(lastValue[0], lastValue[1], 20000+p);
|
||||
if (lastValue != null) {
|
||||
plot.setConnectedPoint(lastValue[0], lastValue[1], 20000+p);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,9 @@ public class ArchivingAllDominating extends AbstractArchiving implements java.io
|
||||
@Override
|
||||
public void addElementsToArchive(Population pop) {
|
||||
|
||||
if (pop.getArchive() == null) pop.SetArchive(new Population());
|
||||
if (pop.getArchive() == null) {
|
||||
pop.SetArchive(new Population());
|
||||
}
|
||||
// System.out.println("addElementsToArchive");
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
|
@ -46,7 +46,9 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
public void addElementsToArchive(Population pop) {
|
||||
Population archive;
|
||||
double[] tmpD;
|
||||
if (pop.getArchive() == null) pop.SetArchive(new Population());
|
||||
if (pop.getArchive() == null) {
|
||||
pop.SetArchive(new Population());
|
||||
}
|
||||
|
||||
// First merge the current population and the archive
|
||||
Population tmpPop = new Population();
|
||||
|
@ -34,7 +34,9 @@ public class ArchivingNSGA extends AbstractArchiving implements java.io.Serializ
|
||||
@Override
|
||||
public void addElementsToArchive(Population pop) {
|
||||
|
||||
if (pop.getArchive() == null) pop.SetArchive(new Population());
|
||||
if (pop.getArchive() == null) {
|
||||
pop.SetArchive(new Population());
|
||||
}
|
||||
|
||||
// test for each element in population if it
|
||||
// is dominating a element in the archive
|
||||
|
@ -35,7 +35,9 @@ public class ArchivingNSGAII extends ArchivingNSGA implements java.io.Serializab
|
||||
@Override
|
||||
public void addElementsToArchive(Population pop) {
|
||||
|
||||
if (pop.getArchive() == null) pop.SetArchive(new Population());
|
||||
if (pop.getArchive() == null) {
|
||||
pop.SetArchive(new Population());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (this.m_Debug && false) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user