13.07.2015 Views

LIAM 2 User Guide

LIAM 2 User Guide

LIAM 2 User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>LIAM</strong> 2 <strong>User</strong> <strong>Guide</strong>, Release 0.7.0• Arithmetic operators: +, -, *, /, ** (exponent), % (modulo)Note that an integer divided by an integer returns a float. For example “1 / 2” will evaluate to 0.5 instead of 0 asin many programming languages. If you are only interested in the integer part of that result (for example, if youknow the result has no decimal part), you can use the trunc function:agegroup5: 5 * trunc(age / 5)• Comparison operators: • Boolean operators: and, or, notNote that starting with version 0.6, you do not need to use parentheses when you mix boolean operators withother operators.inwork: workstate > 0 and workstate < 5to_give_birth: not gender and age >= 15 and age 0) and (workstate < 5) to_give_birth: not gender and (age >= 15) and (age = 65, 9, workstate)You can nest if-statements. The example below retires men (gender = True) over 64 and women over 61.workstate: if(gender,if(age >= 65, 9, workstate),if(age >= 62, 9, workstate))# could also be written like this:workstate: if(age >= if(gender, 65, 62), 9, workstate)5.5.2 globalsGlobals can be used in expressions in any entity. <strong>LIAM</strong>2 currently supports two kinds of globals: tables andmulti-dimensional arrays. They both need to be imported (see the Importing data section) and declared (see theglobals section) before they can be used.Globals tables come in two variety: those with a PERIOD column and those without.The fields in a globals table with a PERIOD column can be used like normal (entity) fields except they need tobe prefixed by the name of their table:myvariable: mytable.MYINTFIELD * 10the value for INTFIELD is in fact the value INTFIELD has for the period currently being evaluated.There is a special case for the periodic table: its fields do not need to be prefixed by “periodic.” (but they can be,if desired).- retirement_age: if(gender, 65, WEMRA)- workstate: if(age >= retirement_age, 9, workstate)16 Chapter 5. Processes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!