Removed all m_ variable names (some remaining in comments -> I don't care!)
Now gonna get drunk and celebrate: 7.5k lines refactored! FYEAH
This commit is contained in:
parent
85fa426e30
commit
5ac9542893
@ -40,8 +40,8 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
transient private JFrame mainFrame;
|
||||
transient private JPanel mainPanel;
|
||||
transient private JPanel buttonPanel;
|
||||
transient private JButton m_RunButton, m_StopButton, m_Continue, m_ShowSolution;
|
||||
transient private JComponent optionsPanel, m_O1, m_O2;
|
||||
transient private JButton runButton, stopButton, continueButton, showSolutionButton;
|
||||
transient private JComponent optionsPanel, parameterPanel1, parameterPanel2;
|
||||
transient private JComponent statusPanel;
|
||||
transient private JLabel statusField;
|
||||
transient private JProgressBar progressBar;
|
||||
@ -65,12 +65,12 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
transient private Population backupPopulation;
|
||||
transient private boolean continueFlag;
|
||||
// Plot Panel stuff
|
||||
transient private Plot m_Plot;
|
||||
transient private Plot plot;
|
||||
transient private ArrayList performedRuns = new ArrayList();
|
||||
transient private ArrayList<Double[]> tmpData;
|
||||
transient private BufferedWriter outputFile;
|
||||
// Test
|
||||
transient private List m_List;
|
||||
transient private List list;
|
||||
|
||||
/**
|
||||
* Create a new EALectureGUI.
|
||||
@ -111,26 +111,26 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
this.mainPanel.setLayout(new BorderLayout());
|
||||
// build the button panel
|
||||
this.buttonPanel = new JPanel();
|
||||
this.m_RunButton = new JButton("Run");
|
||||
this.m_RunButton.addActionListener(this.runListener);
|
||||
this.m_RunButton.setEnabled(true);
|
||||
this.m_RunButton.setToolTipText("Run the optimization process with the current parameter settings.");
|
||||
this.m_StopButton = new JButton("Stop");
|
||||
this.m_StopButton.addActionListener(this.stopListener);
|
||||
this.m_StopButton.setEnabled(false);
|
||||
this.m_StopButton.setToolTipText("Stop the runnig the optimization process.");
|
||||
this.m_Continue = new JButton("Continue");
|
||||
this.m_Continue.addActionListener(this.continueListener);
|
||||
this.m_Continue.setEnabled(false);
|
||||
this.m_Continue.setToolTipText("Resume the previous optimization (check termination criteria and multiruns = 1!).");
|
||||
this.m_ShowSolution = new JButton("Show Solution");
|
||||
this.m_ShowSolution.addActionListener(this.showSolListener);
|
||||
this.m_ShowSolution.setEnabled(true);
|
||||
this.m_ShowSolution.setToolTipText("Show the current best solution.");
|
||||
this.buttonPanel.add(this.m_RunButton);
|
||||
this.buttonPanel.add(this.m_Continue);
|
||||
this.buttonPanel.add(this.m_StopButton);
|
||||
this.buttonPanel.add(this.m_ShowSolution);
|
||||
this.runButton = new JButton("Run");
|
||||
this.runButton.addActionListener(this.runListener);
|
||||
this.runButton.setEnabled(true);
|
||||
this.runButton.setToolTipText("Run the optimization process with the current parameter settings.");
|
||||
this.stopButton = new JButton("Stop");
|
||||
this.stopButton.addActionListener(this.stopListener);
|
||||
this.stopButton.setEnabled(false);
|
||||
this.stopButton.setToolTipText("Stop the runnig the optimization process.");
|
||||
this.continueButton = new JButton("Continue");
|
||||
this.continueButton.addActionListener(this.continueListener);
|
||||
this.continueButton.setEnabled(false);
|
||||
this.continueButton.setToolTipText("Resume the previous optimization (check termination criteria and multiruns = 1!).");
|
||||
this.showSolutionButton = new JButton("Show Solution");
|
||||
this.showSolutionButton.addActionListener(this.showSolListener);
|
||||
this.showSolutionButton.setEnabled(true);
|
||||
this.showSolutionButton.setToolTipText("Show the current best solution.");
|
||||
this.buttonPanel.add(this.runButton);
|
||||
this.buttonPanel.add(this.continueButton);
|
||||
this.buttonPanel.add(this.stopButton);
|
||||
this.buttonPanel.add(this.showSolutionButton);
|
||||
this.mainPanel.add(this.buttonPanel, BorderLayout.NORTH);
|
||||
|
||||
// build the Options Panel
|
||||
@ -151,12 +151,12 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
if ((object != null) && (editor != null)) {
|
||||
paraPanel.registerEditor(object, editor);
|
||||
}
|
||||
this.m_O1 = (paraPanel.makePanel());
|
||||
this.parameterPanel1 = (paraPanel.makePanel());
|
||||
this.optionsPanel = new JTabbedPane();
|
||||
JParaPanel paraPanel2 = new JParaPanel(this.optimizationParameters, "MyGUI");
|
||||
this.m_O2 = (paraPanel2.makePanel());
|
||||
((JTabbedPane) this.optionsPanel).addTab("Optimization Parameters", this.m_O2);
|
||||
((JTabbedPane) this.optionsPanel).addTab("Statistics", this.m_O1);
|
||||
this.parameterPanel2 = (paraPanel2.makePanel());
|
||||
((JTabbedPane) this.optionsPanel).addTab("Optimization Parameters", this.parameterPanel2);
|
||||
((JTabbedPane) this.optionsPanel).addTab("Statistics", this.parameterPanel1);
|
||||
this.mainPanel.add(this.optionsPanel, BorderLayout.CENTER);
|
||||
|
||||
// build the Status Panel
|
||||
@ -171,7 +171,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
double[] tmpD = new double[2];
|
||||
tmpD[0] = 1;
|
||||
tmpD[1] = 1;
|
||||
this.m_Plot = new Plot("EA Lecture Plot", "Function calls", "Fitness", true);
|
||||
this.plot = new Plot("EA Lecture Plot", "Function calls", "Fitness", true);
|
||||
// validate and show
|
||||
this.mainFrame.validate();
|
||||
this.mainFrame.setVisible(true);
|
||||
@ -192,16 +192,16 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
|
||||
@Override
|
||||
public void finished() {
|
||||
m_RunButton.setEnabled(true);
|
||||
m_Continue.setEnabled(true);
|
||||
m_StopButton.setEnabled(false);
|
||||
runButton.setEnabled(true);
|
||||
continueButton.setEnabled(true);
|
||||
stopButton.setEnabled(false);
|
||||
backupPopulation = (Population) optimizationParameters.getOptimizer().getPopulation().clone();
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
m_RunButton.setEnabled(false);
|
||||
m_Continue.setEnabled(false);
|
||||
m_StopButton.setEnabled(true);
|
||||
runButton.setEnabled(false);
|
||||
continueButton.setEnabled(false);
|
||||
stopButton.setEnabled(true);
|
||||
}
|
||||
};
|
||||
/**
|
||||
@ -212,12 +212,12 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
ActionListener stopListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
m_RunButton.setEnabled(true);
|
||||
m_Continue.setEnabled(true);
|
||||
m_StopButton.setEnabled(false);
|
||||
runButton.setEnabled(true);
|
||||
continueButton.setEnabled(true);
|
||||
stopButton.setEnabled(false);
|
||||
worker.interrupt();
|
||||
for (int i = 0; i < multiRuns; i++) {
|
||||
m_Plot.clearGraph(1000 + i);
|
||||
plot.clearGraph(1000 + i);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -238,9 +238,9 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
|
||||
@Override
|
||||
public void finished() {
|
||||
m_RunButton.setEnabled(true);
|
||||
m_Continue.setEnabled(true);
|
||||
m_StopButton.setEnabled(false);
|
||||
runButton.setEnabled(true);
|
||||
continueButton.setEnabled(true);
|
||||
stopButton.setEnabled(false);
|
||||
backupPopulation = (Population) optimizationParameters.getOptimizer().getPopulation().clone();
|
||||
continueFlag = false;
|
||||
}
|
||||
@ -250,9 +250,9 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
continueFlag = true;
|
||||
multiRuns = 1; // multiruns machen bei continue einfach keinen Sinn...
|
||||
worker.start();
|
||||
m_RunButton.setEnabled(false);
|
||||
m_Continue.setEnabled(false);
|
||||
m_StopButton.setEnabled(true);
|
||||
runButton.setEnabled(false);
|
||||
continueButton.setEnabled(false);
|
||||
stopButton.setEnabled(true);
|
||||
}
|
||||
};
|
||||
/**
|
||||
@ -334,14 +334,6 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
break;
|
||||
}
|
||||
}
|
||||
String m_MyHostName = "_";
|
||||
try {
|
||||
m_MyHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR getting HostName (GOStandalone.startExperiment) " + e.getMessage());
|
||||
}
|
||||
// EVAMail.SendMail("GOTask on "+m_MyHostName+ " finished", "Have a look at the results at the result file", "streiche@informatik.uni-tuebingen.de");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,8 +354,8 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
if (!this.outputFileName.equalsIgnoreCase("none")) {
|
||||
String name = "";
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss");
|
||||
String m_StartDate = formatter.format(new Date());
|
||||
name = this.outputPath + this.outputFileName + "_" + this.experimentName + "_" + m_StartDate + ".dat";
|
||||
String startDate = formatter.format(new Date());
|
||||
name = this.outputPath + this.outputFileName + "_" + this.experimentName + "_" + startDate + ".dat";
|
||||
try {
|
||||
this.outputFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name)));
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -389,7 +381,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
|
||||
for (int j = 0; j < this.multiRuns; j++) {
|
||||
this.optimizationParameters.getProblem().initializeProblem(); // in the loop as well, dynamic probs may need that (MK)
|
||||
this.tmpData = new ArrayList<Double[]>();
|
||||
this.tmpData = new ArrayList<>();
|
||||
this.currentRun = j;
|
||||
if (this.show) {
|
||||
this.statusField.setText("Optimizing Run " + (j + 1) + " of " + this.multiRuns + " Multi Runs...");
|
||||
@ -427,7 +419,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
tmpMultiRun.add(this.tmpData);
|
||||
}
|
||||
if (this.show) {
|
||||
this.m_Plot.setInfoString(this.currentExperiment, this.experimentName, 0.5f);
|
||||
this.plot.setInfoString(this.currentExperiment, this.experimentName, 0.5f);
|
||||
}
|
||||
if (this.show) {
|
||||
this.draw();
|
||||
@ -449,7 +441,7 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
}
|
||||
if (this.show) {
|
||||
for (int i = 0; i < this.multiRuns; i++) {
|
||||
this.m_Plot.clearGraph(1000 + i);
|
||||
this.plot.clearGraph(1000 + i);
|
||||
}
|
||||
}
|
||||
updateStatus(0);
|
||||
@ -497,21 +489,13 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
}
|
||||
}
|
||||
// Now enter this stuff into the graph
|
||||
this.m_Plot.clearGraph(this.currentExperiment);
|
||||
// tmpColor = Color.darkGray;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("MCS")) tmpColor = Color.magenta;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("MS-HC")) tmpColor = Color.green;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("GA")) tmpColor = Color.blue;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("PBIL")) tmpColor = Color.CYAN;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("CHC")) tmpColor = Color.ORANGE;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("ES")) tmpColor = Color.red;
|
||||
// if (this.optimizationParameters.getOptimizer().getName().equalsIgnoreCase("CBN-EA")) tmpColor = Color.black;
|
||||
this.plot.clearGraph(this.currentExperiment);
|
||||
|
||||
for (int j = 0; j < data.length; j++) {
|
||||
if (this.continueFlag) {
|
||||
this.m_Plot.setConnectedPoint(data[j][0] + this.recentFunctionCalls, data[j][1], this.currentExperiment);
|
||||
this.plot.setConnectedPoint(data[j][0] + this.recentFunctionCalls, data[j][1], this.currentExperiment);
|
||||
} else {
|
||||
this.m_Plot.setConnectedPoint(data[j][0], data[j][1], this.currentExperiment);
|
||||
this.plot.setConnectedPoint(data[j][0], data[j][1], this.currentExperiment);
|
||||
}
|
||||
}
|
||||
this.currentExperiment++;
|
||||
@ -594,11 +578,11 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
tmpData[0] = new Double(population.getFunctionCalls());
|
||||
// instead of adding simply the best fitness value i'll ask the problem what to show
|
||||
tmpData[1] = this.optimizationParameters.getProblem().getDoublePlotValue(population);
|
||||
if (this.m_Plot != null) {
|
||||
if (this.plot != null) {
|
||||
if (this.continueFlag) {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue() + this.recentFunctionCalls, tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
this.plot.setConnectedPoint(tmpData[0].doubleValue() + this.recentFunctionCalls, tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
} else {
|
||||
this.m_Plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
this.plot.setConnectedPoint(tmpData[0].doubleValue(), tmpData[1].doubleValue(), 1000 + this.currentRun);
|
||||
}
|
||||
}
|
||||
this.tmpData.add(tmpData);
|
||||
@ -714,66 +698,14 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
|
||||
* @param name
|
||||
*/
|
||||
public void setList(List name) {
|
||||
this.m_List = name;
|
||||
this.list = name;
|
||||
}
|
||||
|
||||
public List getListe() {
|
||||
return this.m_List;
|
||||
public List getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public String listTipText() {
|
||||
return "Set the name for the output file, if 'none' no output file will be created.";
|
||||
}
|
||||
// /** This method allows you to set the number of functions calls that are to
|
||||
// * be evaluated. Note generational optimizers may exceed this number since
|
||||
// * they allways evaluate the complete population
|
||||
// * @param functionCalls The maximal number of Function calls
|
||||
// */
|
||||
// public void setFunctionCalls(int functionCalls) {
|
||||
// this.functionCalls = functionCalls;
|
||||
// }
|
||||
// public int getFunctionCalls() {
|
||||
// return this.functionCalls;
|
||||
// }
|
||||
// public String functionCallsTipText() {
|
||||
// return "The maxiaml number of function(fitness) evaluations that are performed. Mote: Generational algorihtms may be delayed!";
|
||||
// }
|
||||
//
|
||||
// /** This method allows you to set the current optimizing algorithm
|
||||
// * @param optimizer The new optimizing algorithm
|
||||
// */
|
||||
// public void setOptimizer(InterfaceOptimizer optimizer) {
|
||||
// this.optimizer = optimizer;
|
||||
// this.optimizer.addPopulationChangedEventListener(this);
|
||||
// this.experimentName = this.optimizer.getName()+"-"+this.performedRuns.size();
|
||||
// this.optimizer.SetProblem(this.problem);
|
||||
// }
|
||||
// public InterfaceOptimizer getOptimizer() {
|
||||
// return this.optimizer;
|
||||
// }
|
||||
// public String optimizerTipText() {
|
||||
// return "Choose a optimizing strategies.";
|
||||
// }
|
||||
// /** This method will set the problem that is to be optimized
|
||||
// * @param problem
|
||||
// */
|
||||
// public void SetProblem (InterfaceOptimizationProblem problem) {
|
||||
// this.problem = problem;
|
||||
// this.optimizer.SetProblem(this.problem);
|
||||
// }
|
||||
// public InterfaceOptimizationProblem getProblem () {
|
||||
// return this.problem;
|
||||
// }
|
||||
// public String problemTipText() {
|
||||
// return "Choose the problem that is to optimize and the EA individual parameters.";
|
||||
// }
|
||||
// public void setTest(InterfaceTest v) {
|
||||
// this.test = v;
|
||||
// }
|
||||
// public InterfaceTest getTest() {
|
||||
// return this.test;
|
||||
// }
|
||||
// public String testTipText() {
|
||||
// return "Test";
|
||||
// }
|
||||
}
|
||||
|
@ -29,39 +29,28 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
*/
|
||||
public double decodeValueOld(BitSet refBitSet, double[] range, int[] locus, boolean correction) {
|
||||
double u_max, u_min;
|
||||
int m_start, m_length;
|
||||
int mStart, mLength;
|
||||
long tmpV;
|
||||
double output;
|
||||
//BitSet tmpBitSet;
|
||||
|
||||
u_min = range[0];
|
||||
u_max = range[1];
|
||||
m_start = locus[0];
|
||||
m_length = locus[1];
|
||||
mStart = locus[0];
|
||||
mLength = locus[1];
|
||||
|
||||
if (m_length != lastLen) {
|
||||
lastMaxVal = Math.pow(2, m_length) - 1;
|
||||
lastLen = m_length;
|
||||
if (mLength != lastLen) {
|
||||
lastMaxVal = Math.pow(2, mLength) - 1;
|
||||
lastLen = mLength;
|
||||
}
|
||||
|
||||
//tmpBitSet = new BitSet(m_length);
|
||||
tmpV = 0;
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (refBitSet.get(m_start + m_length - 1 - i)) {
|
||||
for (int i = 0; i < mLength; i++) {
|
||||
if (refBitSet.get(mStart + mLength - 1 - i)) {
|
||||
tmpV += Math.pow(2, i);
|
||||
// tmpBitSet.set(m_length - 1 - i);
|
||||
}
|
||||
}
|
||||
//System.out.println("intval is "+tmpV);
|
||||
//output = ((double)tmpV/m_max)*(u_max - u_min) + u_min;
|
||||
output = (((double) tmpV * (u_max - u_min)) / lastMaxVal) + u_min;
|
||||
// System.out.println("m_min/m_max " + m_min +"/"+m_max);
|
||||
// System.out.println("u_min/u_max " + u_min +"/"+u_max);
|
||||
// System.out.println("Decoding Long Value: " + tmpV);
|
||||
// System.out.println("Decoding Real Value: " + output);
|
||||
// correction is not necessary
|
||||
//System.out.print("FLOAT Value decoded : " + output + " " + this.printBitSet(tmpBitSet, m_length));
|
||||
//System.out.println(tmpV + "/" + m_max + "*(" + u_max + "-" + u_min + ")+" + u_min +"\n");
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -77,11 +66,11 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
@Override
|
||||
public double decodeValue(BitSet refBitSet, double[] range, int[] locus, boolean correction) {
|
||||
long val = (refBitSet.get(locus[0]) ? 1 : 0);
|
||||
int m_length = locus[1];
|
||||
int mLength = locus[1];
|
||||
|
||||
if (m_length != lastLen) {
|
||||
lastMaxVal = Math.pow(2, m_length) - 1;
|
||||
lastLen = m_length;
|
||||
if (mLength != lastLen) {
|
||||
lastMaxVal = Math.pow(2, mLength) - 1;
|
||||
lastLen = mLength;
|
||||
}
|
||||
|
||||
for (int i = 1 + locus[0]; i < locus[0] + locus[1]; i++) {
|
||||
@ -106,23 +95,19 @@ public class GAStandardCodingDouble implements InterfaceGADoubleCoding, java.io.
|
||||
*/
|
||||
@Override
|
||||
public void codeValue(double value, double[] range, BitSet refBitSet, int[] locus) {
|
||||
double u_max, u_min, m_max, m_min;
|
||||
double uMax, uMin, mMax, mMin;
|
||||
int m_start, m_length, counter = 0;
|
||||
long tmpV;
|
||||
BitSet tmpBitSet;
|
||||
|
||||
u_min = range[0];
|
||||
u_max = range[1];
|
||||
uMin = range[0];
|
||||
uMax = range[1];
|
||||
m_start = locus[0];
|
||||
m_length = locus[1];
|
||||
m_max = Math.pow(2, m_length) - 1;
|
||||
m_min = 0;
|
||||
mMax = Math.pow(2, m_length) - 1;
|
||||
mMin = 0;
|
||||
// here the value will be quantified
|
||||
tmpV = Math.round((((value - u_min) * m_max / (u_max - u_min))));
|
||||
// System.out.println("m_min/m_max " + m_min +"/"+m_max);
|
||||
// System.out.println("u_min/u_max " + u_min +"/"+u_max);
|
||||
// System.out.println("Coding Long Value: " + tmpV);
|
||||
// System.out.println("Coding Real Value: " + value);
|
||||
tmpV = Math.round((((value - uMin) * mMax / (uMax - uMin))));
|
||||
tmpBitSet = new BitSet(m_length);
|
||||
while (tmpV >= 1) {
|
||||
//System.out.println(tmpV);
|
||||
|
@ -24,24 +24,22 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
*/
|
||||
@Override
|
||||
public int decodeValue(BitSet refBitSet, int[] range, int[] locus, boolean correction) {
|
||||
int u_max, u_min, m_max, m_min;
|
||||
int m_start, m_length, counter = 0;
|
||||
int u_max, u_min;
|
||||
int start, mLength;
|
||||
long tmpV;
|
||||
BitSet tmpBitSet;
|
||||
String output = "";
|
||||
|
||||
u_min = range[0];
|
||||
u_max = range[1];
|
||||
m_start = locus[0];
|
||||
m_length = locus[1];
|
||||
m_max = (int) Math.pow(2, m_length) - 1;
|
||||
m_min = 0;
|
||||
tmpBitSet = new BitSet(m_length);
|
||||
start = locus[0];
|
||||
mLength = locus[1];
|
||||
tmpBitSet = new BitSet(mLength);
|
||||
tmpV = 0;
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (refBitSet.get(m_start + m_length - 1 - i)) {
|
||||
for (int i = 0; i < mLength; i++) {
|
||||
if (refBitSet.get(start + mLength - 1 - i)) {
|
||||
tmpV += Math.pow(2, i);
|
||||
tmpBitSet.set(m_length - 1 - i);
|
||||
tmpBitSet.set(mLength - 1 - i);
|
||||
output += "1";
|
||||
} else {
|
||||
output += "0";
|
||||
@ -49,10 +47,10 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
}
|
||||
//System.out.println(tmpV);
|
||||
tmpV += u_min;
|
||||
//System.out.println("Korregiere: " + tmpV + " " + u_min + " " + u_max + " " + output);
|
||||
//System.out.println("Korrigiere: " + tmpV + " " + u_min + " " + u_max + " " + output);
|
||||
if (tmpV > u_max) {
|
||||
// this value is invalid
|
||||
//System.out.print("Korregiere: " + tmpV + " > " + u_max);
|
||||
//System.out.print("Korrigiere: " + tmpV + " > " + u_max);
|
||||
if (correction) {
|
||||
// a new value within the bounds is generated
|
||||
tmpV = RNG.randomInt(u_min, u_max);
|
||||
@ -63,7 +61,6 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
//System.out.println("zu max: " + tmpV);
|
||||
}
|
||||
}
|
||||
//System.out.println("INT Value decoded : " + (int)tmpV + " " + this.printBitSet(tmpBitSet, m_length));
|
||||
return (int) tmpV;
|
||||
}
|
||||
|
||||
@ -79,26 +76,26 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
*/
|
||||
@Override
|
||||
public void codeValue(int value, int[] range, BitSet refBitSet, int[] locus) {
|
||||
int u_max, u_min, m_max, m_min;
|
||||
int m_start, m_length, counter = 0;
|
||||
int uMax, uMin, mMax, mMin;
|
||||
int start, length, counter = 0;
|
||||
long tmpV;
|
||||
BitSet tmpBitSet;
|
||||
|
||||
u_min = range[0];
|
||||
u_max = range[1];
|
||||
m_start = locus[0];
|
||||
m_length = locus[1];
|
||||
m_max = (int) Math.pow(2, m_length) - 1;
|
||||
m_min = 0;
|
||||
tmpV = value - u_min;
|
||||
long tmpOut = tmpV;// damit ist tmpV im range m_Min m_Max
|
||||
if (tmpV > m_max) {
|
||||
tmpV = m_max;
|
||||
uMin = range[0];
|
||||
uMax = range[1];
|
||||
start = locus[0];
|
||||
length = locus[1];
|
||||
mMax = (int) Math.pow(2, length) - 1;
|
||||
mMin = 0;
|
||||
tmpV = value - uMin;
|
||||
long tmpOut = tmpV;// damit ist tmpV im range mMin mMax
|
||||
if (tmpV > mMax) {
|
||||
tmpV = mMax;
|
||||
}
|
||||
if (tmpV < m_min) {
|
||||
tmpV = m_min;
|
||||
if (tmpV < mMin) {
|
||||
tmpV = mMin;
|
||||
}
|
||||
tmpBitSet = new BitSet(m_length);
|
||||
tmpBitSet = new BitSet(length);
|
||||
while (tmpV >= 1) {
|
||||
//System.out.println(tmpV);
|
||||
if ((tmpV % 2) == 1) {
|
||||
@ -113,23 +110,21 @@ public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.i
|
||||
tmpV /= 2;
|
||||
// with this method the least significant bit will be at the lowest position
|
||||
}
|
||||
//System.out.println("tmpV " + tmpOut + " Range("+m_min+";"+m_max+") "+m_length+" "+this.printBitSet(tmpBitSet,m_length));
|
||||
// Das sieht bis hierher richtig toll aus, nur jetzt wirds scheisse m_Length war im Arsch
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
// Das sieht bis hierher richtig toll aus, nur jetzt wirds scheisse length war im Arsch
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (tmpBitSet.get(i)) {
|
||||
refBitSet.set(m_start + m_length - 1 - i);
|
||||
refBitSet.set(start + length - 1 - i);
|
||||
} else {
|
||||
refBitSet.clear(m_start + m_length - 1 - i);
|
||||
refBitSet.clear(start + length - 1 - i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
if (refBitSet.get(m_start + m_length - 1 - i)) {
|
||||
tmpBitSet.set(m_length - 1 - i);
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (refBitSet.get(start + length - 1 - i)) {
|
||||
tmpBitSet.set(length - 1 - i);
|
||||
} else {
|
||||
tmpBitSet.clear(m_start + m_length - 1 - i);
|
||||
tmpBitSet.clear(start + length - 1 - i);
|
||||
}
|
||||
}
|
||||
//System.out.println("INT Value coded : " + value + " " + this.printBitSet(tmpBitSet, m_length));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,5 @@
|
||||
package eva2.optimization.modules;
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 306 $
|
||||
* $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
|
@ -17,22 +17,14 @@ import java.io.Serializable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The class gives access to all SA parameters for the EvA
|
||||
* top level GUI.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 08.06.2004
|
||||
* Time: 21:25:12
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class SAParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable {
|
||||
public class SAParameters extends AbstractOptimizationParameters implements Serializable {
|
||||
// Opt. Algorithms and Parameters
|
||||
private InterfaceOptimizer m_Optimizer = new SimulatedAnnealing();
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
//private int functionCalls = 1000;
|
||||
private InterfaceTerminator m_Terminator = new EvaluationTerminator();
|
||||
// private String m_OutputFileName = "none";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
private InterfaceOptimizer optimizer = new SimulatedAnnealing();
|
||||
private InterfaceOptimizationProblem problem = new B1Problem();
|
||||
private InterfaceTerminator terminator = new EvaluationTerminator();
|
||||
transient private InterfacePopulationChangedEventListener changedEventListener;
|
||||
|
||||
/**
|
||||
* Load or create a new instance of the class.
|
||||
@ -92,11 +84,11 @@ public class SAParameters extends AbstractOptimizationParameters implements Inte
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
public Population getPopulation() {
|
||||
return ((SimulatedAnnealing) this.m_Optimizer).getPopulation();
|
||||
return ((SimulatedAnnealing) this.optimizer).getPopulation();
|
||||
}
|
||||
|
||||
public void setPopulation(Population pop) {
|
||||
((SimulatedAnnealing) this.m_Optimizer).setPopulation(pop);
|
||||
((SimulatedAnnealing) this.optimizer).setPopulation(pop);
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
@ -110,11 +102,11 @@ public class SAParameters extends AbstractOptimizationParameters implements Inte
|
||||
* @return The initial temperature.
|
||||
*/
|
||||
public double getInitialTemperature() {
|
||||
return ((SimulatedAnnealing) this.m_Optimizer).getInitialTemperature();
|
||||
return ((SimulatedAnnealing) this.optimizer).getInitialTemperature();
|
||||
}
|
||||
|
||||
public void setInitialTemperature(double pop) {
|
||||
((SimulatedAnnealing) this.m_Optimizer).setInitialTemperature(pop);
|
||||
((SimulatedAnnealing) this.optimizer).setInitialTemperature(pop);
|
||||
}
|
||||
|
||||
public String initialTemperatureTipText() {
|
||||
@ -128,14 +120,14 @@ public class SAParameters extends AbstractOptimizationParameters implements Inte
|
||||
* @return The initial temperature.
|
||||
*/
|
||||
public double getAlpha() {
|
||||
return ((SimulatedAnnealing) this.m_Optimizer).getAlpha();
|
||||
return ((SimulatedAnnealing) this.optimizer).getAlpha();
|
||||
}
|
||||
|
||||
public void setAlpha(double a) {
|
||||
if (a > 1) {
|
||||
a = 1.0;
|
||||
}
|
||||
((SimulatedAnnealing) this.m_Optimizer).setAlpha(a);
|
||||
((SimulatedAnnealing) this.optimizer).setAlpha(a);
|
||||
}
|
||||
|
||||
public String alphaTipText() {
|
||||
|
@ -214,9 +214,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
||||
double[] fit = evaluate(x);
|
||||
individual.setFitness(fit);
|
||||
|
||||
// if (this.m_UseTestConstraint) {
|
||||
// if (x[0] < 1) individual.addConstraintViolation(1-x[0]);
|
||||
// }
|
||||
if ((this.bestIndividuum == null) || (this.bestIndividuum.getFitness(0) > individual.getFitness(0))) {
|
||||
this.bestIndividuum = (AbstractEAIndividual) individual.clone();
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ class MyLensViewer extends JPanel implements InterfaceSolutionViewer {
|
||||
*/
|
||||
private static final long serialVersionUID = 7945150208043416139L;
|
||||
Population indiesToPaint = new Population();
|
||||
// private double[] m_BestVariables;
|
||||
// private double m_BestFitness;
|
||||
private int theHeight, theWidth;
|
||||
FLensProblem lensProblem;
|
||||
|
||||
@ -64,25 +62,11 @@ class MyLensViewer extends JPanel implements InterfaceSolutionViewer {
|
||||
System.out.println(" G == null!?");
|
||||
return;
|
||||
}
|
||||
// Create a buffered image in which to draw
|
||||
// try {
|
||||
// this.theHeight = (int)g.getClipBounds().getHeight();
|
||||
// this.theWidth = (int)g.getClipBounds().getWidth();
|
||||
// this.m_CenterX = (int)g.getClipBounds().getCenterX();
|
||||
// this.m_CenterY = (int)g.getClipBounds().getCenterY();
|
||||
// } catch (java.lang.NullPointerException npe) {
|
||||
// //System.out.println("Try fail...");
|
||||
// }
|
||||
// This might cure the eternal display problems: just ignore clipping and leave it up to swing
|
||||
Dimension winDim = getSize();
|
||||
theHeight = winDim.height;
|
||||
theWidth = winDim.width;
|
||||
// m_CenterX = theWidth/2;
|
||||
// m_CenterY = theHeight/2;
|
||||
|
||||
// if (this.theHeight == 0) this.theHeight = 250;
|
||||
// if (this.theWidth == 0) this.theWidth = 350;
|
||||
// System.out.println(" h w cx cy " + theHeight + " " + theWidth + " " + m_CenterX + " " + m_CenterY );
|
||||
bufferedImage = new BufferedImage(this.theWidth, this.theHeight, BufferedImage.TYPE_INT_RGB);
|
||||
// Create a graphics contents on the buffered image
|
||||
Graphics2D g2D = bufferedImage.createGraphics();
|
||||
@ -176,7 +160,6 @@ class MyLensViewer extends JPanel implements InterfaceSolutionViewer {
|
||||
// this.paint(this.getGraphics());
|
||||
} else {
|
||||
InterfaceDataTypeDouble best = (InterfaceDataTypeDouble) pop.getBestIndividual();
|
||||
//this.m_BestFitness = ((AbstractEAIndividual)best).getFitness(0);
|
||||
if (indiesToPaint.size() == 0 || ((AbstractEAIndividual) best).isDominant(indiesToPaint.getBestIndividual())) {
|
||||
if (indiesToPaint.size() == 1) {
|
||||
indiesToPaint.set(0, best);
|
||||
@ -377,12 +360,6 @@ public class FLensProblem extends AbstractOptimizationProblem
|
||||
fitness += Math.pow(tmpFit[i], 2);
|
||||
}
|
||||
|
||||
// // Computation of fitness. Uses an approximation for very thin lenses.
|
||||
// // The fitness is the sum over all segments of the deviation from the center
|
||||
// // of focus of a beam running through a segment.
|
||||
// for (int i = 1; i < x.length; i++)
|
||||
// fitness = fitness + Math.pow(radius - m_SegmentHight / 2 - m_SegmentHight * (i - 1) - focalLength / m_SegmentHight * (epsilon - 1) * (x[i] - x[i-1]),2);
|
||||
|
||||
// Here the thickness of the middle segment of the lens is added to the fitness
|
||||
// to permit the optimization to reduce the overall thickness of the lens
|
||||
if (this.useMaterialConst) {
|
||||
|
@ -1,14 +1,5 @@
|
||||
package eva2.optimization.stat;
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 320 $
|
||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
|
||||
|
||||
import eva2.gui.plot.DataViewer;
|
||||
import eva2.gui.plot.DataViewerInterface;
|
||||
@ -24,7 +15,6 @@ import java.util.logging.Logger;
|
||||
public class GenericStatistics implements Serializable {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GenericStatistics.class.getName());
|
||||
//private Object m_target;
|
||||
private int test;
|
||||
private String[] propertyNames;
|
||||
private boolean[] states;
|
||||
@ -43,7 +33,6 @@ public class GenericStatistics implements Serializable {
|
||||
*
|
||||
*/
|
||||
private GenericStatistics(GenericStatistics Source) {
|
||||
//m_target = Source.m_target;
|
||||
test = Source.test;
|
||||
propertyNames = Source.propertyNames;
|
||||
states = Source.states;
|
||||
@ -57,17 +46,13 @@ public class GenericStatistics implements Serializable {
|
||||
*
|
||||
*/
|
||||
public GenericStatistics(Object target) {
|
||||
//m_target = target;
|
||||
//System.out.println("GenericStatistics-->");
|
||||
try {
|
||||
fields = getDeclaredFields(target);
|
||||
//if (TRACE) System.out.println("fields-->"+m_fields.length);
|
||||
propertyNames = new String[fields.length];
|
||||
states = new boolean[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
String desc = fields[i].toString(); //System.out.println("desc "+desc);
|
||||
int istransient = desc.indexOf("transient");
|
||||
//if (TRACE) System.out.println("Field :"+m_fields[i].getName() );
|
||||
Object FieldValue = null;
|
||||
if (istransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack
|
||||
fields[i].setAccessible(true);
|
||||
@ -176,13 +161,12 @@ public class GenericStatistics implements Serializable {
|
||||
if (fields[i].getName().equals(propertyNames[n])) {
|
||||
String desc = fields[i].toString(); //System.out.println("desc "+desc);
|
||||
int istransient = desc.indexOf("transient");
|
||||
//if (TRACE) System.out.println("Field :"+m_fields[i].getName() );
|
||||
|
||||
Object FieldValue = null;
|
||||
if (istransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack
|
||||
fields[i].setAccessible(true);
|
||||
try {
|
||||
FieldValue = fields[i].get(target);
|
||||
//System.out.println("m_PropertyNames "+m_PropertyNames[n] +" value "+FieldValue.toString());
|
||||
if (FieldValue instanceof Double) {
|
||||
data[index] = ((Double) FieldValue).doubleValue();
|
||||
}
|
||||
|
@ -5,29 +5,29 @@ package eva2.optimization.stat;
|
||||
*
|
||||
*/
|
||||
public class MovingAverage {
|
||||
private int m_size = 0;
|
||||
private int m_index = 0;
|
||||
private double m_Average;
|
||||
private double[] m_array;
|
||||
private boolean m_overflow = false;
|
||||
private int size = 0;
|
||||
private int index = 0;
|
||||
private double average;
|
||||
private double[] array;
|
||||
private boolean overflow = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public MovingAverage(int size) {
|
||||
m_size = size;
|
||||
m_array = new double[size];
|
||||
this.size = size;
|
||||
array = new double[size];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private MovingAverage(MovingAverage Source) {
|
||||
m_size = Source.m_size;
|
||||
m_index = Source.m_index;
|
||||
m_Average = Source.m_Average;
|
||||
m_array = (double[]) Source.m_array.clone();
|
||||
m_overflow = Source.m_overflow;
|
||||
size = Source.size;
|
||||
index = Source.index;
|
||||
average = Source.average;
|
||||
array = (double[]) Source.array.clone();
|
||||
overflow = Source.overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,29 +41,29 @@ public class MovingAverage {
|
||||
*
|
||||
*/
|
||||
public void add(double value) {
|
||||
m_array[m_index] = value;
|
||||
m_index++;
|
||||
if (m_index == m_size) {
|
||||
m_index = 0;
|
||||
m_overflow = true;
|
||||
array[index] = value;
|
||||
index++;
|
||||
if (index == size) {
|
||||
index = 0;
|
||||
overflow = true;
|
||||
}
|
||||
//
|
||||
m_Average = 0;
|
||||
int tail = m_index;
|
||||
//if (m_overflow=true)
|
||||
if (m_overflow) {
|
||||
tail = m_size;
|
||||
average = 0;
|
||||
int tail = index;
|
||||
//if (overflow=true)
|
||||
if (overflow) {
|
||||
tail = size;
|
||||
}
|
||||
for (int i = 0; i < tail; i++) {
|
||||
m_Average += m_array[i];
|
||||
average += array[i];
|
||||
}
|
||||
m_Average /= tail;
|
||||
average /= tail;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public double getAverage() {
|
||||
return m_Average;
|
||||
return average;
|
||||
}
|
||||
}
|
@ -43,10 +43,10 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
|
||||
public final static int OUTPUT_FILE_WINDOW = 2;
|
||||
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
||||
private int verboK = 10;
|
||||
private int m_Textoutput = 0;
|
||||
private int textoutput = 0;
|
||||
private int multiRuns = 1;
|
||||
private String resultFilePrefix = "EvA2";
|
||||
protected String m_Name = "not defined";
|
||||
protected String name = "not defined";
|
||||
private boolean useStatPlot = true;
|
||||
private boolean showAdditionalProblemInfo = false;
|
||||
private double convergenceRateThreshold = 0.001;
|
||||
@ -87,7 +87,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
|
||||
*
|
||||
*/
|
||||
public StatisticsParameter() {
|
||||
m_Name = "Statistics";
|
||||
name = "Statistics";
|
||||
outputVerbosity.setSelectedTag(VERBOSITY_KTH_IT);
|
||||
outputTo.setSelectedTag(1);
|
||||
}
|
||||
@ -98,9 +98,8 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = "\r\nStatisticsParameter (" + super.toString() + "):\r\nmultiRuns=" + multiRuns
|
||||
+ ", m_Textoutput=" + m_Textoutput
|
||||
+ // ", m_Plotoutput=" + m_Plotoutput +
|
||||
", verbosity= " + outputVerbosity.getSelectedString()
|
||||
+ ", textoutput=" + textoutput
|
||||
+ ", verbosity= " + outputVerbosity.getSelectedString()
|
||||
+ "\nTo " + outputTo.getSelectedString()
|
||||
+ ", " + BeanInspector.toString(graphSel.getStrings());
|
||||
return ret;
|
||||
@ -125,9 +124,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
|
||||
private StatisticsParameter(StatisticsParameter Source) {
|
||||
convergenceRateThreshold = Source.convergenceRateThreshold;
|
||||
useStatPlot = Source.useStatPlot;
|
||||
m_Textoutput = Source.m_Textoutput;
|
||||
// m_Plotoutput = Source.m_Plotoutput;
|
||||
// m_PlotFitness = Source.m_PlotFitness;
|
||||
textoutput = Source.textoutput;
|
||||
multiRuns = Source.multiRuns;
|
||||
resultFilePrefix = Source.resultFilePrefix;
|
||||
verboK = Source.verboK;
|
||||
@ -145,7 +142,7 @@ public class StatisticsParameter implements InterfaceStatisticsParameter, Interf
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return m_Name;
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,8 @@ import java.util.List;
|
||||
public class StatisticsStandalone extends AbstractStatistics implements InterfaceStatistics, Serializable {
|
||||
private static final long serialVersionUID = -8451652609212653368L;
|
||||
|
||||
// private String m_InfoString;
|
||||
private ArrayList<ArrayList<Object[]>> m_ResultData = null;
|
||||
private ArrayList<String> m_ResultHeaderStrings = null;
|
||||
private ArrayList<ArrayList<Object[]>> resultData = null;
|
||||
private ArrayList<String> resultHeaderStrings = null;
|
||||
private boolean collectData = false;
|
||||
|
||||
|
||||
@ -54,25 +53,25 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
@Override
|
||||
protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
if (collectData) {
|
||||
m_ResultData = new ArrayList<ArrayList<Object[]>>(statisticsParameter.getMultiRuns());
|
||||
resultData = new ArrayList<ArrayList<Object[]>>(statisticsParameter.getMultiRuns());
|
||||
List<String> description = getOutputHeaderFieldNames(informerList);
|
||||
m_ResultHeaderStrings = new ArrayList<String>();
|
||||
resultHeaderStrings = new ArrayList<String>();
|
||||
for (String str : description) {
|
||||
m_ResultHeaderStrings.add(str);
|
||||
resultHeaderStrings.add(str);
|
||||
}
|
||||
for (int i = 0; i < statisticsParameter.getMultiRuns(); i++) {
|
||||
m_ResultData.add(new ArrayList<Object[]>());
|
||||
resultData.add(new ArrayList<Object[]>());
|
||||
}
|
||||
} else {
|
||||
m_ResultData = null;
|
||||
m_ResultHeaderStrings = null;
|
||||
resultData = null;
|
||||
resultHeaderStrings = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void plotCurrentResults() {
|
||||
if (collectData && (m_ResultData != null)) {
|
||||
m_ResultData.get(optRunsPerformed).add(currentStatObjectData);
|
||||
if (collectData && (resultData != null)) {
|
||||
resultData.get(optRunsPerformed).add(currentStatObjectData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
if (specificData != null) {
|
||||
for (int i = 0; i < specificData.length; i++) {
|
||||
// ((ArrayList<Object[]>[]) resultFrame.get(i))[optRunsPerformed].add(new Double[] {new Double(functionCalls), specificData[i]});
|
||||
m_ResultData.get(optRunsPerformed).add(new Object[]{new Double(functionCalls), specificData});
|
||||
resultData.get(optRunsPerformed).add(new Object[]{new Double(functionCalls), specificData});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,14 +107,14 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<Object[]>> getCollectedData() {
|
||||
return m_ResultData;
|
||||
return resultData;
|
||||
}
|
||||
|
||||
public ArrayList<Object[]> getCollectedRunData(int runIndex) {
|
||||
return m_ResultData.get(runIndex);
|
||||
return resultData.get(runIndex);
|
||||
}
|
||||
|
||||
public ArrayList<String> getCollectedDataHeaders() {
|
||||
return m_ResultHeaderStrings;
|
||||
return resultHeaderStrings;
|
||||
}
|
||||
}
|
@ -119,8 +119,6 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
result.clear();
|
||||
// this.m_NormationOperator.computeSelectionProbability(this.population, "Fitness");
|
||||
//System.out.println("Population:"+this.population.getSolutionRepresentationFor());
|
||||
this.populationSelectionOperator.prepareSelection(this.population);
|
||||
this.recombSelectionOperator.prepareSelection(this.population);
|
||||
parents = this.populationSelectionOperator.selectFrom(this.population, this.population.getTargetSize());
|
||||
@ -224,7 +222,6 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
nextGeneration.addPopulation(this.population);
|
||||
// this.m_NormationOperator.computeSelectionProbability(nextGeneration, "Fitness");
|
||||
this.populationSelectionOperator.prepareSelection(this.population);
|
||||
tmp = this.populationSelectionOperator.selectFrom(nextGeneration, this.population.getTargetSize());
|
||||
nextGeneration.clear();
|
||||
@ -341,18 +338,6 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
|
||||
// /** This method will set the normation method that is to be used.
|
||||
// * @param normation
|
||||
// */
|
||||
// public void setNormationMethod (InterfaceNormation normation) {
|
||||
// this.m_NormationOperator = normation;
|
||||
// }
|
||||
// public InterfaceNormation getNormationMethod () {
|
||||
// return this.m_NormationOperator;
|
||||
// }
|
||||
// public String normationMethodTipText() {
|
||||
// return "Select the normation method.";
|
||||
// }
|
||||
|
||||
/**
|
||||
* Enable/disable elitism.
|
||||
|
@ -596,36 +596,18 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
if (best == null) {
|
||||
best = (AbstractEAIndividual) curSpecies.getBestEAIndividual().getClone();
|
||||
}
|
||||
// if (useDistraction) { // Add distractor!
|
||||
// if (distraction == null) distraction = new Distraction(distrDefaultStrength, Distraction.METH_BEST);
|
||||
// distraction.addDistractorFrom(curSpecies);
|
||||
// System.out.println("** Adding distractor! " + BeanInspector.toString(distraction.getDistractionCenter(curSpecies, distraction.getDistractionMethod().getSelectedTagID())));
|
||||
// }
|
||||
int toReinit = 0;
|
||||
if (true) { //if (m_UseArchive) {
|
||||
if (true) {
|
||||
populationArchive.add(best);
|
||||
// System.out.println((""+ population.getFunctionCalls() + " " + (BeanInspector.toString(best.getDoublePosition())).replaceAll(";|\\[|\\]", "")));
|
||||
species.remove(i); // remove the converged Species
|
||||
toReinit = curSpecies.size();
|
||||
}
|
||||
// else {
|
||||
// // reset the converged species to inactivity size = 1
|
||||
// toReinit=curSpecies.size()-1;
|
||||
// deactivateSpecies(curSpecies, best, null);
|
||||
// }
|
||||
// those will not be optimized anymore, so we dont need to doom them, but can directly add them to undiff!
|
||||
undifferentiatedPopulation.addPopulation(initializeIndividuals(toReinit));
|
||||
undifferentiatedPopulation.incrFunctionCallsBy(toReinit);
|
||||
|
||||
// if (this.debug) {
|
||||
// System.out.println("Undiff.Size: " + this.undifferentiatedPopulation.size() +"/"+this.undifferentiatedPopulation.getPopulationSize());
|
||||
// System.out.println("Diff.Size : " + ((Population)this.species.get(i)).size() +"/"+((Population)this.species.get(i)).getPopulationSize());
|
||||
// }
|
||||
// if (this.debug) System.out.println("--------------------------End converged");
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
} else {
|
||||
// actually optimize D_i
|
||||
// this.capMutationRate(curSpecies, 0.05);
|
||||
curSpecies.putData(InterfaceSpeciesAware.populationTagKey, InterfaceSpeciesAware.localPopTag);
|
||||
Population optimizedSpec = optimizeSpecies(curSpecies, true);
|
||||
this.species.set(i, optimizedSpec);
|
||||
@ -998,35 +980,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Return true if the given population is considered active.
|
||||
// *
|
||||
// * @param pop a population
|
||||
// * @return true, if pop is considered an active population, else false
|
||||
// */
|
||||
// protected boolean isActive(Population pop) {
|
||||
// return (pop.size() >= m_actSpecSize);
|
||||
// }
|
||||
// /**
|
||||
// * Deactivate a given species by removing all individuals and inserting
|
||||
// * only the given survivor, sets the population size to one.
|
||||
// *
|
||||
// * @param spec
|
||||
// */
|
||||
// protected void deactivateSpecies(Population spec, AbstractEAIndividual survivor, Population collectDoomed) {
|
||||
// if (!spec.remove(survivor)) System.err.println("WARNING: removing survivor failed in CBN.deactivateSpecies!");;
|
||||
// if (collectDoomed!=null) collectDoomed.addPopulation(spec);
|
||||
// spec.clear();
|
||||
// spec.add(survivor);
|
||||
// spec.setPopulationSize(1);
|
||||
// }
|
||||
// public int countActiveSpec() {
|
||||
// int k = 0;
|
||||
// for (int i=0; i<species.size(); i++) {
|
||||
// if (isActive(species.get(i))) k++;
|
||||
// }
|
||||
// return k;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method allows an optimizer to register a change in the optimizer.
|
||||
@ -1172,19 +1125,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return new SolutionSet(getPopulation(), sols);
|
||||
}
|
||||
|
||||
// /** Clearing removes all but the best individuals from an identified species.
|
||||
// * @return The current status of this flag
|
||||
// */
|
||||
// public boolean getApplyClearing() {
|
||||
// return this.m_UseClearing;
|
||||
// }
|
||||
// public void setApplyClearing(boolean b){
|
||||
// this.m_UseClearing = b;
|
||||
// }
|
||||
// public String applyClearingTipText() {
|
||||
// return "Clearing removes all but the best individuals from an identified species.";
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method allows you to set/get the switch that toggles the use of
|
||||
* species convergence.
|
||||
@ -1259,15 +1199,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return "The cluster algorithm on which the species merging is based.";
|
||||
}
|
||||
|
||||
// public void setUseArchive(boolean v) {
|
||||
// m_UseArchive = v;
|
||||
// }
|
||||
// public boolean isUseArchive() {
|
||||
// return m_UseArchive;
|
||||
// }
|
||||
// public String useArchiveTipText() {
|
||||
// return "Toggle usage of an archive where converged species are saved and the individuals reinitialized.";
|
||||
// }
|
||||
|
||||
/**
|
||||
* Determines how often species differentation/convergence is performed.
|
||||
|
@ -107,7 +107,7 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
private transient EvolutionStrategies[] peakOpts = null;
|
||||
Population population = new Population();
|
||||
private InterfaceOptimizationProblem problem;
|
||||
private transient InterfacePopulationChangedEventListener m_Listener;
|
||||
private transient InterfacePopulationChangedEventListener populationChangedEventListener;
|
||||
private String identifier = "Niching-ES";
|
||||
private transient TopoPlot plot = null;
|
||||
private transient Population randomNewIndies = null;
|
||||
@ -788,8 +788,8 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
if (this.populationChangedEventListener != null) {
|
||||
this.populationChangedEventListener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1024,14 +1024,14 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
m_Listener = ea;
|
||||
populationChangedEventListener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
if (ea.equals(m_Listener)) {
|
||||
m_Listener = null;
|
||||
if (ea.equals(populationChangedEventListener)) {
|
||||
populationChangedEventListener = null;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -38,7 +38,6 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
private InterfaceOptimizer optimizer = new GeneticAlgorithm();
|
||||
private InterfaceMigration migration = new SOBestMigration();
|
||||
private InterfaceOptimizationProblem optimizationProblem = new F8Problem();
|
||||
// private String[] m_NodesList;
|
||||
private int migrationRate = 10;
|
||||
private boolean heterogeneousProblems = false;
|
||||
// These are the processor to run on
|
||||
@ -104,15 +103,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
} else {
|
||||
// this is running on remote machines
|
||||
// ToDo: Parallelize with Threads?!?
|
||||
/*if (this.m_LocalServer == null) {
|
||||
this.m_LocalServer = RMIServer.getInstance();
|
||||
}
|
||||
try {
|
||||
myLocal = (InterfacePopulationChangedEventListener) RMIProxyLocal.newInstance(this);
|
||||
} catch(Exception e) {
|
||||
System.err.println("Island Model EA warning on local RMIServer... but i'll start anyway!");
|
||||
}
|
||||
String[] nodesList = this.m_Servers.getCheckedServerNodes();
|
||||
/*
|
||||
if ((nodesList == null) || (nodesList.length == 0)) {
|
||||
throw new RuntimeException("Error, no active remote servers available! Activate servers or use localOnly mode.");
|
||||
}
|
||||
@ -182,18 +173,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
// this is running on remote machines
|
||||
// ToDo: Parallellize with threads?!?
|
||||
/*
|
||||
if (this.m_LocalServer == null) {
|
||||
this.m_LocalServer = RMIServer.getInstance();
|
||||
}
|
||||
try {
|
||||
myLocal = (InterfacePopulationChangedEventListener) RMIProxyLocal.newInstance(this);
|
||||
} catch(Exception e) {
|
||||
System.err.println("Island Model EA warning on local RMIServer... but i'll try to start anyway!");
|
||||
}
|
||||
String[] nodesList = this.m_Servers.getCheckedServerNodes();
|
||||
if ((nodesList == null) || (nodesList.length == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.islands = new InterfaceOptimizer[nodesList.length];
|
||||
for (int i = 0; i < nodesList.length; i++) {
|
||||
this.islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.optimizer, nodesList[i]);
|
||||
@ -613,11 +593,6 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
System.err.println("Number of CPUs must be at least 1!");
|
||||
}
|
||||
}
|
||||
// TODO Deactivated from GUI because the current implementation does not really parallelize on a multicore.
|
||||
// Instead, the new direct problem parallelization can be used.
|
||||
// public int getNumberLocalCPUs() {
|
||||
// return this.m_LocalCPUs;
|
||||
// }
|
||||
|
||||
public String numberLocalCPUsTipText() {
|
||||
return "Set the number of local CPUS (>=1, only used in local mode).";
|
||||
|
Loading…
x
Reference in New Issue
Block a user