Some lonely test classes moved to the research branch.
This commit is contained in:
parent
8a5f03d87a
commit
0fdb7edc52
@ -1,11 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 28.01.2004
|
|
||||||
* Time: 13:07:47
|
|
||||||
* To change this template use Options | File Templates.
|
|
||||||
*/
|
|
||||||
public interface InterfaceTest {
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 28.01.2004
|
|
||||||
* Time: 13:08:13
|
|
||||||
* To change this template use Options | File Templates.
|
|
||||||
*/
|
|
||||||
public class Test1 implements InterfaceTest, Serializable {
|
|
||||||
private double m_Var = 1.0;
|
|
||||||
|
|
||||||
/**********************************************************************************************************************
|
|
||||||
* These are for GUI
|
|
||||||
*/
|
|
||||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
|
||||||
* name to the current object.
|
|
||||||
* @return The name.
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return "Test1";
|
|
||||||
}
|
|
||||||
/** This method returns a global info string
|
|
||||||
* @return description
|
|
||||||
*/
|
|
||||||
public String globalInfo() {
|
|
||||||
return "Test1.";
|
|
||||||
}
|
|
||||||
public void setVar(double v) {
|
|
||||||
this.m_Var = v;
|
|
||||||
}
|
|
||||||
public double getVar() {
|
|
||||||
return this.m_Var;
|
|
||||||
}
|
|
||||||
public String varTipText() {
|
|
||||||
return "Test1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 28.01.2004
|
|
||||||
* Time: 13:12:40
|
|
||||||
* To change this template use Options | File Templates.
|
|
||||||
*/
|
|
||||||
public class Test2 implements InterfaceTest, Serializable {
|
|
||||||
private double m_Var = 1.0;
|
|
||||||
private boolean m_Bol = true;
|
|
||||||
|
|
||||||
/**********************************************************************************************************************
|
|
||||||
* These are for GUI
|
|
||||||
*/
|
|
||||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
|
||||||
* name to the current object.
|
|
||||||
* @return The name.
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return "Test2";
|
|
||||||
}
|
|
||||||
/** This method returns a global info string
|
|
||||||
* @return description
|
|
||||||
*/
|
|
||||||
public String globalInfo() {
|
|
||||||
return "Test2.";
|
|
||||||
}
|
|
||||||
public void setVar(double v) {
|
|
||||||
this.m_Var = v;
|
|
||||||
}
|
|
||||||
public double getVar() {
|
|
||||||
return this.m_Var;
|
|
||||||
}
|
|
||||||
public String varTipText() {
|
|
||||||
return "Test2";
|
|
||||||
}
|
|
||||||
public void setBol(boolean v) {
|
|
||||||
this.m_Bol = v;
|
|
||||||
}
|
|
||||||
public boolean getBol() {
|
|
||||||
return this.m_Bol;
|
|
||||||
}
|
|
||||||
public String bolTipText() {
|
|
||||||
return "Test2";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.beans.XMLEncoder;
|
|
||||||
import java.beans.XMLDecoder;
|
|
||||||
|
|
||||||
import eva2.server.go.individuals.GAIndividualBinaryData;
|
|
||||||
import eva2.server.go.operators.crossover.CrossoverGANPoint;
|
|
||||||
import eva2.server.go.operators.crossover.CrossoverGAUniform;
|
|
||||||
import eva2.server.go.operators.mutation.MutateGADefault;
|
|
||||||
import eva2.server.go.operators.mutation.MutateGAStandard;
|
|
||||||
import eva2.server.go.problems.F1Problem;
|
|
||||||
|
|
||||||
public class Test3 {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
XMLEncoder e;
|
|
||||||
GAIndividualBinaryData o = new GAIndividualBinaryData();
|
|
||||||
MutateGAStandard m = new MutateGAStandard();
|
|
||||||
m.setNumberOfMutations(2);
|
|
||||||
o.setMutationOperator(m);
|
|
||||||
o.setMutationProbability(0.13);
|
|
||||||
CrossoverGANPoint t = new CrossoverGANPoint();
|
|
||||||
t.setNumberOfCrossovers(1);
|
|
||||||
o.setCrossoverOperator(new CrossoverGAUniform());
|
|
||||||
o.setCrossoverProbability(0.23);
|
|
||||||
o.init(new F1Problem());
|
|
||||||
double[] d = new double[2];
|
|
||||||
d[0] = 2.34;
|
|
||||||
d[1] = 4.5656;
|
|
||||||
o.SetFitness(d);
|
|
||||||
e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("GAIndividualBinaryData.xml")));
|
|
||||||
e.writeObject(o);
|
|
||||||
e.flush();
|
|
||||||
e.close();
|
|
||||||
GAIndividualBinaryData p;
|
|
||||||
XMLDecoder decoder = new XMLDecoder(new FileInputStream("GAIndividualBinaryData.xml"));
|
|
||||||
p = (GAIndividualBinaryData) decoder.readObject();
|
|
||||||
System.out.println(o.getStringRepresentation());
|
|
||||||
System.out.println(p.getStringRepresentation());
|
|
||||||
decoder.close();
|
|
||||||
|
|
||||||
} catch (Exception e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/** Serialize a Java object to XML. All attributes that have getter and
|
|
||||||
* setter methods will be serialized to elements.
|
|
||||||
* @param serializable Java object that implements Serializable.
|
|
||||||
* @param outputStream Output stream to write XML to.
|
|
||||||
*/
|
|
||||||
public static void serialize(Serializable serializable, OutputStream outputStream) throws Exception {
|
|
||||||
//todo: accept vector of serializables ...
|
|
||||||
if (outputStream != null) {
|
|
||||||
XMLEncoder encoder = new XMLEncoder(outputStream);
|
|
||||||
encoder.writeObject(serializable);
|
|
||||||
encoder.close();
|
|
||||||
}
|
|
||||||
} //serialize()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a Java object from XML that was serialized via the
|
|
||||||
* serialize method.
|
|
||||||
* @param inputStream Input stream to read XML from.
|
|
||||||
* @return Serializable Java object from XML.
|
|
||||||
* @throws Exception
|
|
||||||
* @see de.icomps.sgml.xml#serialize(Serializable, OutputStream)
|
|
||||||
*/
|
|
||||||
public static Serializable deserialize(InputStream inputStream) throws Exception {
|
|
||||||
Serializable result = null;
|
|
||||||
//todo: return vector of serializables ...
|
|
||||||
if (inputStream != null) {
|
|
||||||
XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(inputStream));
|
|
||||||
result = (Serializable) decoder.readObject();
|
|
||||||
decoder.close();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}//deserialize()
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 04.03.2004
|
|
||||||
* Time: 13:20:21
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class A {
|
|
||||||
public String getString() {
|
|
||||||
return this.getMyString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMyString() {
|
|
||||||
return "A";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class B extends A {
|
|
||||||
private String getMyString() {
|
|
||||||
return "B";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Test4 {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
A a = new A();
|
|
||||||
B b = new B();
|
|
||||||
System.out.println("A.getString(): " + a.getString());
|
|
||||||
System.out.println("B.getString(): " + b.getString());
|
|
||||||
for (int i = 0; i < 10; i++) System.out.println("i: " + (i%5));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 04.03.2004
|
|
||||||
* Time: 13:24:03
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
|
|
||||||
abstract class M {
|
|
||||||
|
|
||||||
protected String m = "M";
|
|
||||||
|
|
||||||
public abstract void init();
|
|
||||||
|
|
||||||
public void setM(String m) {
|
|
||||||
this.m = m;
|
|
||||||
}
|
|
||||||
public String getM() {
|
|
||||||
return this.m;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class N extends M implements java.io.Serializable {
|
|
||||||
public void init() {
|
|
||||||
this.m = "N";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class Test5 {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
N n = new N();
|
|
||||||
N a = null;
|
|
||||||
n.init();
|
|
||||||
System.out.println("N.getM(): " + n.getM());
|
|
||||||
try {
|
|
||||||
store(n, "N.ser");
|
|
||||||
} catch (java.io.IOException e) {
|
|
||||||
System.out.println("java.io.IOException while writing: " + e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
a = (N)load("N.ser");
|
|
||||||
} catch (java.io.IOException e) {
|
|
||||||
System.out.println("java.io.IOException while reading: " + e.getMessage());
|
|
||||||
}
|
|
||||||
} catch (java.lang.ClassNotFoundException e) {
|
|
||||||
System.out.println("java.lang.ClassNotFoundException: " + e.getMessage());
|
|
||||||
}
|
|
||||||
if (a != null) System.out.println("A.getM(): " + a.getM());
|
|
||||||
}
|
|
||||||
|
|
||||||
static private void store(Serializable o, String Filename) throws IOException {
|
|
||||||
File f = new File(Filename);
|
|
||||||
FileOutputStream file = new FileOutputStream(f);
|
|
||||||
ObjectOutputStream out = new ObjectOutputStream(file);
|
|
||||||
out.writeObject(o);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
static private Object load(String Filename) throws IOException, ClassNotFoundException {
|
|
||||||
File f = new File(Filename);
|
|
||||||
FileInputStream file = new FileInputStream(f);
|
|
||||||
ObjectInputStream in = new ObjectInputStream(file);
|
|
||||||
Object ret = in.readObject();
|
|
||||||
in.close();
|
|
||||||
file.close();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 23.02.2004
|
|
||||||
* Time: 16:52:16
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class entity {
|
|
||||||
private String type = null;
|
|
||||||
private String basetype = null;
|
|
||||||
private String id = null;
|
|
||||||
private String name = null;
|
|
||||||
private String color = null;
|
|
||||||
|
|
||||||
public entity(){
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBasetype(String basetype) {
|
|
||||||
this.basetype = basetype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(String color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBasetype() {
|
|
||||||
return basetype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package eva2.server.go.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: streiche
|
|
||||||
* Date: 23.02.2004
|
|
||||||
* Time: 16:53:16
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class point extends entity {
|
|
||||||
private int x = 0;
|
|
||||||
private int y = 0;
|
|
||||||
|
|
||||||
public point() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public point(int x, int y) {
|
|
||||||
setX(x);
|
|
||||||
setY(y);
|
|
||||||
|
|
||||||
setType("type1");
|
|
||||||
setBasetype("basetype1");
|
|
||||||
setColor("red");
|
|
||||||
setName("my_name");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX(int x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY(int y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
super.setType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBasetype(String basetype) {
|
|
||||||
super.setBasetype(basetype);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(String color) {
|
|
||||||
super.setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
super.setId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
super.setName(name);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user