Talk presented at the 2019 Context-oriented programming workshop colocated with ECOOP in london.
This work presents an extension to Context petri nets (CoPN) to enable the communication between different nodes, each defined using a CoPN. This extension demonstrates the interaction with different context dependency relations in face of unannounced connection and disconnection of nodes.
1. Distributed Context Petri Nets
Jose Daniel Fandiño de la Hoz
Juan Sebastián Sosa
Nicolás Cardozo - @ncardoz
The 11th International Workshop on
Context-Oriented Programming and
Advanced Modularity
July 15, 2019
5. Context-oriented programming2
DCoPNsMotivation Validation Conclusion
Adaptation to the surrounding execution environment
The environment is static
Interactions between adaptations are presupposed
New contexts are not taken
into account at run time
8. Motivating example3
DCoPNsMotivation Validation Conclusion
4.5. Virtual city guide contexts 39
(a) Adaptation of the display of the
POIs list according to the context
GuidedTour
(b) Adaptation of the Guided Tour
map display according to the context
GuidedTour
(c) Adaptation of the view defining the
details of a particular POI according
to the ColoredCategories context
(d) Adaptations of the view related to
the list of POIs according to the Sim-
pleInterface context
Figure 4.8: Screenshots related to the virtual city guide application
Mobile City Guide
Context Behavior
9. Motivating example3
DCoPNsMotivation Validation Conclusion
4.5. Virtual city guide contexts 39
(a) Adaptation of the display of the
POIs list according to the context
GuidedTour
(b) Adaptation of the Guided Tour
map display according to the context
GuidedTour
(c) Adaptation of the view defining the
details of a particular POI according
to the ColoredCategories context
(d) Adaptations of the view related to
the list of POIs according to the Sim-
pleInterface context
Figure 4.8: Screenshots related to the virtual city guide application
Mobile City Guide
Context Behavior
15. Validation Conclusion
7
Definition
A context is defined by a context Petri net (CoPN)
defined as
0.1 slide 14 1
0.1 slide 14
C = ÈPc, Pt, Te, Ti, f, f¶, fl, L, m0, Í
Pc fl Pt = „ fl : T ≠æ Zú
Te fl Ti = „ ’ t œ Te, fl(t) = 0
(Pc fi Pt) fl (Te fi Ti) = „ ’ t œ Ti, fl(t) > 0
f : (P ◊ T ◊ L) fi (T ◊ P ◊ L) ≠æ Zú
m0 : P ◊ L ≠æ Zú
f¶ : P ◊ T ≠æ {0, 1}
0.2 slide 21
¶({CQ, CN, CM}, {ÈE, CQ, CNÍ, ÈS, CM, CQÍ})
¶({CQ, CM}, {ÈS, CM, CQÍ})
union({CQ, CM})
extS({CQ, CM}, {ÈS, CM, CQÍ})
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
16. Validation Conclusion
7
temporary
place
context
place
activation
state
external
transition
clearing
transition
internal
transition
arcs
inhibitor
arcs
[Reactive Petri nets,2003]
[On the analysis of Petri nets with static priorities,1996]
[Petri net semantics of priority systems,2003]
Definition
A context is defined by a context Petri net (CoPN)
defined as
0.1 slide 14 1
0.1 slide 14
C = ÈPc, Pt, Te, Ti, f, f¶, fl, L, m0, Í
Pc fl Pt = „ fl : T ≠æ Zú
Te fl Ti = „ ’ t œ Te, fl(t) = 0
(Pc fi Pt) fl (Te fi Ti) = „ ’ t œ Ti, fl(t) > 0
f : (P ◊ T ◊ L) fi (T ◊ P ◊ L) ≠æ Zú
m0 : P ◊ L ≠æ Zú
f¶ : P ◊ T ≠æ {0, 1}
0.2 slide 21
¶({CQ, CN, CM}, {ÈE, CQ, CNÍ, ÈS, CM, CQÍ})
¶({CQ, CM}, {ÈS, CM, CQÍ})
union({CQ, CM})
extS({CQ, CM}, {ÈS, CM, CQÍ})
GTPr(GT) Pr(¬GT)
req(GT) act(GT)
deac(GT)
req(¬GT)
@context(GuidedTour)
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
17. Validation Conclusion
7
temporary
place
context
place
activation
state
external
transition
clearing
transition
internal
transition
arcs
inhibitor
arcs
[Reactive Petri nets,2003]
[On the analysis of Petri nets with static priorities,1996]
[Petri net semantics of priority systems,2003]
Definition
A context is defined by a context Petri net (CoPN)
defined as
0.1 slide 14 1
0.1 slide 14
C = ÈPc, Pt, Te, Ti, f, f¶, fl, L, m0, Í
Pc fl Pt = „ fl : T ≠æ Zú
Te fl Ti = „ ’ t œ Te, fl(t) = 0
(Pc fi Pt) fl (Te fi Ti) = „ ’ t œ Ti, fl(t) > 0
f : (P ◊ T ◊ L) fi (T ◊ P ◊ L) ≠æ Zú
m0 : P ◊ L ≠æ Zú
f¶ : P ◊ T ≠æ {0, 1}
0.2 slide 21
¶({CQ, CN, CM}, {ÈE, CQ, CNÍ, ÈS, CM, CQÍ})
¶({CQ, CM}, {ÈS, CM, CQÍ})
union({CQ, CM})
extS({CQ, CM}, {ÈS, CM, CQÍ})
GTPr(GT) Pr(¬GT)
req(GT) act(GT)
deac(GT)
req(¬GT)
@context(GuidedTour)
@activate(GuidedTour) @deactivate(GuidedTour)
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
18. Validation Conclusion
7
temporary
place
context
place
activation
state
external
transition
clearing
transition
internal
transition
arcs
inhibitor
arcs
[Reactive Petri nets,2003]
[On the analysis of Petri nets with static priorities,1996]
[Petri net semantics of priority systems,2003]
Definition
A context is defined by a context Petri net (CoPN)
defined as
0.1 slide 14 1
0.1 slide 14
C = ÈPc, Pt, Te, Ti, f, f¶, fl, L, m0, Í
Pc fl Pt = „ fl : T ≠æ Zú
Te fl Ti = „ ’ t œ Te, fl(t) = 0
(Pc fi Pt) fl (Te fi Ti) = „ ’ t œ Ti, fl(t) > 0
f : (P ◊ T ◊ L) fi (T ◊ P ◊ L) ≠æ Zú
m0 : P ◊ L ≠æ Zú
f¶ : P ◊ T ≠æ {0, 1}
0.2 slide 21
¶({CQ, CN, CM}, {ÈE, CQ, CNÍ, ÈS, CM, CQÍ})
¶({CQ, CM}, {ÈS, CM, CQÍ})
union({CQ, CM})
extS({CQ, CM}, {ÈS, CM, CQÍ})
GTPr(GT) Pr(¬GT)
req(GT) act(GT)
deac(GT)
req(¬GT)
@context(GuidedTour)
@activate(GuidedTour) @deactivate(GuidedTour)
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
19. Validation Conclusion
8
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
20. Run-time interaction and consistency9
Consistent States
No enabled internal transitions, and marked
temporary places
WC
req(WC) act(WC) Pr(¬WC)
deac(WC)
req(¬WC)
Pr(WC)
LB
req(LB)
act(LB) Pr(¬LB)
deac(LB)req(¬LB)
Pr(LB)
DCoPNsMotivation Validation Conclusion
21. Run-time interaction and consistency9
Consistent States
No enabled internal transitions, and marked
temporary places
WC
req(WC) act(WC) Pr(¬WC)
deac(WC)
req(¬WC)
Pr(WC)
LB
req(LB)
act(LB) Pr(¬LB)
deac(LB)req(¬LB)
Pr(LB)
DCoPNsMotivation Validation Conclusion
22. Run-time interaction and consistency9
Consistent States
No enabled internal transitions, and marked
temporary places
WC
req(WC) act(WC) Pr(¬WC)
deac(WC)
req(¬WC)
Pr(WC)
LB
req(LB)
act(LB) Pr(¬LB)
deac(LB)req(¬LB)
Pr(LB)
DCoPNsMotivation Validation Conclusion
23. Run-time interaction and consistency9
Consistent States
No enabled internal transitions, and marked
temporary places
WC
req(WC) act(WC) Pr(¬WC)
deac(WC)
req(¬WC)
Pr(WC)
LB
req(LB)
act(LB) Pr(¬LB)
deac(LB)req(¬LB)
Pr(LB)
DCoPNsMotivation Validation Conclusion
24. Run-time interaction and consistency9
Consistent States
No enabled internal transitions, and marked
temporary places
WC
req(WC) act(WC) Pr(¬WC)
deac(WC)
req(¬WC)
Pr(WC)
LB
req(LB)
act(LB) Pr(¬LB)
deac(LB)req(¬LB)
Pr(LB)
DCoPNsMotivation Validation Conclusion
25. Validation Conclusion
10
Run-time interaction and consistency
1. External transitions fire after @activate and @deactivate
[Context Petri Nets: Consistent of Context-dependent Behavior. PNSE’12]
2. Enabled internal transitions are always fired
3.If there is an inconsistency, actions are reverted to previous consistent state
4. Consistent states are accepted
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
DCoPNsMotivation
26. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
27. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
28. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
29. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
30. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
31. Validation Conclusion
11
Context dependency relations
Five types of context dependency relations: Exclusion ( ), Causality
(⇽), Implication (➝), Requirement ( ), suggestion ( )
deac(GT)
IPOreq(IPO) act(IPO) Pr(¬IPO)
deac(IPO)
req(¬IPO)
Pr(IPO)
GT
req(GT)
act(GT) Pr(¬GT)
deac(GT)req(¬GT)
Pr(GT)
[addRequirementTo: GuidedTour of: ItineraryPoiOrder]
[Modeling and analyzing self-adaptive systems with context Petri nets.TASE’13]
DCoPNsMotivation
Context Petri nets
[Context Petri nets enabling consistent composition of context-dependent behavior. PNSE’12]
33. Validation Conclusion
12
Distributed context Petri nets
Definition
A context is defined by a distributed context Petri net
(DCoPN) defined as tuple ⟨PN, UT, F, F0⟩
• PN: set of CoPNs
• UT: set of universal transitions (transitions
belonging to any context)
• F: set of remote arcs
• F0: set of remote inhibitor arcs } Arcs crossing
nodes’ boundaries
DCoPNsMotivation
36. GPSPr(GPS) Pr(¬GPS)
req(GPS) act(GPS)
deac(GPS)
req(¬GPS)
AGPr(AG) Pr(¬AG)
req(AG) act(AG)
deac(AG)
req(¬AG)
MuseumNode
deac(GPS)
deac(AG)
Validation Conclusion
14
Distributed context Petri nets
UserNode
DCoPNsMotivation
1. Each node is
consistent
3. Keep consistency
between connected nodes
2. Globally execute all
connected nodes
37. Validation Conclusion
15
Local consistency
GPSPr(GPS) Pr(¬GPS)
req(GPS) act(GPS)
deac(GPS)
req(¬GPS)
Each node only contains a CoPN; in isolation, this is
consistent following the semantics of CoPNs
DCoPNsMotivation
38. Validation Conclusion
15
Local consistency
GPSPr(GPS) Pr(¬GPS)
req(GPS) act(GPS)
deac(GPS)
req(¬GPS)
Each node only contains a CoPN; in isolation, this is
consistent following the semantics of CoPNs
DCoPNsMotivation
42. Validation Conclusion
17
Global execution
DCoPNsMotivation
GPSPr(GPS) Pr(¬GPS)
req(GPS) act(GPS)
deac(GPS)
req(¬GPS)
UserNode
AGPr(AG) Pr(¬AG)
req(AG) act(AG)
deac(AG)
req(¬AG)
MuseumNode
deac(GPS)
deac(AG)
[Ongaro et al, In Search of an Understandable Consensus Algorithm. USENIX’14]
@deactivate(AG)
43. Validation Conclusion
17
Global execution
DCoPNsMotivation
GPSPr(GPS) Pr(¬GPS)
req(GPS) act(GPS)
deac(GPS)
req(¬GPS)
UserNode
AGPr(AG) Pr(¬AG)
req(AG) act(AG)
deac(AG)
req(¬AG)
MuseumNode
deac(GPS)
deac(AG)
[Ongaro et al, In Search of an Understandable Consensus Algorithm. USENIX’14]
@deactivate(AG)
transitions outside of nodes need
to managed by an oracle
57. Validation Conclusion
21
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Unstable states consist of marked temporary
places, where no reactive transition is enabled
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
58. Validation Conclusion
21
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Unstable states consist of marked temporary
places, where no reactive transition is enabled
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
59. Validation Conclusion
21
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Unstable states consist of marked temporary
places, where no reactive transition is enabled
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
60. Validation Conclusion
22
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Conflicting states consist of context places
markings that violate the definition of its context
dependency relations
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
61. Validation Conclusion
22
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Conflicting states consist of context places
markings that violate the definition of its context
dependency relations
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
62. Validation Conclusion
22
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Conflicting states consist of context places
markings that violate the definition of its context
dependency relations
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
63. Validation Conclusion
22
Global consistency
Two types of inconsistencies can appear in DCoPNs
DCoPNsMotivation
• Conflicting states consist of context places
markings that violate the definition of its context
dependency relations
WCPr(WC) Pr(¬WC)
req(WC)
act(WC)
deac(WC)
req(¬WC)
LBPr(LB) Pr(¬LB)
req(LB) act(LB)
deac(LB)
req(¬LB)
79. Validation Conclusion
Conflict resolution25
DCoPNsMotivation
Context dependency
relation
Situation Inconsistency Resolution
A B
activate(A),req(B), conn(A,B)
activate(A),activate(B),conn(A,B)
Unstable state
Conflict state
revert(A),revert(B)
revert(B)
A B - None
A B activate(A),conn(A,B) Conflict state revert(A)
B A activate(B),conn(A,B) Conflict state revert(B)
A B - None
81. Conclusion26
@ncardoz
Adaptation to the surrounding execution environment
The environment dynamically changes
Interactions between adaptations are presupposed
DCoPNsMotivation Validation Conclusion
82. Conclusion26
@ncardoz
Adaptation to the surrounding execution environment
The environment dynamically changes
Interactions between adaptations are presupposed
➡ Emergence of context dependency relations
DCoPNsMotivation Validation Conclusion
83. Conclusion26
Questions?
@ncardoz
Adaptation to the surrounding execution environment
The environment dynamically changes
Interactions between adaptations are presupposed
➡ Emergence of context dependency relations
DCoPNsMotivation Validation Conclusion