a hands-on ioda tutorial - interaction-oriented simulation...

23
A Hands-on IODA Tutorial Interaction-Oriented Simulation within NetLogo Sébastien Picault [email protected] SMAC team – LIFL – Lille 1 University http://www.lifl.fr/SMAC/ Social Simulation Conference September 1st, 2014

Upload: vuduong

Post on 31-Mar-2018

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

A Hands-on IODA TutorialInteraction-Oriented Simulation within NetLogo

Sébastien [email protected]

SMAC team – LIFL – Lille 1 University

http://www.lifl.fr/SMAC/

Social Simulation ConferenceSeptember 1st, 2014

Page 2: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

Outline of the tutorial

1 The Interaction-Oriented Approach (IODA)

2 The IODA extension for NetLogo

3 Let’s code !

Page 3: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

— I —

The Interaction-Orientedapproach (IODA)

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 3/23

Page 4: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Limitation of classical MABS approaches

I excessive focus on individualsI strong dependencies agents/behaviorsI make model revisions difficult

I alternative: separation declarative/procedural :I simplifies expertise acquisitionI enhanced model intelligibilityI increased reutilisabilityI homogeneity of the concepts

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 4/23

Page 5: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

The notion of interaction

behavior = abstract description + modalitiesabstract description :

conditions/actions rules = interactionsrely upon generic perception/action capabilities(primitives)

+ execution modalities :variability in the primitives,depending on agent families

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 5/23

Page 6: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Structure of an interaction

Trigger Conditions

Actions

Interaction(Src,Tgt)

Src.hungry() Tgt.fresh()

Src.assimilate(Tgt)Tgt.destroy()

Eat(Src,Tgt)

Trigger: motivations/goals for doing the actionsConditions: prerequisite that allow the realization of the

actionsActions: list of the actions to perform

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 6/23

Page 7: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

The interaction-oriented approach

3 key ideasI each relevant entity is an agent

= entity with perception and action capabilitiesI each behavior is an interaction

= conditions/actions rule involving several agentsI a generic engine determines what interactions may occur

agents characterized by theircapability to perform (source)

or undergo (target)an interaction

[Mathieu & al. 2001]

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 7/23

Page 8: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

The IODA approach

separation between declarative/procedural parts:I automatization of model implementation

and of simulations analysisI elicitation of simulation biases [Kubera & al. 2008]

IODA Interaction-Oriented Design of Agent simulationsmethodology and modelling frame

JEDI Java Environment for the Design of agentInteractionshighly tunable platform

[Kubera & al. 2011]JEDI-Builder Code generator

IODA model → JEDI simulationLEIA LEIA lets you Explore Interactions for your Agents

Explorer for the simulation space[Gaillard & al. 2010]

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 8/23

Page 9: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Interaction and update matricesXXXXXXXXXXXXSources

Targets∅ Trees Grass Sheep Goats Wolves

Trees

GrassGrow (0)

Spread (1)

SheepDie (3) Eat (2; 0) Mate (1; 0)

Wander (0)

GoatsDie (4) Climb (3; 1) Eat (2; 0) Mate (1; 0)

Wander (0)

WolvesDie (4) Eat (3; 1) Eat (2; 1) Mate (1; 0)

Wander (0)

UPDATETreesGrass

SheepAge (2)

BecomeSick (1)

GoatsAge (2)

BecomeSick (1)

Wolves Age (1)

I synthetic view of all behaviorsI actions resulting from decisions

vs. spontaneous state changes

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 9/23

Page 10: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

An homogeneous handling of entities

I each relevant entity is an agentI the actitivy of agents is characterized dynamically:

active agent: acts upon the others= no-empty line in the interaction matrix

passive agent: undergoes actions from other entities= non-empty column in the interaction matrix

labile agent: spontaneous state change= non-empty line in the update matrix

I optimization of the simulation engine[Kubera & al. 2010]

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 10/23

Page 11: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

“Reactive” IODA engine

during a time step:1 Update: each labile agent performs the realizable

interactions from the update matrix

2 Interaction selection: each active agent1 perceives neighbors (among the passive agents)2 filters targets of interactions that it can perform

i.e. agents which can undergo those interactions3 evaluates the triggers and conditions of those interactions4 selects one realizable interaction with the highest priority

level5 performs the corresponding actions

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 11/23

Page 12: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

— II —

The IODA extension forNetLogo

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 12/23

Page 13: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Overview

The principles and algorithms of IODA can be implementedon any platform

within NetLogo:I Java extension −→ required data structures

+ file reading functions+ consistency checking / primitives to write

I NetLogo include file −→ reactive simulation engine

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 13/23

Page 14: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Features

I agent families = turtles, breeds or patchesI target selection policiesI consistency checkingI easy tuning of perceptionI physical/social environnements (links)

http://www.lifl.fr/SMAC/projects/ioda/ioda_for_netlogo/

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 14/23

Page 15: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Principles

a IODA NetLogo simulation =I classical NetLogo program using the extension

+ definition of the concrete primitivesfor each agents family

I definition of the interactions in a text fileI definition of the interaction and update matrices in a text

fileI delegation of the scheduling to a dedicated procedureioda:go

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 15/23

Page 16: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (1) – behaviors

I inspired by the classical Termites modelin the NetLogo library

I everything is an agent: termites + wood chips

PPPPPPPPPSource

Target ∅ chips termites

chips

termites(MoveRandomly, 10, 1)

(MoveRandomly, 0) (PutDown, 20, 0.3)(PickUp, 30, 1)

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 16/23

Page 17: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (2) – NetLogo template

__includes ["../../IODA_2_2.nls"]extensions [ioda]

breed [ termites termite ]breed [ chips chip ]termites-own [ carrying? ]

to setupclear-allcreate-termites nb-termites [ init-termite ]create-chips nb-chips [ init-chip ]ioda:load-interactions "interactions.txt"ioda:load-matrices "matrix.txt" " \t"ioda:setupreset-ticks

end

to goioda:gotick

endS. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 17/23

Page 18: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (3) - matrices

I defined in a CSV file (arbitrary separators)I here: a file "matrix.txt"

;source interaction priority target distancetermites MoveRandomly 0termites MoveRandomly 10 chips 1termites PutDown 20 chips 0.3termites PickUp 30 chips 1

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 18/23

Page 19: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (4) – interactions

defined in a text file (here: "interactions.txt")

interaction MoveRandomlyactions wiggle

end

interaction PickUpcondition not-carrying?actions take-load get-away

end

interaction PutDowncondition carrying?actions drop-load random-turn get-away

end

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 19/23

Page 20: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (5) – primitivesto-report termites::not-carrying?

report not carrying?endto-report termites::carrying?

report carrying?endto termites::filter-neighbors

ioda:filter-neighbors-in-radius 1endto termites::take-load

set carrying? trueask ioda:my-target [ioda:die]

endto termites::wiggle

left random 50 right random 50 fd 1endto termites::drop-load

set carrying? falsehatch-chips 1 [init-chip]

endto termites::get-away

fd 20endto termites::random-turn

right random 360end

I each abstractprimitive must beconcretely defined forthe agents family thatare likely to use it

I filter-neighborsprimitive for handlingthe perception ofneighbors

I predefined primitivese.g. ioda:die

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 20/23

Page 21: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Example (6) – outcome

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 21/23

Page 22: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

— III —

Let’s code!

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 22/23

Page 23: A Hands-on IODA Tutorial - Interaction-Oriented Simulation ...cristal.univ-lille.fr/SMAC/projects/ioda/SSC2014/slides.pdf · JEDI JavaEnvironmentfortheDesignofagent Interactions highly

IODA The IODA extension for NetLogo IODA

Using the extension

http://www.lifl.fr/SMAC/projects/ioda/SSC2014

S. Picault — SMAC, LIFL — Univ. of Lille A Hands-on IODA Tutorial 23/23