from engineer to alchemist, there and back again: an alchemist tale

46
SAPERE Self-aware Pervasive Service Ecosystems From Engineer to Alchemist, There and Back Again: An Alchemist Tale Danilo Pianini – [email protected] Alma Mater Studiorum—Universit` a di Bologna Cesena, May 8th, 2012 Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 1 / 46

Upload: danilo-pianini

Post on 05-Dec-2014

506 views

Category:

Technology


2 download

DESCRIPTION

When computer science meets (bio)chemistry, a new world of possibilities emerges. Taking inspiration from mechanisms that exist in nature, and empowering them with the magic of computation, engineers become alchemists: they create new worlds, ruled by their own (bio)chemical rules. We will call such virtual worlds"computational ecosystems". In this talk we introduce Alchemist, a simulator developed by our research group in order to let us experiment with this complexity. Alchemist takes inspiration from chemical simulators and ABMs, trying to grab the best of both worlds by providing a fast, reliable and extensible framework. We will have a flyby of the simulator features, showing some case studies: crowd steering, crowd evacuation, morphogenesis, anticipative adaptation. The final part of the talk will frame the future activities, offering a pool of opportunities to those interested in this research area

TRANSCRIPT

Page 1: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

SAPERE Self-aware Pervasive Service Ecosystems

From Engineer to Alchemist, There and Back Again: AnAlchemist Tale

Danilo Pianini – [email protected]

Alma Mater Studiorum—Universita di Bologna

Cesena, May 8th, 2012

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 1 / 46

Page 2: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Outline Do or do not, there is no try.

1 SimulationDefinitionsModelsWhen it’s useful?

2 AlchemistSAPERE backgroundComputational modelEngine and architectureCase studiesPerformance

3 DevelopmentDevelopment modelContributorsFuture activities

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 2 / 46

Page 3: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation

Simulation

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 3 / 46

Page 4: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation Definitions

Scientific Method

Traditional science workflow [Parisi, 2001]

Traditional scientific method

identificationdirect observationtheories / hypothesisempirical observationquantitative analysisvalidation / invalidation

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 4 / 46

Page 5: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation Definitions

Definition of Simulation

A new way for describing scientific theories

[Parisi, 2001]

Simulation is the process with which we can study the dynamicevolution of a model system, usually through computational tools

[Banks, 1999]

Simulation is the imitation of the operation of a real-world process orsystem over time

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 5 / 46

Page 6: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation Models

Simulation Requires a Model

M. Minsky – Models, Minds, Machines

A model (M) for a system (S), and an experiment (E) is anything to whichE can be applied in order to answer questions about S.

Representation / abstraction

Formalisation

Aggregation, Simplification, Omission

Building a model...

How complex should be the model?

Which assumptions should be done?

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 6 / 46

Page 7: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation Models

From Model to Simulation. . .

Computer simulation

Models are designed runnable processes

Simulation creates a virtual laboratory

controlled conditionsit’s easy to modify the experiment (variables, parameters, etc.)

Simulations imitate the operations of the modelled process

generation of an artificial evolution of the system

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 7 / 46

Page 8: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation Models

. . . and Back

Deductions on the real system represented

Evaluation of theories about the model

Model validation [Klugl and Norling, 2006]

if the data is reliable;

if prediction doesn’t match the observed behaviour do not match

⇒ the model must be revised

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 8 / 46

Page 9: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Simulation When it’s useful?

Why do we Need Simulations?

[Parisi, 2001, Klugl and Norling, 2006]

The real system cannot actually be observed

The time scale of the real system is too small or too large forobservation

The original system doesn’t yet exist (or not anymore)

The system is too complex

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 9 / 46

Page 10: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist

Alchemist

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 10 / 46

Page 11: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist SAPERE background

The SAPERE Project

http://www.sapere-project.eu/

SAPERE (Self-aware Pervasive Service Ecosystems) is an EU STREPproject under the FP7 FET Proactive Initiative: Self-Awareness inAutonomic Systems (AWARENESS)

The objective of SAPERE is the development of a highly-innovativetheoretical and practical framework for the decentralized deploymentand execution of self-aware and adaptive services for future andemerging pervasive network scenarios

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 11 / 46

Page 12: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist SAPERE background

SAPERE World

LSA Space

LSA

LSALSA

LSA

eco-lawEngine

Software services

SAPERE Node

eco-law activation

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

SAPERENode

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 12 / 46

Page 13: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist SAPERE background

Simulation of a SAPERE environment

The role of simulation

Emergence cannot be fully designed

It’s crazy to deploy a whole ecosystem without any test

Fist class abstractions

Dynamic environment

Different, mobile, communicating nodes

Programmability through a set of chemical-like laws

Continuous Time Markov Chain (CTMC) model

Autonomous agents

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 13 / 46

Page 14: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist SAPERE background

Two approaches

Classic ABM modelling

High flexibility

Topology as first-class abstraction

Dynamics explicitly modelled

No native support for CTMC model

Chemical inspired modelling

Natively CTMC

Very fast and reliable algorithms exist in literature

Very limited topology: multicompartment at best

Only classic reactions can change the world status: limited flexibility

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 14 / 46

Page 15: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Computational model

Alchemist simulation approach

Base idea

Start from the existing work with stochastic chemical systemssimulation

Extend it as needed to reach desired flexibility

Goals

Full support for Continuous Time Markov Chains (CTMC)

Support for differently distributed events (e.g. Triggers)

Rich environments, with obstacles, mobile nodes, etc.

More expressive reactions

Fast and flexible SSA engine

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 15 / 46

Page 16: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Computational model

Enriching the environment description

Environment

Node

Reactions

Molecules

Alchemist world

The Environment contains and links together Nodes

Each Node is programmed with a set of Reactions

Nodes contain Molecules

Each Molecule in a node is described with a ConcentrationDanilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 16 / 46

Page 17: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Computational model

Extending the concept of reaction

From a set of reactants that combine themselves in a set of products to:

Number of

neighbors<3

Node

contains

something

Any other

condition

about this

environment

Rate equation: how conditions

influence the execution speed

Conditions Probability distribution Actions

Any other

action

on this

environment

Move a node

towards...

Change

concentration

of something

Reaction

In Alchemist, every event is an occurrence of a Reaction

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 17 / 46

Page 18: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

SSA Algorithms

Several SSA exist, they follow the same base schema [Gillespie, 1977]:

1 Select next reaction using markovian rates

2 Execute it

3 Update the rates which may have changed

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 18 / 46

Page 19: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Do the math: reaction speed

Consider a chemical reaction in the form:

A + Bµ−→ C

The probability that this reaction will trigger depends on:

1 Number of molecules A and B: the higher, the higher the probabilitythose molecule will encounter and react

2 µ, a speed coefficient for the reaction

We define the propensity of a reaction as its speed in a precise instant oftime as

aµ = µ[A][B]

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 19 / 46

Page 20: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Do the math: next reaction choice

If we assume every reaction is a Poisson process, the probability for it tobe the next one is:

P(next = µ) =

∫ ∞0

P(µ, τ)dτ =

∫ ∞0

aµe−τ∑

j aj dτ =aµ∑j aj

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 20 / 46

Page 21: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Do the math: next reaction time

We can also compute the next time of occurrence:

P(τ)dτ =∑j

P(µ, τ)dτ =

∑j

aj

e−τ∑

j aj dτ

∑j

aj = λ −→ λe−λx

F (x ≤ t) =

∫ t

−∞λe−λxdx =

[−e−λt

]t−∞

= e−λt

Now, given a uniformly distributed random r , it’s possible to compute it’sequivalent for the desired distribution:

e−λt = r ⇒ t =− ln (r)

λ

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 21 / 46

Page 22: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Existing algorithms

Direct method

1 Compute propensity for each reaction

2 Select next reaction probabilistically

3 Execute it

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 22 / 46

Page 23: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Existing algorithms

A+B→C

B+C→D E+G→A

D+E→E+F F→D+G

Direct method + Dependency graph

1 Compute the dependencies among reactions

2 Compute propensity for each reaction

3 Select next reaction probabilistically

4 Execute it

5 Update propensities only for potentially involved reactions

6 Goto 3Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 23 / 46

Page 24: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Existing algorithms

Next Reaction

1 Compute a putative execution time for each reaction

2 Store reactions in a binary heap

3 Pick the next reaction

4 Execute it

5 Compute putative times only for potentially involved reactions

6 Goto 3

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 24 / 46

Page 25: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Existing algorithms

[Slepoy et al., 2008]

1 Compute propensities

2 Split the reactions in groups by their propensity

3 Throw randoms until a reaction in a group is selected

4 Execute it

5 Update propensities only for potentially involved reactions

6 Goto 3

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 25 / 46

Page 26: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

More flexibility!

What they miss is what we added

Support for instantaneus events (∞ Markovian rate)

Reactions can be added and removed during the simulation

Support for non-exponential time distributed events (e.g. triggers)

Dependencies among reactions are evaluated considering their“context”, speeding up the update phase

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 26 / 46

Page 27: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Smart data structures ⇒ bleeding edge performances

2.04 4

3.71

7.32 1

5.51 0

2

8.91 0

4.20 0

9.10 0

10.10 0

inf0 0

A+B→C

B+C→D E+G→A

D+E→E+F F→D+G

Next Reaction efficient structures made dynamic

Dynamic Indexed Priority Queue

Allow to access the next reaction to execute in O(1) timeWorst case update in log2 (N) (average case a lot better)Extended to ensure balancing with insertion and removal

Dynamic Dependency Graph

Allows to smartly update only a subset of all the reactionExtended with the concept of input and output context

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 27 / 46

Page 28: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Modular structure

Environment

User Interface

Alchemist language

Application-specific Alchemist Bytecode Compiler

Environment description in application-specific language

Incarnation-specific language

Reporting System

Interactive UI

Reaction Manager

Dependency Graph

Core Engine

Simulation Flow Language Parser

Environment Instantiator

XML Bytecode

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 28 / 46

Page 29: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Engine and architecture

Some Features in short

Parallel executor

Approximate Stochastic Model Checker

Parallelised engine

Alchemist2Blender

PVeStA integration

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 29 / 46

Page 30: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Crowd evacuation

EXIT 1

EXIT 2

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 30 / 46

Page 31: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Crowd steering

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 31 / 46

Page 32: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Adaptive Displays

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 32 / 46

Page 33: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Simple Morphogenesis proof of concept

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 33 / 46

Page 34: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Morphogenesis of a Drosophila Melanogaster

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 34 / 46

Page 35: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Anticipative adaptation

0 5

10 15

20 25

30 35

40 45 0

5

10

15

20

25

30

35

40

45

0

10

20

30

40

50

60

'datald.log' using 2:3:4

0

10

20

30

40

50

60

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 35 / 46

Page 36: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Case studies

Realistic pedestrians

see the video...

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 36 / 46

Page 37: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Performance

Testbed

We realised the same crowd-steering application for both Alchemistand RePast, in order to evaluate the performance gap (if any)

Source code for RePast and standalone Alchemist applicationavailable athttp://www.apice.unibo.it/xwiki/bin/view/Alchemist/JOS

We choose a simplified use case which allows simulation in RePastwithout any change in its engine

This actually cripples out the most important Alchemist optimizationfor complex environment (the dependency graph)

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 37 / 46

Page 38: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Alchemist Performance

Results

0

50

100

150

200

250

300

350

400

450

500

50 100 150 200 250 300 350 400 450 500

Exe

cuti

on t

ime [

s]

Number of agents

Performance comparison with Repast

Repast Alchemist

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 38 / 46

Page 39: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development

Development

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 39 / 46

Page 40: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Development model

Distributed development

Alchemist is a training ground for some good team development practices

Linux kernel-like development model

Java

XText

Mercurial DCVS

Bitbucket web-based code hosting

Maven

JUnit

Source is released under GPL

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 40 / 46

Page 41: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Contributors

People involved

Michele Bombardi (Done)Realistic pedestrians

Chiara Casalboni (Done)Realistic pedestrians

Francesca Cioffi (Done)Further experiments with Alchemist-SAPERE

Davide Ensini (Done)Approximate Stochastic Model Checker improvement

Enrico Galassi (Done)Alchemist-SAPERE high level language

Enrico Gualandi (Ongoing)Alchemist-SAPERE languages review

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 41 / 46

Page 42: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Contributors

People involved

Luca Mella (Done)Tools for social network analysis

Alessandro Montalti (Done)MS-BioNet to AlchemistXML translator

Luca Nenni (Done)Alchemist2Blender

Enrico Polverelli (Done)Gradient based patterns

Michele Pratiffi (Done)Image importer for Alchemist

Giacomo Pronti (Done)SAPERE incarnation main author

Luca Ricci (Ongoing)Map importer for Alchemist

Andrea Vandin (IMT Lucca)PVeStA integration

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 42 / 46

Page 43: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Future activities

There is a lot of work to do!

MS-Bionet compatibility layer

AlcheGRID

Alchemist2Blender improvement

OpenStreet Map importer and Google Map importer

Blender Integration improvement

Gnuplot integration

CellML / SBML to AlchemistXML

Chemistry Incarnation review

Alchemist for Bio DSL

Realistic biological gradients

GPX tracks loader

RDF to Alchemist-SAPERE translator

These are examples, if you have something in mind, be proactive!Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 43 / 46

Page 44: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Future activities

Bibliography I

Banks, J. (1999).Introduction to simulation.In Farrington, P., Nembhard, H. B., Sturrock, D. T., and Evans,G. W., editors, Proceedings of the 1999 Winter SimulationConference, pages 7–13.

Gillespie, D. T. (1977).Exact stochastic simulation of coupled chemical reactions.Journal of Physical Chemistry, 81(25):2340–2361.

Klugl, F. and Norling, E. (2006).Agent-based simulation: Social science simulation and beyond.Technical report, The Eighth European Agent Systems SummerSchool (EASSS 2006), Annecy.

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 44 / 46

Page 45: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

Development Future activities

Bibliography II

Parisi, D. (2001).Simulazioni - La realta rifatta al computer.Societa editrice il Mulino.

Slepoy, A., Thompson, A. P., and Plimpton, S. J. (2008).A constant-time kinetic Monte Carlo algorithm for simulation of largebiochemical reaction networks.The Journal of Chemical Physics, 128(20):205101+.

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 45 / 46

Page 46: From Engineer to Alchemist, There and Back Again: An Alchemist Tale

SAPERE Self-aware Pervasive Service Ecosystems

From Engineer to Alchemist, There and Back Again: AnAlchemist Tale

Danilo Pianini – [email protected]

Alma Mater Studiorum—Universita di Bologna

Cesena, May 8th, 2012

Danilo Pianini (UniBo) An Alchemist Tale Cesena, May 8th, 2012 46 / 46