The document describes a Functional Reactive Approach to Self-Organisation Programming (FRASP). FRASP interprets the aggregate programming model from a functional reactive programming (FRP) perspective and implements it as a Scala DSL. It provides reactive abstractions like Flow to express distributed, time-varying computations. Examples demonstrate how FRASP can declaratively define self-organizing behaviors like gradient fields and self-healing channels through reactive compositions of local computations.
Information science research with large language models: between science and ...
Self-Organisation Programming: a Functional Reactive Macro Approach (FRASP) [Presentation at ACSOS'23]
1. Self-Organisation Programming:
a Functional Reactive Macro Approach
Roberto Casadei, Francesco Dente,
Gianluca Aguzzi, Danilo Pianini, Mirko Viroli
Department of Computer Science and Engineering
ALMA MATER STUDIORUM – Università of Bologna
June 21st, 2023
ACSOS’23, Toronto, Canada
https://www.slideshare.net/RobertoCasadei
R. Casadei Motivation Contribution Wrap-up References 1/16
3. Context and Goals
building collective intelligence [1] in large-scale artificial systems
e.g.: swarms, edge-cloud infrastructures, crowds of wearable-augmented people
[1] R. Casadei, “Artificial Collective Intelligence Engineering: A Survey of Concepts and Perspectives,” Artificial Life,
Jul. 2023
R. Casadei Motivation Contribution Wrap-up References 2/16
4. A key problem: self-organisation engineering
how to drive the (emergence of the) self-organisation in a
collection of agents or devices?
[2] G. Aguzzi, R. Casadei, and M. Viroli, “Towards reinforcement learning-based aggregate computing,” in
COORDINATION, ser. LNCS, Springer, 2022
[3] R. Casadei, “Macroprogramming: Concepts, state of the art, and opportunities of macroscopic behaviour
modelling,” ACM Comput. Surv., no. 13s, 2023
[4] J. Beal, D. Pianini, and M. Viroli, “Aggregate programming for the internet of things,” IEEE Computer, no. 9, 2015
R. Casadei Motivation Contribution Wrap-up References 3/16
5. A key problem: self-organisation engineering
how to drive the (emergence of the) self-organisation in a
collection of agents or devices?
self-organisation engineering
(semi-)automatic approaches
MARL Program Synthesis [2] ...
“manual” approaches
node-centric
TOTA (reactive tuples)
...
macro-programming [3]
aggregate computing [4]
[2] G. Aguzzi, R. Casadei, and M. Viroli, “Towards reinforcement learning-based aggregate computing,” in
COORDINATION, ser. LNCS, Springer, 2022
[3] R. Casadei, “Macroprogramming: Concepts, state of the art, and opportunities of macroscopic behaviour
modelling,” ACM Comput. Surv., no. 13s, 2023
[4] J. Beal, D. Pianini, and M. Viroli, “Aggregate programming for the internet of things,” IEEE Computer, no. 9, 2015
R. Casadei Motivation Contribution Wrap-up References 3/16
6. SotA: Aggregate Computing (AC) (in 1 Slide)
Self-org-like computational model
structure: graph w/ local neighbourhoods
interaction: repeated msg exchange with neighbours
behaviour: repeated execution of async rounds of sense
– compute – (inter)act (program maps context to act)
R. Casadei Motivation Contribution Wrap-up References 4/16
7. SotA: Aggregate Computing (AC) (in 1 Slide)
Self-org-like computational model
structure: graph w/ local neighbourhoods
interaction: repeated msg exchange with neighbours
behaviour: repeated execution of async rounds of sense
– compute – (inter)act (program maps context to act)
formal model of executions: event structures
δ0
δ1
δ2
δ3
δ4
device
time
0
0 0
1 0
2 0
3 0
4
1
0 1
1 1
2 1
3 1
4 1
5
2
0 2
1 2
2 2
3
3
0 3
1 3
2 3
3 3
4 3
5
4
0 4
1 4
2
m
e
s
s
a
g
e
self-message
reboot
R. Casadei Motivation Contribution Wrap-up References 4/16
8. SotA: Aggregate Computing (AC) (in 1 Slide)
Self-org-like computational model
structure: graph w/ local neighbourhoods
interaction: repeated msg exchange with neighbours
behaviour: repeated execution of async rounds of sense
– compute – (inter)act (program maps context to act)
abstraction: computational fields (dev/evt 7→ V)
formal core language: field calculus [5]
paradigm: functional, macro-programming
source destination
gradient distance
gradient
=
+
dilate
width
37
10
1 def channel(source: Boolean, destination:
2 Boolean, width: Double) =
3 dilate(gradient(source) + gradient(destination) =
4 distance(source, destination), width)
M. Viroli, J. Beal, F. Damiani, G. Audrito, R. Casadei, and D. Pianini, “From dis-
tributed coordination to field calculus and aggregate computing,” J. Log. Algebraic
Methods Program., 2019
formal model of executions: event structures
δ0
δ1
δ2
δ3
δ4
device
time
0
0 0
1 0
2 0
3 0
4
1
0 1
1 1
2 1
3 1
4 1
5
2
0 2
1 2
2 2
3
3
0 3
1 3
2 3
3 3
4 3
5
4
0 4
1 4
2
m
e
s
s
a
g
e
self-message
reboot
R. Casadei Motivation Contribution Wrap-up References 4/16
9. SotA: Aggregate Computing (AC) (in 1 Slide)
Self-org-like computational model
structure: graph w/ local neighbourhoods
interaction: repeated msg exchange with neighbours
behaviour: repeated execution of async rounds of sense
– compute – (inter)act (program maps context to act)
abstraction: computational fields (dev/evt 7→ V)
formal core language: field calculus [5]
paradigm: functional, macro-programming
source destination
gradient distance
gradient
=
+
dilate
width
37
10
1 def channel(source: Boolean, destination:
2 Boolean, width: Double) =
3 dilate(gradient(source) + gradient(destination) =
4 distance(source, destination), width)
M. Viroli, J. Beal, F. Damiani, G. Audrito, R. Casadei, and D. Pianini, “From dis-
tributed coordination to field calculus and aggregate computing,” J. Log. Algebraic
Methods Program., 2019
formal model of executions: event structures
δ0
δ1
δ2
δ3
δ4
device
time
0
0 0
1 0
2 0
3 0
4
1
0 1
1 1
2 1
3 1
4 1
5
2
0 2
1 2
2 2
3
3
0 3
1 3
2 3
3 3
4 3
5
4
0 4
1 4
2
m
e
s
s
a
g
e
self-message
reboot
sensors
local functions
actuators
Application
Code
Developer
APIs
Field Calculus
Constructs
Resilient
Coordination
Operators
Device
Capabilities
functions rep
nbr
T
G
C
functions
communication state
Perception
Perception
summarize
average
regionMax
…
Action
Action State
State
Collective Behavior
Collective Behavior
distanceTo
broadcast
partition
…
timer
lowpass
recentTrue
…
collectivePerception
collectiveSummary
managementRegions
…
Crowd Management
Crowd Management
dangerousDensity crowdTracking
crowdWarning safeDispersal
restriction
selfstabilisation
J. Beal, D. Pianini, and M. Viroli, “Aggregate programming for the internet of
things,” IEEE Computer, no. 9, 2015
R. Casadei Motivation Contribution Wrap-up References 4/16
10. Motivation: combining strengths from SotA approaches
Feature TOTA aggregate computing
programming
approach , local-to-global - global-to-local
complexity
management “ modularity - compositionality
declarativeness
- high - high
scheduling ap-
proach - reactive , periodic (round-based)
scheduling
granularity - fine-grained , coarse-grained
R. Casadei Motivation Contribution Wrap-up References 5/16
11. Motivation: combining strengths from SotA approaches
Feature TOTA aggregate com-
puting
FRASP
programming
approach , local-to-global - global-to-local - global-to-local
complexity
management “ modularity - compositionality - compositionality
declarativeness
- high - high - high
scheduling ap-
proach - reactive , periodic (round-
based)
- reactive
scheduling
granularity - fine-grained , coarse-grained - fine-grained
R. Casadei Motivation Contribution Wrap-up References 5/16
14. FRASP
FRASP
is a
Functional Reactive Approach
to
Self-organisation Programming
designed by interpreting the aggregate programming model by a (distributed) functional
reactive programming (FRP) perspective [6]
impl as a Scala DSL using Sodium FRP library
R. Casadei Motivation Contribution Wrap-up References 6/16
15. FRASP
FRASP
is a
Functional Reactive Approach
to
Self-organisation Programming
designed by interpreting the aggregate programming model by a (distributed) functional
reactive programming (FRP) perspective [6]
impl as a Scala DSL using Sodium FRP library
FRP in a nutshell
FRP provides abstractions to express and combine time-varying values into a
dependency graph
1 val v1 = /* ... */ ;
2 val v2 = /* ... */ ;
3 val v3 = v1 + v2 ; // v3 gets updated upon change of v1 or v2
R. Casadei Motivation Contribution Wrap-up References 6/16
16. FRASP
FRASP
is a
Functional Reactive Approach
to
Self-organisation Programming
designed by interpreting the aggregate programming model by a (distributed) functional
reactive programming (FRP) perspective [6]
impl as a Scala DSL using Sodium FRP library
FRP in a nutshell
FRP provides abstractions to express and combine time-varying values into a
dependency graph
1 val v1 = /* ... */ ;
2 val v2 = /* ... */ ;
3 val v3 = v1 + v2 ; // v3 gets updated upon change of v1 or v2
AC + FRP: intuition
1 val selforgSubRes1 = f(/* ... */);
2 val selforgSubRes2 = g(/* ... */);
3 val selforgOutput = h(selforgSubRes1, selforgSubRes2); // h re-eval'ed iff inputs change
R. Casadei Motivation Contribution Wrap-up References 6/16
17. FRASP in a nutshell
Data types
Flow[T]: a reactive collective
sub-computation representing a
time-varying signal of Ts
distributed! each device get its own
“flow” for a single task; the system
behaviour/result for the task is given by
all these flows
NbrField[T]: a collection of data from
neighbours
Neighbouring sensors
1 def nbrRange(): Flow[NbrField[Double]] =
2 nbrSensor(nbrRange)
Stateful flow evolution
1 loop(0)(v = v + 1) // implicitly
throttling
mux: strict choice
1 mux(sensor(temperature) THRESHOLD) {
2 constant(hot)
3 } {
4 constant(normal)
5 }
branch: non-strict choice
1 branch(sensor(color) == red){
2 nbr(constant(1)).sum // run by reds
3 } {
4 nbr(constant(1)).sum // run by blues
5 }
lift: combining flows
1 lift(nbr(mid(),nbrRange()){ (nId,nDst) =
2 s${nId} is at distance ${nDst}
3 }
R. Casadei Motivation Contribution Wrap-up References 7/16
18. Example: gradient
Code and graphical representation of execution https://youtu.be/3QIWfNq3yxU
1 def gradient(source: Flow[Boolean]): Flow[Double] =
2 loop(Double.PositiveInfinity) { g = {
3 mux(source) {
4 constant(0.0)
5 } {
6 lift(nbrRange(), nbr(g))(_ + _).withoutSelf.min
7 }
8 }
gradient: field of minimum distances from source
Notation
∠ blue shadow: source
∠ gray: obstacle (no gradient computation)
∠ hotter colours → lower distance to source
R. Casadei Motivation Contribution Wrap-up References 8/16
21. Example: self-healing channel
Graphical representation of dependencies among reactive self-organising computations
source destination
gradient distance
gradient
=
+
dilate
width
37
10
Channel
gradient
(source)
gradient
(destination)
distanceBetween
source destination
Sub-
computations
Computation
Sensors
nbrRange
Input
Width
Platform
Local sensors
Neighbour data
R. Casadei Motivation Contribution Wrap-up References 11/16
22. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
stabilised channel (connects source to destination via a path of devices)
R. Casadei Motivation Contribution Wrap-up References 12/16
23. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
a new potential destination appears
R. Casadei Motivation Contribution Wrap-up References 12/16
24. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
the channel gets recomputed
R. Casadei Motivation Contribution Wrap-up References 12/16
25. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
the channel gets recomputed
R. Casadei Motivation Contribution Wrap-up References 12/16
26. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
the channel gets recomputed
R. Casadei Motivation Contribution Wrap-up References 12/16
27. Example: self-healing channel
Reactive Dynamics https://youtu.be/j_JX5wW03-w
the channel re-stabilises
R. Casadei Motivation Contribution Wrap-up References 12/16
30. Conclusion
FRASP (Functional Reactive Approach to Self-Org Programming) re-interprets the
aggregate programming model by a functional reactive programming (FRP) perspective
R. Casadei Motivation Contribution Wrap-up References 14/16
31. Conclusion
FRASP (Functional Reactive Approach to Self-Org Programming) re-interprets the
aggregate programming model by a functional reactive programming (FRP) perspective
∠ and also provides an original flavour of distributed FRP
R. Casadei Motivation Contribution Wrap-up References 14/16
32. Conclusion
FRASP (Functional Reactive Approach to Self-Org Programming) re-interprets the
aggregate programming model by a functional reactive programming (FRP) perspective
∠ and also provides an original flavour of distributed FRP
Combines the benefits of existing approaches (cf. AC and TOTA)
∠ expressiveness and compositionality
∠ reactive execution (configurable)
∠ fine-grained reactive execution (not only the whole programs but parts of it)
R. Casadei Motivation Contribution Wrap-up References 14/16
33. Conclusion
FRASP (Functional Reactive Approach to Self-Org Programming) re-interprets the
aggregate programming model by a functional reactive programming (FRP) perspective
∠ and also provides an original flavour of distributed FRP
Combines the benefits of existing approaches (cf. AC and TOTA)
∠ expressiveness and compositionality
∠ reactive execution (configurable)
∠ fine-grained reactive execution (not only the whole programs but parts of it)
Future work
∠ libraries of reactive self-org blocks
∠ implementation of advanced self-org constructs like aggregate processes
R. Casadei Motivation Contribution Wrap-up References 14/16
35. References (1/1)
[1] R. Casadei, “Artificial Collective Intelligence Engineering: A Survey of Concepts and Perspectives,”
Artificial Life, pp. 1–35, Jul. 2023, ISSN: 1064-5462. DOI: 10.1162/artl_a_00408.
[2] G. Aguzzi, R. Casadei, and M. Viroli, “Towards reinforcement learning-based aggregate computing,”
in COORDINATION, ser. LNCS, vol. 13271, Springer, 2022, pp. 72–91. DOI:
10.1007/978-3-031-08143-9_5.
[3] R. Casadei, “Macroprogramming: Concepts, state of the art, and opportunities of macroscopic
behaviour modelling,” ACM Comput. Surv., vol. 55, no. 13s, 2023, ISSN: 0360-0300. DOI:
10.1145/3579353.
[4] J. Beal, D. Pianini, and M. Viroli, “Aggregate programming for the internet of things,” IEEE Computer,
vol. 48, no. 9, pp. 22–30, 2015. DOI: 10.1109/MC.2015.261.
[5] M. Viroli, J. Beal, F. Damiani, G. Audrito, R. Casadei, and D. Pianini, “From distributed coordination to
field calculus and aggregate computing,” J. Log. Algebraic Methods Program., vol. 109, 2019. DOI:
10.1016/j.jlamp.2019.100486.
[6] E. Bainomugisha, A. L. Carreton, T. V. Cutsem, S. Mostinckx, and W. D. Meuter, “A survey on reactive
programming,” ACM Comput. Surv., vol. 45, no. 4, 52:1–52:34, 2013. DOI:
10.1145/2501654.2501666.
R. Casadei Motivation Contribution Wrap-up References 16/16