SlideShare a Scribd company logo
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)
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
… 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
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
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
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
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
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
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
!
!
1. Introduce adaptive behavior?
2. Make adaptive behavior modular?
9
Object to adapt
Full Station
Full Bus
!
Road blocked!
!
[Gonzalez et al. Context-traits MODULARITY’13]
9
Object to adapt
FullBus = cop.Context({
name = “Full bus”
})Full Station
Full Bus
!
Road blocked!
!
[Gonzalez et al. Context-traits MODULARITY’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]
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]
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]
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
3. Plug adaptations whenever
they are required?
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
13
Realization concerns
FullBus.adapt(Bus, FullBusBehavior)
RoadBlocked.adapt(Bus, BrokenBusBehavior)
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
Adaptations
are
composable by
definition
13
Realization concerns
FullBus.adapt(Bus, FullBusBehavior)
RoadBlocked.adapt(Bus, BrokenBusBehavior)
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
Reuse behavior
of other
available
adaptation
Adaptations
are
composable by
definition
14
Realization concerns
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
filter(this.passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
14
Realization concerns
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
filter(this.passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
FullBus.activate(); RoadBlocked.activate()
behave like FullBus, then like
RoadBlocked
14
Realization concerns
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
filter(this.passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
FullBus.activate(); RoadBlocked.activate()
RoadBlocked.activate(); FullBus.activate()
behave like FullBus, then like
RoadBlocked
behave like RoadBlocked,
then like FullBus
14
Realization concerns
BrokenBusBehavior = Trait({
nextBusStation: function() {
callTowCar();
proceed();
}
})
FullBusBehavior = Trait({
nextBusStation: function() {
filter(this.passengers, p =>
p.destination() != this.currentNode);
this.route.depot.sendBus(
this.currentNode);
}
})
cop.manager.addObjectPolicy(Bus, [BrokenBusBehavior, FullBusBehavior])
FullBus.activate(); RoadBlocked.activate()
RoadBlocked.activate(); FullBus.activate()
behave like FullBus, then like
RoadBlocked
behave like RoadBlocked,
then like FullBus
always use
BrokenBusBehavior
before
FullBusBehavior
4. Appropriateness of adaptations?
16
Temporal concerns
function checkCapacity(bus) {
if(bus.load >= 0.7)
FullBus.activate();
else
FullBus.deactivate();
}
Context
discovery
world
sensors/monitors
enacting
adaptations
execution
loop
Bus = Trait({
moveBus: function() {
nextBusStation();
},
nextBusStation() { … }
})
16
Temporal concerns
function checkCapacity(bus) {
if(bus.load >= 0.7)
FullBus.activate();
else
FullBus.deactivate();
}
Context
discovery
world
sensors/monitors
enacting
adaptations
execution
loop
Bus = Trait({
moveBus: function() {
nextBusStation();
},
nextBusStation() { … }
})
FullBusBehavior = Trait({
nextBusStation: function() {
…
}
})
16
Temporal concerns
function checkCapacity(bus) {
if(bus.load >= 0.7)
FullBus.activate();
else
FullBus.deactivate();
}
Context
discovery
world
sensors/monitors
enacting
adaptations
execution
loop
Bus = Trait({
moveBus: function() {
nextBusStation();
},
nextBusStation() { … }
})
5. Managing interaction between
adaptations?
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
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
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
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
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?
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
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
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
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
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)

More Related Content

PDF
Learning run-time composition of interacting adaptations
PDF
IOC + Javascript
PDF
Context Traits Dynamic Behaviour Adaptation Through Run-Time Trait Recomposition
PDF
[JIST] Programming language implementations for context-oriented self-adaptiv...
PDF
Multi-agent approach to resource allocation inautonomous vehicle fleet
PDF
JavaScript Abstraction
PDF
A Generic Agent Model Towards Comparing Resource Allocation Approaches to On-...
PDF
Adaptation in Distributed Collective Systems
Learning run-time composition of interacting adaptations
IOC + Javascript
Context Traits Dynamic Behaviour Adaptation Through Run-Time Trait Recomposition
[JIST] Programming language implementations for context-oriented self-adaptiv...
Multi-agent approach to resource allocation inautonomous vehicle fleet
JavaScript Abstraction
A Generic Agent Model Towards Comparing Resource Allocation Approaches to On-...
Adaptation in Distributed Collective Systems

More from Universidad de los Andes (18)

PDF
Analyzing Program Similarities and Differences Across Multiple Languages
PDF
Explorations of a self-replication algorithm to flexibly match patterns
PDF
An expressive and modular layer activation mechanism for Context-Oriented Pro...
PDF
[FTfJP23] Points-to Analysis for Context-oriented Javascript Programs
PDF
[CAIN'23] Prevalence of Code Smells in Reinforcement Learning Projects
PDF
[CIbSE2023] Cross-language clone detection for Mobile Apps
PDF
Keeping Up! with LaTeX
PDF
[JPDC,JCC@LMN22] Ad hoc systems Management and specification with distributed...
PDF
[CCC'21] Evaluation of Work Stealing Algorithms
PDF
Generating Adaptations from the System Execution using Reinforcement Learning...
PDF
Does Neuron Coverage Matter for Deep Reinforcement Learning? A preliminary study
PDF
Distributed context Petri nets
PDF
CQL: declarative language for context activation
PDF
Generating software adaptations using machine learning
PDF
[Bachelor_project] Asignación de exámenes finales
PDF
Programming language techniques for adaptive software
PDF
Peace COrP: Learning to solve conflicts between contexts
PDF
Emergent Software Services
Analyzing Program Similarities and Differences Across Multiple Languages
Explorations of a self-replication algorithm to flexibly match patterns
An expressive and modular layer activation mechanism for Context-Oriented Pro...
[FTfJP23] Points-to Analysis for Context-oriented Javascript Programs
[CAIN'23] Prevalence of Code Smells in Reinforcement Learning Projects
[CIbSE2023] Cross-language clone detection for Mobile Apps
Keeping Up! with LaTeX
[JPDC,JCC@LMN22] Ad hoc systems Management and specification with distributed...
[CCC'21] Evaluation of Work Stealing Algorithms
Generating Adaptations from the System Execution using Reinforcement Learning...
Does Neuron Coverage Matter for Deep Reinforcement Learning? A preliminary study
Distributed context Petri nets
CQL: declarative language for context activation
Generating software adaptations using machine learning
[Bachelor_project] Asignación de exámenes finales
Programming language techniques for adaptive software
Peace COrP: Learning to solve conflicts between contexts
Emergent Software Services
Ad

Recently uploaded (20)

PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
Yogi Goddess Pres Conference Studio Updates
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Computing-Curriculum for Schools in Ghana
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
GDM (1) (1).pptx small presentation for students
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Final Presentation General Medicine 03-08-2024.pptx
O7-L3 Supply Chain Operations - ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Microbial diseases, their pathogenesis and prophylaxis
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
VCE English Exam - Section C Student Revision Booklet
Orientation - ARALprogram of Deped to the Parents.pptx
Ad

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 ! !
  • 10. 1. Introduce adaptive behavior? 2. Make adaptive behavior modular?
  • 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
  • 17. 3. Plug adaptations whenever they are required?
  • 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
  • 19. 13 Realization concerns FullBus.adapt(Bus, FullBusBehavior) RoadBlocked.adapt(Bus, BrokenBusBehavior) BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) Adaptations are composable by definition
  • 20. 13 Realization concerns FullBus.adapt(Bus, FullBusBehavior) RoadBlocked.adapt(Bus, BrokenBusBehavior) BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) Reuse behavior of other available adaptation Adaptations are composable by definition
  • 21. 14 Realization concerns BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) FullBusBehavior = Trait({ nextBusStation: function() { filter(this.passengers, p => p.destination() != this.currentNode); this.route.depot.sendBus( this.currentNode); } })
  • 22. 14 Realization concerns BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) FullBusBehavior = Trait({ nextBusStation: function() { filter(this.passengers, p => p.destination() != this.currentNode); this.route.depot.sendBus( this.currentNode); } }) FullBus.activate(); RoadBlocked.activate() behave like FullBus, then like RoadBlocked
  • 23. 14 Realization concerns BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) FullBusBehavior = Trait({ nextBusStation: function() { filter(this.passengers, p => p.destination() != this.currentNode); this.route.depot.sendBus( this.currentNode); } }) FullBus.activate(); RoadBlocked.activate() RoadBlocked.activate(); FullBus.activate() behave like FullBus, then like RoadBlocked behave like RoadBlocked, then like FullBus
  • 24. 14 Realization concerns BrokenBusBehavior = Trait({ nextBusStation: function() { callTowCar(); proceed(); } }) FullBusBehavior = Trait({ nextBusStation: function() { filter(this.passengers, p => p.destination() != this.currentNode); this.route.depot.sendBus( this.currentNode); } }) cop.manager.addObjectPolicy(Bus, [BrokenBusBehavior, FullBusBehavior]) FullBus.activate(); RoadBlocked.activate() RoadBlocked.activate(); FullBus.activate() behave like FullBus, then like RoadBlocked behave like RoadBlocked, then like FullBus always use BrokenBusBehavior before FullBusBehavior
  • 25. 4. Appropriateness of adaptations?
  • 26. 16 Temporal concerns function checkCapacity(bus) { if(bus.load >= 0.7) FullBus.activate(); else FullBus.deactivate(); } Context discovery world sensors/monitors enacting adaptations execution loop Bus = Trait({ moveBus: function() { nextBusStation(); }, nextBusStation() { … } })
  • 27. 16 Temporal concerns function checkCapacity(bus) { if(bus.load >= 0.7) FullBus.activate(); else FullBus.deactivate(); } Context discovery world sensors/monitors enacting adaptations execution loop Bus = Trait({ moveBus: function() { nextBusStation(); }, nextBusStation() { … } }) FullBusBehavior = Trait({ nextBusStation: function() { … } })
  • 28. 16 Temporal concerns function checkCapacity(bus) { if(bus.load >= 0.7) FullBus.activate(); else FullBus.deactivate(); } Context discovery world sensors/monitors enacting adaptations execution loop Bus = Trait({ moveBus: function() { nextBusStation(); }, nextBusStation() { … } })
  • 29. 5. Managing interaction between adaptations?
  • 30. 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
  • 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)