Lub A language for Dynamic Context Oriented Programming Steven Costiou Mickaël Kerboeuf, Glenn Cavarlé, Alain Plantec UMR CNRS 6285, Lab-STICC/MOCS Université de Bretagne Occidentale
LubA language for Dynamic Context
Oriented Programming
Steven CostiouMickaël Kerboeuf, Glenn Cavarlé, Alain Plantec
UMR CNRS 6285, Lab-STICC/MOCSUniversité de Bretagne Occidentale
▪ The drones are flying in close formation
▪ One of the drones loses its guidance system
▪ Assumption: the fail-safe behaviour for that case has not been anticipated
▪ Possible solution: dynamically change the drone fleet’s behaviour• The faulty drone behaviour is changed to use the GPS of a mate
drone
The drone fleet example
1. Problematic: Dynamic behavior adaptation
2. Our proposition: Lub, a language for behavior adaptation through dynamic lookup instrumentation
3. Evaluation with Pharo: The drone example experiment
● Autonomous systems need for dynamic behaviour adaptation in case of unexpected Events
● The system must not be lost
● The mission must not be cancelled
Dynamic behavior adaptation
● The runtime system must be able to dynamically updates its behavior
● One must be able to communicate with the system and safely push the new behavior
Dynamic behavior adaptation
Existing approaches for dynamic behavior update ?
● Adaptation through architectural reconfiguration
Navigation ComponentComponent AGPS
Component BOther
positioning system
pinPoint()
pinPoint()
Component based solutions
● Many COP languages▪ ContextL (Costanza and Hirschfeld 2005), ContextJ (Appeltauer et al.
2011), EventCj (Kamina et al. 2011), etc.▪ Combination “per-instance” + “no-scope-limitation” hard to find
:navigation
pinPoint()
pinPoint()
pinPoint()with LayerB { pinPoint() }
:positionTracker
LayerA
LayerB
LayerCPositionTracker
instance of
Navigation
instance of
Context Oriented Programming (COP)
● Lookup delegated to a third party object● Modifies the lookup semantics
:navigation:positionTracker
pinPoint()
Specify
Add
pinPoint()
Navigation
PositionTracker
instance of
instance of
Talents (Ressia 2014)
:talent
Comparisons of these approaches
1. Problematic: Dynamic behavior adaptation
2. Our proposition: Lub, a language for behavior adaptation through dynamic lookup instrumentation
3. Evaluation with Pharo: The drone example experiment
Comparisons of these approaches
● Proposition: Changeable lookup base
● Lookup base▪ The class where the lookup starts from
:a
A
MESSAGE SEND
A1
A2A2’
LOOKUP
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
Lookup base
● Implements changeable lookup base
● OO language, Class/Instance based
● Instance based adaptation at runtime
● Preserved self reference: structural links and states are unchanged
● Two dedicated operators▪ to change the lookup base▪ to select methods impacted by the lookup base
change
The Lub language
The Lub metamodel
Lub adaptation example
Definition of a LookupBase (LUB): references a class where to perform the lookup.
Lub adaptation example
Definition of a LookupBase (LUB): references a class where to perform the lookup.
Instance of the LookupBase, set as the current one of the object to adapt.
Lub adaptation example
:a
A
MESSAGE SEND
A1
A2A2’
LOOKUP
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
Lookup mechanics extension
● Lookup base
:a
:lookupBase
A
MESSAGE SEND
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
Lookup mechanics extension
● Lookup base● Lookup extension
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“Computes the drone’s position using the GPS of a mate drone”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {class := PeerPositionTracker.
}
A Lub specification
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“Computes the drone’s position using the GPS of a mate drone”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {class := PeerPositionTracker.
}
Definition of an adaptation: dynamic adding of the PeerPositionTracker class
A Lub specification
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“Computes the drone’s position using the GPS of a mate drone”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {class := PeerPositionTracker.
}
Definition of an adaptation: dynamic adding of the PeerPositionTracker class
Definition of a Lookup Base: references the PeerPositionTracker class
A Lub specification
tracker := (simulation agentNamed: ‘dr2’) positionTracker.tracker lookupBase: PeerTrackerLookupBase
Change of dr2’s LookupBase
A Lub specification
1. Problematic: Dynamic behavior adaptation
2. Our proposition: Lub, a language for behavior adaptation through dynamic lookup instrumentation
3. Evaluation with Pharo: The drone example experiment
dr2
dr1
target
GPS LOSS
BEHAVIOR ADAPTATION
Drone fleet example simulation
t2
t1
t3
t4
t = 2Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (90@39)Accessing Tracker 2 [dr2 : GPSMobileDrone] No pinpoint device available.Tracker 2 updating lookup base with : PeerTrackerLookupBase
t = 3Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (89@40)Accessing Adapted tracker (dr2 requesting dr1 position: Accessing Tracker 1 )[dr2 : GPSMobileDrone] this is dr2 at (175@81)
t = 4Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (88@41)Accessing Adapted tracker (dr2 requesting dr1 position: Accessing Tracker 1 )[dr2 : GPSMobileDrone] this is dr2 at (174@84)
Simulation log after adaptation
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“computations”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {
class := PeerPositionTracker.} :a
:lookupBase
A
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
Operator selection
:a
:lookupBase
A
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
pinPoint:
Operator selection
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“computations”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {
class := PeerPositionTracker.with { pinPoint: }
}
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“computations”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {
class := PeerPositionTracker.with { pinPoint: }
}:a
:lookupBase
A
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
printTrackerpinPoint:
Operator selection
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“computations”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {
class := PeerPositionTracker.with { pinPoint: }
}:a
:lookupBase
A
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
printTrackerpinPoint:
Operator selection
class PeerPositionTracker {
attributes { }operations {
pinPoint: drone“computations”
printTracker^’Adapted Tracker’
}}
LookupBase PeerTrackerLookupBase {
class := PeerPositionTracker.with { pinPoint: }
}:a
:lookupBase
A
A1
A2A2’
B
B1
B2B2’
LOOKUP
LOOKUP
START LOOKUP
LOOKUP FAILURE
START LOOKUP
LOOKUP FAILUREdoesNotUnderstand:
printTrackerpinPoint:
Operator selection
t = 2Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (90@39)Accessing Tracker 2 [dr2 : GPSMobileDrone] No pinpoint device available.Tracker 2 updating lookup base with : PeerTrackerLookupBase
t = 3Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (89@40)Accessing Tracker 2 (dr2 requesting dr1 position: Accessing Tracker 1 )[dr2 : GPSMobileDrone] this is dr2 at (175@81)
t = 4Accessing Tracker 1 [dr1 : GPSMobileDrone] this is dr1 at (88@41)Accessing Tracker 2 (dr2 requesting dr1 position: Accessing Tracker 1 )[dr2 : GPSMobileDrone] this is dr2 at (174@84)
Simulation log after pinPoint: adaptation
● Vérification/validation
● Validation on a physical device▪ Reproducing the GPS drone example adaptation
● Investigate the communication problem▪ How to communicate and to push new behaviors ?▪ Nickolaos Papoulias thesis (2013): “remote
debugging and reflection in resource constrained devices”
Perspectives
LubA language for Dynamic Context
Oriented Programming
Steven CostiouMickaël Kerboeuf, Glenn Cavarlé, Alain Plantec
UMR CNRS 6285, Lab-STICC/MOCSUniversité de Bretagne Occidentale
Lub runtime model