Package repast.simphony.parameter
Class ParameterTreeSweeper
java.lang.Object
repast.simphony.parameter.ParameterTreeSweeper
- All Implemented Interfaces:
ParameterSetter,ParameterSweeper
- Direct Known Subclasses:
OptimizedParameterSweeper
The default implementation of a parameter sweeper. This will just next through all its
First, execute a next on all of the elements in the tree generating a base set of parameters that will be executed.
Second, execute the leaves of the tree until they are finished. After one finishes it will next the parent of that item, and then execute its subleaves again. In other words, the lowest levels are executed until they are finished, as they finish their parents are then called, followed by calling the lower levels again. Finish propagates upwards until everything has finished.
ParameterSetters always performing the nexts in the same way.
For a given parameter tree this sweeper will: First, execute a next on all of the elements in the tree generating a base set of parameters that will be executed.
Second, execute the leaves of the tree until they are finished. After one finishes it will next the parent of that item, and then execute its subleaves again. In other words, the lowest levels are executed until they are finished, as they finish their parents are then called, followed by calling the lower levels again. Finish propagates upwards until everything has finished.
- Author:
- Jerry Vos
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected ParameterSetterprotected NaryTree<ParameterSetter>protected ParameterSetterprotected RunParameterSetterprotected NaryTreeTraverser<ParameterSetter> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ParameterSetter setter) Adds the givenParameterSetterto be executed as a direct descendent of previously added node.voidadd(ParameterSetter parent, ParameterSetter setter) Adds the givenParameterSetterto specified parent initialzier.voidaddDoubleRange(String param, double base, double max, double step) Adds a sweep dimension for the specifed double parameter -- that is, for every run currently defined for this sweeper, runs will now be made for each step from base to max.voidaddIntRange(String param, int base, int max, int step) Adds a sweep dimension for the specifed integer parameter -- that is, for every run currently defined for this sweeper, runs will now be made for each step from base to max.voidaddToRoot(ParameterSetter setter) Adds the specified parameter setter as a child of the root.booleanatEnd()Returns true if all theParameterSetters have finished.protected booleanchildrenFinished(ParameterSetter parent) protected ParametersfirstParameters(Parameters params) getChildren(ParameterSetter parentSetter) Retrieves theParameterSetters that are direct children of the specified setter.Retrieves the rootParameterSetter, that all other setters are a child of.intvoidnext(Parameters params) Executes theParameterSetters as specified in this class's description.protected ParametersnextParameters(Parameters params) protected ParametersnextParameters(ParameterSetter init, Parameters params) protected voidnextSelf(ParameterSetter init, Parameters params) voidremove(ParameterSetter setter) Removes the givenParameterSetterfrom those to be executedvoidreset(Parameters params) Resets all the parameter initializersprotected voidresetChildren(ParameterSetter init, Parameters params) voidsetRunCount(int count) Sets the number of time that the sweeper should execute a run for each unique parameter combination.toString()toStringChildren(ParameterSetter setter)
-
Field Details
-
rootSetter
-
runSetter
-
lastAddedSetter
-
firstTime
protected boolean firstTime -
paramTree
-
traverser
-
-
Constructor Details
-
ParameterTreeSweeper
public ParameterTreeSweeper()Default constructor.
-
-
Method Details
-
atEnd
public boolean atEnd()Returns true if all theParameterSetters have finished.- Specified by:
atEndin interfaceParameterSetter- Returns:
- (not) all
ParameterSetters have finished
-
next
Executes theParameterSetters as specified in this class's description.- Specified by:
nextin interfaceParameterSetter- Parameters:
params- the parameters object to load settings into
-
reset
Resets all the parameter initializers- Specified by:
resetin interfaceParameterSetter
-
nextParameters
-
nextSelf
-
resetChildren
-
childrenFinished
-
nextParameters
-
firstParameters
-
add
Adds the givenParameterSetterto specified parent initialzier.- Specified by:
addin interfaceParameterSweeper- Parameters:
parent- the parent setter the new setter is a child ofsetter- a parameter setter that will be executed- Throws:
IllegalArgumentException- if either the parent or the setter are null.
-
add
Adds the givenParameterSetterto be executed as a direct descendent of previously added node. The last added setter will be the "innermost" setter executed during a sweep. All convenience methods use this method. (This supports the typical usage where we simply intend to create an n-D cube space to sweep through.- Parameters:
setter- a parameter setter that will be executed
-
addToRoot
Adds the specified parameter setter as a child of the root.- Parameters:
setter- the setter to add
-
remove
Removes the givenParameterSetterfrom those to be executed- Specified by:
removein interfaceParameterSweeper- Parameters:
setter- a parameter setter to remove
-
addIntRange
Adds a sweep dimension for the specifed integer parameter -- that is, for every run currently defined for this sweeper, runs will now be made for each step from base to max. (Conveience method.)- Parameters:
param- parameter namebase- starting valuemax- ending valuestep- added to current value to get next
-
addDoubleRange
Adds a sweep dimension for the specifed double parameter -- that is, for every run currently defined for this sweeper, runs will now be made for each step from base to max. (Conveience method.)- Parameters:
param- parameter namebase- starting valuemax- ending valuestep- added to current value to get next
-
setRunCount
public void setRunCount(int count) Sets the number of time that the sweeper should execute a run for each unique parameter combination. Note: this method only manages the default run initialzer that will be placed just below root. If aRunParameterSetteris also added elsewhere, that intializer will also create new runs. Also, if new runs are added directly to root (e.g., not using conveinience methods) those runs may not be subject to this count.- Parameters:
count- number of runs to execute for each combination of paramaters
-
getRunCount
public int getRunCount() -
getRootParameterSetter
Retrieves the rootParameterSetter, that all other setters are a child of.- Specified by:
getRootParameterSetterin interfaceParameterSweeper- Returns:
- the root
ParameterSetter
-
getChildren
Retrieves theParameterSetters that are direct children of the specified setter.- Specified by:
getChildrenin interfaceParameterSweeper- Parameters:
parentSetter- the setter whose children to fetch- Returns:
- the direct descendants of the specified setter
-
toStringChildren
-
toString
-