Presentation at the 5th eCAS Workshop on Engineering Collective Adaptive Systems 2020, colocated with acsos.
Collective Adaptive Systems (CAS) are increasingly used as a model for building and managing large- scale cyber-physical systems, highlighting the need for a flexible approach for their definition and engineering. CAS consist of multiple individual context-aware self-adaptive systems, which need to adapt to their own environment, but also interact with each other, resulting in the global CAS behavior. Interactions can emerge as complementary or conflicting, and needs to be managed to assure a correct global behavior. Context-oriented Programming (COP) is one of the programming paradigms that has risen as a suitable approach to developing self-adaptive systems, due to the natural mapping of its programming constructs to self- adaptive systems taxonomy. Recently, multiple extensions to the COP model have been developed, which manage inter- actions between adaptive components (or systems), enabling its suitability for developing CAS as well. In this paper, we map out the COP language abstractions to the characteristics of CAS, demonstrating COP applicability, its formalization, verification tools, and adaptation composition techniques to foster CAS. Our discussion is illustrated using city-wide bus transport management system, as an example of a CAS.
APM Welcome, APM North West Network Conference, Synergies Across Sectors
Language Abstractions and Techniques for Developing Collective Adaptive Systems Using Context-oriented Programming
1. Nicolás Cardozo - Ivana Dusparic
@ncardoz - @ivanadusparic
n.cardozo@uniandes.edu.co - ivana.dusparic@scss.tcd.ie
Language abstractions and Techniques for
Developing Collective Adaptive Systems
Using Context-oriented Programming
2020
August 21
st
, 2020 (online)
2. Collective adaptive systems
2
Adaptive
Interactive
Autonomous adaptation to changes in the
surrounding execution environment to satisfy
performance and quality attributes of the system
Manage interaction between system entities to
ensure the emergence of desired behavior
3. … How do you engineer such systems?
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
4. 4
Building a CAS
City transport systems characterize by the interaction
between its different individual systems (bus routes)
consisting of:
• Buses
• Stations
• Traveling passengers
• Traffic conditions
Roads Stations Buses
5. 5
Building a CAS
We want to build a transport management system that adapts to
the situations that arise from the system execution
Alerts raised upon identified problems in the system functioning
RoadBlocked FullStation FullBus
6. 5
Building a CAS
We want to build a transport management system that adapts to
the situations that arise from the system execution
Alerts raised upon identified problems in the system functioning
Dynamically change
the system behavior
for a more
appropriate one
foo() { … }
bar() { … }
Context-oriented programming
RoadBlocked FullStation FullBus
7. 6
TranCity
Stations Buses
Enable passengers to enter
to wait for a bus in their
desired route.
Move between stations in a
specified route. At stations
passengers get off, letting new
passengers on the bus
Station = Trait({
id: id,
name: name,
open: true,
capacity: 120,
load: 0.0,
passengers: []
addPassenger: function(p) {
this.passengers.push(p);
this.setLoad();
},
})
Bus = Trait({
id: id,
route: “R4”,
capacity: 56,
load: 0,
currentNode: “S1”,
passengers: []
moveBus: function() {
//add and remove passengers
//move to the next station
},
})
Regular JS
objects
8. 6
TranCity
Stations Buses
execution
loop
Enable passengers to enter
to wait for a bus in their
desired route.
Move between stations in a
specified route. At stations
passengers get off, letting new
passengers on the bus
Station = Trait({
id: id,
name: name,
open: true,
capacity: 120,
load: 0.0,
passengers: []
addPassenger: function(p) {
this.passengers.push(p);
this.setLoad();
},
})
Bus = Trait({
id: id,
route: “R4”,
capacity: 56,
load: 0,
currentNode: “S1”,
passengers: []
moveBus: function() {
//add and remove passengers
//move to the next station
},
})
Regular JS
objects
9. 7
Alerts and expected behavior
Full Station
Full Bus
Close the station
Divert passengers to near stations in
their route
Don’t allow passengers on the bus
Send additional bus to route of the full
bus
!
Road blocked
Split the route at the blockage point,
serve each road segment independently
(as a new route). Divert passengers
across the blocked point
!
!
11. 9
Object to adapt
Full Station
Full Bus
!
Road blocked!
!
[Gonzalez et al. Context-traits MODULARITY’13]
12. 9
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})Full Station
Full Bus
!
Road blocked!
!
[Gonzalez et al. Context-traits MODULARITY’13]
13. 9
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})Full Station
Full Bus
!
Road blocked!
!
FullBusBehavior = Trait({
nextBusStation: function() {
filter(passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
[Gonzalez et al. Context-traits MODULARITY’13]
14. 9
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})Full Station
Full Bus
!
Road blocked!
!
FullBusBehavior = Trait({
nextBusStation: function() {
filter(passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
FullBus.adapt(bus, FullBusBehavior)
[Gonzalez et al. Context-traits MODULARITY’13]
15. 9
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})Full Station
Full Bus
!
Road blocked!
!
FullBusBehavior = Trait({
nextBusStation: function() {
filter(passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
FullBus.adapt(bus, FullBusBehavior)
Regular JS
objects
[Gonzalez et al. Context-traits MODULARITY’13]
16. 10
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})
FullBusBehavior = Trait({
nextBusStation: function() {
filter(this.passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
FullBus.adapt(bus, FullBusBehavior)
Independent objects
introduced “on-the-fly”
Minimum connection between
application and adaptation
18. 12
Realization concerns
FullBus.adapt( * , FullBusBehavior );
bus
<<object instance>>
Adaptations applicable
to a single object
Bus
<<class>>
Adaptations applicable
to all objects specified
by a given class
check()
<<function>>
Adaptations applicable
to a given function
Fine grained adaptation enable global or localized modification of entities’
behavior
31. 18
Interaction concerns
EDPr(ED)
Pr(¬ED)
req(ED) act(ED)
deac(ED)
req(¬ED)
FBPr(FB) Pr(¬FB)
req(FB)
act(FB)
deac(FB)
req(¬FB)
[Fandiño de la Hoz et al. Distributed Context Petri Nets. COP’19]
FullBus
Empty Depot
Node 2
Node 1
Context dependency relations define interaction between (unknown)
adaptations across nodes
context dependency relations
encoded as Petri net
interaction
32. 19
Interaction concerns
[Cardozo and Dusparic. Learning Run-time Composition of Interacting Adaptations. SEAMS’20]
FullStationBehavior = Trait({
closeStation: function() {
sendBus();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
sendBus();
}
})
DepotEmptyBehavior = Trait({
recallBus: function() {
…
}
})
Based on interaction, learn when adaptations should be composed or
execute individually to best suit the requirements from the environment
? ?
?
Learn
relationships
using RL
33. 20
Interaction concerns
[Cardozo and Dusparic. Learning Run-time Composition of Interacting Adaptations. SEAMS’20]
FullStationBehavior = Trait({
closeStation: function() {
sendBus();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
sendBus();
}
})
DepotEmptyBehavior = Trait({
recallBus: function() {
…
}
})
Based on interaction, learn when adaptations should be composed or
execute individually to best suit the requirements from the environment
compatible compose conflicting individually
conflicting individually
34. 21
Conclusion
Context-oriented programming (COP) is effective in
realizing Collective Adaptive Systems (CAS)
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
35. 21
Conclusion
Context-oriented programming (COP) is effective in
realizing Collective Adaptive Systems (CAS)
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
‣ COP posits first-class modular entities to represent contexts and behavioral
adaptations
36. 21
Conclusion
Context-oriented programming (COP) is effective in
realizing Collective Adaptive Systems (CAS)
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
‣ COP posits first-class modular entities to represent contexts and behavioral
adaptations
‣ Adaptations are introduced dynamically through software composition
37. 21
Conclusion
Context-oriented programming (COP) is effective in
realizing Collective Adaptive Systems (CAS)
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
‣ COP posits first-class modular entities to represent contexts and behavioral
adaptations
‣ Adaptations are introduced dynamically through software composition
‣ Adaptations take place reactively and promptly to changes in the environment
38. 21
Conclusion
Context-oriented programming (COP) is effective in
realizing Collective Adaptive Systems (CAS)
1. How to introduce behavior adaptations?
2. How to make adaptive behavior modular?
3. How to plug adaptations whenever they are required?
4. How to execute adaptations appropriately to the environment?
5. How to manage interaction between adaptations?
‣ COP posits first-class modular entities to represent contexts and behavioral
adaptations
‣ Adaptations are introduced dynamically through software composition
‣ Adaptations take place reactively and promptly to changes in the environment
‣ Adaptations are managed through defined dependency relations realized
dynamically, or learned from interactions
39. Nicolás Cardozo - Ivana Dusparic
@ncardoz - @ivanadusparic
n.cardozo@uniandes.edu.co - ivana.dusparic@scss.tcd.ie
Thanks for watching!
Language abstractions and Techniques for
Developing Collective Adaptive Systems Using
Context-oriented Programming
2020
August 21
st
, 2020 (online)