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.

CHAPTERSIXLINKSIndividuals can be linked with each other or with individuals of other entities, for example, mothers are linked totheir children, partners are linked to each other and persons belong to households.A typical link declaration has the following form:name: {type: , target: , field: }<strong>LIAM</strong> 2 uses integer fields to establish the link between entities. Those integer fields contain the id-number ofthe linked individual.For link fields, -1 is a special value meaning the link points to nothing (eg. a person has no partner). Other negativevalues should never be used (whatever the reason) for link fields.<strong>LIAM</strong> 2 allows two types of links: many2one and one2many.6.1 many2oneA many2one link links an individual of the entity to one other individual in the same (eg. a person to his/hermother) or another entity (eg. a person to its household).This allows the modeller to use information stored in the linked entities.entities:person:fields:- age: int- income: float- mother_id: int- father_id: int- partner_id: intlinks:mother: {type: many2one, target: person, field: mother_id}father: {type: many2one, target: person, field: father_id}partner: {type: many2one, target: person, field: partner_id}processes:age: age + 1mother_age: mother.ageparents_income: mother.income + father.incomeTo access a field of a linked individual (possibly of the same entity), you use:link_name.field_nameFor example, the mother_age process uses the ‘mother’ link to assign the age of the mother to the mother_agefield. If an individual’s link does not point to anything (eg. a person has no known mother), trying to use the linkwould yield the missing value (eg. for orphans, mother.age is -1 and parents_income is nan).35

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

Saved successfully!

Ooh no, something went wrong!