Next: Optimization Options
Up: Optimization from Matlab
Previous: Quick Howto
Contents
The main optimize command starts actually two new Java threads
handling Java callbacks to Matlab within the single Matlab thread.
The result of the optimization will be written back to the JEInterface
instance and is not a direct output value of the optimize
call. There will be a text notice in the Matlab console as soon as
the optimization has finished. Notice that in Matlab object oriented
style, an object Obj cannot be modified simply by calling
the mutator, e.g. setOpt(Obj, p1, val1), but must be reassigned
for every mutating call, as in: Obj=setOpt(Obj, p1, val1).
After optimization, you may retrieve the result by calling getResult
on the interface instance. Or, in case you want to retrieve multiple
solutions to the target function, you may start a post processing
step and retrieve a list of solutions using getMultipleSolutions.
Some optimizers allow the solutions to get worse during the optimization
run. This allows them to overcome local optima and increases the chance
to find a global one. But on the other hand it means that the result
of the last optimization iteration is not necessarily the best solution
found during the whole run. Therefore, EVA2 saves the best
solution found external to the optimizer, which is what is returned
by the getResult method.
Most optimization strategies have specific parameters influencing
their performance. The optimizecall gives access to standard
parameter settings. To modify specific parameters, use the getDescmethod
to list available parameters of an optimizer. You may then use the
method optimizeWith and deliver specific parameters in name/value
pairs to configure a specific run, where the names must correspond
to a member variable of the optimizer as listed by getDesc
and the value object must of course be of the correct type.
For further details, check the method overview in the list below.
Each interface method (except the constructor) has at least a parameter
JI, designating the JEInterface object to work on.
 JI=JEInterface(fHndl,datatype,R,[initR[,fArg[,optName,optValue]*]])
 JEInterface
constructor: fHndl: handle of the target function. datatype:
give a char 'int', 'binary', or 'double' depending on the desired
data type. R: a 2
dim array defining the solution subspace
with lower and upper bounds. initR: For the integer and real
valued case, an initialization range can optionally be set, but must
be a subset of R of same dimensions  often it can be set
equal to R. fArg: additional static parameters to the
target function as single object (scalar, struct, or list). optName,
optValue: optional namevalue pairs defining MaxFunCalls,
TolX and TolFun similar to the Matlab optimset structure.
The Display option may trigger verbose output.
 showOptimizers(JI)
 Print a list of optimization strategies
accessible through JEInterface by ID numbers.
 JI=optimize(JI,optType[,resultFilePrefix])
 Start the
optimization using the strategy indicated by the ID optType.
Optionally write verbose results to an output file with prefix resultFilePrefix
in the working directory. Returns the modified JEInterface instance.
The method also opens a message box with a cancel button to stop the
optimization.
 [sol,fit]=getResult(JI)
 After optimization: return
the final solution and its fitness. During optimization: return the
current best solution and its fitness.
 getMessage(JI)
 Return a text message describing the
termination state of the optimization, e.g. the number of function
calls performed.
 JI=postProcess(JI,steps,sigmaClust[,nBest])
 Do postprocessing
of the last optimization results and export the solution set to the
interface instance (cf. Sec. 2.3.4). If sigmaClust
> 0 a clustering step is performed (density based clustering), so
that any solutions in a distance below sigmaClust are associated.
Notice that sigmaClust is treated relative to the problem range.
If steps > 0, then a hill climbing step is performed after
clustering for the given number of evaluations. If nBest is
given, it defines the maximal number of solutions to be exported to
the interface instance. Post processing can be stopped by JI=stopOptimize(JI)
just as the optimization itself.
 [sols,fits]=getMultipleResults(JI)
 After optimization
or postprocessing: retrieve the solution set in a matrix and calculate
the corresponding fitness values.
 makeOptions(JI[,optName,optVal]*)
 Produce an options
structure with given settings. Notice that you need to use setOptions
with the returned structure to apply the options for a given JI instance,
as in: JI=setOptions(JI,makeOptions(JI,'TolX',1e8)).
 getOptions(JI)
 Get the current optimset structure
of the JEInterface instance.
 getOpt(JI,optName)
 Get the value of a specific option
optName from the optimset structure of the JEInterface
instance.
 JI=setOpt(JI,optName,optVal)
 Set a specific option optName
of the optimset structure in JI to the value optVal.
Returns the modified JEInterface instance.
 JI=setOptions(JI,optset)
 Set a whole new optimset
structure optset. Returns the modified JEInterface instance.
 getDesc(JI,optTypeOrObject[,showValues])
 Show information
about an optimizer class (if optType is an integer ID) or
any other object together with the parameters that can be modified
in a standardized way. The available settings are analogous to the
optimizer options presented by the Java GUI. If showValues==1
holds, the current values of the given instance are displayed as well.
 optimizeWith(JI,optType[,outputFilePrefix][,memName,memVal]*)
 Optimize
using an optimizer by ID and specific settings for this optimizer.
The settings given must conform to the options shown by getDesc(JI,optType).
The available settings are analogous to the optimizer options presented
by the Java GUI. The method also opens a message box with a cancel
button to stop the optimization.
 testEvalFunc(JI)
 Test the function handle for some basic
conformations with expected output.
 setVerbose(JI,swtch[,fname])
 Activate debug output
if swtch is 1, else deactivate it. If fname is given,
that's the filename the debug information is written to.
 JI=stopOptimize(JI[,'kill'])
 Stop a running optimization
process, which is usually done by the cancel button. In case brute
force was used (STRGC), this method may be used with the 'kill'
argument to try to clean up Java threads still running as ``zombies''.
 setResultJE
 (Internal) Writeback method required internally
by EVA2. Calling it by hand may interfere with optimization.
 setResultArrayJE
 (Internal) Writeback method required
internally by EVA2. Calling it by hand may interfere with optimization.
 getProgress(JI)
 (Internal) During optimization, return
the number of fitness calls performed until now.
 runEvalLoopJE
 (Internal) Start a EvA run, optimization
or post processing.
The methods are listed in about the order a user might require them
in. The constructor as well as all mutating methods return a JEInterface
object which is to be assigned to a variable, preferably the same
as the one assigned on construction. This is a drawback of the Matlab
object concept: mutators are actually also constructors and copy the
whole Matlab object, but they do not copy the referenced Java instance.
Notice that the last three methods, setResultJE, setResultArrayJE
and evaluateJE, are used internally by the Java part of the
interface and should not be called by hand. To find out more about
the optimization strategies you can access through JEInterface, use
the showOptimizers method and take a look at the EA references,
e.g. the technical report on JAVAEVA [8].
Table 1:
JEInterface optimization options overview.
Option name 
Values 
Description 
Display 
'off'  'iter'  'final'  'notify' 
Output verbosity to Matlab console. 
MaxFunEvals 
positive integer 
Maximum number of evaluations to be performed. 
MaxIter 
 
Unused. 
TolFun 
real 
Absolute convergence bound in function codomain. 
TolFunEvals 
positive integer 
No. of evaluations of the TolFun convergence criterion. 
TolX 
real 
Absolute convergence bound in function domain. 
TolXEvals 
positive integer 
No. of evaluations of the TolX convergence criterion. 

Next: Optimization Options
Up: Optimization from Matlab
Previous: Quick Howto
Contents
Marcel Kronfeld
20110505