Recent trends like the Internet of Things (IoT) suggest a vi-
sion of dense and multi-scale deployments of computing devices in nearly
all kinds of environments. A prominent engineering challenge revolves
around programming the collective adaptive behaviour of such compu-
tational ecosystems. This requires abstractions able to capture concepts
like ensembles (dynamic groups of cooperating devices) and collective
tasks (joint activities carried out by ensembles). In this work, we con-
sider collections of devices interacting with neighbours and that execute
in nearly-synchronised sense–compute–interact rounds, where the com-
putation is given by a single control program. To support programming
whole computational collectives, we propose the abstraction of a dis-
tributed collective process (DCP), which can be used to define at once
the ensemble formation logic and its collective task. We implement the
abstraction in the eXchange Calculus (XC), a core language based on
neighbouring values (maps from neighbours to values) where state man-
agement and interaction is handled through a single primitive, exchange.
Then, we discuss the features of the abstraction, its suitability for differ-
ent kinds of distributed computing applications, and provide a proof-of-
concept implementation of a wave-like process propagation.
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Programming Distributed Collective Processes for Dynamic Ensembles and Collective Tasks
1. Programming Distributed Collective Processes for
Dynamic Ensembles and Collective Tasks
Giorgio Audrito1
, Roberto Casadei2
, Ferruccio Damiani1
,
Gianluca Torta1
, Mirko Viroli2
1
Università degli Studi di Torino
2
ALMA MATER STUDIORUM – Università of Bologna
June 21st, 2023
COORDINATION’23, Lisbon, Portugal
https://www.slideshare.net/RobertoCasadei
R. Casadei Motivation Background Contribution Wrap-up References 1/18
3. Motivation: macro-programming [2] collective systems
Target systems: distributed networks of devices (cf. IoT, swarms, edge-fog-cloud)
Target computations: collective computations (progressive, cooperative) [1]
Approach: macro-programming (a single program for the whole behaviour)
[1] R. Casadei, M. Viroli, G. Audrito, D. Pianini, and F. Damiani, “Engineering collective intelligence at the edge with
aggregate processes,” Engineering Applications of Artificial Intelligence, 2021
[2] R. Casadei, “Macroprogramming: Concepts, state of the art, and opportunities of macroscopic behaviour
modelling,” ACM Computing Surveys, Jan. 2023
R. Casadei Motivation Background Contribution Wrap-up References 2/18
5. Macroprogramming collective systems – e.g.: swarms
move in flocking formation
R. Casadei Motivation Background Contribution Wrap-up References 3/18
6. Macroprogramming collective systems – e.g.: swarms
move in flocking formation ...while also, dynamically...
R. Casadei Motivation Background Contribution Wrap-up References 3/18
7. Macroprogramming collective systems – e.g.: swarms
move in flocking formation ...while also, dynamically...
detect or estimate something
R. Casadei Motivation Background Contribution Wrap-up References 3/18
8. Macroprogramming collective systems – e.g.: swarms
move in flocking formation ...while also, dynamically...
detect or estimate something
elect leader
R. Casadei Motivation Background Contribution Wrap-up References 3/18
9. Macroprogramming collective systems – e.g.: swarms
move in flocking formation ...while also, dynamically...
detect or estimate something
elect leader
organise teams for missions departing from the flock
R. Casadei Motivation Background Contribution Wrap-up References 3/18
11. Background: the eXchange Calculus (XC) [3]
System model (modellable as an event structure)
network of devices working at asynchronous rounds and interacting with neighbours
each round: sense – compute – (inter-)act
the program maps local data to outputs and data to be shared with neighbours
1
1 1
2 1
3
2
1 2
2 2
3 2
4 2
5
3
1 3
2 3
3 3
4
4
1 4
2 4
3 4
4 4
5 4
6
5
1 5
2 5
3
Devices
Time
[3] G. Audrito, R. Casadei, F. Damiani, G. Salvaneschi, and M. Viroli, “Functional programming for distributed systems
with XC,” in ECOOP 2022, ser. LIPIcs, Schloss Dagstuhl, 2022
R. Casadei Motivation Background Contribution Wrap-up References 4/18
12. Background: the eXchange Calculus (XC) [3]
eXchange Calculus (XC): the language
A functional language (λ-calculus) + 3 key elements:
1. neighbouring values (nvalues): default + (optional) neighbour-specific data
2. a single construct for communication: exchange
3. alignment: interaction is scoped by individual behavioural modules, enabling
compositionality
[3] G. Audrito, R. Casadei, F. Damiani, G. Salvaneschi, and M. Viroli, “Functional programming for distributed systems
with XC,” in ECOOP 2022, ser. LIPIcs, Schloss Dagstuhl, 2022
R. Casadei Motivation Background Contribution Wrap-up References 5/18
14. XC: sharing via exchange (1/2)
exchange: a single primitive for state management and bidirectional communication
exchange(ei, (n) = return er send es)
exchange
exchange
exchange
exchange
n
ei
. . . program. . .
er
es
16. XC: composition and alignment
a program evaluation yields a sort of tree of exchanges
different exchanges −→ separate messages
alignment means that data is exchanged only between corresponding nodes in the tree
i.e. match by: • position in program • stack trace −→ enables composition
XC program tree
distanceInServiceProvisioning distanceTo
distanceTo
if/else
distanceEstimate
exchange
nfold
distanceEstimate
exchange
nfold
δ1
δ2
δ3
devices
time
partial alignment of expressions
R. Casadei Motivation Background Contribution Wrap-up References 9/18
19. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
R. Casadei Motivation Background Contribution Wrap-up References 11/18
20. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
• generative
a process is an activity that can be spawned locally in a given round (generative)
R. Casadei Motivation Background Contribution Wrap-up References 11/18
21. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
• generative • dynamic domain
a process is an activity that may spread to neighbours, expanding its range (dynamic
domain)
R. Casadei Motivation Background Contribution Wrap-up References 11/18
22. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
• generative • dynamic domain • concurrent
processes may overlap (concurrency)
R. Casadei Motivation Background Contribution Wrap-up References 11/18
23. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
• generative • dynamic domain • concurrent • collective activity
any process defines both how the domain evolves and the collective activity carried out
within that evolving domain
e.g., in a smart city:
red: resource
recruitment process
green: monitoring
process
blue: access control
process
R. Casadei Motivation Background Contribution Wrap-up References 11/18
24. Proposed abstraction: distributed collective process
What do we mean for a (distributed collective) process?
• generative • controllable, dynamic domain • concurrent • collective activity
device may quit processes, making them shrink and finally terminate (transience), while
other processes may go on indefinitely (long-running)
R. Casadei Motivation Background Contribution Wrap-up References 11/18
25. Distributed Collective Processes (DCP): elements
We distinguish a DCP type P from its running instances Pi
R. Casadei Motivation Background Contribution Wrap-up References 12/18
26. Distributed Collective Processes (DCP): elements
We distinguish a DCP type P from its running instances Pi
Elements of a process instance
Process ID (PID): identifies the instance, and also holds init data
Domain: the set of devices running it
Local result: a pair (local output, status)
∠ status: an NValue mapping neighbours to a Boolean (to control process expansion!)
true: the neighbour will receive the process
false: the neighbour won’t be involved in the process
R. Casadei Motivation Background Contribution Wrap-up References 12/18
27. Distributed Collective Processes (DCP): elements
We distinguish a DCP type P from its running instances Pi
Elements of a process instance
Process ID (PID): identifies the instance, and also holds init data
Domain: the set of devices running it
Local result: a pair (local output, status)
∠ status: an NValue mapping neighbours to a Boolean (to control process expansion!)
true: the neighbour will receive the process
false: the neighbour won’t be involved in the process
Defining process types
Generator expression GP : returns a (possibly empty) set of PIDs
Process logic P: the (complex) expression producing the output-state pair
R. Casadei Motivation Background Contribution Wrap-up References 12/18
28. Distributed Collective Processes (DCP): spawning
Spawning processes
spawnXC (P, GP )
where
spawnXC is a new XC primitive responsible of managing execution of a sets of processes
of the same type ( big-step opsem in the paper)
P is a function expressing the process logic
GP is the generation set of PIDs
R. Casadei Motivation Background Contribution Wrap-up References 13/18
29. Distributed Collective Processes (DCP): spawning
Spawning processes
spawnXC (P, GP )
where
spawnXC is a new XC primitive responsible of managing execution of a sets of processes
of the same type ( big-step opsem in the paper)
P is a function expressing the process logic
GP is the generation set of PIDs
Example: resource look-up via limited multi-gradient
Goal: get IDs of devices (in the surrounding) offering a set
of desired resources
GP : for each resource request, yield a PID of form
(sourceId, reqId, maxDist, {R1 : qty1, ..., Rn : qtyn})
P.status =
(
distanceTo(sourceId) ≤ maxDist ∨ ¬(isSource ∧ done)
⊥ otherwise
P.logic: collect map of pairs (devId, {Ri}) into source
R. Casadei Motivation Background Contribution Wrap-up References 13/18
30. Proof-of-Concept Implementation
FCPP implementation [4]
1 template ....
2 std::unordered_mapK, R
3 spawn(node_t node, trace_t call_point,
4 G process, S key_set, Ts const... xs)
time
aproc
tvar = 10, dens = 10, hops = 20, speed = 0
0 5 10 15 20 25 30 35 40 45 50
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
spherical (xc)
∠ multiple wave-like propagations
∠ aproc: average number of active process instances
Scala implementation [5]
1 def spawn[K,A,R](process: K = A = (R,Boolean),
2 newKeys: Set[K],
3 args: A): Map[K,R]
[4] G. Audrito, “FCPP: an efficient and extensible field calculus framework,” in International Conference on Autonomic
Computing and Self-Organizing Systems (ACSOS), IEEE, 2020
[5] R. Casadei, M. Viroli, G. Aguzzi, and D. Pianini, “Scafi: A scala DSL and toolkit for aggregate programming,”
SoftwareX, 2022
R. Casadei Motivation Background Contribution Wrap-up References 14/18
32. Conclusion
A distributed collective process abstraction, formalised in the eXchange Calculus (XC)
R. Casadei Motivation Background Contribution Wrap-up References 15/18
33. Conclusion
A distributed collective process abstraction, formalised in the eXchange Calculus (XC)
Generalisation over earlier work
∠ implementation in field calculus
R. Casadei, M. Viroli, G. Audrito, D. Pianini, and F. Damiani, “Aggregate processes in field
calculus,” in COORDINATION 2019, ser. LNCS, Springer, 2019
∠ an investigation of different domain evolution techniques
G. Audrito, R. Casadei, and G. Torta, “On the dynamic evolution of distributed
computational aggregates,” in ACSOS-C 2022, IEEE, 2022
R. Casadei Motivation Background Contribution Wrap-up References 15/18
34. Conclusion
A distributed collective process abstraction, formalised in the eXchange Calculus (XC)
Generalisation over earlier work
∠ implementation in field calculus
R. Casadei, M. Viroli, G. Audrito, D. Pianini, and F. Damiani, “Aggregate processes in field
calculus,” in COORDINATION 2019, ser. LNCS, Springer, 2019
∠ an investigation of different domain evolution techniques
G. Audrito, R. Casadei, and G. Torta, “On the dynamic evolution of distributed
computational aggregates,” in ACSOS-C 2022, IEEE, 2022
Support for programming collective adaptive / self-organising behaviour
∠ space-based coordination – e.g. situated tuples
R. Casadei, M. Viroli, A. Ricci, and G. Audrito, “Tuple-based coordination in large-scale
situated systems,” in COORDINATION 2021, ser. LNCS, Springer, 2021
∠ self-organising structures – e.g. SCR (Self-organising Coordination Regions) pattern
R. Casadei, D. Pianini, M. Viroli, and A. Natali, “Self-organising coordination regions: A
pattern for edge computing,” in COORDINATION 2019, ser. LNCS, Springer, 2019
∠ definition of dynamic ensembles
∠ epidemic processes others (future work)
R. Casadei Motivation Background Contribution Wrap-up References 15/18
36. References (1/2)
[1] R. Casadei, M. Viroli, G. Audrito, D. Pianini, and F. Damiani, “Engineering collective intelligence at the
edge with aggregate processes,” Engineering Applications of Artificial Intelligence, vol. 97,
p. 104 081, 2021.
[2] R. Casadei, “Macroprogramming: Concepts, state of the art, and opportunities of macroscopic
behaviour modelling,” ACM Computing Surveys, Jan. 2023. DOI: 10.1145/3579353. [Online].
Available: https://doi.org/10.1145/3579353.
[3] G. Audrito, R. Casadei, F. Damiani, G. Salvaneschi, and M. Viroli, “Functional programming for
distributed systems with XC,” in ECOOP 2022, ser. LIPIcs, vol. 222, Schloss Dagstuhl, 2022,
20:1–20:28. DOI: 10.4230/LIPIcs.ECOOP.2022.20.
[4] G. Audrito, “FCPP: an efficient and extensible field calculus framework,” in International Conference
on Autonomic Computing and Self-Organizing Systems (ACSOS), IEEE, 2020, pp. 153–159. DOI:
10.1109/ACSOS49614.2020.00037.
[5] R. Casadei, M. Viroli, G. Aguzzi, and D. Pianini, “Scafi: A scala DSL and toolkit for aggregate
programming,” SoftwareX, vol. 20, p. 101 248, 2022. DOI: 10.1016/j.softx.2022.101248.
[Online]. Available: https://doi.org/10.1016/j.softx.2022.101248.
[6] R. Casadei, M. Viroli, G. Audrito, D. Pianini, and F. Damiani, “Aggregate processes in field calculus,”
in COORDINATION 2019, ser. LNCS, vol. 11533, Springer, 2019, pp. 200–217. DOI:
10.1007/978-3-030-22397-7_12. [Online]. Available:
https://doi.org/10.1007/978-3-030-22397-7_12.
R. Casadei Motivation Background Contribution Wrap-up References 17/18
37. References (2/2)
[7] G. Audrito, R. Casadei, and G. Torta, “On the dynamic evolution of distributed computational
aggregates,” in ACSOS-C 2022, IEEE, 2022, pp. 37–42. DOI:
10.1109/ACSOSC56246.2022.00024.
[8] R. Casadei, M. Viroli, A. Ricci, and G. Audrito, “Tuple-based coordination in large-scale situated
systems,” in COORDINATION 2021, ser. LNCS, vol. 12717, Springer, 2021, pp. 149–167. DOI:
10.1007/978-3-030-78142-2_10.
[9] R. Casadei, D. Pianini, M. Viroli, and A. Natali, “Self-organising coordination regions: A pattern for
edge computing,” in COORDINATION 2019, ser. LNCS, vol. 11533, Springer, 2019, pp. 182–199.
DOI: 10.1007/978-3-030-22397-7_11.
R. Casadei Motivation Background Contribution Wrap-up References 18/18