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 Doublem_bestfcurr best fitness.protected OptDatam_bestvcurr 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 voidcheckBest(Double fitness, OptData vars, FitnessFunction ff)voidcleanUp()Default implementation does nothing.intcompareTo(Object o)Compares this object with the specified object for order.voiddestroy()Frees up memory in a "destructive" non-reversible way.booleanequals(Object o)Returns whether the two objects are the same.static AbstractOptimiserforCommandLine(String cmdline)Instantiates the optimiser from the given commandline (i.e., classname and optional options).static AbstractOptimiserforName(String classname, String[] options)Instantiates the optimiser with the given options.static String[]getOptimisers()Returns a list with classnames of optimiser.protected voidinitialize()Initializes the members.abstract OptDataoptimise(OptData datadef, FitnessFunction fitness)Do the optimisation.voidreset()Resets the optimizer.AbstractOptimisershallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.AbstractOptimisershallowCopy(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:
initializein classAbstractOptionHandler
-
reset
public void reset()
Resets the optimizer.- Overrides:
resetin 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:
cleanUpin interfaceCleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Calls cleanUp() and cleans up the options.- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin 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:
compareToin 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
-
-