Final renaming (doc), slight clean-up and refactoring.

This commit is contained in:
Marcel Kronfeld 2008-04-29 09:15:23 +00:00
parent a707de1b4b
commit 3013e905d6
25 changed files with 451 additions and 184 deletions

View File

@ -26,6 +26,7 @@
<!-- SET THE DIRECTORY PROPERTIES -->
<property name="source.directory" value="src" />
<property name="ant.directory" value="ant" />
<property name="build.directory" value="build" />
<property name="distribution.directory" value="dist" />
<property name="resources.directory" value="resources" />
@ -33,6 +34,10 @@
<property name="binary.distribution.directory" value="${distribution.directory}/bin-dist" />
<property name="javadoc.directory" value="doc/api" />
<property name="library.directory" value="lib" />
<property name="debug.flag" value="true" />
<property name="JE2Probs.directory" value="../JE2Probs" />
<property name="JE2ESModel.directory" value="../JE2ESModel" />
<property name="JE2Research.directory" value="../JE2Research" />
<!-- SET THE BINARY LIBRARIES PROPERTIES -->
<property name="check.libraries.ant" value="ant/check.xml" />
@ -170,13 +175,15 @@
<target name="compileAll" depends="usage, update.libraries" description="Update libraries and compile the project.">
<antcall target="compile">
</antcall>
<antcall target="compileProbs">
</antcall>
</target>
<target name="compileInfo" unless="silent">
<echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
<echo message="JAVA_HOME is set to = ${env.JAVA_HOME}"/>
<echo message="You are using JDK version ${ant.java.version}"/>
<echo message="currently JDK version 1.3 is recomended!"/>
<echo message="currently JDK version 1.5 is recomended!"/>
<echo message=""/>
<echo message="use 'ant compileAll' - to compile all java sources (+ WSI)."/>
<echo message="use 'ant compile' - to compile only the java sources (faster)."/>
@ -184,7 +191,7 @@
<target name="compile" depends="usage, init, check, compileInfo" description="Compiles the project." >
<!-- COMPILE PROJECT -->
<javac destdir="${build.directory}" optimize="on" deprecation="on" nowarn="on">
<javac destdir="${build.directory}" optimize="on" deprecation="on" nowarn="on" debug="${debug.flag}" >
<src path="${source.directory}" />
<exclude name="ant/**" />
<exclude name="build/**" />
@ -212,8 +219,30 @@
<copy todir="${build.directory}/resources">
<fileset dir="${resources.directory}" includes="**/*" />
</copy>
<copy todir="${JE2Probs.directory}/${build.directory}/resources">
<fileset dir="${JE2Probs.directory}/${resources.directory}" includes="**/*" />
</copy>
<copy todir="${JE2ESModel.directory}/${build.directory}/resources">
<fileset dir="${JE2ESModel.directory}/${resources.directory}" includes="**/*" />
</copy>
<copy todir="${JE2Research.directory}/${build.directory}/resources">
<fileset dir="${JE2Research.directory}/${resources.directory}" includes="**/*" />
</copy>
</target>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Compile JE2Probs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<target name="compileProbs" depends="usage, init, compileInfo" description="Compiles the Probs project." >
<!-- COMPILE PROBS PROJECT -->
<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2Probs.directory}" target="compile">
<property name="silent" value="true"/>
</ant>
</target>
<!-- =================================================================== -->
<!-- Jars all classes into one jar file -->
<!-- =================================================================== -->
@ -265,7 +294,7 @@
<mkdir dir="${bin.dist.dir}" />
<mkdir dir="${bin.dist.dir}/${library.directory}" />
<delete>
<fileset dir="${bin.dist.dir}/${library.directory}" includes="*EvA*jar" />
<fileset dir="${bin.dist.dir}/${library.directory}" includes="*EvA2Base*jar" />
</delete>
<jar jarfile="${bin.dist.dir}/${library.directory}/EvA2Base.jar" basedir="${build.directory}" >

BIN
resources/images/icon4.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

165
resources/lgpl-3.0.txt Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -76,7 +76,7 @@ import wsi.ra.tool.BasicResourceLoader;
public class EvAClient implements RemoteStateListener, Serializable {
public static final String EVA_PROPERTY_FILE = "resources/EvA2.props";
private static Properties EVA_PROPERTIES;
public static final String iconLocation = "resources/images/icon3.gif";
public static final String iconLocation = "resources/images/icon4.gif";
private static final String splashLocation = "resources/images/splashScreen2.png";
private static final String infoTitle = "EvA2 Information";
final int splashScreenTime = 1500;
@ -478,6 +478,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
}
public static String getProductName() {
return m_ProductName;
}
protected void logMessage(String msg) {
if (TRACE || m_LogPanel == null) System.out.println(msg);
if (m_LogPanel != null) m_LogPanel.logMessage(msg);

View File

@ -1,5 +1,7 @@
package eva2.gui;
import eva2.tools.ReflectPackage;
/**
* Created by IntelliJ IDEA.
* User: streiche
@ -13,16 +15,43 @@ public class PropertyFilePath implements java.io.Serializable {
public String FilePath = "";
public String FileExtension = "";
public PropertyFilePath(String s) {
/**
* Constructor setting the absolute path. F
*
* @param s
*/
private PropertyFilePath(String s) {
this.setCompleteFilePath(s);
}
public PropertyFilePath(PropertyFilePath d) {
this.FileName = d.FileName;
this.FilePath = d.FilePath;
this.FileExtension = d.FileExtension;
}
/**
* Get an instance by an absolute path.
*
* @param path
* @return
*/
public static PropertyFilePath getFilePathAbsolute(String path) {
return new PropertyFilePath(path);
}
/**
* Get an instance by a relative path.
*
* @param relPath
* @return
*/
public static PropertyFilePath getFilePathFromResource(String relPath) {
String fName = ReflectPackage.getResourcePathFromCP(relPath);
if (fName == null) return null;
else return new PropertyFilePath(fName);
}
public Object clone() {
return (Object) new PropertyFilePath(this);
}

View File

@ -26,6 +26,9 @@ public class MutateESSuccessRule extends MutateESStandard implements InterfaceMu
protected double m_SuccessRate = 0.2;
protected double m_Alpha = 1.2;
public MutateESSuccessRule() {
}
public MutateESSuccessRule(MutateESSuccessRule mutator) {
this.m_MutationStepSize = mutator.m_MutationStepSize;
this.m_SuccessRate = mutator.m_SuccessRate;

View File

@ -20,10 +20,7 @@ import eva2.server.go.tools.FileLoader;
* To change this template use File | Settings | File Templates.
*/
public class MetricD1ApproxParetoFront implements eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
private String base = System.getProperty("user.dir");
private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_250.txt");
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("resources/MOPReference/T1_250.txt");
private String[] m_Titles;
private double[][] m_Reference;

View File

@ -21,9 +21,9 @@ import eva2.server.go.tools.FileLoader;
*/
public class MetricD1TrueParetoFront implements eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
private String base = System.getProperty("user.dir");
private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_250.txt");
// private String base = System.getProperty("user.dir");
// private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("resources/MOPReference/T1_250.txt");
private String[] m_Titles;
private double[][] m_Reference;

View File

@ -24,10 +24,7 @@ import eva2.server.go.tools.FileLoader;
* To change this template use File | Settings | File Templates.
*/
public class MetricErrorRatio implements eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
private String base = System.getProperty("user.dir");
private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_250.txt");
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("resources/MOPReference/T1_250.txt");
private double m_Epsilon = 0.0001;
private String[] m_Titles;
private double[][] m_Reference;

View File

@ -19,10 +19,7 @@ import eva2.server.go.tools.FileLoader;
* To change this template use File | Settings | File Templates.
*/
public class MetricMaximumParetoFrontError implements eva2.server.go.operators.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
private String base = System.getProperty("user.dir");
private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_250.txt");
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("resources/MOPReference/T1_250.txt");
private String[] m_Titles;
private double[][] m_Reference;

View File

@ -20,11 +20,8 @@ import eva2.server.go.tools.FileLoader;
* To change this template use File | Settings | File Templates.
*/
public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io.Serializable {
private double[][] m_ObjectiveSpaceRange;
private String base = System.getProperty("user.dir");
private String FS = System.getProperty("file.separator");
private PropertyFilePath m_InputFilePath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_250.txt");
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("resources/MOPReference/T1_250.txt");
private String[] m_Titles;
private double[][] m_Reference;
private double m_ReferenceSMetric = -1;
@ -42,8 +39,6 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
}
}
this.m_InputFilePath = b.m_InputFilePath;
this.base = System.getProperty("user.dir");
this.FS = System.getProperty("file.separator");
if (b.m_Titles != null) {
this.m_Titles = new String[b.m_Titles.length];
System.arraycopy(b.m_Titles, 0, this.m_Titles, 0, this.m_Titles.length);

View File

@ -51,7 +51,17 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
* @return the problem dimension
*/
public abstract int getProblemDimension();
/**
* Initialize a single individual with index k in the
* initPopulation cycle.
* @param k
* @param indy
*/
protected void initIndy(int k, AbstractEAIndividual indy) {
indy.init(this);
}
@Override
public void initPopulation(Population population) {
AbstractEAIndividual tmpIndy;
@ -61,7 +71,7 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
for (int i = 0; i < population.getPopulationSize(); i++) {
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
tmpIndy.init(this);
initIndy(i, tmpIndy);
population.add(tmpIndy);
}
// population init must be last

View File

@ -36,25 +36,6 @@ public class B1Problem extends AbstractProblemBinary implements java.io.Serializ
return (Object) new B1Problem(this);
}
/** This method inits a given population
* @param population The populations that is to be inited
*/
public void initPopulation(Population population) {
AbstractEAIndividual tmpIndy;
population.clear();
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(this.m_ProblemDimension);
for (int i = 0; i < population.getPopulationSize(); i++) {
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
tmpIndy.init(this);
population.add(tmpIndy);
}
// population init must be last
// it set's fitcalls and generation to zero
population.init();
}
/** This is a simple method that evaluates a given Individual. The fitness
* values of the individual will be set inside this method.
* @param b The BitSet that is to be evaluated.

View File

@ -2,14 +2,13 @@ package eva2.server.go.problems;
import java.util.*;
import java.util.BitSet;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.individuals.GAIndividualBinaryData;
import eva2.server.go.individuals.InterfaceDataTypeBinary;
import eva2.server.go.populations.Population;
import eva2.server.go.strategies.InterfaceOptimizer;
import wsi.ra.math.RNG;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.individuals.InterfaceDataTypeBinary;
import eva2.server.go.strategies.InterfaceOptimizer;
import eva2.server.go.problems.AbstractProblemBinary;
/**
* Created by IntelliJ IDEA.
@ -18,7 +17,7 @@ import wsi.ra.math.RNG;
* Time: 15:12:46
* To change this template use Options | File Templates.
*/
public class BKnapsackProblem extends AbstractOptimizationProblem implements java.io.Serializable {
public class BKnapsackProblem extends AbstractProblemBinary implements java.io.Serializable {
private int m_Limit = 5000;
private double m_Punish = 2.0;
@ -128,12 +127,12 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
{392,-386}};
public BKnapsackProblem() {
this.m_Template = new GAIndividualBinaryData();
super();
}
public BKnapsackProblem(BKnapsackProblem b) {
//AbstractOptimizationProblem
if (b.m_Template != null)
this.m_Template = (AbstractEAIndividual)((AbstractEAIndividual)b.m_Template).clone();
cloneObjects(b);
// BKnapsackProblem
this.m_Limit = b.m_Limit;
this.m_Punish = b.m_Punish;
@ -141,6 +140,10 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
this.m_Lamarkism = b.m_Lamarkism;
}
public int getProblemDimension() {
return items.length;
}
/** This method returns a deep clone of the problem.
* @return the clone
*/
@ -154,45 +157,28 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
// nothing to init here
}
/** This method inits a given population
* @param population The populations that is to be inited
*/
public void initPopulation(Population population) {
AbstractEAIndividual tmpIndy;
protected void initIndy(int k, AbstractEAIndividual indy) {
indy.init(this);
if (RNG.flipCoin(this.m_ProblemSpecificInit)) {
BitSet tmpSet = new BitSet();
tmpSet.clear();
population.clear();
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(items.length);
for (int i = 0; i < population.getPopulationSize(); i++) {
tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone();
tmpIndy.init(this);
if (RNG.flipCoin(this.m_ProblemSpecificInit)) {
BitSet tmpSet = new BitSet();
tmpSet.clear();
while (evaluate(tmpSet, items.length)[1] > 0) {
tmpSet.set(RNG.randomInt(0,items.length-1));
}
((InterfaceDataTypeBinary)tmpIndy).SetBinaryDataLamarkian(tmpSet);
}
population.add(tmpIndy);
}
// population init must be last
// it set's fitcalls and generation to zero
population.init();
while (eval(tmpSet)[1] > 0) {
tmpSet.set(RNG.randomInt(0,items.length-1));
}
((InterfaceDataTypeBinary)indy).SetBinaryDataLamarkian(tmpSet);
}
}
/** This method evaluates a single individual and sets the fitness values
* @param individual The individual that is to be evalutated
*/
public void evaluate(AbstractEAIndividual individual) {
BitSet tmpBitSet;
double[] result;
InterfaceDataTypeBinary tmpIndy;
tmpIndy = (InterfaceDataTypeBinary) individual;
tmpBitSet = tmpIndy.getBinaryData();
result = this.evaluate(tmpBitSet, tmpIndy.size());
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
result = this.eval(tmpBitSet);
if (RNG.flipCoin(this.m_LocalSearch)) {
// first remove surplus assets
while (result[1] > 0) {
@ -210,7 +196,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
}
// remove the weakest
tmpBitSet.clear(weakest);
result = this.evaluate(tmpBitSet, tmpIndy.size());
result = this.eval(tmpBitSet);
}
// now lets see if we can replace some guy with a more efficient one
int weakest = tmpBitSet.nextSetBit(0);
@ -228,7 +214,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
}
tmpBitSet.clear(weakest);
result = this.evaluate(tmpBitSet, tmpIndy.size());
result = this.eval(tmpBitSet);
int weight = 0;
for (int i = 0; i < items.length; i++) {
if (tmpBitSet.get(i)) weight += items[i][0];
@ -244,11 +230,11 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
}
}
if (stronger >= 0) tmpBitSet.set(stronger);
result = this.evaluate(tmpBitSet, tmpIndy.size());
result = this.eval(tmpBitSet);
}
if (this.m_Lamarkism) {
tmpIndy.SetBinaryDataLamarkian(tmpBitSet);
((InterfaceDataTypeBinary) individual).SetBinaryDataLamarkian(tmpBitSet);
}
}
result[0] += 5100;
@ -261,9 +247,11 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
* @param l The length of the BitSet.
* @return Double[]
*/
public double[] evaluate(BitSet b, int l) {
public double[] eval(BitSet b) {
double[] result = new double[3];
int l = items.length;
if (getProblemDimension() != l) System.err.println("Error in BKnapsack!");
result[0] = 0;
result[1] = 0; // the weight exceed
result[2] = 0; // net worth
@ -292,7 +280,7 @@ public class BKnapsackProblem extends AbstractOptimizationProblem implements jav
tmpIndy = (InterfaceDataTypeBinary) individual;
tmpBitSet = tmpIndy.getBinaryData();
report = this.evaluate(tmpBitSet, tmpIndy.size());
report = this.eval(tmpBitSet);
result += individual.getStringRepresentation() + "\n";
result += "Is worth: " + Math.abs(report[2]) + " and ";
if (report[1] == 0) result += "does not exceed the weight limit!";

View File

@ -13,7 +13,6 @@ import eva2.gui.BeanInspector;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.individuals.ESIndividualDoubleData;
import eva2.server.go.individuals.InterfaceDataTypeDouble;
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
import eva2.server.go.operators.postprocess.InterfacePostProcessParams;
import eva2.server.go.operators.postprocess.PostProcess;
import eva2.server.go.operators.postprocess.PostProcessParams;
@ -38,7 +37,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
public static boolean hideFromGOE = true;
private F1Problem f1 = new F1Problem(); // TODO
// private F1Problem f1 = new F1Problem(); // TODO
// transient private double[] currArray = null;
// private String mtCmd = null;
@ -194,11 +193,11 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
public double[] eval(double[] x) {
log("evaluating " + BeanInspector.toString(x) + "\n");
double[] res = handler.requestEval(this, x);
double diff = PhenotypeMetric.euclidianDistance(res, f1.eval(x));
log("result: " + BeanInspector.toString(res) + " compared to " + BeanInspector.toString(f1.eval(x)) + "\n");
if (diff != 0) {
log("!!! diff is " + diff + "\n");
}
// double diff = PhenotypeMetric.euclidianDistance(res, f1.eval(x));
// log("result: " + BeanInspector.toString(res) + " compared to " + BeanInspector.toString(f1.eval(x)) + "\n");
// if (diff != 0) {
// log("!!! diff is " + diff + "\n");
// }
return res;
// synchronized (this) {

View File

@ -299,7 +299,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
int points = 500;
String base = System.getProperty("user.dir");
String FS = System.getProperty("file.separator");
PropertyFilePath fileOutPath = new PropertyFilePath(base+FS+"resources"+FS+"MOPReference"+FS+"T1_"+points+".txt");
PropertyFilePath fileOutPath = PropertyFilePath.getFilePathFromResource("resources/MOPReference"+FS+"T1_"+points+".txt");
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(fileOutPath.getCompleteFilePath()));

View File

@ -7,7 +7,7 @@ import eva2.server.go.InterfacePopulationChangedEventListener;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.individuals.InterfaceGAIndividual;
import eva2.server.go.operators.selection.InterfaceSelection;
import eva2.server.go.operators.selection.SelectBest;
import eva2.server.go.operators.selection.SelectBestSingle;
import eva2.server.go.operators.selection.SelectRandom;
import eva2.server.go.populations.PBILPopulation;
import eva2.server.go.populations.Population;
@ -38,7 +38,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
private Population m_Population = new Population();
private InterfaceOptimizationProblem m_Problem = new B1Problem();
private InterfaceSelection m_RecombSelectionOperator = new SelectRandom();
private InterfaceSelection m_PopulSelectionOperator = new SelectBest();
private InterfaceSelection m_PopulSelectionOperator = new SelectBestSingle();
transient private String m_Identifier = "";
transient private InterfacePopulationChangedEventListener m_Listener;

View File

@ -19,6 +19,7 @@ import eva2.server.go.operators.cluster.ClusteringDensityBased;
import eva2.server.go.operators.cluster.InterfaceClustering;
import eva2.server.go.operators.mutation.InterfaceMutation;
import eva2.server.go.operators.mutation.MutateESGlobal;
//import eva2.server.go.populations.Distraction;
import eva2.server.go.populations.Population;
import eva2.server.go.problems.B1Problem;
import eva2.server.go.problems.Interface2DBorderProblem;
@ -65,7 +66,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
private int m_PopulationSize = 50;
private int convergedCnt = 0;
private static boolean TRACE = true;
private static boolean TRACE = false;
private int m_ShowCycle = 100;
transient private TopoPlot m_Topology;
private int haltingWindow = 15;
@ -586,12 +587,10 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
this.m_Population.addPopulation((Population)this.m_Species.get(i));
}
if (TRACE) System.out.println("Population size: " + this.m_Population.size());
if (TRACE) {
// for (int i=0; i<m_Species.size(); i++) {
// System.out.print("distraction center at " + BeanInspector.toString(m_Species.get(i).getDistractionCenter()));
// System.out.println(", strength " + m_Species.get(i).getDistractionStrength());
// }
}
// if (TRACE) {
// Distraction distr = new Distraction(5., 0, m_Species);
// if (m_Undifferentiated.size()>0) distr.calcDistractionFor(m_Undifferentiated.getBestEAIndividual());
// }
this.firePropertyChangedEvent("NextGenerationPerformed");
}

View File

@ -10,6 +10,7 @@ import eva2.server.go.problems.AbstractOptimizationProblem;
import eva2.server.go.problems.F1Problem;
import eva2.server.go.problems.InterfaceOptimizationProblem;
import wsi.ra.math.RNG;
import eva2.tools.EVAERROR;
import eva2.tools.SelectedTag;
import eva2.tools.Tag;
@ -241,7 +242,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
indy1 = (InterfaceESIndividual)pop.get(RNG.randomInt(0, pop.size()-1));
indy2 = (InterfaceESIndividual)pop.get(RNG.randomInt(0, pop.size()-1));
} catch (java.lang.ClassCastException e) {
System.out.println("Differential Evolution currently requires InterfaceESIndividual as basic data type!");
EVAERROR.errorMsgOnce("Differential Evolution currently requires InterfaceESIndividual as basic data type!");
}
xk = indy1.getDGenotype();
xl = indy2.getDGenotype();

View File

@ -21,7 +21,7 @@ import wsi.ra.jproxy.RMIServer;
/** The one and only island model for parallelization. Since parallelization based
* on the RMIProxyRemoteThread is on the one hand much slower than benchmark function
* evaluation and on the other hand the GUI based distribution scheme is rather prone
* to config errors (the correct ssh version is required, the JOpt.jar needs to be in
* to config errors (the correct ssh version is required, the jar needs to be in
* the working dir and possible problem data must be on the servers to) an implicit
* island-model has been implemented too to allow fast and reliabel computation.
* This is still usefull, since it is less prone to premature convergence and also

View File

@ -146,7 +146,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
public static int[] strategies = new int[10]; // Just for information
public static int[] status = new int[9]; // Just for information
public static boolean testBC = false; // TODO project to JOpt
public static boolean testBC = false; // TODO project to EvA2
public static int adaptOption = 2;
public static double blind=0; // 0.5 //"Blind" move for very good particles, with a probability Tribes.blind
public static boolean repel=false; // If 1, use a "repelling" strategy (see moveExplorer() )
@ -625,7 +625,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
/**
* As TRIBES manages an own structured set of particles (the list of Tribes containing explorers
* and memories), the setPopulation method is only telling Tribes the range
* of the indiviuals in the beginning of the run, the indiviudals will be discarded.
* of the indiviuals in the beginning of the run, the individuals will be discarded.
*/
public void setPopulation(Population pop) {
if (pop == null) return;

View File

@ -2,11 +2,10 @@ package eva2.server.modules;
import java.io.Serializable;
import eva2.gui.BeanInspector;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.InterfacePopulationChangedEventListener;
import eva2.server.go.individuals.GAIndividualDoubleData;
import eva2.server.go.operators.terminators.EvaluationTerminator;
import eva2.server.go.problems.B1Problem;
import eva2.server.go.problems.F1Problem;
import eva2.server.go.strategies.GeneticAlgorithm;
import eva2.tools.Serializer;
@ -45,7 +44,8 @@ public class GOParameters extends AbstractGOParameters implements InterfaceGOPar
*
*/
public GOParameters() {
super(new GeneticAlgorithm(), new B1Problem(), new EvaluationTerminator(1000));
super(new GeneticAlgorithm(), new F1Problem(), new EvaluationTerminator(1000));
((F1Problem)m_Problem).setEAIndividual(new GAIndividualDoubleData());
}
/**

View File

@ -195,7 +195,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
this.goParams.getOptimizer().optimize();
// registerPopulationStateChanged *SHOULD* be fired by the optimizer or resp. the population
// as we are event listener
// System.out.println(this.goParams.getOptimizer().getPopulation().getIndyList());
//System.out.println(this.goParams.getOptimizer().getPopulation().getIndyList());
} while (isOptRunning() && !this.goParams.getTerminator().isTerminated(this.goParams.getOptimizer().getPopulation()));
runCounter++;

View File

@ -3,15 +3,18 @@ package eva2.tools;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import wsi.ra.tool.BasicResourceLoader;
//import wsi.ra.tool.BasicResourceLoader;
/**
@ -238,74 +241,117 @@ public class ReflectPackage {
classPath = System.getProperty("java.class.path",".");
if (useFilteredClassPath) {
try {
String[] pathElements = getClassPathElements();
File f;
ArrayList<String> valids = new ArrayList<String>(pathElements.length);
for (int i=0; i<pathElements.length; i++) {
// System.err.println(pathElements[i]);
f = new File(pathElements[i]);
// if (f.canRead()) {valids.add(pathElements[i]);}
if (f.exists() && f.canRead()) {
valids.add(pathElements[i]);
}
}
// dynCP = valids.toArray(dynCP); // this causes Matlab to crash meanly.
dynCP = new String[valids.size()];
for (int i=0; i<valids.size(); i++) dynCP[i] = valids.get(i);
dynCP = getValidCPArray();
} catch (Exception e) {
System.err.println(e.getMessage());
}
} else dynCP = getClassPathElements();
}
// dynCP = System.getProperty("java.class.path",".").split(File.pathSeparator);
if (TRACE) System.out.println("classpath is " + classPath);
// System.err.println("no of path elements is " + dynCP.length);
// if (usePathMap) {
// System.err.println("Checking for " + pckg);
// ArrayList<String> pathes = pathMap.get(pckg);
// System.err.println("stored objects: " + ((pathes != null) ? pathes.size() : 0));
// if (pathes == null) {
// pathes = new ArrayList<String>();
// for (int i=0; i<dynCP.length; i++) {
// int added = 0;
// if (dynCP[i].endsWith(".jar")) {
// added = getClassesFromJarFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
// } else {
// added = getClassesFromFilesFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
// }
// if (added > 0) pathes.add(dynCP[i]);
// }
// pathMap.put(pckg, pathes);
// } else {
// for (int i=0; i<pathes.size(); i++) {
// System.err.println("reusing " + pathes.get(i));
// if (pathes.get(i).endsWith(".jar")) getClassesFromJarFltr(set, pathes.get(i), pckg, includeSubs, reqSuperCls);
// else getClassesFromFilesFltr(set, pathes.get(i), pckg, includeSubs, reqSuperCls);
// }
// }
// } else {
for (int i=0; i<dynCP.length; i++) {
if (TRACE) System.out.println("reading element "+dynCP[i]);
if (dynCP[i].endsWith(".jar")) {
getClassesFromJarFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
} else {
if (TRACE) System.out.println("reading from files: "+dynCP[i]+" "+pckg);
getClassesFromFilesFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
}
for (int i=0; i<dynCP.length; i++) {
if (TRACE) System.out.println("reading element "+dynCP[i]);
if (dynCP[i].endsWith(".jar")) {
getClassesFromJarFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
} else {
if (TRACE) System.out.println("reading from files: "+dynCP[i]+" "+pckg);
getClassesFromFilesFltr(set, dynCP[i], pckg, includeSubs, reqSuperCls);
}
// }
}
Object[] clsArr = set.toArray();
if (bSort) {
Arrays.sort(clsArr, new ClassComparator());
}
List list;
// #1
list = Arrays.asList(clsArr);
return (Class[])list.toArray(new Class[list.size()]);
}
/**
* Request a valid absolute resource path from a relative resource path
* by searching the classpath entries. Returns null if the resource is not found.
* @param res
*/
public static String getResourcePathFromCP(String res) {
String[] cpEntries = getClassPathElements();
URL url = ClassLoader.getSystemResource(res);
if (TRACE) System.out.println(res + ((url == null) ? " not" : " was") + " found by classloader.");
if (url != null) return url.getFile();
File f;
String fNameSep;
if (res.startsWith(System.getProperty("file.separator"))) fNameSep = res;
else fNameSep = System.getProperty("file.separator")+res;
for (int i=0; i<cpEntries.length; i++) {
if (!cpEntries[i].endsWith(".jar")) { // its a fs directory (hopefully)
if (TRACE) System.out.println("reading element "+cpEntries[i]);
f = new File(cpEntries[i]+fNameSep);
if (TRACE) System.out.println(res + ((!f.exists()) ? " not" : " was") + " found in " + cpEntries[i]);
if (f.exists()) return f.getAbsolutePath();
}
}
return null;
}
/**
* Request a valid absolute resource path from a relative resource path
* by searching the classpath entries. Returns null if the resource is not found.
* @param res
*/
public static InputStream getResourceStreamFromCP(String res) {
InputStream in = BasicResourceLoader.instance().getStreamFromResourceLocation(res);
if (TRACE) System.out.println(res + ((in == null) ? " not" : " was") + " found by classloader.");
if (in != null) return in;
String[] cpEntries = getClassPathElements();
File f;
String fNameSep;
if (res.startsWith(System.getProperty("file.separator"))) fNameSep = res;
else fNameSep = System.getProperty("file.separator")+res;
for (int i=0; i<cpEntries.length; i++) {
if (!cpEntries[i].endsWith(".jar")) { // its a fs directory (hopefully)
if (TRACE) System.out.println("reading element "+cpEntries[i]);
f = new File(cpEntries[i]+fNameSep);
if (TRACE) System.out.println(res + ((!f.exists()) ? " not" : " was") + " found in " + cpEntries[i]);
if (f.exists()) {
try {
return new FileInputStream(f);
} catch(Exception e) {
System.err.println("error reading file " + f.getAbsolutePath() + ": " + e.getMessage());
}
}
}
}
return null;
}
public static ArrayList<String> getValidCPEntries() {
String[] pathElements = getClassPathElements();
File f;
ArrayList<String> valids = new ArrayList<String>(pathElements.length);
for (int i=0; i<pathElements.length; i++) {
// System.err.println(pathElements[i]);
f = new File(pathElements[i]);
// if (f.canRead()) {valids.add(pathElements[i]);}
if (f.exists() && f.canRead()) {
valids.add(pathElements[i]);
}
}
return valids;
}
public static String[] getValidCPArray() {
ArrayList<String> valids = getValidCPEntries();
// vp = valids.toArray(dynCP); // this causes Matlab to crash meanly.
String[] vp = new String[valids.size()];
for (int i=0; i<valids.size(); i++) vp[i] = valids.get(i);
return vp;
}
/**
* Retrieve assignable classes of the given package from classpath.

View File

@ -302,8 +302,7 @@ public class BasicResourceLoader implements ResourceLoader
* @param rawResrcLoc Description of the Parameter
* @return the byte array of file.
*/
public byte[] getBytesFromResourceLocation(String rawResrcLoc)
{
public InputStream getStreamFromResourceLocation(String rawResrcLoc) {
String resourceLocation = rawResrcLoc.replace('\\', '/');
//System.out.println("Try to get: "+resourceLocation);
@ -318,14 +317,14 @@ public class BasicResourceLoader implements ResourceLoader
resourceLocation = resourceLocation.trim();
// is a relative path defined ?
// this can only be possible, if this is a file resource loacation
// this can only be possible, if this is a file resource location
if (resourceLocation.startsWith("..") ||
resourceLocation.startsWith("/") ||
resourceLocation.startsWith("\\") ||
((resourceLocation.length() > 1) &&
(resourceLocation.charAt(1) == ':')))
{
return getBytesFromFile(resourceLocation);
return getStreamFromFile(resourceLocation);
}
InputStream in = ClassLoader.getSystemResourceAsStream(resourceLocation);
@ -346,10 +345,23 @@ public class BasicResourceLoader implements ResourceLoader
{
logger.debug("Stream opened for " + resourceLocation);
}
return in;
}
/**
* Gets the byte data from a file at the given resource location.
*
* @param rawResrcLoc Description of the Parameter
* @return the byte array of file.
*/
public byte[] getBytesFromResourceLocation(String rawResrcLoc)
{
InputStream in = getStreamFromResourceLocation(rawResrcLoc);
byte[] bytes = getBytesFromStream(in);
return bytes;
if (in == null) {
return null;
}
return getBytesFromStream(in);
}
/**
@ -442,7 +454,7 @@ public class BasicResourceLoader implements ResourceLoader
* @param fileName Description of the Parameter
* @return the byte array of the file.
*/
private byte[] getBytesFromFile(String fileName)
private FileInputStream getStreamFromFile(String fileName)
{
if (fileName.startsWith("/cygdrive/"))
{
@ -462,6 +474,7 @@ public class BasicResourceLoader implements ResourceLoader
try
{
fis = new FileInputStream(file);
return fis;
}
catch (Exception e)
{
@ -470,11 +483,25 @@ public class BasicResourceLoader implements ResourceLoader
return null;
}
}
/**
* Gets the byte data from a file.
*
* @param fileName Description of the Parameter
* @return the byte array of the file.
*/
private byte[] getBytesFromFile(String fileName) {
FileInputStream fis = getStreamFromFile(fileName);
if (fis == null) {
System.err.println("couldnt get file input stream!");
return null;
}
BufferedInputStream bis = new BufferedInputStream(fis);
// only files with <65536 bytes are allowed
//if( file.length() > 65536 ) System.out.println("Resource files should be smaller than 65536 bytes...");
int size = (int) file.length();
int size = (int) new File(fileName).length();
byte[] b = new byte[size];
int rb = 0;
int chunk = 0;