Class ParameterTreeSweeper

java.lang.Object
repast.simphony.parameter.ParameterTreeSweeper
All Implemented Interfaces:
ParameterSetter, ParameterSweeper
Direct Known Subclasses:
OptimizedParameterSweeper

public class ParameterTreeSweeper extends Object implements ParameterSweeper
The default implementation of a parameter sweeper. This will just next through all its 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 Details

  • Constructor Details

    • ParameterTreeSweeper

      public ParameterTreeSweeper()
      Default constructor.
  • Method Details

    • atEnd

      public boolean atEnd()
      Returns true if all the ParameterSetters have finished.
      Specified by:
      atEnd in interface ParameterSetter
      Returns:
      (not) all ParameterSetters have finished
    • next

      public void next(Parameters params)
      Executes the ParameterSetters as specified in this class's description.
      Specified by:
      next in interface ParameterSetter
      Parameters:
      params - the parameters object to load settings into
    • reset

      public void reset(Parameters params)
      Resets all the parameter initializers
      Specified by:
      reset in interface ParameterSetter
    • nextParameters

      protected Parameters nextParameters(ParameterSetter init, Parameters params)
    • nextSelf

      protected void nextSelf(ParameterSetter init, Parameters params)
    • resetChildren

      protected void resetChildren(ParameterSetter init, Parameters params)
    • childrenFinished

      protected boolean childrenFinished(ParameterSetter parent)
    • nextParameters

      protected Parameters nextParameters(Parameters params)
    • firstParameters

      protected Parameters firstParameters(Parameters params)
    • add

      public void add(ParameterSetter parent, ParameterSetter setter)
      Adds the given ParameterSetter to specified parent initialzier.
      Specified by:
      add in interface ParameterSweeper
      Parameters:
      parent - the parent setter the new setter is a child of
      setter - a parameter setter that will be executed
      Throws:
      IllegalArgumentException - if either the parent or the setter are null.
    • add

      public void add(ParameterSetter setter)
      Adds the given ParameterSetter 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

      public void addToRoot(ParameterSetter setter)
      Adds the specified parameter setter as a child of the root.
      Parameters:
      setter - the setter to add
    • remove

      public void remove(ParameterSetter setter)
      Removes the given ParameterSetter from those to be executed
      Specified by:
      remove in interface ParameterSweeper
      Parameters:
      setter - a parameter setter to remove
    • addIntRange

      public 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. (Conveience method.)
      Parameters:
      param - parameter name
      base - starting value
      max - ending value
      step - added to current value to get next
    • addDoubleRange

      public 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. (Conveience method.)
      Parameters:
      param - parameter name
      base - starting value
      max - ending value
      step - 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 a RunParameterSetter 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

      public ParameterSetter getRootParameterSetter()
      Retrieves the root ParameterSetter, that all other setters are a child of.
      Specified by:
      getRootParameterSetter in interface ParameterSweeper
      Returns:
      the root ParameterSetter
    • getChildren

      public Collection<ParameterSetter> getChildren(ParameterSetter parentSetter)
      Retrieves the ParameterSetters that are direct children of the specified setter.
      Specified by:
      getChildren in interface ParameterSweeper
      Parameters:
      parentSetter - the setter whose children to fetch
      Returns:
      the direct descendants of the specified setter
    • toStringChildren

      public String toStringChildren(ParameterSetter setter)
    • toString

      public String toString()
      Overrides:
      toString in class Object