Overview● System Model● Model Details● A few examples
– Generic Techniques– Node Cloning– Free Teleconference
Approach● Make application adaptation points explicit
– Provide mechanism to choose, startup, teardown, and swap alternatives.
● Evaluation-based– Very little analysis– Exploit contexts or cached results to “learn” what
should be done● Reduce ad-hoc decision making
– How well can you make do with what you have?
System Model
Components● Goal – parameterized intent or
representation of a desired condition● Technique – code that implements a Goal● Planner – runtime system that matches
Goals to Techniques
Planner● Recursively bind Techniques to Goals
– AND/“OR” tree● At each OR node, choose a node for
execution.– based on the satisfaction property
● Execute the chosen nodes● Maintain the tree over time
– Re-execute relevant stages– Propagate property updates
Planner
FindAudioSource()
via MP3s
viaMP3Server
FindAudioSink()
PlayMusic(criteria=“jazz”)
AudioFader()
viaAudioFader
viaLaptop
.75
.75
.50
.50
.25
.25
.50
.50
viaSpeaker
.75
.75
.67
.67
(…other music sources…)
Model Details
Goals● parameterized
specification of a class of intents or desires– input parameters– types and names of
returned Properties● Goal names the
specification used.
<?xml version="1.0" standalone="yes" ?> <goal> <documentation> <brief_description> A <this /> connects two Oxygen users so that they may communicate. </brief_description> <long_description> A <this /> connects two Oxygen users so that they may communicate. The initiator of the conversation may set an "importance" level for the teleconference, which may be used by the receiving end to determine if the conversation should be accepted and the like. </long_description> </documentation> <parameters> <parameter> <name>person1</name> <type>http://o2s.lcs.mit.edu/specs/rtypes/Person.xml</type> <documentation> <brief_description> The initiating end of the teleconference. </brief_description> </documentation> </parameter> <parameter> <name>person2</name> <type>http://o2s.lcs.mit.edu/specs/rtypes/Person.xml</type> <documentation> <brief_description> The other end of the teleconference. </brief_description>
from http://o2s.csail.mit.edu/system.html
Goal Instances● Goal bound with parameters
SendText(“jmp”, “Meeting Time!”)
● Return value of call is a Solution– Properties mirror that of the chosen Technique.
● A Goal Instance persists until it is told to shutdown.
Techniques● parameterized template for satisfying a
particular Goal– Both declarative and imperitive code– subgoals
● Technique Instances satisfy Goal Instances– parameters bound to Goal Instance's– fill in Properties of Solutions
Technique Code● Partitioned into
Stages– write stage N+1 as
though stage N has completed
● All state is stored in Solution objects– subgoal properties– one's own properties
to PlayMusic(criteria=any): via MP3s: subgoals: source = FindMusicStream(goal.criteria) sink = FindAudioSink() fader = AudioFader() eval: solution.satisfaction = (source.satisfaction + sink.satisfaction) / 2 exec: fader.resource.connect(source.out, sink.in) update sink from old: fader.replace(old, sink.in)
Technique Stages● only exec is required● The Planner keeps
track of stage dependencies.
● evaluation stages must be idempotent– are time limited!
● evaluation stages– first– subgoals– eval– foreground
● execution stages– exec– update– shutdown
A Few Examples
PlayMusic via MP3 Technique
• Don't want a new Technique for each and every format.
to PlayMusic(criteria):
via MP3s:
subgoals:
source = FindMusicStream(criteria=goal.criteria, stream_format="MP3") sink = FindAudioSink(stream_format="MP3") fader = AudioFader(in_stream_format="MP3", out_stream_format="MP3")
...
PlayMusic via GenericStream
• Choose an AudioFader that matches the inputs and outputs.
to PlayMusic(criteria):
via GenericStream:
subgoals:
source = FindMusicStream(criteria=goal.criteria) sink = FindAudioSink()
subgoals: fader = AudioFader(in_stream_type=source.stream_format, out_stream_type=sink.stream_format)
Making the Best Choices
• Given two subgoals, the best of each may not be the best pair.
VideoSink()
via Monitor/AudioSink
via TV
AudioSink()
OutputAV()
viaMonitor
viaTV Speaker
.75
.75
.50 .25
.75
.50
viaReceiver
.75
AND/“OR” Tree?● Nodes may be
cloned– GenerateSolution
subgoal– “When necessary”
● Push decision making up the tree.
viaTV
Speaker
VideoSink()
via AV
via TV
AudioSink()
OutputAV()
viaMonitor
viaReceiver
via AV#2
via TV
OutputAV()
viaMonitor
viaTV
Speaker
viaReceiver
via AV#3 via AV#4via AV#1
Free Communication● Use parameters to
influence the choices of the Planner– pass down
information– fail if a choice is not
good enough
to FreeTeleconference(person_a, person_b): via CheckFree: subgoals: tc = Teleconference(goal.person_a, goal.person_b) eval: if tc.cost > 0: fail(“No free teleconference!") ...
to FreeTeleconference(person_a, person_b):
via RequireFree: subgoals: tc = Teleconference(goal.person_a, goal.person_b, cost=0) ...
Limits to Parameter Passing
● Passing down needs to be specified
● Passing up needs to be calculated
G1(cost=$$)
via T1
G2()
via T2
G3()
via T3
$$
$$
Questions?
Planner in o2s/plannerTechniques scattered through o2s/playground