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.
ParameterSetter
s 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
Modifier and TypeFieldDescriptionprotected boolean
protected ParameterSetter
protected NaryTree<ParameterSetter>
protected ParameterSetter
protected RunParameterSetter
protected NaryTreeTraverser<ParameterSetter>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ParameterSetter setter) Adds the givenParameterSetter
to be executed as a direct descendent of previously added node.void
add
(ParameterSetter parent, ParameterSetter setter) Adds the givenParameterSetter
to specified parent initialzier.void
addDoubleRange
(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.void
addIntRange
(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.void
addToRoot
(ParameterSetter setter) Adds the specified parameter setter as a child of the root.boolean
atEnd()
Returns true if all theParameterSetter
s have finished.protected boolean
childrenFinished
(ParameterSetter parent) protected Parameters
firstParameters
(Parameters params) getChildren
(ParameterSetter parentSetter) Retrieves theParameterSetter
s that are direct children of the specified setter.Retrieves the rootParameterSetter
, that all other setters are a child of.int
void
next
(Parameters params) Executes theParameterSetter
s as specified in this class's description.protected Parameters
nextParameters
(Parameters params) protected Parameters
nextParameters
(ParameterSetter init, Parameters params) protected void
nextSelf
(ParameterSetter init, Parameters params) void
remove
(ParameterSetter setter) Removes the givenParameterSetter
from those to be executedvoid
reset
(Parameters params) Resets all the parameter initializersprotected void
resetChildren
(ParameterSetter init, Parameters params) void
setRunCount
(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 theParameterSetter
s have finished.- Specified by:
atEnd
in interfaceParameterSetter
- Returns:
- (not) all
ParameterSetter
s have finished
-
next
Executes theParameterSetter
s as specified in this class's description.- Specified by:
next
in interfaceParameterSetter
- Parameters:
params
- the parameters object to load settings into
-
reset
Resets all the parameter initializers- Specified by:
reset
in interfaceParameterSetter
-
nextParameters
-
nextSelf
-
resetChildren
-
childrenFinished
-
nextParameters
-
firstParameters
-
add
Adds the givenParameterSetter
to specified parent initialzier.- Specified by:
add
in 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 givenParameterSetter
to 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 givenParameterSetter
from those to be executed- Specified by:
remove
in 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 aRunParameterSetter
is 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:
getRootParameterSetter
in interfaceParameterSweeper
- Returns:
- the root
ParameterSetter
-
getChildren
Retrieves theParameterSetter
s that are direct children of the specified setter.- Specified by:
getChildren
in interfaceParameterSweeper
- Parameters:
parentSetter
- the setter whose children to fetch- Returns:
- the direct descendants of the specified setter
-
toStringChildren
-
toString
-