Reference 〉Function

Helipad.param( str|tuple param, str|bool|num val = None )

Sets or gets a parameter. Note the parameter must have been previously registered with model.addParameter(), model.addBreedParam(), or model.addGoodParameter().


  • param str|tuple, required

    A parameter identification string or tuple. A string value indicates a global parameter. Per-good parameters can be indicated with a three-item tuple, ('paramName', 'good', 'goodName'). A per-breed parameter can be indicated with a three- or four-item tuple, ('paramName', 'breed', 'breedName', 'primitive'), with the last element optional if there is only one primitive.

    If only this argument is set, the function returns the value of the named parameter.

    Parameter values for all goods or breeds can be retrieved, but not set, with a two-item tuple (e.g. ('name', 'good')). This will return a dict of all item values for the parameter if val is not set, but will throw an exception if val is set.

  • val str|bool|num, optional

    If this argument is set, the function sets the value of the parameter to val.

    Default value: None

Return Value str|bool|num|dict|None

If val is not set, returns the parameter value: a string if the parameter is a menu, a boolean if a checkbox, or a number if a slider. If a two-item tuple is passed for param without specifying an item, the function returns a dict with parameter values for all relevant items. If val is set, the function sets the parameter to val and does not return a value.

Notes and Examples

  1. charwick

    Mar 24, 2020 at 3:33

    This example doubles the value of the 'agentSpeed' parameter.

    currentSpeed = model.param('agentSpeed') #Getting the value (1 argument)
    model.param('agentSpeed', 2 * currentSpeed) #Setting the value (2 arguments)
  2. charwick

    Jun 25, 2020 at 19:47

    A few examples to show the uses of the parameter identification pattern. Note that the fourth element of the breed parameter tuple can be omitted if there are not multiple agent primitives.

    a = model.param('pSmooth') #Gets the value of the global pSmooth parameter
    b = model.param(('rbd','breed')) #Gets the value of the  rbd breed parameter and returns a dict of values for all breeds
    model.param(('rbd','breed','hobbit'), 50) #Sets the value of the rbd breed parameter for the hobbit breed to 50

    If there are multiple primitives so that the fourth tuple element is required, a dict of values for all breeds can still be gotten by passing None as the third tuple element.

  3. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.