Simulating Emergent Properties of Coordination in MAUDE

Simulating Emergent Properties of
Coordination in MAUDE: the Collective
Sorting Case
Matteo Casadei, Luca Gardelli, Mirko Viroli
DEIS - Cesena
ALMA MATER STUDIORUM–Università di Bologna
{m.casadei, luca.gardelli, mirko.viroli}@unibo.it
Foreword
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
2
Complex Systems…
•  …increasingly used in coordination models and
languages…
•  …usually described by stochastic models
•  For example: self-organization principles to
cope with dynamism and unpredictability of
distributed systems
•  Growing importance of simulation tools in the
analysis and the design stage of these
systems
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
3
Main Challenge
•  Find a way to use complex systems
effectively, in particular in the analysis and the
design process of coordination models and
languages
•  We want to address complex systems using
stochastic models!
•  Define a stochastic framework to support
modelling and simulation of complex
systems…
•  …providing enough power to study interesting
properties of coordination models
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
4
Outline
•  Importance of complex systems in
coordination
•  Role of the MAUDE language in stochastic simulation
of complex systems
•  MAUDE-based implementation of a Stochastic
Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective Sorting by
our Stochastic Framework
•  Some Results about Collective Sorting simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
5
Complex Systems and Coordination
•  Coordination means “interaction management”
•  but environment could be subject to
unpredictable changes, so adaptivity can
represent a useful emergent property
•  Many works moving towards this direction, like:
•  Tuples On The Air (TOTA)
•  SwarmLinda
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
6
Outline…
•  Importance of complex systems in coordination
•  Role of the MAUDE language in stochastic
simulation of complex systems
•  MAUDE-based implementation of a Stochastic
Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective Sorting by
our Stochastic Framework
•  Some Results about Collective Sorting simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
7
Why MAUDE?
•  There are many formal tools addressing the
study stochastic systems, but…
•  … they are suitable to model better only
particular sets of system: for example
Stochastic Pi Machine (SPIM)
•  MAUDE is very suitable for our purposes,
because it allows an easy syntactic and
semantic definition of custom languages
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
8
MAUDE: basics (1)
•  It is a powerful programming language useful to
model and to specify a wide range of systems
•  It is based on equational and rewriting logic
• 
Modules are the basic components of every
MAUDE program
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
9
MAUDE: basics (2)
•  Example of ADT definition in MAUDE:
Types Definition
Operation Definition
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
10
The MAUDE language is useful…
•  …to cope with stochastic aspects of complex systems
•  It allows a simple specification of a system by defining
transition rules
•  It is flexible to define syntax and semantics
•  Suitable tool for analysing systems properties: e.g. theorem
proving and model checking
•  Examples of executable system specifications in MAUDE:
•  Milner’s CCS, Reo (more recently)
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
11
Outline…
•  Importance of complex systems in coordination
•  Role of the MAUDE language in stochastic simulation
of complex systems
•  MAUDE-based implementation of a
Stochastic Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective Sorting by
our Stochastic Framework
•  Some Results about Collective Sorting simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
12
The Stochastic Simulation Framework
•  It is based on a simple idea deriving from
stochastic pi-calculus
•  The idea is to model a stochastic system by a
labelled transition system
•  Transitions are of the kind:
•  A system can move from the state S to the state S’
by an action a occuring with a given rate r
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
13
Main Components of the Framework
•  STOCHASTIC-SELECTION module: it
contains probabilistic and random functions.
•  STANDARD-CARRIER module: it defines all
the common types needed in every system
we will simulate by the framework
•  STOCHASTIC-TRACES module: it defines the
simulation engine
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
14
The STOCHASTIC-SELECTION module
Simulation Event
Nat
id of the action
causing the event
Float: elapsed time
Computed from an
exponential distribution
Implements the stochastic policy:
next(2.0 3.0 5.0) means that the next sim.event @(N,F)
The next simulation event will
•  action 0, with probability
•  action 1, with probability
•  action 2, with probability
be caused by
20%
30%
50%
in this case the average value for the elapsed time is 0.1
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
15
The STANDARD-CARRIER module
An Effect
A#F->[Ss]
Represents the possible
evolution of the system if
the Action A will be performed
(with a rate F)
Abstract definition:
Represents the description
of the transition system
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
16
The STOCHASTIC-TRACES module (1)
•  Types definition
Step is the ADT representing a simulation step:
[200:[email protected]] means that
• the simulated system is in the state S
• the simulation has started since 2.67 time units
• 200 steps remaining before the end of the
simulation
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
17
The STOCHASTIC-TRACES module (2)
•  Semantics of the Stochastic Engine
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
18
Understanding The Framework
•  Simple example: the Na-Cl chemical reaction
dynamics
State
Action
FOCLASA@CONCUR2006
August 31, 2006
Rate
Simulating Emergent Properties of
Coordination in MAUDE
19
A Simulation Trace
Counter
State: <Na,Na+,Cl,Cl->
Elapsed Time
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
20
From the Trace to Charts
•  Easy off-line generation of charts starting from the
previous trace!
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
21
Outline…
•  Importance of complex systems in coordination
•  Role of the MAUDE language in stochastic simulation
of complex systems
•  MAUDE-based implementation of a Stochastic
Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective Sorting by
our Stochastic Framework
•  Some Results about Collective Sorting simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
22
Collective Sorting: Scenario (1)
•  We have a Multiagent system:
•  The environment has items of different kinds
•  Agents: they have to order items on the basis
of a common criterion
This is a Coordination Problem!
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
23
Collective Sorting: a possible architecture
•  A set of sorter agents interacting via Tuple Spaces
TS1
TS2
TS4
TS3
•  Each agent can read insert and remove tuples from tuple
spaces
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
24
Collective Sorting: agents’ agenda
•  1) It chooses a destination tuple space TSd
(different from the source one TSs)
•  2) It chooses a kind K of tuple.
•  3) It reads a tuple Ta from TSs
•  4) It reads a tuple Tb from TSd
•  5) It moves a tuple of kind K from TSs to TDs
if the kind of Tb = K and different from the
kind of Ta
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
25
Uniform Reading
The previous readings are performed by a new
primitive uniform reading (urd)
given a tuple template t(X), a tuple is read in a probabilistic
way among all the matching tuples
For example:
if a Tuple Space contains
•  10 tuples t(a)
•  20 tuples t(b)
performing the uniform reading urd(t(X)) we have a
probabilty of
• 66% to read a tuple t(b)
• 33% to read t(a)
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
26
Outline…
•  Importance of complex systems in coordination
•  Role of the MAUDE language in stochastic simulation
of complex systems
•  MAUDE-based implementation of a Stochastic
Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective
Sorting by our Stochastic Framework
•  Some Results about Collective Sorting simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
27
Structure of the Collective Sorting Model
•  Based on three modules:
•  CS-TYPES module specifies types useful in
the definition of the system state
•  CS-FUNCTION defines utility function
•  CS implements the transition system using
our stochastic engine
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
28
Collective Sorting Syntax
e.g. ‘id[10] means 10
tuples of type ‘id
e.g.:
<1@’a[4]|’b[6]|’c[3]>
It is a TS with id 1
and 3 tuple types
e.g. [1];[2];[a];[a];[b]
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
29
Implementation Details
•  A snippet of the CS module:
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
30
Outline…
•  Importance of complex systems in coordination
•  Role of the MAUDE language in stochastic simulation
of complex systems
•  MAUDE-based implementation of a Stochastic
Simulation Framework
•  A case study: the Collective Sorting
•  Modelling and Simulating the Collective Sorting by
our Stochastic Framework
•  Some Results about Collective Sorting
simulations
•  Conclusion and future work
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
31
Test Instance
•  We simulated a Collective Sorting instance
with 4 Tuple Spaces and 4 Tuple Kinds
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
32
Simulation Result (1)
•  Tuple Space trend: only one tuple type aggregates here
•  Tuples of different kind are moved in other tuple spaces
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
33
Simulation Result (2)
Trend of the winning tuple in each tuple space
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
34
Simulation Result (3)
Entropy is a measure of the “chaos” in a tuple space
The entropy reaches zero in every tuple space:
Complete order of the system
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
35
Conclusion and Future Work
•  We argued the necessity of considering
stochasticity when working in the coordination
field
•  We developed a stochastic engine allowing us an
easy prototyping of coordination tecniques by
simulation
•  Future work:
•  Improve the simulation framework
•  Better exploration of the collective sorting, for
example applying load balancing approaches
FOCLASA@CONCUR2006
August 31, 2006
Simulating Emergent Properties of
Coordination in MAUDE
36
Thank you!
Simulating Emergent Properties of
Coordination in MAUDE: the Collective
Sorting Case
Matteo Casadei, Luca Gardelli, Mirko Viroli
DEIS – Cesena
ALMA MATER STUDIORUM–Università di Bologna
{m.casadei, luca.gardelli, mirko.viroli}@unibo.it