Reference 〉 Function

Shocks.atperiod(nint|list)

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

Parameters

  • n int|list, required

    The period(s) at which the timer function should return True.

Return Value func(int)

A timer function that takes the model time and returns a boolean.

Notes and Examples

  1. charwick

    Mar 24, 2020 at 3:47

    This code registers a shock that reduces the population of human-primitive agents by half in period 2018.

    def thanos(pop):
    	return pop/2
    
    model.shocks.register('snap', 'agents_human', thanos, model.shocks.atperiod(2018), desc="I am inevitable.")
  2. 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.