public abstract class BaseOptimizer extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, Options, Printable, Commandable
Abstractly, an optimization algorithms is required to create a new generation of candidate entries using some strategy. For now, a list of all possible candidates must be provided to define the search space for this algorithms. Regardless of the method used to generate a new generation, only candidates from this list will be included.
After creating those new candidates, it is the task of an "oracle" defined by a BaseOracle class to evaluate their fitness. This process is allowed continue until it has reached a user-defined number of iterations or the Oracle is unable to evaluate all entries.
When creating a new implementation of this class, you must:
Implemented Commands:
run - Start optimizer
set initial $<dataset> - Define initial population
set search $<dataset> - Define search space
set objective <min|max> <method> [<options...>] - Set the objective function
set oracle <method> [<options...>] - Define method used to calculate properties of selected candidates
set gensize <number - Set number of new candidates per iteration
set maxiter <number> - Set the number of iterations algorithm will perform
stats ntop <number> - Control number of top entries to detect when evaluating algorithm performance
stats success <include|exclude> <filter method> [<filter options...>]
- Define a filter used to define when an entry is a "success"
write generations <directory> <format> - Write out the data from each generation
Will run until max iterations is reached, or oracle is unable to process
all new candidates.BaseEntryRanker
class. ("?" for options)
Available Print Command:
stats - Print statistics about optimization run
Modifier and Type | Field and Description |
---|---|
protected int |
CurrentIteration
How many iterations have been completed
|
int |
EntriesPerGeneration
How many entries to create per generation
|
protected boolean |
HasStarted
Whether the algorithm has started
|
protected Dataset |
InitialData
Initial population used for algorithm
|
protected int |
MaxIteration
Iteration at which optimization stops
|
protected BaseEntryRanker |
ObjectiveFunction
Entry ranker used for objective function
|
protected BaseOracle |
Oracle
Oracle used as a method for evaluating new iterations
|
boolean |
PrintStatus
Whether status messages should be printed
|
protected java.util.Set<BaseEntry> |
SearchSpace
Entries that are acceptable to search
|
OptimizationStatistics |
Statistics
Statistics about the run
|
Constructor and Description |
---|
BaseOptimizer()
Construct an empty BaseOptimizer
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
about()
Prints a simple status message about this object
|
protected void |
checkComponents()
Check if all of the necessary components are loaded
|
protected void |
checkIfReady()
Throw an error if all components are not ready
|
BaseOptimizer |
clone() |
int |
currentIteration() |
protected void |
errorIfStarted()
Throw an error if the algorithm has started.
|
void |
evaluate()
Evaluate the results of the run using the internal statistics object
|
Dataset |
getEmptyDataset()
Get an empty dataset based on initial population.
|
Dataset |
getFullDataset(int iteration)
Returns all entries evaluated up a certain iteration.
|
java.util.Set |
getFullSet(int iteration)
Return all entries evaluated up a certain iteration.
|
Dataset |
getGeneration(int number)
Get a Dataset representing all entries generated at a certain generation.
|
Dataset |
getInitialData()
Initial population defined
|
protected abstract Dataset |
getNewCandidates()
Based on the current optimization state, return a list of new candidate entries
|
BaseEntryRanker |
getObjectiveFunction() |
java.util.Set |
getSearchSpace()
Retrieve entries that define the search space
|
boolean |
hasStarted() |
int |
maximumIterations() |
java.lang.String |
printCommand(java.util.List<java.lang.String> Command)
Handles more complicated printing commands.
|
java.lang.String |
printDescription(boolean htmlFormat)
Print full name of object, and a simple description of the options.
|
void |
run()
Run the optimization algorithm until it either the Oracle is unable to evaluate all new candidates, or the algorithm completes
|
java.lang.Object |
runCommand(java.util.List<java.lang.Object> Command)
Process some command described by a list of Objects.
|
void |
runStatisticsCommand(java.util.List<java.lang.Object> Command)
Handle commands related to controlling what statistics are generated
|
protected void |
runWriteCommand(java.util.List<java.lang.Object> Command)
Run commands devoted to writing out data
|
protected void |
setComponent(java.util.List<java.lang.Object> Command)
Set a specific component or setting of an optimizer.
|
void |
setEntriesPerGeneration(int EntriesPerGeneration)
Set the number of new entries created per iteration
|
void |
setInitialData(Dataset InitialData)
Define the initial population
|
void |
setMaxIterations(int number)
Set the maximum number of iterations the algorithm is allowed.
|
void |
setObjectiveFunction(BaseEntryRanker ObjectiveFunction)
Define the objective function
|
void |
setOracle(BaseOracle oracle)
Define BaseOracle used to evaluate properties/class variable
|
void |
setSearchSpace(Dataset SearchSpace)
Define the search space over which the algorithm is allowed to sample.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
printUsage, setOptions
protected java.util.Set<BaseEntry> SearchSpace
protected int CurrentIteration
protected int MaxIteration
protected Dataset InitialData
protected BaseEntryRanker ObjectiveFunction
protected BaseOracle Oracle
protected boolean HasStarted
public boolean PrintStatus
public int EntriesPerGeneration
public OptimizationStatistics Statistics
public void setMaxIterations(int number)
number
- Desired maximumpublic int currentIteration()
public int maximumIterations()
public java.util.Set getSearchSpace()
public void setSearchSpace(Dataset SearchSpace)
SearchSpace
- Dataset defining entriespublic Dataset getInitialData()
public void setInitialData(Dataset InitialData)
InitialData
- Dataset containing initial entriespublic void setObjectiveFunction(BaseEntryRanker ObjectiveFunction)
ObjectiveFunction
- Desired objective functionpublic BaseEntryRanker getObjectiveFunction()
public Dataset getEmptyDataset()
public void setEntriesPerGeneration(int EntriesPerGeneration)
EntriesPerGeneration
- Number of entries desiredpublic void setOracle(BaseOracle oracle)
oracle
- Desired Oraclepublic boolean hasStarted()
protected void errorIfStarted()
protected void checkIfReady() throws java.lang.Exception
java.lang.Exception
- Detailing all that is not readyprotected void checkComponents() throws java.lang.Exception
java.lang.Exception
- Tells the first unset component that was encounteredpublic Dataset getGeneration(int number)
number
- Iteration numberpublic Dataset getFullDataset(int iteration)
iteration
- Iteration to get the full set foriteration - 1
public java.util.Set getFullSet(int iteration)
iteration
- Iteration to get the full set foriteration - 1
public void run() throws java.lang.Exception
java.lang.Exception
- Upon any failure during optimizationpublic void evaluate()
public BaseOptimizer clone()
clone
in class java.lang.Object
protected abstract Dataset getNewCandidates()
public java.lang.String about()
Printable
public java.lang.String printDescription(boolean htmlFormat)
Printable
Example: For a model training a separate WekaRegression for intermetallics
magpie.models.regression.SplitRegression
printDescription
in interface Printable
htmlFormat
- Whether format for output to an HTML page
(e.g., <div> to create indentation) or for printing to screen.#printModel()
public java.lang.String printCommand(java.util.List<java.lang.String> Command) throws java.lang.Exception
Printable
printCommand
in interface Printable
Command
- Command specifying what to printjava.lang.Exception
- If command not understoodpublic java.lang.Object runCommand(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Commandable
runCommand
in interface Commandable
Command
- Command as a list of objectsjava.lang.Exception
- If something goes wrongprotected void runWriteCommand(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Command
- java.lang.Exception
public void runStatisticsCommand(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Command
- Command to be runjava.lang.Exception
protected void setComponent(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Command
- Setting command to be processedjava.lang.Exception