Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 4. Basic concepts, a rudimentary model, and input data (demo01.yml)
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 2 Import - other model (parts) to include in the simulation Globals - time series and other external data e.g. macroeconomic context Entities – which unit is modelled? e.g. person, household, enterprise, … Simulation - how do we run that? Model structure - Top level concepts
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 3 A model file can (optionally) import (an)other model file(s) This can be used to simply split a large model file into smaller files or (more interestingly) to create simulation variants without having to duplicate the common parts. Import
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 4 Globals are variables (aka. parameters) that do not relate to any particular entity defined in the model They can be used in any entity Two kinds of globals: tables and multi-dimensional arrays Globals can be loaded from either.csv files during the simulation, or from the HDF5 input file, along with the entities data Periodic globals have a special status. They can have a different value for each period Globals
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 5 Fields: entity characteristics what do we (want to) know about an individual? Links: interaction between entities same entity: e.g. who is the mother? different entities: e.g. in what household does the person live? Macros: make the model more readable Processes: how do entities evolve over time? the model definition (transformations, regressions, alignments,...) Entities
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 6 Types of fields: bool: boolean (True or False) int: integer float: real number Two implicit fields that do not have to be defined: id: the unique identifier of the item period: the current period in the run of the program Two options for the definition of fields initialdata: False when the field is not present in the input dataset output: False when we don’t want the field in the output dataset Entities - Fields
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 7 The processes define how individuals of each entity evolve over time. Expressions: Arithmetic operators: +, -, *, /, ** (exponent), % (modulo) Comparison operators: =, > Boolean operators: and, or, not Assignments: - variable_name: expression Example: - age: age + 1 Functions: processes are grouped in functions Entities - Processes
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 8 entities: person: fields: # period and id are implicit - age: int - gender: bool - agegroup: {type: int, initialdata: False} processes: ageing: - age: age + 1 Entities - example
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 9 processes: what happens to the entities and in what order? init: processes executed in the period before start_period input: which input file to use? output: where is the output? start_period: first period to simulate periods: how many periods do we want to simulate? Simulation
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 10 This block defines which processes are executed and in what order They will be executed for each period starting from start_period for periods times Since processes are defined on specific entities, you have to specify the entity before each list of processes You can execute the same process more than once during a simulation and you can alternate between entities in the simulation of a period Example: simulation: processes: - person: [ageing, birth, death] - household: [clean_empty] - person: [get_a_life] - person: [csv_output] - household: [csv_output] Simulation - processes
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 11 The initial (observed) data is read from the file specified in the input entry Specifying the path is optional. If it is omitted, it defaults to the directory where the simulation file is located The hdf5-file format can be browsed with vitables (F9) or another hdf5- browser available on the net Simulation - input
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 12 The simulation result is stored in the file specified in the output entry Only the variables defined at the entity level are stored. Temporary variables are not saved. Specifying the path is optional. If it is omitted, it defaults to the directory where the simulation file is located. Simulation - output
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 13 Random_seed Skip_shows: True | False (default) Default_entity Logging level: periods | functions (default) | processes timings: True (default) | False Assertions Autodump Autodiff Simulation - options