Minor adaptations.
This commit is contained in:
parent
50511b0ed5
commit
7633618f59
@ -12,6 +12,18 @@ function int = JEInterface(interfaceName, fhandle, range, varargin)
|
|||||||
% JavaEvA default values.
|
% JavaEvA default values.
|
||||||
% defaultArgs: (optional) additional constant argument to the target
|
% defaultArgs: (optional) additional constant argument to the target
|
||||||
% function, empty by default.
|
% function, empty by default.
|
||||||
|
% Recognized options are:
|
||||||
|
% TolX: convergence criterion in the solution space
|
||||||
|
% TolFun: convergence criterion in the target space
|
||||||
|
% MaxFunEvals: maximum number of function evaluations
|
||||||
|
% Display: 'off'/'final'/'notify'/'iter', where 'notify' corresponds to
|
||||||
|
% displaying every k-th iteration, which k=10 as default.
|
||||||
|
% The termination criterion of a run is a combination of the TolX, TolFun and
|
||||||
|
% MaxFunEvals criteria. The run terminates if MaxFunEvals has been reached
|
||||||
|
% or the best solution changes both in domain and codomain less than TolX
|
||||||
|
% and TolFun for a certain time, e.g. 100 evaluations.
|
||||||
|
% To ignore a criterion, set it to 0. E.g. to perform 10^5 evaluations in
|
||||||
|
% any case, set TolX=TolFun=0 and MaxFunEvals=10^5.
|
||||||
|
|
||||||
int.args = [];
|
int.args = [];
|
||||||
int.opts = optimset('MaxFunEvals', javaeva.OptimizerFactory.getDefaultFitCalls, 'TolX', 1e-4, 'TolFun', 1e-4);
|
int.opts = optimset('MaxFunEvals', javaeva.OptimizerFactory.getDefaultFitCalls, 'TolX', 1e-4, 'TolFun', 1e-4);
|
||||||
|
@ -39,6 +39,7 @@ if ((nargin == 2) || (nargin == 3))
|
|||||||
% values of 1e-4 in . Thats what we do as well
|
% values of 1e-4 in . Thats what we do as well
|
||||||
if (isempty(int.opts.TolX)) ; xTol = 1e-4; end
|
if (isempty(int.opts.TolX)) ; xTol = 1e-4; end
|
||||||
if (isempty(int.opts.TolFun)) ; fTol = 1e-4; end
|
if (isempty(int.opts.TolFun)) ; fTol = 1e-4; end
|
||||||
|
|
||||||
% construct Terminators
|
% construct Terminators
|
||||||
if ((xTol > 0) && (fTol > 0))
|
if ((xTol > 0) && (fTol > 0))
|
||||||
% both criteria are given, use combination
|
% both criteria are given, use combination
|
||||||
@ -63,7 +64,7 @@ if ((nargin == 2) || (nargin == 3))
|
|||||||
javaeva.OptimizerFactory.setTerminator(convTerm);
|
javaeva.OptimizerFactory.setTerminator(convTerm);
|
||||||
else % there is a convergence terminator
|
else % there is a convergence terminator
|
||||||
javaeva.OptimizerFactory.setTerminator(convTerm); % so set it
|
javaeva.OptimizerFactory.setTerminator(convTerm); % so set it
|
||||||
if (~isempty(maxEvals))
|
if (~isempty(maxEvals) && (maxEvals > 0))
|
||||||
% if TolX/TolFun plus MaxFunEvals is defined additionally, combine an
|
% if TolX/TolFun plus MaxFunEvals is defined additionally, combine an
|
||||||
% EvaluationTerminator in disjunction, as Matlab does.
|
% EvaluationTerminator in disjunction, as Matlab does.
|
||||||
javaeva.OptimizerFactory.addTerminator(EvaluationTerminator(maxEvals), 0);
|
javaeva.OptimizerFactory.addTerminator(EvaluationTerminator(maxEvals), 0);
|
||||||
@ -73,10 +74,17 @@ if ((nargin == 2) || (nargin == 3))
|
|||||||
% set display
|
% set display
|
||||||
if (strcmp(int.opts.Display,'off') || isempty(int.opts.Display))
|
if (strcmp(int.opts.Display,'off') || isempty(int.opts.Display))
|
||||||
int.mp.setStatsOutput(0);
|
int.mp.setStatsOutput(0);
|
||||||
elseif (strcmp(int.opts.Display, 'iter'))
|
elseif (strcmp(int.opts.Display, 'final'))
|
||||||
int.mp.setStatsOutput(1);
|
int.mp.setStatsOutput(1);
|
||||||
|
elseif (strcmp(int.opts.Display, 'notify'))
|
||||||
|
% 'notify' is not the perfect notion for "show every k-th
|
||||||
|
% iteration", but optimset wont allow changing names.
|
||||||
|
int.mp.setStatsOutput(2);
|
||||||
|
elseif (strcmp(int.opts.Display, 'iter'))
|
||||||
|
% this should rather be 2 in JE slang, but in matlab slang its more like 3
|
||||||
|
int.mp.setStatsOutput(3);
|
||||||
else
|
else
|
||||||
error('invalid Display option, only off/iter are recognized');
|
error('invalid Display option, only off/final/notify/iter are recognized');
|
||||||
end
|
end
|
||||||
|
|
||||||
int=runEvalLoopJE(int, 1, optType, outputFilePrefix, -1, -1, -1);
|
int=runEvalLoopJE(int, 1, optType, outputFilePrefix, -1, -1, -1);
|
||||||
|
@ -2,6 +2,10 @@ function int=runEvalLoopJE(int, optOrPostProc, optType, outputFilePrefix, steps,
|
|||||||
% Internal method starting a JavaEvA optimization loop.
|
% Internal method starting a JavaEvA optimization loop.
|
||||||
% Calling this directly may interfere with optimization.
|
% Calling this directly may interfere with optimization.
|
||||||
|
|
||||||
|
% This function handles the communciation between JE and Matlab, main
|
||||||
|
% optimization configuration is done in the
|
||||||
|
% optimize/optimizeWith/postProcess functions from which this one should be
|
||||||
|
% called.
|
||||||
% optOrPostProc: 1 for optimize, 2 for postProcess
|
% optOrPostProc: 1 for optimize, 2 for postProcess
|
||||||
% optType, outputFilePrefix are parameters for optimize, dont care when
|
% optType, outputFilePrefix are parameters for optimize, dont care when
|
||||||
% postprocessing.
|
% postprocessing.
|
||||||
@ -36,16 +40,18 @@ end
|
|||||||
% stopOptimization is empty. if it is then it is not the toolbox calling
|
% stopOptimization is empty. if it is then it is not the toolbox calling
|
||||||
% and we create an own button to stop it.
|
% and we create an own button to stop it.
|
||||||
if isempty(stopOptimization),
|
if isempty(stopOptimization),
|
||||||
% create a cancel button box (case without SBtoolbox)
|
% set switch to 0 now
|
||||||
h=figure('Position',[100 600 250 80], 'MenuBar', 'none', 'Name', 'JavaEvA optimization running...', 'NumberTitle','off');
|
|
||||||
uicontrol(h,'Style', 'pushbutton', 'String', 'Cancel', 'Position', [25 25 60 30], 'Callback', 'global stopOptimization; stopOptimization=1;');
|
|
||||||
uicontrol(h,'Style', 'text', 'String', stopText, 'Position', [100 25 120 30]);
|
|
||||||
drawnow;
|
|
||||||
% set it to 0 now
|
|
||||||
stopOptimization = 0;
|
stopOptimization = 0;
|
||||||
|
|
||||||
|
% create a cancel button box (case without SBtoolbox)
|
||||||
|
boxHandle=figure('Position',[100 600 250 80], 'MenuBar', 'none', 'Name', 'JavaEvA optimization running...', 'NumberTitle','off');
|
||||||
|
uicontrol(boxHandle,'Style', 'pushbutton', 'String', 'Cancel', 'Position', [25 25 60 30], 'Callback', 'global stopOptimization; stopOptimization=1;');
|
||||||
|
uicontrol(boxHandle,'Style', 'text', 'String', stopText, 'Position', [100 25 120 30]);
|
||||||
|
drawnow;
|
||||||
% set flag for non toolbox optimization
|
% set flag for non toolbox optimization
|
||||||
nontoolboxopt = 1;
|
nontoolboxopt = 1;
|
||||||
else
|
else
|
||||||
|
% disp('seems like the toolbox is going on');
|
||||||
% its an estimation using the toolbox' parameter estimation thing
|
% its an estimation using the toolbox' parameter estimation thing
|
||||||
nontoolboxopt = 0;
|
nontoolboxopt = 0;
|
||||||
end
|
end
|
||||||
@ -77,10 +83,12 @@ catch
|
|||||||
disp('Error in evaluate!');
|
disp('Error in evaluate!');
|
||||||
%int.mediator.quit; % just in case
|
%int.mediator.quit; % just in case
|
||||||
%int.mediator='';
|
%int.mediator='';
|
||||||
if (nontoolboxopt == 1)
|
|
||||||
if (ishandle(h)) , close(h); end
|
% why should this be done more than once in the end?
|
||||||
clear global stopOptimization
|
%if (nontoolboxopt == 1)
|
||||||
end
|
% if (ishandle(int.boxHandle)) , close(int.boxHandle); int.boxHandle=''; end
|
||||||
|
% clear global stopOptimization
|
||||||
|
%end
|
||||||
end
|
end
|
||||||
|
|
||||||
% write back results
|
% write back results
|
||||||
@ -94,6 +102,6 @@ int.mediator='';
|
|||||||
% and not from the toolboxes parameter estimation function (which has an
|
% and not from the toolboxes parameter estimation function (which has an
|
||||||
% own stop button). we decide this by checking nontoolboxopt
|
% own stop button). we decide this by checking nontoolboxopt
|
||||||
if nontoolboxopt == 1,
|
if nontoolboxopt == 1,
|
||||||
if (ishandle(h)) , close(h); end
|
if (ishandle(boxHandle)) , close(boxHandle); end
|
||||||
clear global stopOptimization
|
clear global stopOptimization
|
||||||
end
|
end
|
||||||
|
@ -16,6 +16,7 @@ if (nargin > 1) && (ischar(varargin{1}) && (strcmp(varargin{1},'kill')==1))
|
|||||||
JEMediator.quit; % just in case
|
JEMediator.quit; % just in case
|
||||||
JEMediator='';
|
JEMediator='';
|
||||||
clear global JEMediator;
|
clear global JEMediator;
|
||||||
|
clear global stopOptimization;
|
||||||
else
|
else
|
||||||
disp('no mediator to kill');
|
disp('no mediator to kill');
|
||||||
end
|
end
|
||||||
|
@ -11,13 +11,31 @@ behaviour seen in animals like birds or ants. A swarm of particles is a set of i
|
|||||||
"flying" across the search space with individual velocity vectors. There is no selection as in
|
"flying" across the search space with individual velocity vectors. There is no selection as in
|
||||||
classic Evolutionary Algorithms. Instead, the individuals exchange knowledge about the space they
|
classic Evolutionary Algorithms. Instead, the individuals exchange knowledge about the space they
|
||||||
have come across. Each one is attracted to the best position the individual has seen so far (cognitive
|
have come across. Each one is attracted to the best position the individual has seen so far (cognitive
|
||||||
component) and to the best position known by its neighbors (social component).<br>
|
component) and to the best position known by its neighbors (social component).
|
||||||
|
<p>
|
||||||
The neighborhood is defined by the swarm velocity, which may be a linear ordering, a grid and some others.
|
The neighborhood is defined by the swarm velocity, which may be a linear ordering, a grid and some others.
|
||||||
The influence of the velocity of the last time-step is taken into account using an inertness/
|
The influence of the velocity of the last time-step is taken into account using an inertness/
|
||||||
constriction parameter, which controls the convergence behaviour of the swarm.
|
constriction parameter, which controls the convergence behaviour of the swarm.
|
||||||
|
</p>
|
||||||
The influence of social and cognitive attraction are weighed using the <i>phi</i> parameters. In the
|
The influence of social and cognitive attraction are weighed using the <i>phi</i> parameters. In the
|
||||||
constriction variant there is a dependence enforced between constriction and the phi, making sure that
|
constriction variant there is a dependence enforced between constriction and the phi, making sure that
|
||||||
the swarm converges slowly but steadily, see the publications of Clerc, e.g. <br>
|
the swarm converges slowly but steadily, see the publications of M.Clerc, e.g.
|
||||||
|
Typical values for the attractor weights are phi1=phi2=2.05.
|
||||||
|
<p>
|
||||||
|
The topology defines the communication structure of the swarm. In linear topology, each particle has contact
|
||||||
|
to n others in two directions, so there is a linear overlay structure. The grid topology connects a particle
|
||||||
|
in 4 directions, while the star variant is completely connected. The random variant just connects each
|
||||||
|
particle to k others by random and anew in every generation cycle.
|
||||||
|
Basically, the more connections are available, the quicker will information about good areas spread through
|
||||||
|
the swarm and lead to quicker convergence, thereby increasing the risk of converging prematurely.
|
||||||
|
By default, the random (e.g. with range=4) or grid structure (e.g. with range=2) are good choices.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The multi-swarm approach splits the main swarm in sub-swarms defined by the distance to a local "leader",
|
||||||
|
as in the dynamic multi-swarm approaches by Shi and Branke, for example. The tree structure orders the
|
||||||
|
swarm to a tree of degree k, where the fittest individuals are on top and inform all their children nodes.
|
||||||
|
In this case, the higher the degree, the quicker will information spread. HPSO is a hierarchical tree variant
|
||||||
|
by Janson and Middendorf, 2005.
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -142,4 +142,14 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
return ((InterfaceDataTypeInteger)indy).getIntegerData();
|
return ((InterfaceDataTypeInteger)indy).getIntegerData();
|
||||||
} else return null;
|
} else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the verbosity level in the statistics module to the given value. See StatsParameter.
|
||||||
|
* @param vLev
|
||||||
|
*/
|
||||||
|
public void setVerbosityLevel(int vLev) {
|
||||||
|
if (vLev >= 0 && vLev < proc.getStatistics().getStatisticsParameter().getOutputVerbosity().getTags().length) {
|
||||||
|
proc.getStatistics().getStatisticsParameter().getOutputVerbosity().setSelectedTag(vLev);
|
||||||
|
} else System.err.println("Invalid verbosity leveln in OptimizerRunnable.setVerbosityLevel!");
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import wsi.ra.jproxy.RMIProxyLocal;
|
import wsi.ra.jproxy.RMIProxyLocal;
|
||||||
@ -86,6 +87,7 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
|||||||
m_Adapter.startOpt();
|
m_Adapter.startOpt();
|
||||||
m_actStop.setEnabled(true);
|
m_actStop.setEnabled(true);
|
||||||
m_RunButton.setEnabled(false);
|
m_RunButton.setEnabled(false);
|
||||||
|
m_PPButton.setEnabled(false);
|
||||||
// m_RestartButton.setEnabled(false);
|
// m_RestartButton.setEnabled(false);
|
||||||
m_JHelpButton.setEnabled(true);
|
m_JHelpButton.setEnabled(true);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
@ -124,7 +126,7 @@ public class JModuleGeneralPanel implements RemoteStateListener, Serializable {
|
|||||||
m_PPButton.addActionListener(new ActionListener() {
|
m_PPButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
try {
|
try {
|
||||||
m_Adapter.startPostProcessing();
|
if (!m_Adapter.startPostProcessing()) JOptionPane.showMessageDialog(null, "Post processing seems deactivated! Check the settings.", "Warning", JOptionPane.WARNING_MESSAGE);
|
||||||
// m_actStop.setEnabled(true);
|
// m_actStop.setEnabled(true);
|
||||||
// m_RunButton.setEnabled(false);
|
// m_RunButton.setEnabled(false);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
|
@ -9,8 +9,9 @@ import javaeva.server.go.individuals.ESIndividualDoubleData;
|
|||||||
* Time: 19:15:03
|
* Time: 19:15:03
|
||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
public class F14Problem extends F1Problem implements java.io.Serializable {
|
public class F14Problem extends F1Problem implements InterfaceMultimodalProblem, java.io.Serializable {
|
||||||
double rotation = 0.;
|
double rotation = 0.;
|
||||||
|
double rotationDX = 2;
|
||||||
|
|
||||||
public F14Problem() {
|
public F14Problem() {
|
||||||
this.m_Template = new ESIndividualDoubleData();
|
this.m_Template = new ESIndividualDoubleData();
|
||||||
@ -35,8 +36,8 @@ public class F14Problem extends F1Problem implements java.io.Serializable {
|
|||||||
*/
|
*/
|
||||||
public double[] eval(double[] x) {
|
public double[] eval(double[] x) {
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double x0 = x[0]-2;
|
double x0 = x[0]-rotationDX;
|
||||||
double x1 = x[1]-2;
|
double x1 = x[1]-rotationDX;
|
||||||
if (rotation != 0.) {
|
if (rotation != 0.) {
|
||||||
double cosw = Math.cos(rotation);
|
double cosw = Math.cos(rotation);
|
||||||
double sinw = Math.sin(rotation);
|
double sinw = Math.sin(rotation);
|
||||||
@ -60,6 +61,10 @@ public class F14Problem extends F1Problem implements java.io.Serializable {
|
|||||||
this.rotation = 2 * Math.PI * rotation / 360.0;
|
this.rotation = 2 * Math.PI * rotation / 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String rotationTipText() {
|
||||||
|
return "The rotation angle in degrees.";
|
||||||
|
}
|
||||||
|
|
||||||
/** This method returns a string describing the optimization problem.
|
/** This method returns a string describing the optimization problem.
|
||||||
* @return The description.
|
* @return The description.
|
||||||
*/
|
*/
|
||||||
@ -67,7 +72,7 @@ public class F14Problem extends F1Problem implements java.io.Serializable {
|
|||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
result += "F14 function:\n";
|
result += "F14 function:\n";
|
||||||
result += "Several local minima in a straight line\n";
|
result += "Several local minima in linear order which may be rotated.\n";
|
||||||
//result += this.m_Template.getSolutionRepresentationFor();
|
//result += this.m_Template.getSolutionRepresentationFor();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -80,13 +85,13 @@ public class F14Problem extends F1Problem implements java.io.Serializable {
|
|||||||
* @return The name.
|
* @return The name.
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "F14 Problem";
|
return "F14-Problem";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns a global info string
|
/** This method returns a global info string
|
||||||
* @return description
|
* @return description
|
||||||
*/
|
*/
|
||||||
public String globalInfo() {
|
public String globalInfo() {
|
||||||
return "F14 function.";
|
return "F14 function: numerous optima in linear order which may be rotated.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
|
|||||||
transient PrintStream dos = null;
|
transient PrintStream dos = null;
|
||||||
protected double[][] range = null;
|
protected double[][] range = null;
|
||||||
private static final String defTestOut = "matlabproblem-testout.dat";
|
private static final String defTestOut = "matlabproblem-testout.dat";
|
||||||
boolean forwardStatisticsOutput = false;
|
int verbosityLevel = 0;
|
||||||
private MatlabEvalMediator handler = null;
|
private MatlabEvalMediator handler = null;
|
||||||
|
|
||||||
public static boolean hideFromGOE = true;
|
public static boolean hideFromGOE = true;
|
||||||
@ -133,8 +133,11 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
|
|||||||
// this.jmInterface = jmInterface;
|
// this.jmInterface = jmInterface;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void setStatsOutput(boolean forwardStats) {
|
public void setStatsOutput(int verboLevel) {
|
||||||
forwardStatisticsOutput = forwardStats;
|
if ((verboLevel >= 0) && (verboLevel <= 3)) {
|
||||||
|
verbosityLevel = verboLevel;
|
||||||
|
}
|
||||||
|
else System.err.println("Error, invalid verbosity level for statistics output!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String jmiInterfaceNameTipText() {
|
public String jmiInterfaceNameTipText() {
|
||||||
@ -225,6 +228,8 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
|
|||||||
runnable = OptimizerFactory.getOptRunnable(optType, (AbstractOptimizationProblem)this, outputFilePrefix);
|
runnable = OptimizerFactory.getOptRunnable(optType, (AbstractOptimizationProblem)this, outputFilePrefix);
|
||||||
// runnable.getGOParams().setPostProcessParams(new PostProcessParams(0, 0.01, 5));
|
// runnable.getGOParams().setPostProcessParams(new PostProcessParams(0, 0.01, 5));
|
||||||
runnable.setTextListener(this);
|
runnable.setTextListener(this);
|
||||||
|
runnable.setVerbosityLevel(verbosityLevel);
|
||||||
|
|
||||||
if ((specParams != null) && (specParams.length > 0)) {
|
if ((specParams != null) && (specParams.length > 0)) {
|
||||||
if ((specValues == null) || (specValues.length != specParams.length)) {
|
if ((specValues == null) || (specValues.length != specParams.length)) {
|
||||||
System.err.println("mismatching value list for parameter arguments: " + specValues);
|
System.err.println("mismatching value list for parameter arguments: " + specValues);
|
||||||
@ -388,7 +393,7 @@ public class MatlabProblem extends AbstractProblemDouble implements InterfaceTex
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void print(String str) {
|
public void print(String str) {
|
||||||
if (forwardStatisticsOutput) {
|
if (verbosityLevel > 0) {
|
||||||
// matlab displays sysout output in the command window, so we simply use this channel
|
// matlab displays sysout output in the command window, so we simply use this channel
|
||||||
System.out.print(str);
|
System.out.print(str);
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,8 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
protected int m_TopologyRange = 2;
|
protected int m_TopologyRange = 2;
|
||||||
protected double m_InitialVelocity = 0.2;
|
protected double m_InitialVelocity = 0.2;
|
||||||
protected double m_SpeedLimit = 0.1;
|
protected double m_SpeedLimit = 0.1;
|
||||||
protected double m_Phi1 = 2.8;
|
protected double m_Phi1 = 2.05;
|
||||||
protected double m_Phi2 = 1.3;
|
protected double m_Phi2 = 2.05;
|
||||||
// for multi-swarm topology: radius of the swarm relative to the range
|
// for multi-swarm topology: radius of the swarm relative to the range
|
||||||
protected double m_swarmRadius = 0.2;
|
protected double m_swarmRadius = 0.2;
|
||||||
// for multi-swarm: maximum sub swarm size. zero means unlimited
|
// for multi-swarm: maximum sub swarm size. zero means unlimited
|
||||||
@ -105,7 +105,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
|
|
||||||
public ParticleSwarmOptimization() {
|
public ParticleSwarmOptimization() {
|
||||||
this.m_Topology = new SelectedTag( "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" );
|
this.m_Topology = new SelectedTag( "Linear", "Grid", "Star", "Multi-Swarm", "Tree", "HPSO", "Random" );
|
||||||
m_Topology.setSelectedTag(2);
|
m_Topology.setSelectedTag(1);
|
||||||
|
|
||||||
algType = new SelectedTag("Inertness", "Constriction");
|
algType = new SelectedTag("Inertness", "Constriction");
|
||||||
algType.setSelectedTag(1);
|
algType.setSelectedTag(1);
|
||||||
@ -1680,7 +1680,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
setGOEShowProperties(getClass());
|
setGOEShowProperties(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGOEShowProperties(Class cls) {
|
public void setGOEShowProperties(Class<?> cls) {
|
||||||
GenericObjectEditor.setShowProperty(cls, "topologyRange", (m_Topology.getSelectedTag().getID() < 2) || (m_Topology.getSelectedTag().getID() == 6));
|
GenericObjectEditor.setShowProperty(cls, "topologyRange", (m_Topology.getSelectedTag().getID() < 2) || (m_Topology.getSelectedTag().getID() == 6));
|
||||||
GenericObjectEditor.setShowProperty(cls, "subSwarmRadius", (m_Topology.getSelectedTag().getID() == 3));
|
GenericObjectEditor.setShowProperty(cls, "subSwarmRadius", (m_Topology.getSelectedTag().getID() == 3));
|
||||||
GenericObjectEditor.setShowProperty(cls, "subSwarmSize", (m_Topology.getSelectedTag().getID() == 3));
|
GenericObjectEditor.setShowProperty(cls, "subSwarmSize", (m_Topology.getSelectedTag().getID() == 3));
|
||||||
@ -1821,17 +1821,18 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
return treeStruct;
|
return treeStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTreeStruct(int treeStruct) {
|
public void SetTreeStruct(int treeStruct) {
|
||||||
this.treeStruct = treeStruct;
|
this.treeStruct = treeStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUseAlternative() {
|
// This was for testing rotation operators
|
||||||
return useAlternative;
|
// public boolean isUseAlternative() {
|
||||||
}
|
// return useAlternative;
|
||||||
|
// }
|
||||||
public void setUseAlternative(boolean useAlternative) {
|
//
|
||||||
this.useAlternative = useAlternative;
|
// public void setUseAlternative(boolean useAlternative) {
|
||||||
}
|
// this.useAlternative = useAlternative;
|
||||||
|
// }
|
||||||
|
|
||||||
public int getTreeBranchDegree() {
|
public int getTreeBranchDegree() {
|
||||||
return treeBranchDeg;
|
return treeBranchDeg;
|
||||||
|
@ -19,9 +19,6 @@ import java.util.Vector;
|
|||||||
import javaeva.gui.JTabbedModuleFrame;
|
import javaeva.gui.JTabbedModuleFrame;
|
||||||
import javaeva.gui.LogPanel;
|
import javaeva.gui.LogPanel;
|
||||||
import javaeva.server.go.InterfaceProcessor;
|
import javaeva.server.go.InterfaceProcessor;
|
||||||
import javaeva.server.go.operators.postprocess.PostProcessParams;
|
|
||||||
import javaeva.server.stat.InterfaceTextListener;
|
|
||||||
|
|
||||||
import wsi.ra.jproxy.MainAdapterClient;
|
import wsi.ra.jproxy.MainAdapterClient;
|
||||||
import wsi.ra.jproxy.RemoteStateListener;
|
import wsi.ra.jproxy.RemoteStateListener;
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
@ -112,11 +109,14 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPostProcessing() {
|
public boolean hasPostProcessing() {
|
||||||
return (m_Processor instanceof Processor);
|
return ((m_Processor instanceof Processor) && ((Processor)m_Processor).getGOParams().getPostProcessParams().isDoPostProcessing());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPostProcessing() {
|
public boolean startPostProcessing() {
|
||||||
if (hasPostProcessing()) ((Processor)m_Processor).performPostProcessing();
|
if (hasPostProcessing() && ((Processor)m_Processor).getGOParams().getPostProcessParams().isDoPostProcessing()) {
|
||||||
|
((Processor)m_Processor).performPostProcessing();
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +29,16 @@ public interface ModuleAdapter extends RemoteStateListener {
|
|||||||
public void restartOpt();
|
public void restartOpt();
|
||||||
public void stopOpt();
|
public void stopOpt();
|
||||||
public void runScript();
|
public void runScript();
|
||||||
|
/**
|
||||||
|
* Return true if post processing is available in principle, else false.
|
||||||
|
* @return true if post processing is available in principle, else false
|
||||||
|
*/
|
||||||
public boolean hasPostProcessing();
|
public boolean hasPostProcessing();
|
||||||
public void startPostProcessing();
|
/**
|
||||||
|
* Return true if post processing was performed, else false.
|
||||||
|
* @return true if post processing was performed, else false
|
||||||
|
*/
|
||||||
|
public boolean startPostProcessing();
|
||||||
public void addRemoteStateListener(RemoteStateListener x);
|
public void addRemoteStateListener(RemoteStateListener x);
|
||||||
public String getAdapterName();
|
public String getAdapterName();
|
||||||
public void setConnection(boolean flag);
|
public void setConnection(boolean flag);
|
||||||
|
@ -14,6 +14,7 @@ import javaeva.server.go.problems.AbstractOptimizationProblem;
|
|||||||
import javaeva.server.go.tools.RandomNumberGenerator;
|
import javaeva.server.go.tools.RandomNumberGenerator;
|
||||||
import javaeva.server.stat.InterfaceStatistics;
|
import javaeva.server.stat.InterfaceStatistics;
|
||||||
import javaeva.server.stat.InterfaceTextListener;
|
import javaeva.server.stat.InterfaceTextListener;
|
||||||
|
import javaeva.server.stat.StatisticsWithGUI;
|
||||||
import wsi.ra.jproxy.RemoteStateListener;
|
import wsi.ra.jproxy.RemoteStateListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,8 +145,12 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//m_Statistics.stopOptPerformed(false);
|
//m_Statistics.stopOptPerformed(false);
|
||||||
setOptRunning(false); // normal finish
|
setOptRunning(false); // normal finish
|
||||||
if (m_ListenerModule!=null) m_ListenerModule.performedStop(); // is only needed in client server mode
|
if (m_ListenerModule!=null) {
|
||||||
if (m_ListenerModule!=null) m_ListenerModule.updateProgress(0, "Error in optimization: " + e.getMessage());
|
m_ListenerModule.performedStop(); // is only needed in client server mode
|
||||||
|
String errMsg = e.getMessage();
|
||||||
|
if ((errMsg == null) || (errMsg.length() == 0)) errMsg="check console output for error messages.";
|
||||||
|
m_ListenerModule.updateProgress(0, "Error in optimization: " + errMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resPop;
|
return resPop;
|
||||||
}
|
}
|
||||||
@ -266,7 +271,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
|||||||
public String getInfoString() {
|
public String getInfoString() {
|
||||||
//StringBuffer sb = new StringBuffer("processing ");
|
//StringBuffer sb = new StringBuffer("processing ");
|
||||||
StringBuffer sb = new StringBuffer(this.goParams.getProblem().getName());
|
StringBuffer sb = new StringBuffer(this.goParams.getProblem().getName());
|
||||||
sb.append("/");
|
sb.append("+");
|
||||||
sb.append(this.goParams.getOptimizer().getName());
|
sb.append(this.goParams.getOptimizer().getName());
|
||||||
// commented out because the number of multi-runs can be changed after start
|
// commented out because the number of multi-runs can be changed after start
|
||||||
// so it might create misinformation (would still be the user's fault, though)
|
// so it might create misinformation (would still be the user's fault, though)
|
||||||
@ -315,7 +320,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
|||||||
*/
|
*/
|
||||||
public Population performPostProcessing(PostProcessParams ppp, InterfaceTextListener listener) {
|
public Population performPostProcessing(PostProcessParams ppp, InterfaceTextListener listener) {
|
||||||
if (ppp.isDoPostProcessing()) {
|
if (ppp.isDoPostProcessing()) {
|
||||||
if (listener != null) listener.println("Post processing params: " + BeanInspector.toString(ppp));
|
if (listener != null) {
|
||||||
|
listener.println("Post processing params: " + BeanInspector.toString(ppp));
|
||||||
|
// if textwindow was closed, check if it should be reopened for pp
|
||||||
|
if (m_Statistics instanceof StatisticsWithGUI) ((StatisticsWithGUI)m_Statistics).maybeShowProxyPrinter();
|
||||||
|
}
|
||||||
Population resultPop = goParams.getOptimizer().getAllSolutions();
|
Population resultPop = goParams.getOptimizer().getAllSolutions();
|
||||||
if (resultPop.getFunctionCalls() != goParams.getOptimizer().getPopulation().getFunctionCalls()) {
|
if (resultPop.getFunctionCalls() != goParams.getOptimizer().getPopulation().getFunctionCalls()) {
|
||||||
// System.err.println("bad case in Processor::performNewPostProcessing ");
|
// System.err.println("bad case in Processor::performNewPostProcessing ");
|
||||||
|
@ -18,8 +18,8 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
private PrintWriter resultOut;
|
private PrintWriter resultOut;
|
||||||
public final static boolean TRACE = false;
|
public final static boolean TRACE = false;
|
||||||
protected InterfaceStatisticsParameter m_StatsParams;
|
protected InterfaceStatisticsParameter m_StatsParams;
|
||||||
protected String startDate;
|
// protected String startDate;
|
||||||
protected long startTime;
|
// protected long startTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep track of all intermediate fitness values, best, avg. and worst, averaging over all runs
|
* Keep track of all intermediate fitness values, best, avg. and worst, averaging over all runs
|
||||||
@ -70,20 +70,22 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
return textListeners.remove(listener);
|
return textListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initOutput() {
|
/**
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(
|
* Collect start date and time of the run and if indicated, open a file output stream.
|
||||||
"E'_'yyyy.MM.dd'_at_'hh.mm.ss");
|
*
|
||||||
startDate = formatter.format(new Date());
|
* @param infoString
|
||||||
startTime = System.currentTimeMillis();
|
*/
|
||||||
|
protected void initOutput(String infoString) {
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_at_'hh.mm.ss");
|
||||||
|
String startDate = formatter.format(new Date());
|
||||||
// open the result file:
|
// open the result file:
|
||||||
String resFName = m_StatsParams.getResultFileName();
|
|
||||||
if ((m_StatsParams.getOutputTo().getSelectedTagID()!=1) // not "text only"
|
if ((m_StatsParams.getOutputTo().getSelectedTagID()!=1) // not "text only"
|
||||||
&& (m_StatsParams.getOutputVerbosity().getSelectedTagID() > StatsParameter.VERBOSITY_NONE)) { // verbosity accordingly high
|
&& (m_StatsParams.getOutputVerbosity().getSelectedTagID() > StatsParameter.VERBOSITY_NONE)) { // verbosity accordingly high
|
||||||
//!resFName.equalsIgnoreCase("none") && !resFName.equals("")) {
|
//!resFName.equalsIgnoreCase("none") && !resFName.equals("")) {
|
||||||
String name = resFName + "_" + startDate + ".txt";
|
String fname = makeOutputFileName(m_StatsParams.getResultFilePrefix(), infoString, startDate);
|
||||||
if (TRACE) System.out.println("FileName =" + name);
|
if (TRACE) System.out.println("FileName =" + fname);
|
||||||
try {
|
try {
|
||||||
resultOut = new PrintWriter(new FileOutputStream(name));
|
resultOut = new PrintWriter(new FileOutputStream(fname));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Error: " + e);
|
System.out.println("Error: " + e);
|
||||||
@ -93,6 +95,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
} else resultOut = null;
|
} else resultOut = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String makeOutputFileName(String prefix, String infoString, String startDate) {
|
||||||
|
return (prefix + "_" + infoString).replace(' ', '_') + "_" + startDate + ".txt";
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* If set to true, before every run the parameters will be stored to a file at the start
|
* If set to true, before every run the parameters will be stored to a file at the start
|
||||||
* of each run. Default is true.
|
* of each run. Default is true.
|
||||||
@ -111,7 +116,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
optRunsPerformed = 0;
|
optRunsPerformed = 0;
|
||||||
convergenceCnt = 0;
|
convergenceCnt = 0;
|
||||||
if (saveParams) m_StatsParams.saveInstance();
|
if (saveParams) m_StatsParams.saveInstance();
|
||||||
initOutput();
|
initOutput(infoString);
|
||||||
bestCurrentIndividual = null;
|
bestCurrentIndividual = null;
|
||||||
bestIndivdualAllover = null;
|
bestIndivdualAllover = null;
|
||||||
if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
|
if (refineMultiRuns) meanCollection = new ArrayList<double[][]>();
|
||||||
|
@ -46,8 +46,8 @@ public interface InterfaceStatisticsParameter {
|
|||||||
public SelectedTag getPlotFitness();
|
public SelectedTag getPlotFitness();
|
||||||
public void setPlotFitness(SelectedTag newMethod);
|
public void setPlotFitness(SelectedTag newMethod);
|
||||||
|
|
||||||
public String getResultFileName();
|
public String getResultFilePrefix();
|
||||||
public void SetResultFileName(String x);
|
public void SetResultFilePrefix(String x);
|
||||||
|
|
||||||
public void setConvergenceRateThreshold(double x);
|
public void setConvergenceRateThreshold(double x);
|
||||||
public double getConvergenceRateThreshold();
|
public double getConvergenceRateThreshold();
|
||||||
|
@ -70,7 +70,7 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
|||||||
*/
|
*/
|
||||||
public StatisticsStandalone(String resultFileName) {
|
public StatisticsStandalone(String resultFileName) {
|
||||||
this(new StatsParameter());
|
this(new StatsParameter());
|
||||||
m_StatsParams.SetResultFileName(resultFileName);
|
m_StatsParams.SetResultFilePrefix(resultFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +100,6 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
|||||||
*/
|
*/
|
||||||
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams) {
|
public synchronized void startOptPerformed(String infoString, int runNumber, Object goParams) {
|
||||||
super.startOptPerformed(infoString, runNumber, goParams);
|
super.startOptPerformed(infoString, runNumber, goParams);
|
||||||
|
|
||||||
m_GraphInfoString = infoString;
|
m_GraphInfoString = infoString;
|
||||||
|
|
||||||
// m_TextCounter = m_StatisticsParameter.GetTextoutput();
|
// m_TextCounter = m_StatisticsParameter.GetTextoutput();
|
||||||
@ -137,10 +136,14 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void maybeShowProxyPrinter() {
|
||||||
|
if (m_ProxyPrinter != null) m_ProxyPrinter.setShow((m_StatsParams).isShowTextOutput());
|
||||||
|
}
|
||||||
|
|
||||||
protected void initPlots(List<String[]> description) {
|
protected void initPlots(List<String[]> description) {
|
||||||
if (TRACE) System.out.println("initPlots");
|
if (TRACE) System.out.println("initPlots");
|
||||||
|
|
||||||
if (m_ProxyPrinter != null) m_ProxyPrinter.setShow((m_StatsParams).isShowTextOutput());
|
maybeShowProxyPrinter();
|
||||||
|
|
||||||
m_FitnessFrame = new GraphWindow[description.size()];
|
m_FitnessFrame = new GraphWindow[description.size()];
|
||||||
for (int i = 0; i < m_FitnessFrame.length; i++) {
|
for (int i = 0; i < m_FitnessFrame.length; i++) {
|
||||||
|
@ -41,7 +41,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
public final static int VERBOSITY_FINAL = 1;
|
public final static int VERBOSITY_FINAL = 1;
|
||||||
public final static int VERBOSITY_KTH_IT = 2;
|
public final static int VERBOSITY_KTH_IT = 2;
|
||||||
public final static int VERBOSITY_ALL = 3;
|
public final static int VERBOSITY_ALL = 3;
|
||||||
SelectedTag outputVerbosity = new SelectedTag("No output", "Results", "K-th iteration", "All iterations");
|
SelectedTag outputVerbosity = new SelectedTag("No output", "Final results", "K-th iterations", "All iterations");
|
||||||
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
||||||
private int verboK = 10;
|
private int verboK = 10;
|
||||||
|
|
||||||
@ -125,6 +125,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
m_PlotFitness = Source.m_PlotFitness;
|
m_PlotFitness = Source.m_PlotFitness;
|
||||||
m_MultiRuns = Source.m_MultiRuns;
|
m_MultiRuns = Source.m_MultiRuns;
|
||||||
m_ResultFilePrefix = Source.m_ResultFilePrefix;
|
m_ResultFilePrefix = Source.m_ResultFilePrefix;
|
||||||
|
verboK = Source.verboK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,7 +269,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void SetResultFileName(String x) {
|
public void SetResultFilePrefix(String x) {
|
||||||
if (x==null) m_ResultFilePrefix = "";
|
if (x==null) m_ResultFilePrefix = "";
|
||||||
else m_ResultFilePrefix = x;
|
else m_ResultFilePrefix = x;
|
||||||
}
|
}
|
||||||
@ -276,7 +277,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getResultFileName() {
|
public String getResultFilePrefix() {
|
||||||
return m_ResultFilePrefix;
|
return m_ResultFilePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user