Package adams.opt.optimise
Class AbstractOptimiser
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.opt.optimise.AbstractOptimiser
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
,Comparable
- Direct Known Subclasses:
AbstractGeneticAlgorithm
,GridSearch
,RandomOptimiser
,RefineRange
,SplitSearch
public abstract class AbstractOptimiser extends AbstractOptionHandler implements Comparable, CleanUpHandler
Abstract ancestor for optimization schemes.- Version:
- $Revision$
- Author:
- Dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Double
m_bestf
curr best fitness.protected OptData
m_bestv
curr best vars .-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractOptimiser()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
checkBest(Double fitness, OptData vars, FitnessFunction ff)
void
cleanUp()
Default implementation does nothing.int
compareTo(Object o)
Compares this object with the specified object for order.void
destroy()
Frees up memory in a "destructive" non-reversible way.boolean
equals(Object o)
Returns whether the two objects are the same.static AbstractOptimiser
forCommandLine(String cmdline)
Instantiates the optimiser from the given commandline (i.e., classname and optional options).static AbstractOptimiser
forName(String classname, String[] options)
Instantiates the optimiser with the given options.static String[]
getOptimisers()
Returns a list with classnames of optimiser.protected void
initialize()
Initializes the members.abstract OptData
optimise(OptData datadef, FitnessFunction fitness)
Do the optimisation.void
reset()
Resets the optimizer.AbstractOptimiser
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractOptimiser
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
reset
public void reset()
Resets the optimizer.- Overrides:
reset
in classAbstractOptionHandler
-
optimise
public abstract OptData optimise(OptData datadef, FitnessFunction fitness)
Do the optimisation.- Parameters:
datadef
- data initialisations.fitness
- fitness function.- Returns:
- best vars
-
checkBest
public void checkBest(Double fitness, OptData vars, FitnessFunction ff)
-
cleanUp
public void cleanUp()
Default implementation does nothing.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Calls cleanUp() and cleans up the options.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classAbstractOptionHandler
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public AbstractOptimiser shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Returns:
- the shallow copy
-
shallowCopy
public AbstractOptimiser shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getOptimisers
public static String[] getOptimisers()
Returns a list with classnames of optimiser.- Returns:
- the optimiser classnames
-
forName
public static AbstractOptimiser forName(String classname, String[] options)
Instantiates the optimiser with the given options.- Parameters:
classname
- the classname of the optimiser to instantiateoptions
- the options for the optimiser- Returns:
- the instantiated optimiser or null if an error occurred
-
forCommandLine
public static AbstractOptimiser forCommandLine(String cmdline)
Instantiates the optimiser from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the generator to instantiate- Returns:
- the instantiated optimiser or null if an error occurred
-
-