FunctionArea may now plot circles easily. The FLensProblemViewer seems to be cured.
This commit is contained in:
@@ -3,6 +3,7 @@ package eva2;
|
|||||||
/**
|
/**
|
||||||
* Main product and version information strings.
|
* Main product and version information strings.
|
||||||
*
|
*
|
||||||
|
* 2.025: FunctionArea may now plot circles easily. The FLensProblemViewer seems to be cured.
|
||||||
* 2.024: Cleaned up AbstractGOParams, deactivated parent logging (saving memory)
|
* 2.024: Cleaned up AbstractGOParams, deactivated parent logging (saving memory)
|
||||||
* 2.023: Cleaned up the PF strategy
|
* 2.023: Cleaned up the PF strategy
|
||||||
* 2.022: Some changes to the SimpleProblemWrapper, not of great interest. However,
|
* 2.022: Some changes to the SimpleProblemWrapper, not of great interest. However,
|
||||||
@@ -14,7 +15,7 @@ package eva2;
|
|||||||
public class EvAInfo {
|
public class EvAInfo {
|
||||||
public static final String productName = "EvA 2";
|
public static final String productName = "EvA 2";
|
||||||
public static final String productLongName = "Evolutionary Algorithms Workbench 2";
|
public static final String productLongName = "Evolutionary Algorithms Workbench 2";
|
||||||
public static final String versionNum = new String ("2.024");
|
public static final String versionNum = new String ("2.025");
|
||||||
public static final String url = "http://www.ra.cs.uni-tuebingen.de/software/EvA2";
|
public static final String url = "http://www.ra.cs.uni-tuebingen.de/software/EvA2";
|
||||||
|
|
||||||
public static final String propertyFile = "resources/EvA2.props";
|
public static final String propertyFile = "resources/EvA2.props";
|
||||||
|
@@ -16,6 +16,7 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
|
|
||||||
private DPointIcon m_Icon = new Chart2DDPointIconCross();
|
private DPointIcon m_Icon = new Chart2DDPointIconCross();
|
||||||
private String m_Text = " ";
|
private String m_Text = " ";
|
||||||
|
private Color m_Color;
|
||||||
|
|
||||||
public Chart2DDPointIconText(String s) {
|
public Chart2DDPointIconText(String s) {
|
||||||
m_Text = s;
|
m_Text = s;
|
||||||
@@ -34,6 +35,7 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
*/
|
*/
|
||||||
public void paint( Graphics g ){
|
public void paint( Graphics g ){
|
||||||
this.m_Icon.paint(g);
|
this.m_Icon.paint(g);
|
||||||
|
g.setColor(m_Color);
|
||||||
g.drawString(this.m_Text, 4, 4);
|
g.drawString(this.m_Text, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,4 +48,13 @@ public class Chart2DDPointIconText implements DPointIcon {
|
|||||||
public DBorder getDBorder() {
|
public DBorder getDBorder() {
|
||||||
return new DBorder(4, 4, 4, 4);
|
return new DBorder(4, 4, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the color for the text.
|
||||||
|
*
|
||||||
|
* @param col
|
||||||
|
*/
|
||||||
|
public void setColor(Color col) {
|
||||||
|
m_Color = col;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -88,7 +88,51 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
repaint();
|
repaint();
|
||||||
notifyNegLog = true;
|
notifyNegLog = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* @param val
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
|
public void drawCircle(double val, double[] position, int graphID) {
|
||||||
|
drawCircle(""+val, position, graphID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* @param val
|
||||||
|
* @param position
|
||||||
|
* @param graphID
|
||||||
|
*/
|
||||||
|
public void drawCircle(char c, double val, double[] position, int graphID) {
|
||||||
|
drawCircle(c+""+val, position, graphID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plot a circle icon to the function area which is annotated with a char and
|
||||||
|
* a double value. The color corresponds to the color of the graph with given ID
|
||||||
|
*
|
||||||
|
* @param label
|
||||||
|
* @param position
|
||||||
|
* @param graphID
|
||||||
|
*/
|
||||||
|
public void drawCircle(String label, double[] position, int graphID) {
|
||||||
|
DPointSet popRep;
|
||||||
|
popRep = new DPointSet();
|
||||||
|
popRep.addDPoint(new DPoint(position[0], position[1]));
|
||||||
|
DPointIcon icon = new Chart2DDPointIconText(label);
|
||||||
|
((Chart2DDPointIconText)icon).setIcon(new Chart2DDPointIconCircle());
|
||||||
|
((Chart2DDPointIconText)icon).setColor(getGraphPointSet(graphID).getColor());
|
||||||
|
popRep.setIcon(icon);
|
||||||
|
addDElement(popRep);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@@ -40,7 +40,7 @@ public class GraphPointSet {
|
|||||||
private Color m_Color;
|
private Color m_Color;
|
||||||
private DPointIcon m_Icon;
|
private DPointIcon m_Icon;
|
||||||
private int m_CacheIndex = 0;
|
private int m_CacheIndex = 0;
|
||||||
private int m_CacheSize = 1;
|
private int m_CacheSize = 0;
|
||||||
private double [] m_cachex;
|
private double [] m_cachex;
|
||||||
private double [] m_cachey;
|
private double [] m_cachey;
|
||||||
/**
|
/**
|
||||||
|
@@ -13,6 +13,7 @@ package eva2.gui;
|
|||||||
* IMPORTS
|
* IMPORTS
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Robot;
|
import java.awt.Robot;
|
||||||
@@ -276,6 +277,13 @@ public class Plot implements PlotInterface, Serializable {
|
|||||||
m_Frame.setVisible(true);
|
m_Frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPreferredSize(Dimension prefSize) {
|
||||||
|
if (m_Frame != null) {
|
||||||
|
m_Frame.setPreferredSize(prefSize);
|
||||||
|
m_Frame.pack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the Plot object is valid.
|
* Return true if the Plot object is valid.
|
||||||
*
|
*
|
||||||
|
@@ -21,9 +21,9 @@ import eva2.tools.EVAERROR;
|
|||||||
/** This is the abstract EA individual implementing the most important methods giving
|
/** This is the abstract EA individual implementing the most important methods giving
|
||||||
* access to mutation and crossover rates and operators, fitness values and selection
|
* access to mutation and crossover rates and operators, fitness values and selection
|
||||||
* probabilities. All EA individuals should typically extend this abstract EA individual.
|
* probabilities. All EA individuals should typically extend this abstract EA individual.
|
||||||
* In that case the EA individuals only implement the genotpye and phenotype interfaces.
|
* In that case the EA individuals only implement the genotype and phenotype interfaces.
|
||||||
* The names of the implementation should be build like this:
|
* The names of the implementation should be build like this:
|
||||||
* (Genotpye)Individual(Phenotype)
|
* (Genotype)Individual(Phenotype)
|
||||||
* Thus a binary individual coding double values is named GAIndividualDoubleData and a
|
* Thus a binary individual coding double values is named GAIndividualDoubleData and a
|
||||||
* real-valued individual coding binary values is named ESIndividualBinaryData.
|
* real-valued individual coding binary values is named ESIndividualBinaryData.
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
@@ -911,6 +911,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
else return this.getFitness();
|
else return this.getFitness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDominantNotEqual(double[] otherFitness) {
|
||||||
|
return isDominatingFitnessNotEqual(m_Fitness, otherFitness);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDominant(double[] otherFitness) {
|
public boolean isDominant(double[] otherFitness) {
|
||||||
return isDominatingFitness(m_Fitness, otherFitness);
|
return isDominatingFitness(m_Fitness, otherFitness);
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,11 @@
|
|||||||
package eva2.server.go.individuals;
|
package eva2.server.go.individuals;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import wsi.ra.math.RNG;
|
||||||
|
|
||||||
import eva2.server.go.IndividualInterface;
|
|
||||||
import eva2.server.go.operators.crossover.CrossoverESDefault;
|
import eva2.server.go.operators.crossover.CrossoverESDefault;
|
||||||
import eva2.server.go.operators.mutation.InterfaceMutation;
|
import eva2.server.go.operators.mutation.InterfaceMutation;
|
||||||
import eva2.server.go.operators.mutation.MutateESGlobal;
|
import eva2.server.go.operators.mutation.MutateESGlobal;
|
||||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||||
import wsi.ra.math.RNG;
|
|
||||||
|
|
||||||
/** This individual uses a real-valued genotype to code for double values.
|
/** This individual uses a real-valued genotype to code for double values.
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
|
@@ -17,363 +17,363 @@ import wsi.ra.math.RNG;
|
|||||||
*/
|
*/
|
||||||
public class ESIndividualPermutationData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypePermutation, java.io.Serializable {
|
public class ESIndividualPermutationData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypePermutation, java.io.Serializable {
|
||||||
|
|
||||||
private double[][] m_Genotype;
|
private double[][] m_Genotype;
|
||||||
private int[][] m_Phenotype;
|
private int[][] m_Phenotype;
|
||||||
private double[][][] m_Range;
|
private double[][][] m_Range;
|
||||||
private int[] firstindex;
|
private int[] firstindex;
|
||||||
|
|
||||||
|
|
||||||
public ESIndividualPermutationData() {
|
public ESIndividualPermutationData() {
|
||||||
this.m_MutationProbability = 1.0;
|
this.m_MutationProbability = 1.0;
|
||||||
this.m_MutationOperator = new MutateESGlobal();
|
this.m_MutationOperator = new MutateESGlobal();
|
||||||
this.m_CrossoverProbability = 0.5;
|
this.m_CrossoverProbability = 0.5;
|
||||||
this.m_CrossoverOperator = new CrossoverESDefault();
|
this.m_CrossoverOperator = new CrossoverESDefault();
|
||||||
this.m_Genotype = new double[1][1];
|
this.m_Genotype = new double[1][1];
|
||||||
this.m_Range = new double[1][1][2];
|
this.m_Range = new double[1][1][2];
|
||||||
this.m_Range[0][0][0] = 0;
|
this.m_Range[0][0][0] = 0;
|
||||||
this.m_Range[0][0][1] = 1;
|
this.m_Range[0][0][1] = 1;
|
||||||
this.firstindex = new int[]{0};
|
this.firstindex = new int[]{0};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ESIndividualPermutationData(ESIndividualPermutationData individual) {
|
public ESIndividualPermutationData(ESIndividualPermutationData individual) {
|
||||||
if (individual.m_Phenotype != null) {
|
if (individual.m_Phenotype != null) {
|
||||||
this.m_Phenotype = new int[individual.m_Phenotype.length][];
|
this.m_Phenotype = new int[individual.m_Phenotype.length][];
|
||||||
for (int i = 0; i < m_Phenotype.length; i++) {
|
for (int i = 0; i < m_Phenotype.length; i++) {
|
||||||
this.m_Phenotype[i] =new int[ individual.m_Phenotype[i].length];
|
this.m_Phenotype[i] =new int[ individual.m_Phenotype[i].length];
|
||||||
System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length);
|
System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.firstindex = individual.firstindex;
|
this.firstindex = individual.firstindex;
|
||||||
this.m_Genotype = new double[individual.m_Genotype.length][];
|
this.m_Genotype = new double[individual.m_Genotype.length][];
|
||||||
this.m_Range = new double[individual.m_Genotype.length][][];
|
this.m_Range = new double[individual.m_Genotype.length][][];
|
||||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||||
// if (individual.m_Phenotype != null) {
|
// if (individual.m_Phenotype != null) {
|
||||||
|
|
||||||
this.m_Genotype[i] = new double[individual.m_Genotype[i].length];
|
this.m_Genotype[i] = new double[individual.m_Genotype[i].length];
|
||||||
this.m_Range[i] = new double[individual.m_Genotype[i].length][2];
|
this.m_Range[i] = new double[individual.m_Genotype[i].length][2];
|
||||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||||
this.m_Genotype[i][j] = individual.m_Genotype[i][j];
|
this.m_Genotype[i][j] = individual.m_Genotype[i][j];
|
||||||
this.m_Range[i][j][0] = individual.m_Range[i][j][0];
|
this.m_Range[i][j][0] = individual.m_Range[i][j][0];
|
||||||
this.m_Range[i][j][1] = individual.m_Range[i][j][1];
|
this.m_Range[i][j][1] = individual.m_Range[i][j][1];
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloning the members of AbstractEAIndividual
|
// cloning the members of AbstractEAIndividual
|
||||||
this.m_Age = individual.m_Age;
|
this.m_Age = individual.m_Age;
|
||||||
this.m_CrossoverOperator = individual.m_CrossoverOperator;
|
this.m_CrossoverOperator = individual.m_CrossoverOperator;
|
||||||
this.m_CrossoverProbability = individual.m_CrossoverProbability;
|
this.m_CrossoverProbability = individual.m_CrossoverProbability;
|
||||||
this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone();
|
this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone();
|
||||||
this.m_MutationProbability = individual.m_MutationProbability;
|
this.m_MutationProbability = individual.m_MutationProbability;
|
||||||
this.m_SelectionProbability = new double[individual.m_SelectionProbability.length];
|
this.m_SelectionProbability = new double[individual.m_SelectionProbability.length];
|
||||||
for (int i = 0; i < this.m_SelectionProbability.length; i++) {
|
for (int i = 0; i < this.m_SelectionProbability.length; i++) {
|
||||||
this.m_SelectionProbability[i] = individual.m_SelectionProbability[i];
|
this.m_SelectionProbability[i] = individual.m_SelectionProbability[i];
|
||||||
}
|
}
|
||||||
this.m_Fitness = new double[individual.m_Fitness.length];
|
this.m_Fitness = new double[individual.m_Fitness.length];
|
||||||
for (int i = 0; i < this.m_Fitness.length; i++) {
|
for (int i = 0; i < this.m_Fitness.length; i++) {
|
||||||
this.m_Fitness[i] = individual.m_Fitness[i];
|
this.m_Fitness[i] = individual.m_Fitness[i];
|
||||||
}
|
}
|
||||||
cloneAEAObjects((AbstractEAIndividual) individual);
|
cloneAEAObjects((AbstractEAIndividual) individual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
return (Object) new ESIndividualPermutationData(this);
|
return (Object) new ESIndividualPermutationData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method checks on equality regarding genotypic equality
|
/** This method checks on equality regarding genotypic equality
|
||||||
* @param individual The individual to compare to.
|
* @param individual The individual to compare to.
|
||||||
* @return boolean if equal true else false.
|
* @return boolean if equal true else false.
|
||||||
*/
|
*/
|
||||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||||
if (individual instanceof ESIndividualPermutationData) {
|
if (individual instanceof ESIndividualPermutationData) {
|
||||||
ESIndividualPermutationData indy = (ESIndividualPermutationData) individual;
|
ESIndividualPermutationData indy = (ESIndividualPermutationData) individual;
|
||||||
if ((this.m_Genotype == null) || (indy.m_Genotype == 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;
|
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_Range.length != indy.m_Range.length) return false;
|
||||||
for (int i = 0; i < this.m_Range.length; i++) {
|
for (int i = 0; i < this.m_Range.length; i++) {
|
||||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) 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][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][1] != indy.m_Range[i][1]) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* InterfaceDataTypePermutation methods
|
* InterfaceDataTypePermutation methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setPermutationDataLength(int[] length){
|
public void setPermutationDataLength(int[] length){
|
||||||
|
|
||||||
this.m_Genotype = new double[length.length][];
|
this.m_Genotype = new double[length.length][];
|
||||||
this.m_Range = new double[length.length][][];
|
this.m_Range = new double[length.length][][];
|
||||||
for (int i = 0; i < this.m_Range.length; i++) {
|
for (int i = 0; i < this.m_Range.length; i++) {
|
||||||
this.m_Genotype[i] = new double[length[i]];
|
this.m_Genotype[i] = new double[length[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < this.m_Range.length; i++) {
|
for (int i = 0; i < this.m_Range.length; i++) {
|
||||||
|
|
||||||
this.m_Range[i] = new double[length[i]][2];
|
this.m_Range[i] = new double[length[i]][2];
|
||||||
for (int j = 0; j < this.m_Range[i].length; j++) {
|
for (int j = 0; j < this.m_Range[i].length; j++) {
|
||||||
this.m_Range[i][j][0] = 0;
|
this.m_Range[i][j][0] = 0;
|
||||||
this.m_Range[i][j][1] = 1;
|
this.m_Range[i][j][1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] sizePermutation() {
|
public int[] sizePermutation() {
|
||||||
int[] res = new int[m_Genotype.length];
|
int[] res = new int[m_Genotype.length];
|
||||||
for (int i = 0; i < m_Genotype.length; i++) {
|
for (int i = 0; i < m_Genotype.length; i++) {
|
||||||
res[i] = m_Genotype[i].length;
|
res[i] = m_Genotype[i].length;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPermutationData(int[][] perm){
|
public void SetPermutationData(int[][] perm){
|
||||||
this.m_Phenotype = perm;
|
this.m_Phenotype = perm;
|
||||||
this.m_Range = new double[perm.length][][];
|
this.m_Range = new double[perm.length][][];
|
||||||
for (int i = 0; i < perm.length; i++) {
|
for (int i = 0; i < perm.length; i++) {
|
||||||
this.m_Range[i] = new double[perm[i].length][2];
|
this.m_Range[i] = new double[perm[i].length][2];
|
||||||
for (int j = 0; j < this.m_Range[i].length; j++) {
|
for (int j = 0; j < this.m_Range[i].length; j++) {
|
||||||
this.m_Range[i][j][0] = 0;
|
this.m_Range[i][j][0] = 0;
|
||||||
this.m_Range[i][j][1] = 1;
|
this.m_Range[i][j][1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPermutationDataLamarckian(int[][] perm){
|
public void SetPermutationDataLamarckian(int[][] perm){
|
||||||
this.SetPermutationData(perm);
|
this.SetPermutationData(perm);
|
||||||
|
|
||||||
this.m_Genotype = new double[perm.length][];
|
this.m_Genotype = new double[perm.length][];
|
||||||
this.m_Range = new double[perm.length][][];
|
this.m_Range = new double[perm.length][][];
|
||||||
for (int p = 0; p < perm.length; p++) {
|
for (int p = 0; p < perm.length; p++) {
|
||||||
int biggest = Integer.MIN_VALUE;
|
int biggest = Integer.MIN_VALUE;
|
||||||
int smallest = Integer.MAX_VALUE;
|
int smallest = Integer.MAX_VALUE;
|
||||||
this.m_Range[p] = new double[perm[p].length][2];
|
this.m_Range[p] = new double[perm[p].length][2];
|
||||||
for (int i = 0; i < perm[p].length; i++) {
|
for (int i = 0; i < perm[p].length; i++) {
|
||||||
if (perm[p][i] > biggest) biggest = perm[p][i];
|
if (perm[p][i] > biggest) biggest = perm[p][i];
|
||||||
if (perm[p][i] < smallest) smallest = perm[p][i];
|
if (perm[p][i] < smallest) smallest = perm[p][i];
|
||||||
this.m_Range[p][i][0] = 0;
|
this.m_Range[p][i][0] = 0;
|
||||||
this.m_Range[p][i][1] = 1;
|
this.m_Range[p][i][1] = 1;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
||||||
this.m_Genotype[p][i] = (perm[p][i] - smallest)/(double)biggest;
|
this.m_Genotype[p][i] = (perm[p][i] - smallest)/(double)biggest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getPermutationData() {
|
public int[][] getPermutationData() {
|
||||||
this.m_Phenotype = new int[this.m_Genotype.length][];
|
this.m_Phenotype = new int[this.m_Genotype.length][];
|
||||||
for (int p = 0; p < m_Genotype.length; p++) {
|
for (int p = 0; p < m_Genotype.length; p++) {
|
||||||
this.m_Phenotype[p] = new int[m_Genotype[p].length];
|
this.m_Phenotype[p] = new int[m_Genotype[p].length];
|
||||||
boolean notValid = true;
|
boolean notValid = true;
|
||||||
while (notValid) {
|
while (notValid) {
|
||||||
notValid = false;
|
notValid = false;
|
||||||
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
||||||
for (int j = 0; j < this.m_Genotype[p].length; j++) {
|
for (int j = 0; j < this.m_Genotype[p].length; j++) {
|
||||||
if ((i != j) && (this.m_Genotype[p][i] == this.m_Genotype[p][j])) {
|
if ((i != j) && (this.m_Genotype[p][i] == this.m_Genotype[p][j])) {
|
||||||
notValid = true;
|
notValid = true;
|
||||||
this.m_Genotype[p][j] = RNG.randomDouble(0, 1);
|
this.m_Genotype[p][j] = RNG.randomDouble(0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
for (int i = 0; i < this.m_Genotype[p].length; i++) {
|
||||||
for (int j = 0; j < this.m_Genotype[p].length; j++) {
|
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]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.m_Phenotype;
|
return this.m_Phenotype;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to read the permutation data without
|
/** This method allows you to read the permutation data without
|
||||||
* an update from the genotype
|
* an update from the genotype
|
||||||
* @return int[] representing the permutation.
|
* @return int[] representing the permutation.
|
||||||
*/
|
*/
|
||||||
public int[][] getPermutationDataWithoutUpdate() {
|
public int[][] getPermutationDataWithoutUpdate() {
|
||||||
return this.m_Phenotype;
|
return this.m_Phenotype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getFirstindex() {
|
public int[] getFirstindex() {
|
||||||
return firstindex;
|
return firstindex;
|
||||||
}
|
}
|
||||||
public void setFirstindex(int[] firstindex) {
|
public void setFirstindex(int[] firstindex) {
|
||||||
this.firstindex = firstindex;
|
this.firstindex = firstindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* AbstractEAIndividual methods
|
* AbstractEAIndividual methods
|
||||||
*/
|
*/
|
||||||
/** This method will allow a default initialisation of the individual
|
/** This method will allow a default initialisation of the individual
|
||||||
* @param opt The optimization problem that is to be solved.
|
* @param opt The optimization problem that is to be solved.
|
||||||
*/
|
*/
|
||||||
public void init(InterfaceOptimizationProblem opt) {
|
public void init(InterfaceOptimizationProblem opt) {
|
||||||
this.defaultInit();
|
this.defaultInit();
|
||||||
this.m_MutationOperator.init(this, opt);
|
this.m_MutationOperator.init(this, opt);
|
||||||
this.m_CrossoverOperator.init(this, opt);
|
this.m_CrossoverOperator.init(this, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will init the individual with a given value for the
|
/** This method will init the individual with a given value for the
|
||||||
* phenotype.
|
* phenotype.
|
||||||
* @param obj The initial value for the phenotype
|
* @param obj The initial value for the phenotype
|
||||||
* @param opt The optimization problem that is to be solved.
|
* @param opt The optimization problem that is to be solved.
|
||||||
*/
|
*/
|
||||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||||
if (obj instanceof int[][]) {
|
if (obj instanceof int[][]) {
|
||||||
int[][] bs = (int[][]) obj;
|
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.SetPermutationDataLamarckian(bs);
|
this.SetPermutationDataLamarckian(bs);
|
||||||
} else {
|
} else {
|
||||||
this.defaultInit();
|
this.defaultInit();
|
||||||
System.out.println("Initial value for ESIndividualPermutationData is not int[]!");
|
System.out.println("Initial value for ESIndividualPermutationData is not int[]!");
|
||||||
}
|
}
|
||||||
this.m_MutationOperator.init(this, opt);
|
this.m_MutationOperator.init(this, opt);
|
||||||
this.m_CrossoverOperator.init(this, opt);
|
this.m_CrossoverOperator.init(this, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return a string description of the GAIndividal
|
/** This method will return a string description of the GAIndividal
|
||||||
* noteably the Genotype.
|
* noteably the Genotype.
|
||||||
* @return A descriptive string
|
* @return A descriptive string
|
||||||
*/
|
*/
|
||||||
public String getStringRepresentation() {
|
public String getStringRepresentation() {
|
||||||
String result = "";
|
String result = "";
|
||||||
result += "ESIndividual coding permutation: (";
|
result += "ESIndividual coding permutation: (";
|
||||||
result += "Fitness {";
|
result += "Fitness {";
|
||||||
for (int i = 0; i < this.m_Fitness.length; i++) result += this.m_Fitness[i] + ";";
|
for (int i = 0; i < this.m_Fitness.length; i++) result += this.m_Fitness[i] + ";";
|
||||||
result += "}/SelProb{";
|
result += "}/SelProb{";
|
||||||
for (int i = 0; i < this.m_SelectionProbability.length; i++) result += this.m_SelectionProbability[i] + ";";
|
for (int i = 0; i < this.m_SelectionProbability.length; i++) result += this.m_SelectionProbability[i] + ";";
|
||||||
result += "})\n Value: ";
|
result += "})\n Value: ";
|
||||||
result += "[";
|
result += "[";
|
||||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||||
result += this.m_Genotype[i] + "; ";
|
result += this.m_Genotype[i] + "; ";
|
||||||
}
|
}
|
||||||
result += "]";
|
result += "]";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* InterfaceESIndividual methods
|
* InterfaceESIndividual methods
|
||||||
*/
|
*/
|
||||||
/** This method will allow the user to read the ES 'genotype'
|
/** This method will allow the user to read the ES 'genotype'
|
||||||
* @return BitSet
|
* @return BitSet
|
||||||
*/
|
*/
|
||||||
public double[] getDGenotype() {
|
public double[] getDGenotype() {
|
||||||
return mapMatrixToVector(m_Genotype);
|
return mapMatrixToVector(m_Genotype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double[] mapMatrixToVector(double[][] matrix) {
|
public double[] mapMatrixToVector(double[][] matrix) {
|
||||||
int sumentries = 0;
|
int sumentries = 0;
|
||||||
for (int i = 0; i < matrix.length; i++) {
|
for (int i = 0; i < matrix.length; i++) {
|
||||||
sumentries += matrix[i].length;
|
sumentries += matrix[i].length;
|
||||||
}
|
}
|
||||||
double[] res = new double[sumentries];
|
double[] res = new double[sumentries];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i = 0; i < matrix.length; i++) {
|
for (int i = 0; i < matrix.length; i++) {
|
||||||
for (int j = 0; j < matrix[i].length; j++) {
|
for (int j = 0; j < matrix[i].length; j++) {
|
||||||
res[counter] = matrix[i][j];
|
res[counter] = matrix[i][j];
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[][] mapVectorToMatrix(double[] vector, int[] sizes) {
|
public double[][] mapVectorToMatrix(double[] vector, int[] sizes) {
|
||||||
double[][] matrix = new double[sizes.length][];
|
double[][] matrix = new double[sizes.length][];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i = 0; i < sizes.length; i++) {
|
for (int i = 0; i < sizes.length; i++) {
|
||||||
matrix[i] = new double[sizes[i]];
|
matrix[i] = new double[sizes[i]];
|
||||||
for (int j = 0; j < matrix[i].length; j++) {
|
for (int j = 0; j < matrix[i].length; j++) {
|
||||||
matrix[i][j] = vector[counter];
|
matrix[i][j] = vector[counter];
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will allow the user to set the current ES 'genotype'.
|
/** This method will allow the user to set the current ES 'genotype'.
|
||||||
* @param b The new genotype of the Individual
|
* @param b The new genotype of the Individual
|
||||||
*/
|
*/
|
||||||
public void SetDGenotype(double[] b) {
|
public void SetDGenotype(double[] b) {
|
||||||
this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation());
|
this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation());
|
||||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
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][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][1]) this.m_Genotype[i][j] = this.m_Range[i][j][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method performs a simple one element mutation on the double vector
|
/** This method performs a simple one element mutation on the double vector
|
||||||
*/
|
*/
|
||||||
public void defaultMutate() {
|
public void defaultMutate() {
|
||||||
for (int i = 0; i < m_Genotype.length; i++) {
|
for (int i = 0; i < m_Genotype.length; i++) {
|
||||||
int mutationIndex = RNG.randomInt(0, this.m_Genotype[i].length-1);
|
int mutationIndex = RNG.randomInt(0, this.m_Genotype[i].length-1);
|
||||||
this.m_Genotype[i][mutationIndex] += ((this.m_Range[i][mutationIndex][1] - this.m_Range[i][mutationIndex][0])/2)*RNG.gaussianDouble(0.05f);
|
this.m_Genotype[i][mutationIndex] += ((this.m_Range[i][mutationIndex][1] - this.m_Range[i][mutationIndex][0])/2)*RNG.gaussianDouble(0.05f);
|
||||||
if (this.m_Genotype[i][mutationIndex] < this.m_Range[i][mutationIndex][0]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][0];
|
if (this.m_Genotype[i][mutationIndex] < this.m_Range[i][mutationIndex][0]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][0];
|
||||||
if (this.m_Genotype[i][mutationIndex] > this.m_Range[i][mutationIndex][1]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][1];
|
if (this.m_Genotype[i][mutationIndex] > this.m_Range[i][mutationIndex][1]) this.m_Genotype[i][mutationIndex] = this.m_Range[i][mutationIndex][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method initializes the double vector
|
/** This method initializes the double vector
|
||||||
*/
|
*/
|
||||||
public void defaultInit() {
|
public void defaultInit() {
|
||||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||||
this.m_Genotype[i][j] = RNG.randomDouble(this.m_Range[i][j][0], this.m_Range[i][j][1]);
|
this.m_Genotype[i][j] = RNG.randomDouble(this.m_Range[i][j][0], this.m_Range[i][j][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return the range for all double attributes.
|
/** This method will return the range for all double attributes.
|
||||||
* @return The range array.
|
* @return The range array.
|
||||||
*/
|
*/
|
||||||
public double[][] getDoubleRange() {
|
public double[][] getDoubleRange() {
|
||||||
int sumentries = 0;
|
int sumentries = 0;
|
||||||
for (int i = 0; i < this.m_Range.length; i++) {
|
for (int i = 0; i < this.m_Range.length; i++) {
|
||||||
sumentries += this.m_Range[i].length;
|
sumentries += this.m_Range[i].length;
|
||||||
}
|
}
|
||||||
double[][] res = new double[sumentries][2];
|
double[][] res = new double[sumentries][2];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i = 0; i < this.m_Range.length; i++) {
|
for (int i = 0; i < this.m_Range.length; i++) {
|
||||||
for (int j = 0; j < this.m_Range[i].length; j++) {
|
for (int j = 0; j < this.m_Range[i].length; j++) {
|
||||||
res[counter][0] = this.m_Range[i][j][0];
|
res[counter][0] = this.m_Range[i][j][0];
|
||||||
res[counter][1] = this.m_Range[i][j][1];
|
res[counter][1] = this.m_Range[i][j][1];
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************
|
|
||||||
* These are for GUI
|
|
||||||
*/
|
|
||||||
/** This method allows the CommonJavaObjectEditorPanel to read the
|
|
||||||
* name to the current object.
|
|
||||||
* @return The name.
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return "ES individual";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This method returns a global info string
|
/**********************************************************************************************************************
|
||||||
* @return description
|
* These are for GUI
|
||||||
*/
|
*/
|
||||||
public String globalInfo() {
|
/** This method allows the CommonJavaObjectEditorPanel to read the
|
||||||
return "This is an ES individual suited to optimize permutations.";
|
* name to the current object.
|
||||||
}
|
* @return The name.
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return "ES individual";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method returns a global info string
|
||||||
|
* @return description
|
||||||
|
*/
|
||||||
|
public String globalInfo() {
|
||||||
|
return "This is an ES individual suited to optimize permutations.";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +1,46 @@
|
|||||||
package eva2.server.go.problems;
|
package eva2.server.go.problems;
|
||||||
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.Stroke;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import wsi.ra.math.RNG;
|
||||||
import eva2.server.go.GOStandaloneVersion;
|
import eva2.server.go.GOStandaloneVersion;
|
||||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||||
import eva2.server.go.individuals.ESIndividualDoubleData;
|
import eva2.server.go.individuals.ESIndividualDoubleData;
|
||||||
import eva2.server.go.individuals.GAIndividualDoubleData;
|
|
||||||
import eva2.server.go.individuals.InterfaceDataTypeDouble;
|
import eva2.server.go.individuals.InterfaceDataTypeDouble;
|
||||||
import eva2.server.go.populations.Population;
|
import eva2.server.go.populations.Population;
|
||||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||||
import wsi.ra.math.RNG;
|
|
||||||
import eva2.server.modules.GOParameters;
|
import eva2.server.modules.GOParameters;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
class MyLensViewer extends JPanel {
|
class MyLensViewer extends JPanel {
|
||||||
|
|
||||||
private double[] m_BestVariables;
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 7945150208043416139L;
|
||||||
|
private double[] m_BestVariables;
|
||||||
private double m_BestFitness;
|
private double m_BestFitness;
|
||||||
private int m_Height, m_Width, m_CenterX, m_CenterY;
|
private int m_Height, m_Width;
|
||||||
FLensProblem m_LensProblem;
|
FLensProblem m_LensProblem;
|
||||||
|
|
||||||
public MyLensViewer (FLensProblem f) {
|
public MyLensViewer (FLensProblem f) {
|
||||||
this.m_LensProblem = f;
|
this.m_LensProblem = f;
|
||||||
Dimension d = new Dimension (450, 350);
|
Dimension d = new Dimension (280, 220);
|
||||||
this.setPreferredSize(d);
|
this.setPreferredSize(d);
|
||||||
this.setMinimumSize(d);
|
this.setMinimumSize(d);
|
||||||
resetBest();
|
resetBest();
|
||||||
@@ -40,12 +55,12 @@ class MyLensViewer extends JPanel {
|
|||||||
Shape tmpShape;
|
Shape tmpShape;
|
||||||
BufferedImage bufferedImage;
|
BufferedImage bufferedImage;
|
||||||
BasicStroke ds = new BasicStroke();
|
BasicStroke ds = new BasicStroke();
|
||||||
Stroke dashStroke, lineStroke, pointStroke;
|
Stroke dashStroke;
|
||||||
int currentPos, width, mag = 10;
|
int mag = 10;
|
||||||
int centerLens, centerScreen, segment;
|
int centerLens, centerScreen, segment;
|
||||||
|
|
||||||
lineStroke = ds;
|
// lineStroke = ds;
|
||||||
pointStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {1, 4}, 0);
|
// pointStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {1, 4}, 0);
|
||||||
dashStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {8, 8}, 0);
|
dashStroke = new BasicStroke(ds.getLineWidth(), ds.getEndCap(), ds.getLineJoin(), ds.getMiterLimit() , new float[] {8, 8}, 0);
|
||||||
|
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
@@ -54,16 +69,24 @@ class MyLensViewer extends JPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a buffered image in which to draw
|
// Create a buffered image in which to draw
|
||||||
try {
|
// try {
|
||||||
this.m_Height = (int)g.getClipBounds().getHeight();
|
// this.m_Height = (int)g.getClipBounds().getHeight();
|
||||||
this.m_Width = (int)g.getClipBounds().getWidth();
|
// this.m_Width = (int)g.getClipBounds().getWidth();
|
||||||
this.m_CenterX = (int)g.getClipBounds().getCenterX();
|
// this.m_CenterX = (int)g.getClipBounds().getCenterX();
|
||||||
this.m_CenterY = (int)g.getClipBounds().getCenterY();
|
// this.m_CenterY = (int)g.getClipBounds().getCenterY();
|
||||||
} catch (java.lang.NullPointerException npe) {
|
// } catch (java.lang.NullPointerException npe) {
|
||||||
//System.out.println("Try fail...");
|
// //System.out.println("Try fail...");
|
||||||
}
|
// }
|
||||||
if (this.m_Height == 0) this.m_Height = 250;
|
// This might cure the eternal display problems: just ignore clipping and leave it up to swing
|
||||||
if (this.m_Width == 0) this.m_Width = 350;
|
Dimension winDim = getSize();
|
||||||
|
m_Height = winDim.height;
|
||||||
|
m_Width = winDim.width;
|
||||||
|
// m_CenterX = m_Width/2;
|
||||||
|
// m_CenterY = m_Height/2;
|
||||||
|
|
||||||
|
// if (this.m_Height == 0) this.m_Height = 250;
|
||||||
|
// if (this.m_Width == 0) this.m_Width = 350;
|
||||||
|
// System.out.println(" h w cx cy " + m_Height + " " + m_Width + " " + m_CenterX + " " + m_CenterY );
|
||||||
bufferedImage = new BufferedImage(this.m_Width, this.m_Height, BufferedImage.TYPE_INT_RGB);
|
bufferedImage = new BufferedImage(this.m_Width, this.m_Height, BufferedImage.TYPE_INT_RGB);
|
||||||
// Create a graphics contents on the buffered image
|
// Create a graphics contents on the buffered image
|
||||||
Graphics2D g2D = bufferedImage.createGraphics();
|
Graphics2D g2D = bufferedImage.createGraphics();
|
||||||
@@ -139,6 +162,10 @@ class MyLensViewer extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public class FLensProblem extends AbstractOptimizationProblem implements InterfaceOptimizationProblem, java.io.Serializable {
|
public class FLensProblem extends AbstractOptimizationProblem implements InterfaceOptimizationProblem, java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 4694920294291719310L;
|
||||||
protected AbstractEAIndividual m_OverallBest = null;
|
protected AbstractEAIndividual m_OverallBest = null;
|
||||||
protected int m_ProblemDimension = 10;
|
protected int m_ProblemDimension = 10;
|
||||||
protected double m_Noise = 0.0;
|
protected double m_Noise = 0.0;
|
||||||
@@ -244,25 +271,6 @@ public class FLensProblem extends AbstractOptimizationProblem implements Interfa
|
|||||||
population.init();
|
population.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** This method evaluates a given population and set the fitness values
|
|
||||||
// * accordingly
|
|
||||||
// * @param population The population that is to be evaluated.
|
|
||||||
// */
|
|
||||||
// public void evaluate(Population population) {
|
|
||||||
// evaluatePopulationStart(population);
|
|
||||||
// AbstractEAIndividual tmpIndy;
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < population.size(); i++) {
|
|
||||||
// tmpIndy = (AbstractEAIndividual) population.get(i);
|
|
||||||
// tmpIndy.resetConstraintViolation();
|
|
||||||
// this.evaluate(tmpIndy);
|
|
||||||
// population.incrFunctionCalls();
|
|
||||||
// }
|
|
||||||
// evaluatePopulationEnd(population);
|
|
||||||
// //if (sleepTime > 0 ) try { Thread.sleep(sleepTime); } catch(Exception e) {}
|
|
||||||
//// if (this.m_Show) this.updateProblemFrame(population);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void evaluatePopulationEnd(Population pop) {
|
public void evaluatePopulationEnd(Population pop) {
|
||||||
if (this.m_Show) this.updateProblemFrame(pop);
|
if (this.m_Show) this.updateProblemFrame(pop);
|
||||||
}
|
}
|
||||||
|
@@ -588,8 +588,8 @@ public class Mathematics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes the doubles in the array by their sum.
|
* Normalizes the doubles in the array by their sum,
|
||||||
*
|
* so that they add up to one.
|
||||||
* @param doubles the array of double
|
* @param doubles the array of double
|
||||||
* @exception IllegalArgumentException if sum is Zero or NaN
|
* @exception IllegalArgumentException if sum is Zero or NaN
|
||||||
*/
|
*/
|
||||||
|
@@ -57,7 +57,11 @@ public class DLine extends DComponent
|
|||||||
if( color != null ) g.setColor( color );
|
if( color != null ) g.setColor( color );
|
||||||
Point p1 = m.getPoint( start ),
|
Point p1 = m.getPoint( start ),
|
||||||
p2 = m.getPoint( end ) ;
|
p2 = m.getPoint( end ) ;
|
||||||
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
if ((p1!=null) && (p2!=null)) {
|
||||||
|
g.drawLine( p1.x, p1.y, p2.x, p2.y );
|
||||||
|
} else {
|
||||||
|
System.err.println("Couldnt paint rect!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
|
@@ -87,6 +87,9 @@ private boolean under_construction = false;
|
|||||||
*/
|
*/
|
||||||
public Point getPoint( double x, double y ){
|
public Point getPoint( double x, double y ){
|
||||||
DRectangle rect = getSourceOf( getDRectangle() );
|
DRectangle rect = getSourceOf( getDRectangle() );
|
||||||
|
if (rect == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try{
|
try{
|
||||||
if( x_scale != null ) x = x_scale.getSourceOf( x );
|
if( x_scale != null ) x = x_scale.getSourceOf( x );
|
||||||
if( y_scale != null ) y = y_scale.getSourceOf( y );
|
if( y_scale != null ) y = y_scale.getSourceOf( y );
|
||||||
@@ -214,8 +217,11 @@ private boolean under_construction = false;
|
|||||||
*/
|
*/
|
||||||
DRectangle getSourceOf( DRectangle rect ){
|
DRectangle getSourceOf( DRectangle rect ){
|
||||||
if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect);
|
if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect);
|
||||||
if( !getDRectangle().contains( rect ) ) throw
|
if( !getDRectangle().contains( rect ) ) {
|
||||||
new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
return null;
|
||||||
|
//throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
|
||||||
|
}
|
||||||
|
|
||||||
if( x_scale == null && y_scale == null ) return rect;
|
if( x_scale == null && y_scale == null ) return rect;
|
||||||
if( rect.isEmpty() ) return (DRectangle)rect.clone();
|
if( rect.isEmpty() ) return (DRectangle)rect.clone();
|
||||||
DPoint p1 = new DPoint( rect.x, rect.y ),
|
DPoint p1 = new DPoint( rect.x, rect.y ),
|
||||||
|
@@ -191,7 +191,10 @@ public class RNG extends Random {
|
|||||||
return (float)random.nextGaussian()*dev;
|
return (float)random.nextGaussian()*dev;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
* Return a Gaussian double with mean 0 and deviation dev.
|
||||||
|
*
|
||||||
|
* @param dev the deviation of the distribution.
|
||||||
|
* @return a Gaussian double with mean 0 and given deviation.
|
||||||
*/
|
*/
|
||||||
public static double gaussianDouble(double dev) {
|
public static double gaussianDouble(double dev) {
|
||||||
//counter++;
|
//counter++;
|
||||||
|
@@ -188,6 +188,7 @@ public class BasicResourceLoader implements ResourceLoader
|
|||||||
* @param rawData Strings containing an array with double data columns
|
* @param rawData Strings containing an array with double data columns
|
||||||
* @param colSplit String regexp for the splitting of a line
|
* @param colSplit String regexp for the splitting of a line
|
||||||
* @param selectedCols indices of the columns to retrieve, null for all.
|
* @param selectedCols indices of the columns to retrieve, null for all.
|
||||||
|
* @see java.util.regex.Pattern
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double[][] parseDoubleArray(ArrayList<String> rawData, String colSplit, int[] selectedCols) {
|
public static double[][] parseDoubleArray(ArrayList<String> rawData, String colSplit, int[] selectedCols) {
|
||||||
@@ -199,7 +200,7 @@ public class BasicResourceLoader implements ResourceLoader
|
|||||||
entries = rawData.get(i).split(colSplit);
|
entries = rawData.get(i).split(colSplit);
|
||||||
if (i == 0) { // at the first pass
|
if (i == 0) { // at the first pass
|
||||||
dat = new double[rawData.size()][(selectedCols == null) ? entries.length : selectedCols.length];
|
dat = new double[rawData.size()][(selectedCols == null) ? entries.length : selectedCols.length];
|
||||||
}
|
}
|
||||||
fillLine(dat, i, entries, selectedCols);
|
fillLine(dat, i, entries, selectedCols);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -270,11 +271,19 @@ public class BasicResourceLoader implements ResourceLoader
|
|||||||
}
|
}
|
||||||
if (cols == null) {
|
if (cols == null) {
|
||||||
for (int i=0; i<entries.length; i++) {
|
for (int i=0; i<entries.length; i++) {
|
||||||
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
try {
|
||||||
|
dest[lineCnt][i] = Double.valueOf(entries[i]);
|
||||||
|
} catch(NumberFormatException ex) {
|
||||||
|
System.err.println("Invalid Double format in line " + lineCnt + ", data was " + entries[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i=0; i<cols.length; i++) {
|
for (int i=0; i<cols.length; i++) {
|
||||||
dest[lineCnt][i] = Double.valueOf(entries[cols[i]]);
|
try {
|
||||||
|
dest[lineCnt][i] = Double.valueOf(entries[cols[i]]);
|
||||||
|
} catch(NumberFormatException ex) {
|
||||||
|
System.err.println("Invalid Double format in line " + lineCnt + ", data was " + entries[cols[i]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user