Download LIAM2 User Guide

Transcript
LIAM2 User Guide, Release 0.9rc2
The processes on age and agegroup are grouped in ageing. In the simulation block you specify the ageing-process
if you want to update age and agegroup.
By using procedures, you can actually make building blocks or modules in the model.
5.4.1 Local (temporary) variables
Temporary variables defined/computed within a procedure are local to that procedure: they are only valid within
that procedure. If you want to pass variables between procedures you have to make them global by defining them
in the fields section.
(bad) example
person:
fields:
- age: int
processes:
ageing:
- age: age + 1
- isold: age >= 150
# isold is a local variable
rejuvenation:
- age: age - 1
- backfromoldage: isold and age < 150
# WRONG !
In this example, isold and backfromoldage are local variables. They can only be used in the procedure where they
are defined. Because we are trying to use the local variable isold in another procedure in this example, LIAM2
will refuse to run, complaining that isold is not defined.
5.4.2 Actions
Actions inside procedures don’t even need a process name.
example
processes:
death_procedure:
- dead: age > 150
- remove(dead)
5.5 Expressions
Expressions can either compute new values for existing individuals, or change the number of individuals by using
the so-called life-cycle functions.
5.5.1 simple expressions
Let us start with a simple increment; the following process increases the value of a variable by one each simulation
period.
age: age + 1
The name of the process is age and what it does is increasing the variable age of each individual by one, each
period.
• Arithmetic operators: +, -, *, /, ** (exponent), % (modulo)
5.5. Expressions
17