Change for GAES Blatt 7/08
This commit is contained in:
parent
1c3310c4d5
commit
a31beb8fa1
@ -22,8 +22,11 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
InterfaceSimpleProblem<?> simProb = new SimpleF1();
|
InterfaceSimpleProblem<?> simProb = new SimpleF1();
|
||||||
protected double m_DefaultRange = 10;
|
protected double m_DefaultRange = 10;
|
||||||
protected double m_Noise = 0;
|
protected double m_Noise = 0;
|
||||||
transient Plot m_plot;
|
private int repaintMinWait = 20;
|
||||||
|
private int repaintCnt = 0;
|
||||||
|
transient Plot m_plot = null;
|
||||||
String plotFunc = "plotBest";
|
String plotFunc = "plotBest";
|
||||||
|
transient private boolean resetTemplate = true;
|
||||||
|
|
||||||
public SimpleProblemWrapper() {
|
public SimpleProblemWrapper() {
|
||||||
m_plot = null;
|
m_plot = null;
|
||||||
@ -77,11 +80,15 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
}
|
}
|
||||||
public void evaluatePopulationEnd(Population population) {
|
public void evaluatePopulationEnd(Population population) {
|
||||||
super.evaluatePopulationEnd(population);
|
super.evaluatePopulationEnd(population);
|
||||||
|
repaintCnt += population.size();
|
||||||
if (m_plot != null) {
|
if (m_plot != null) {
|
||||||
Object[] args = new Object[2];
|
if (repaintCnt >= repaintMinWait) { // dont repaint always for small pops
|
||||||
args[0] = m_plot;
|
Object[] args = new Object[2];
|
||||||
args[1] = population.getBestEAIndividual();
|
args[0] = m_plot;
|
||||||
BeanInspector.callIfAvailable(simProb, plotFunc, args);
|
args[1] = population.getBestEAIndividual();
|
||||||
|
BeanInspector.callIfAvailable(simProb, plotFunc, args);
|
||||||
|
repaintCnt = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +117,19 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void initTemplate() {
|
protected void initTemplate() {
|
||||||
if (simProb instanceof SimpleProblemDouble) {
|
if (resetTemplate) {
|
||||||
this.m_Template = new ESIndividualDoubleData();
|
if (simProb instanceof SimpleProblemDouble) {
|
||||||
((ESIndividualDoubleData)this.m_Template).setDoubleDataLength(simProb.getProblemDimension());
|
this.m_Template = new ESIndividualDoubleData();
|
||||||
((ESIndividualDoubleData)this.m_Template).SetDoubleRange(makeRange());
|
} else if (simProb instanceof SimpleProblemBinary) {
|
||||||
} else if (simProb instanceof SimpleProblemBinary) {
|
this.m_Template = new GAIndividualBinaryData();
|
||||||
this.m_Template = new GAIndividualBinaryData();
|
}
|
||||||
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(simProb.getProblemDimension());
|
|
||||||
}
|
}
|
||||||
|
if (m_Template instanceof InterfaceDataTypeDouble) {
|
||||||
|
((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(simProb.getProblemDimension());
|
||||||
|
((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(makeRange());
|
||||||
|
} else if (m_Template instanceof InterfaceDataTypeBinary) {
|
||||||
|
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(simProb.getProblemDimension());
|
||||||
|
} else System.err.println("Individual type not valid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double[][] makeRange() {
|
protected double[][] makeRange() {
|
||||||
@ -223,6 +235,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIndividualTemplate(AbstractEAIndividual indy) {
|
public void setIndividualTemplate(AbstractEAIndividual indy) {
|
||||||
|
resetTemplate = false;
|
||||||
m_Template = indy;
|
m_Template = indy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user