Reference 〉 Class

Shocks( Helipad model )

The Shocks class is an interface for registering automatic shocks to a model parameter. A shock takes a timer function, which determines when to shock the parameter; a value function, which determines how to shock the parameter; and – of course – which parameter to shock. Shocks can be turned on and off from the control panel.

The shocks object is subscriptable: shocks[key] returns the shock registered with name=key. See shocks.register(). It should not be instantiated by user code; the model’s shocks object is initialized during setup and stored in model.shocks.

Initialization Parameters

  • model Helipad, required

    The model object.


Click a method name for more detailed documentation.

  • atperiod( n )

    Generates a timer function that returns True every at one or several specified periods.

  • everyn( n, offset )

    Generates a timer function that returns True periodically every so many periods.

  • randn( n )

    Generates a timer function that returns True with some probability each period.

  • register( name, param, valFunc, … )

    Registers a shock to a parameter value. Associated with a value function, which shocks the variable, and a timer function, which determines when and how often to execute the value function.

  • step( )

    Runs through the timer functions of the registered shocks and executes the shock function for any timer function that returns True.

    This function is called from model.step(). It should not be called from user code.


  • number int

    The number of registered shocks.

    Initial value: 0

  • shocks dict{str:Shock}

    Stores information on registered shocks, including the timer and value functions. See shocks.register() for usage and Shock for the internal data structure.

    Initial value: {}

  • buttons dict{str:Shock}

    The subset of Shocks.shocks where shock.timerFunc=='button' and therefore render as buttons in the control panel.

  • shocksExceptButtons dict{str:Shock}

    The subset of Shocks.shocks where shock.timerFunc is a function and therefore render as checkboxes in the control panel.

  • Shock class

    A class to structure the shock data stored in Shocks.shocks, instantiated as the Shock object.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published.

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