engineering complex computational ecosystems (phd defense)

71
Engineering Complex Computational Ecosystems Danilo Pianini Supervisor: prof. Mirko Viroli Tutor: prof. Antonio Natali [email protected] Alma Mater Studiorum—Universit` a di Bologna Final Exam of the ET-IT Program XXVII Cycle Dipartimento di Ingegneria dell’Energia Elettrica e dell’Informazione “Guglielmo Marconi” Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 1 / 71

Upload: danilo-pianini

Post on 16-Jul-2015

126 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Engineering Complex Computational Ecosystems (PhD defense)

Engineering Complex Computational Ecosystems

Danilo PianiniSupervisor: prof. Mirko ViroliTutor: prof. Antonio Natali

[email protected]

Alma Mater Studiorum—Universita di Bologna

Final Exam of the ET-IT Program XXVII CycleDipartimento di Ingegneria dell’Energia Elettrica e dell’Informazione

“Guglielmo Marconi”

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 1 / 71

Page 2: Engineering Complex Computational Ecosystems (PhD defense)

Outline Accepting the limitations of birthform betrays lack of imagination

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 2 / 71

Page 3: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage

Outline

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 3 / 71

Page 4: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Towards a pervasive world

Pervasive Devices

Image courtesy of Alois Ferscha (Pervasive Computing Group, Johannes Kepler Universitat Linz)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 4 / 71

Page 5: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Towards a pervasive world

Progress look pretty normal when you look back...

Image from Tim Urban’s “Wait but why” blog (http://waitbutwhy.com/)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 5 / 71

Page 6: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Towards a pervasive world

...but fasten your belt anyway, please

Image from Tim Urban’s “Wait but why” blog (http://waitbutwhy.com/)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 6 / 71

Page 7: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Engineering a pervasive world

The hard part

Challenges

Interaction can be P2P, centralised, or likely mixed

Devices may or may not be mobile

Desired behaviour may change greatly in response to changes in thelocal environment

Evolution of deployed systems is generally unpredictable

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 7 / 71

Page 8: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Engineering a pervasive world

Issues for engineers

Lack of design patterns

The closest thing are nature inspired patterns, that make the aggregate ofdevices expose some emergent behaviour in a robust, adaptive anddistributed fashion [ZV11]. Nature is cool, but not always optimal.

Languages

Few languages explicitly target the aggregate of devices rather than thesingle one.

Verification

Unpredictability widen the spectrum of possible evolutions, which makeunit testing and model checking not feasible: simulation is often the onlyway to go

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 8 / 71

Page 9: Engineering Complex Computational Ecosystems (PhD defense)

Set the stage Engineering a pervasive world

Contribution of this PhD

A toolchain for software ecosystems [PMV13]

Meta-meta-model supporting very different approaches

Built-in, SSA inspired, novel simulation engine

Probabilistic and distributed model checking [PSV14]

A language for aggregate programming [PVB15]

Based on field calculus: formal and lightweight operational semantics

The same code runs in simulator and real world devices

Interoperability with Java (no need to reinvent the wheel)

Self-organisation patterns and possible today’s applications

Crowd steering [VPMS12, MVR+11, PVZF14, APNF13]

Resource discovery [SYD+13]

Anticipative adaptation [MPV12]Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 9 / 71

Page 10: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems

Outline

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 10 / 71

Page 11: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems

What is it

Idea

A simulator was needed for the European project SAPERE [ZCF+11]

SAPERE adopts a chemical-like metaphor [ZOA+14]

Stochastic chemical simulators (SSA) are extremely efficient[GB00, STP08]

Rather than relying on existing ABMs, very expressive but not asscalable as we desired, let’s extend SSAs to be able to express whatwe want [PMV11]

The simulator evolved beyond its original purposes to the point where itstands now.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 11 / 71

Page 12: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Computational model

Generalised chemistry

Pure chemistry vs. pervasive computing

Single, static compartment versus multiple, possibly mobile, andinterconnected nodes whose connection may depend on environmentaland technological factors

Molecules are described by concentration (an integer), devices maycarry any kind of data item

Reactions “scheduling” in nature follows a Poisson distribution whoserate equation depends on reagents’ concentration [Gil77]. Events in apervasive computing scenario may be influenced by any of theenvironment components and follow any probability distribution(triggers, timers, and people walking are not Markovian)

Devices live in an environment

Yes, it is a nicely big leap

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 12 / 71

Page 13: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Computational model

Close the gap: environment

ReactionA proactive behaviour

Linking RuleA function of the environment

that decides wether or nottwo nodes are connected

Moleculetoken representing a

chunk of data(think of it as a pointer)

ConcentrationActual data associated

with a "molecule"

EnvironmentRiemannian manifold

where nodes live

NodeA container of reactionsand molecules situated

in the environment

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 13 / 71

Page 14: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Computational model

Close the gap: reactions

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

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 14 / 71

Page 15: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Computational model

((Meta) Meta) Models

Meta levels explained

The simulated instance of the system, or scenario, is the model

The specific concentration type (e.g. integer, tuple, or even JavaObject) along with specific actions and conditions that act upon suchdata type represents the meta-model (in the Alchemist jargon,“incarnation”).

The components of the Alchemist abstract computational model arethe meta-meta model, which is common to all incarnations (and, inturn, to all scenarios).

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 15 / 71

Page 16: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Engine, architecture, tools

Architecture

Dynamic Dependency Graph

Dynamic Reaction Manager

Discrete Event Engine

Core

Environment(model)

ReportingGraphical Output

Logging System

Interactive UI

XML Bytecode

Environment Builder

LanguageChain

DSL to XML Compiler

Domain Specific Language

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 16 / 71

Page 17: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Engine, architecture, tools

Engine

Full fledged Discrete Event Simulator derived from Gibson/BruckSSA, extended with novel structures

Supports dependency graph among reactions (this really boostsperformance)

Supports execution “contexts”, pruning the dependency graph,strongly boosting the boost

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 AlchemistDanilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 17 / 71

Page 18: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: an integrated toolchain for complex ecosystems Engine, architecture, tools

Handle with care

When is Alchemist worth it?

An incarnation exposing the desired level of abstraction is alreadyavailable: faster and closer to the model than a generic ABM

There is a long-term investment on Alchemist, and a new incarnationis developed: performance pay back the investment

Incarnations available

Pure chemistry – Little more than an incubation test, deprecated

SAPERE – Mature incarnation, simulates a network of programmabletuple spaces. Programs are chemical-like tuple re-writing rules

Protelis – Supports the execution of Protelis programs on networksof simulated devices. Usable, but under heavy development.

Biochemistry – Sketched, will replace chemistry, exposing muchbetter support for biological oriented applications (back to the fold)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 18 / 71

Page 19: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming

Outline

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 19 / 71

Page 20: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Paradigm shift: programming space/time

Classic approach

Local to global

Complex global behaviour

Simple local behaviour

The whole is more than the sum of the parts

Interaction is key

Nature inspiration

Several systems use nature as inspiration:

physical particles [MZ09]

chemical reactions [ZCF+11]

ants, termites and other social insects [TM03]

Very brief list! There are many more.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 20 / 71

Page 21: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Paradigm shift: programming space/time

Nice properties and hard challenges

The beauty

High resilience and fault tolerance

Self adaptation

Openness

Self healing

The beast

Local to global is hard to engineer

The desired functionality happens at the aggregate level

It is very difficult to design the local behaviour in such a way that theinteraction of many of them produces the desired global behaviour

Many attempts, but no good engineering processes to safely designsuch systems

Often, development becomes a try-and-simulate loopDanilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 21 / 71

Page 22: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Paradigm shift: programming space/time

Collective to local

Desiderata

We want to achieve a collective behaviour

We want to move our focus and abstractions towards the the wholenetwork, rather than focussing on the single devices that compose itand their interaction

We want to support space-time abstractions

Possible solution

Create a language that allows to express collective properties

Create a runtime that can run such programs

Possibly, also create a tool to test programs prior to deployment

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 22 / 71

Page 23: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Paradigm shift: programming space/time

Real languages

Aggregate programming languages

Several attempts to bring existing languages to the aggregateperspective, we tried with Linda [VPB12]

MIT Proto [BB06] is the most known and successful

Developed at MIT and maintained at BBN Technologies

Functional language, LISP-like syntax (I know you hate it too)

All devices run the same program

Computation happens in rounds:

Every device sleeps for some timeProcesses the messages received from the neighboursExecutes its programSends all the neighbours its result

Complex operational semantics

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 23 / 71

Page 24: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Paradigm shift: programming space/time

Field Calculus

A “distillate” of Proto

Provides a lightweight operational semantics [VDB13]

((((LISP-like syntax))))

Still a functional language

Simple enough to formally prove properties, powerful enough to beuniversal (proved!)

Theoretical object, no runtime nor simulation tool provided

Key mechanism: alignment

At the end of each cycle, send to your neighbours your annotated AST

At the beginning of each cycle, each device can inspect what washappening in its surroundings

If two devices took different branches of a if, they are no longeraligned until such branch returns

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 24 / 71

Page 25: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Protelis: practical aggregate programming

Protelis

Functional language

Same operational semantics of the field calculus

Java-like syntax with infix operators

Java interoperability: static methods imports and calls, methodinvocation with dynamic binding

Higher order functions (functions as arguments, closures,lambdas)

Dynamic code

Eclipse plugin

Integrated with Alchemist

Stand-alone framework for real devices

Write once, run everywhere — evolved :)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 25 / 71

Page 26: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Protelis: practical aggregate programming

Alignment with HOF

How to deal with alignment?

Without HOF, all the devices are forced to run the same code: theonly branching point is if.

With HOF, and in particular with support for dynamic code, instead:1 The same function can be defined in multiple points2 Different functions may have the same name (dynamic injection)3 The same function can be invoked in multiple points4 The same code path may invoke a different function

Alignment

Alignment had been improved to consider HOF support. Two functionsalign only if:

They have the same name and body

They were defined in the exact same point in code

They are invoked in the exact same point in codeDanilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 26 / 71

Page 27: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Protelis: practical aggregate programming

LISP-like to Java-like syntax

1 (def distance -to (source)2 (rep d infinity (mux source 0 (min-hood (+ (nbr d) (nbr-range))))))3 distance -to(event)

1 def distanceTo(source) {2 rep (d <- Infinity) {3 mux (source) {4 0

5 } else {6 minHood(nbr(d) + nbrRange)7 }

8 }

9 distanceTo(event)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 27 / 71

Page 28: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming Protelis: practical aggregate programming

Example with HOF

1 def gBB(source, initial, metric, accumulate) {2 rep(distanceValue <- [Infinity , initial]) {3 mux(source) {4 [0, initial]

5 } else {6 let ndv = nbr(distanceValue);7 minHood([ndv.get(0) + metric.apply(), accumulate.apply(ndv.get(1))])

8 }

9 }.get(1)

10 }

1112 def distanceCompetition(d, lead, uid, grain, metric) {13 mux(d > grain * 1.5) { uid } else {14 let gsize = grain * 0.5;

15 mux (d >= gsize) { Infinity } else {16 minHood(mux(nbr(d) + metric.apply() >= gsize) { Infinity } else { nbr(lead) })17 }

18 }

19 }

2021 def breakUsingUIDs(uid, grain, metric) {22 uid == rep(lead <- uid) {23 distanceCompetition(

24 gBB(uid == lead, 0, metric, (v) -> {v + metric.apply()}), lead, uid, grain, metric)

25 }

26 }

2728 breakUsingUIDs(grain, metric)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 28 / 71

Page 29: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Outline

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 29 / 71

Page 30: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Applications for densely populated environments

Crowd steering and evacuation

Provide guidance to prevent dangerous situations, e.g.:

In case of emergency, dynamically balance the crowds to minimize theevacuation timeAvoid crowded paths when providing directionsPrevent dangerous crowd formationAlert users joining a dangerous cluster

Other services

Local communication

Context sensitive applications

Local services and advertisement

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 30 / 71

Page 31: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Crowd-sensitive user steeringSteering against GPS traces taken at Vienna City Marathon 2013

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 31 / 71

Page 32: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Context sensitive user steeringGeneralisation of the former, ran in London

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 32 / 71

Page 33: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Mobile code

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 33 / 71

Page 34: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Upgradable mobile code

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 34 / 71

Page 35: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Upgradable mobile code

Crowd steeringservice version 2

Crowd steeringservice version 1

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 35 / 71

Page 36: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Upgradable mobile code

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 36 / 71

Page 37: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Overlapping services

Exhibitiontickets

Foodservice

Public water

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 37 / 71

Page 38: Engineering Complex Computational Ecosystems (PhD defense)

Future technology applied today

Overlapping services

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 38 / 71

Page 39: Engineering Complex Computational Ecosystems (PhD defense)

Conclusion and future work

Outline

1 Set the stageTowards a pervasive worldEngineering a pervasive world

2 Alchemist: an integrated toolchain for complex ecosystemsComputational modelEngine, architecture, tools

3 Aggregate programmingParadigm shift: programming space/timeProtelis: practical aggregate programming

4 Future technology applied today

5 Conclusion and future work

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 39 / 71

Page 40: Engineering Complex Computational Ecosystems (PhD defense)

Conclusion and future work Results

Results

A toolchain for software ecosystems

Novel, chemical inspired architecture, developed from scratch

Flexible still retaining high performace

A language for aggregate programming [PVB15]

Based on Field Calculus, lightweight semantics

Support for higher order functions, closures, code injection

Integrated development: write your program, run both in Alchemistand real devices

Self-organisation patterns and possible today’s applications

Novel self-organisation patterns

Application of existing and novel patterns to crowd steering, WSNand other high- density scenarios

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 40 / 71

Page 41: Engineering Complex Computational Ecosystems (PhD defense)

Conclusion and future work Future works

Future development

A toolchain for software ecosystems

Stabilise development, strenghten existing features

Include interactivity

Rethink the distributed approximate model checker

Complete biochemistry incarnation

A language for aggregate programming

Are we about to create distributed processes?

Protelis could be a nice language for distributed service scheduling

Enable better modularity

Strong type checking

Self-organisation patterns and possible today’s applications

Create a rich library of reusable building blocks for self-* applicationDanilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 41 / 71

Page 42: Engineering Complex Computational Ecosystems (PhD defense)

References

References I

Bernhard Anzengruber, Danilo Pianini, Jussi Nieminen, and Alois Ferscha.Predicting social density in mass events to prevent crowd disasters.Lecture Notes in Computer Science (including subseries Lecture Notes in ArtificialIntelligence and Lecture Notes in Bioinformatics), 8238 LNCS:206–215, 2013.cited By 1; Conference of 5th International Conference on Social Informatics, SocInfo 2013; Conference Date: 25 November 2013 Through 27 November 2013; ConferenceCode:101766.

Jacob Beal and Jonathan Bachrach.Infrastructure for engineered emergence on sensor/actuator networks.IEEE Intelligent Systems, 21(2):10–19, 2006.

Michael A. Gibson and Jehoshua Bruck.Efficient exact stochastic simulation of chemical systems with many species and manychannels.J. Phys. Chem. A, 104:1876–1889, 2000.

Daniel T. Gillespie.Exact stochastic simulation of coupled crfreactions.The Journal of Physical Chemistry, 81(25):2340–2361, December 1977.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 42 / 71

Page 43: Engineering Complex Computational Ecosystems (PhD defense)

References

References II

Sara Montagna, Danilo Pianini, and Mirko Viroli.Gradient-based self-organisation patterns of anticipative adaptation.In Proceedings of 6th IEEE International Conference on Self-Adaptive and Self-OrganizingSystems (SASO 2012), pages 169–174, September 2012.

Sara Montagna, Mirko Viroli, Matteo Risoldi, Danilo Pianini, and GiovannaDi Marzo Serugendo.Self-organising pervasive ecosystems: A crowd evacuation example.Lecture Notes in Computer Science (including subseries Lecture Notes in ArtificialIntelligence and Lecture Notes in Bioinformatics), 6968 LNCS:115–129, 2011.cited By 4; Conference of 3rd International Workshop on Software Engineering for ResilientSystems, SERENE 2011 ; Conference Date: 29 September 2011 Through 30 September2011; Conference Code:86796.

Marco Mamei and Franco Zambonelli.Programming pervasive and mobile computing applications: The tota approach.ACM Trans. Softw. Eng. Methodol., 18(4):1–56, 2009.

Danilo Pianini, Sara Montagna, and Mirko Viroli.A chemical inspired simulation framework for pervasive services ecosystems.In Proceedings of the Federated Conference on Computer Science and InformationSystems, pages 667–674. IEEE Computer Society Press, 2011.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 43 / 71

Page 44: Engineering Complex Computational Ecosystems (PhD defense)

References

References III

Danilo Pianini, Sara Montagna, and Mirko Viroli.Chemical-oriented simulation of computational systems with Alchemist.Journal of Simulation, 2013.

Danilo Pianini, Stefano Sebastio, and Andrea Vandin.Distributed statistical analysis of complex systems modeled through a chemical metaphor.pages 416–423. Institute of Electrical and Electronics Engineers Inc., 2014.cited By 0; Conference of 2014 International Conference on High Performance Computingand Simulation, HPCS 2014 ; Conference Date: 21 July 2014 Through 25 July 2014;Conference Code:107210.

Danilo Pianini, Mirko Viroli, and Jacob Beal.Protelis: practical aggregate programming.In SAC, Salamanca, Spain, 2015. Accepted, to appear this year.

Danilo Pianini, Mirko Viroli, Franco Zambonelli, and Alois Ferscha.Hpc from a self-organisation perspective: The case of crowd steering at the urban scale.pages 460–467. Institute of Electrical and Electronics Engineers Inc., 2014.cited By 0; Conference of 2014 International Conference on High Performance Computingand Simulation, HPCS 2014 ; Conference Date: 21 July 2014 Through 25 July 2014;Conference Code:107210.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 44 / 71

Page 45: Engineering Complex Computational Ecosystems (PhD defense)

References

References IV

Alexander Slepoy, Aidan P. Thompson, and Steven J. Plimpton.A constant-time kinetic monte carlo algorithm for simulation of large biochemical reactionnetworks.The Journal of Chemical Physics, 128(20):205101, 2008.

Graeme Stevenson, Juan Ye, Simon Dobson, Danilo Pianini, Sara Montagna, and MirkoViroli.Combining self-organisation, context-awareness and semantic reasoning: The case ofresource discovery in opportunistic networks.pages 1369–1376, Coimbra, 2013.cited By 1; Conference of 28th Annual ACM Symposium on Applied Computing, SAC2013 ; Conference Date: 18 March 2013 Through 22 March 2013; Conference Code:96995.

Robert Tolksdorf and Ronaldo Menezes.Using swarm intelligence in linda systems.In Andrea Omicini, Paolo Petta, and Jeremy Pitt, editors, ESAW, volume 3071 of LectureNotes in Computer Science, pages 49–65. Springer, 2003.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 45 / 71

Page 46: Engineering Complex Computational Ecosystems (PhD defense)

References

References V

Mirko Viroli, Ferruccio Damiani, and Jacob Beal.A calculus of computational fields.In Carlos Canal and Massimo Villari, editors, Advances in Service-Oriented and CloudComputing, volume 393 of Communications in Computer and Information Science, pages114–128. Springer Berlin Heidelberg, 2013.

Mirko Viroli, Danilo Pianini, and Jacob Beal.Linda in space-time: an adaptive coordination model for mobile ad-hoc environments.In Marjan Sirjani, editor, Coordination Languages and Models, volume 7274 of LNCS,pages 212–229. Springer-Verlag, June 2012.Proceedings of the 14th Conference of Coordination Models and Languages (Coordination2012), Stockholm (Sweden), 14-15 June.

Mirko Viroli, Danilo Pianini, Sara Montagna, and Graeme Stevenson.Pervasive ecosystems: a coordination model based on semantic chemistry.In Sascha Ossowski, Paola Lecca, Chih-Cheng Hung, and Jiman Hong, editors, 27thAnnual ACM Symposium on Applied Computing (SAC 2012), Riva del Garda, TN, Italy,26–30 March 2012. ACM.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 46 / 71

Page 47: Engineering Complex Computational Ecosystems (PhD defense)

References

References VI

Franco Zambonelli, Gabriella Castelli, Laura Ferrari, Marco Mamei, Alberto Rosi, GiovannaDi Marzo, Matteo Risoldi, Akla-Esso Tchao, Simon Dobson, Graeme Stevenson, Yuan Ye,Elena Nardini, Andrea Omicini, Sara Montagna, Mirko Viroli, Alois Ferscha, SaschaMaschek, and Bernhard Wally.Self-aware pervasive service ecosystems.Procedia Computer Science, 7:197–199, December 2011.Proceedings of the 2nd European Future Technologies Conference and Exhibition 2011(FET 11).

Franco Zambonelli, Andrea Omicini, Bernhard Anzengruber, Gabriella Castelli,Francesco L. DeAngelis, Giovanna Di Marzo Serugendo, Simon Dobson, Jose LuisFernandez-Marquez, Alois Ferscha, Marco Mamei, Stefano Mariani, Ambra Molesini, SaraMontagna, Jussi Nieminen, Danilo Pianini, Matteo Risoldi, Alberto Rosi, GraemeStevenson, Mirko Viroli, and Juan Ye.Developing pervasive multi-agent systems with nature-inspired coordination.Pervasive and Mobile Computing, 2014.Special Issue on “10 years of Pervasive Computing” in honor of Chatschik Bisdikian.

Franco Zambonelli and Mirko Viroli.A survey on nature-inspired metaphors for pervasive service ecosystems.International Journal of Pervasive Computing and Communications, 7(3):186–204, 2011.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 47 / 71

Page 48: Engineering Complex Computational Ecosystems (PhD defense)

References

Engineering Complex Computational Ecosystems

Danilo PianiniSupervisor: prof. Mirko ViroliTutor: prof. Antonio Natali

[email protected]

Alma Mater Studiorum—Universita di Bologna

Final Exam of the ET-IT Program XXVII CycleDipartimento di Ingegneria dell’Energia Elettrica e dell’Informazione

“Guglielmo Marconi”

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 48 / 71

Page 49: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: director’s cut

Model to model

Generic procedure

1 Map your meta model onto Alchemist’s meta-meta model entities

2 Optionally, write a Domain Specific Language (DSL) which generatesan Alchemist-XML compatible file from your domain-specific entities

3 Write whichever model you want to test and simulate

4 Simulate it using Alchemist

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 49 / 71

Page 50: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: director’s cut

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) Engineering Computational Ecosystems April 13, 2015 / Bologna 50 / 71

Page 51: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: director’s cut

Real world maps and GPS traces

Figure: A snapshot of the whole city of Vienna as simulated in Alchemist. Thissnapshot is taken while simulating the city at 10am during the annual marathon,each black point corresponds to a GPS trace.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 51 / 71

Page 52: Engineering Complex Computational Ecosystems (PhD defense)

Alchemist: director’s cut

Approximate Stochastic Model Checker

Problem

Model checking is not feasible with such complexity, but Monte Carlosampling is

How many simulations should you run to in order to get the meanvalue of some property, along with its confidence and approximation?

Alchemist + MultiVeStA

Alchemist has been chained with MultiVeStA

A properties can be written in MultiQuaTeX

MultiVeStA runs the number of experiments required using thechained Alchemist engine

Big plus: MultiVeStA supports distributed execution

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 52 / 71

Page 53: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Example

1 (def distance -to (source)2 (rep d infinity (mux source 0 (min-hood (+ (nbr d) (nbr-range))))))3 distance -to(event)

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 53 / 71

Page 54: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

We want to do more

Dynamic and mobile code with higher order functions

Functions can be arguments and can be returned

Closures

Anonymous functions

Dynamic code

Sugar and utilities

Java interoperability

C family like syntax

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 54 / 71

Page 55: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Upgradable mobile code

1 def upgrade (injection) {2 rep (versioned <- [0, "\"no program installed.\""]) {3 max-hood (nbr (4 if (injection.get(0)) {5 if(versioned < injection) {6 injection

7 } else {8 versioned

9 }

10 } else {11 versioned

12 }

13 ))

14 }

15 }

16 let prog = upgrade([version, code]);17 let code = prog.get(1);18 eval(code);

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 55 / 71

Page 56: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Overlapping services

1 def map(f, t){2 if (t.isEmpty()) {3 t

4 } else {5 [f.apply(t.get(0))].mergeAfter(map(f, t.subTupleEnd(1)))

6 }

7 }

8 def distanceTo(source) {9 rep (d <- Infinity) {

10 mux (source) { 0 } else { min-hood (nbr(d) + nbr-range) }11 }

12 }

13 def inRange(source, r) { distanceTo(source) < r }14 /* actual program */

15 let services = [service0 , service1 , service2];16 map((s) -> {

17 if(inRange(s)) {18 eval(s)19 } else {20 "out of range"21 }

22 }, services);

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 56 / 71

Page 57: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Simpler semantics

Proto Field calculus

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 57 / 71

Page 58: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Key mechanism: Alignment

Abstract syntax trees in Field Calculus

Representation of the abstract syntactic structure of a program

The computation modifies every node of the tree, associating thecorresponding value to it

At the end of the round, it is sent to every neighbour

During the round, each device can read the data every other nodehad at the same point in the code, and use it

If some neighbour has not any data associated with the code path, itmeans that it has chosen a different branch

Such node would be not aligned, and not considered for subsequentcomputation

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 58 / 71

Page 59: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Example

1 (if (> x 0) (x + 1) (x - 1))

if

>

x 0

+ -

x x1 1

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 59 / 71

Page 60: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Example

if•4

>•true

x•3 0•0

+•4 -•

x•3 x•1•1 1•

if•-2

>•true

x•-1 0•0

+• -•-2

x• x•-11• 1•1

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 60 / 71

Page 61: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Conclusion

Aggregate programming

Focus on the whole network

Think in space and time

Much less focus on communication protocols

Paradigm shift: requires training!

Protelis

Solid foundations (field calculus)

Support for higher order functions

Interoperability with Java

Friendly syntax

Simulation framework

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 61 / 71

Page 62: Engineering Complex Computational Ecosystems (PhD defense)

Aggregate programming: director’s cut

Future work

Language side

Sugar, sugar, sugar

Namespacing (done by now, if no disasters happened just before thisdissertation)

Libraries

Tools side

Distributed middleware

Better simulator UI

Better batch executor and logging service

Tons of documentation

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 62 / 71

Page 63: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Why crowds

We are preparing for a world that does not exist yet.

Why we often focus on crowds

Smallest and most diffused devices in today’s world are normallyaccessories or wearables

The higher density of people, the higher density of devices

Challenging issues to tackle, including low reliability of Internetconnection

Crowds of people are real world scenarios available today that closelyresemble our future pervasive world.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 63 / 71

Page 64: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Today’s infrastructure

Internet

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 64 / 71

Page 65: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Big crowds

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 65 / 71

Page 66: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Big crowds and cloud don’t play well

Internet

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 66 / 71

Page 67: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Big crowds and cloud don’t play well

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 67 / 71

Page 68: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Big crowds and dangers

Photo: Sam Panthanky/AFP/Getty Images

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 68 / 71

Page 69: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Big crowds and dangers

Crowd disasters

July 24, 2010 – Germany, Duisburg – 21 deaths

January 1, 2013 – Ivory Coast, Abidjan – 60 deaths

February 20, 2003 – USA, Rhode Island – 100 deaths

October 13, 2013 – India, Madhya Pradesh, Datia – 115 deaths

May 9, 2001 – Ghana, Accra – 126 deaths

January 23, 2013 – Brazil, Santa Maria – 242 deaths

January 12, 2006 – Saudi Arabia, Mecca – 345 deaths

November 22, 2010 – Cambodia, Phnom Penh – 347 deaths

August 31, 2005 – Iraq, Baghdad – 1000 deaths

This is a small list of stampedes, there are thousands more.

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 69 / 71

Page 70: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Channel

Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 70 / 71

Page 71: Engineering Complex Computational Ecosystems (PhD defense)

Self-org patterns: director’s cut

Crowd sensitive steering benefits: data

0

20

40

60

80

100

0 0.2 0.4 0.6 0.8 1

Num

ber

of

people

wit

hin

10

0 m

ete

rs

Normalised vicinity to target

Benefit of crowd-sensitiveness

Classic steeringCrowd sensitive steering

Number of users surrounding the user (within 100 meters from her). With “normalised distance”, we mean that we divided the distance the user still hasto walk to reach the target by the total length of the suggested path.Danilo Pianini (UniBo) Engineering Computational Ecosystems April 13, 2015 / Bologna 71 / 71