Exemplo n.º 1
0
def rmpyl_icaps14():
    """
    Example from (Santana & Williams, ICAPS14).
    """
    prog = RMPyL()
    prog *= prog.decide(
                {'name':'transport-choice','domain':['Bike','Car','Stay'],
                 'utility':[100,70,0]},
                 prog.observe(
                    {'name':'slip','domain':[True,False],
                     'ctype':'probabilistic','probability':[0.051,1.0-0.051]},
                     prog.sequence(Episode(action='(ride-bike)',
                                           duration={'ctype':'controllable','lb':15,'ub':25}),
                                   Episode(action='(change)',
                                           duration={'ctype':'controllable','lb':20,'ub':30})),
                      Episode(action='(ride-bike)',duration={'ctype':'controllable','lb':15,'ub':25})),
                 prog.observe(
                    {'name':'accident','domain':[True,False],
                     'ctype':'probabilistic','probability':[0.013,1.0-0.013]},
                     prog.sequence(Episode(action='(tow-vehicle)',
                                          duration={'ctype':'controllable','lb':30,'ub':90}),
                                  Episode(action='(cab-ride)',
                                          duration={'ctype':'controllable','lb':10,'ub':20})),
                     Episode(action='(drive)',duration={'ctype':'controllable','lb':10,'ub':20})),
                 Episode(action='(stay)'))

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=30.0)
    return prog
Exemplo n.º 2
0
def rmpyl_low_risk():
    prog = RMPyL()
    prog *= Episode(action='(cab-ride)',duration={'ctype':'uncontrollable_probabilistic',
                                                  'distribution':{'type':'uniform',
                                                                  'lb':5.0,'ub':10.0}})
    prog.add_overall_temporal_constraint(ctype='controllable',lb=5.0,ub=9.9)
    return prog
Exemplo n.º 3
0
def rmpyl_observation_risk():
    prog = RMPyL()
    prog *= prog.observe(
        {
            'name': 'travel',
            'ctype': 'probabilistic',
            'domain': ['Short', 'Long'],
            'probability': [0.7, 0.3]
        },
        Episode(action='(cab-ride-long)',
                duration={
                    'ctype': 'uncontrollable_probabilistic',
                    'distribution': {
                        'type': 'uniform',
                        'lb': 5.0,
                        'ub': 11.0
                    }
                }),
        Episode(action='(cab-ride-short)',
                duration={
                    'ctype': 'uncontrollable_probabilistic',
                    'distribution': {
                        'type': 'uniform',
                        'lb': 5.0,
                        'ub': 10.0
                    }
                }))
    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=10.0)
    return prog
def nominal_case(blocks, time_window=-1, dur_dict=None):
    """
    Nominal case, where the robot observes what the human has already completed,
    and acts accordingly
    """
    agent = 'Baxter'
    manip = 'BaxterRight'

    prog = RMPyL(name='run()')

    prog *= prog.sequence(
        say('Should I start?'),
        prog.observe(
            {
                'name': 'ask-human',
                'ctype': 'probabilistic',
                'domain': ['YES', 'NO'],
                'probability': [0.9, 0.1]
            }, observe_decide_act(prog, blocks, manip, agent, dur_dict),
            say('All done!')))
    if time_window > 0.0:
        prog.add_overall_temporal_constraint(ctype='controllable',
                                             lb=0.0,
                                             ub=time_window)

    return prog
Exemplo n.º 5
0
def rmpyl_infeasible():
    prog = RMPyL()
    prog *= Episode(action='(cab-ride)',
                    duration={
                        'ctype': 'controllable',
                        'lb': 10,
                        'ub': 20
                    })
    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=5.0)
    return prog
Exemplo n.º 6
0
def rmpyl_observation_risk():
    prog = RMPyL()
    prog *= prog.observe(
                {'name':'travel','ctype':'probabilistic',
                 'domain':['Short','Long'],'probability':[0.7,0.3]},
                 Episode(action='(cab-ride-long)',duration={'ctype':'uncontrollable_probabilistic',
                                                             'distribution':{'type':'uniform',
                                                                             'lb':5.0,'ub':11.0}}),
                 Episode(action='(cab-ride-short)',duration={'ctype':'uncontrollable_probabilistic',
                                                            'distribution':{'type':'uniform',
                                                                            'lb':5.0,'ub':10.0}}))
    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=10.0)
    return prog
Exemplo n.º 7
0
def rmpyl_parallel_and_choice_user_defined_tcs(hello,uav):
    """Simple RMPyL example with parallel execution of actions on different choice
    branches with user-defined constraints."""
    prog = RMPyL()

    #Choice using the previous example as a subroutine to generate partial progs
    prog *= prog.decide({'name':'Choose-branch','domain':['1','2'],'utility':[1,2]},
                        rmpyl_parallel_user_defined_tcs(hello,uav),
                        rmpyl_parallel_user_defined_tcs(hello,uav))

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=70.0)

    return prog
Exemplo n.º 8
0
def rmpyl_low_risk():
    prog = RMPyL()
    prog *= Episode(action='(cab-ride)',
                    duration={
                        'ctype': 'uncontrollable_probabilistic',
                        'distribution': {
                            'type': 'uniform',
                            'lb': 5.0,
                            'ub': 10.0
                        }
                    })
    prog.add_overall_temporal_constraint(ctype='controllable', lb=5.0, ub=9.9)
    return prog
Exemplo n.º 9
0
def rmpyl_uav():
    hello = UAV('hello')
    uav = UAV('uav')

    prog = RMPyL()
    # prog *= hello.fly()
    prog.plan = prog.sequence(
        hello.scan(), hello.fly(), uav.fly(), uav.scan(),
        prog.decide(
            {
                'name': 'UAV-choice',
                'domain': ['Hello', 'UAV'],
                'utility': [5, 7]
            }, hello.fly(), uav.fly()))

    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=18.0)
    return prog
Exemplo n.º 10
0
def rmpyl_uav():
    hello = UAV('hello')
    uav = UAV('uav')

    prog = RMPyL()
    # prog *= hello.fly()
    prog.plan = prog.sequence(
                    hello.scan(),
                    hello.fly(),
                    uav.fly(),
                    uav.scan(),
                    prog.decide({'name':'UAV-choice','domain':['Hello','UAV'],
                                 'utility':[5,7]},
                                 hello.fly(),
                                 uav.fly()))

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=18.0)
    return prog
Exemplo n.º 11
0
def rmpyl_original_verbose(hello,uav):
    """
    Implementation of the original RMPL using a more verbose syntax and adding
    a chance constraint.

    ##### Original RMPL

    class UAV {
        value on;
        value off;

        primitive method fly() [3,10];
        primitive method scan() [1,10];
    }

    class Main {
      UAV helo;
      UAV uav;

      method run () {
        [0, 18] sequence {
            parallel {
                sequence {
                    helo.scan();
                    helo.fly();
                }
                sequence {
                    uav.fly();
                    uav.scan();
                }
            }
            choose {
                with reward: 5 {helo.fly();}
                with reward: 7 {uav.fly();}
            }
        }
      }
    }
    """
    prog = RMPyL()
    prog.plan = prog.sequence(
                prog.parallel(
                    prog.sequence(
                        hello.scan(),
                        hello.fly()),
                    prog.sequence(
                        uav.fly(),
                        uav.scan())),
                prog.decide({'name':'UAV-choice','domain':['Hello','UAV'],'utility':[5,7]},
                            hello.fly(),
                            uav.fly()))
    overall_tc = prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=18.0)
    cc_time = ChanceConstraint(constraint_scope=[overall_tc],risk=0.1)
    prog.add_chance_constraint(cc_time)
    return prog
Exemplo n.º 12
0
def rmpyl_choice_risk():
    prog = RMPyL()
    prog *= prog.decide(
        {
            'name': 'transport-choice',
            'domain': ['Bike', 'Car', 'Stay'],
            'utility': [100, 70, 0]
        },
        prog.observe(
            {
                'name': 'travel',
                'ctype': 'probabilistic',
                'domain': ['Short', 'Long'],
                'probability': [0.7, 0.3]
            },
            Episode(action='(cab-ride-long)',
                    duration={
                        'ctype': 'uncontrollable_probabilistic',
                        'distribution': {
                            'type': 'uniform',
                            'lb': 5.0,
                            'ub': 11.0
                        }
                    }),
            Episode(action='(cab-ride-short)',
                    duration={
                        'ctype': 'uncontrollable_probabilistic',
                        'distribution': {
                            'type': 'uniform',
                            'lb': 5.0,
                            'ub': 10.0
                        }
                    })),
        Episode(action='(drive-car)',
                duration={
                    'ctype': 'controllable',
                    'lb': 6.0,
                    'ub': 8.0
                }), Episode(action='(stay)'))

    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=10.0)
    return prog
Exemplo n.º 13
0
def rmpyl_parallel_user_defined_tcs(hello,uav):
    """Simple RMPyL example with parallel execution of actions with user-defined
    constraints."""
    prog = RMPyL()
    hello_flight = hello.fly()
    uav_flight = uav.fly()
    uav_scan = uav.scan()
    prog *= hello_flight+(uav_scan*uav_flight)

    tc1 = TemporalConstraint(start=uav_scan.end,end=hello_flight.start,
                             ctype='controllable',lb=2.0,ub=3.0)

    tc2 = TemporalConstraint(start=hello_flight.end,end=uav_flight.start,
                             ctype='controllable',lb=3.0,ub=4.0)
    for tc in [tc1,tc2]:
        prog.add_temporal_constraint(tc)

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=50.0)

    return prog
Exemplo n.º 14
0
def rmpyl_choice_risk():
    prog = RMPyL()
    prog *= prog.decide(
                {'name':'transport-choice','domain':['Bike','Car','Stay'],
                 'utility':[100,70,0]},
                 prog.observe(
                             {'name':'travel','ctype':'probabilistic',
                              'domain':['Short','Long'],'probability':[0.7,0.3]},
                              Episode(action='(cab-ride-long)',duration={'ctype':'uncontrollable_probabilistic',
                                                                          'distribution':{'type':'uniform',
                                                                                          'lb':5.0,'ub':11.0}}),
                              Episode(action='(cab-ride-short)',duration={'ctype':'uncontrollable_probabilistic',
                                                                         'distribution':{'type':'uniform',
                                                                                         'lb':5.0,'ub':10.0}})),
                 Episode(action='(drive-car)',
                                       duration={'ctype':'controllable','lb':6.0,'ub':8.0}),
                 Episode(action='(stay)'))

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=10.0)
    return prog
Exemplo n.º 15
0
def nominal_case(blocks,time_window=-1,dur_dict=None):
    """
    Nominal case, where the robot observes what the human has already completed,
    and acts accordingly
    """
    agent='Baxter'
    manip='BaxterRight'

    prog = RMPyL(name='run()')

    prog *= prog.sequence(say('Should I start?'),
                          prog.observe({'name':'ask-human',
                                        'ctype':'probabilistic',
                                        'domain':['YES','NO'],
                                        'probability':[0.9,0.1]},
                                        observe_decide_act(prog,blocks,manip,agent,dur_dict),
                                        say('All done!')))
    if time_window>0.0:
        prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=time_window)

    return prog
Exemplo n.º 16
0
def rmpyl_breakfast():
    """
    Example from (Levine & Williams, ICAPS14).
    """
    #Actions that Alice performs
    get_mug_ep = Episode(action='(get alice mug)',
                         duration={
                             'ctype': 'controllable',
                             'lb': 0.5,
                             'ub': 1.0
                         })
    get_glass_ep = Episode(action='(get alice glass)',
                           duration={
                               'ctype': 'controllable',
                               'lb': 0.5,
                               'ub': 1.0
                           })

    make_cofee_ep = Episode(action='(make-coffee alice)',
                            duration={
                                'ctype': 'controllable',
                                'lb': 3.0,
                                'ub': 5.0
                            })
    pour_cofee_ep = Episode(action='(pour-coffee alice mug)',
                            duration={
                                'ctype': 'controllable',
                                'lb': 0.5,
                                'ub': 1.0
                            })
    pour_juice_glass = Episode(action='(pour-juice alice glass)',
                               duration={
                                   'ctype': 'controllable',
                                   'lb': 0.5,
                                   'ub': 1.0
                               })

    get_bagel_ep = Episode(action='(get alice bagel)',
                           duration={
                               'ctype': 'controllable',
                               'lb': 0.5,
                               'ub': 1.0
                           })
    get_cereal_ep = Episode(action='(get alice cereal)',
                            duration={
                                'ctype': 'controllable',
                                'lb': 0.5,
                                'ub': 1.0
                            })

    toast_bagel_ep = Episode(action='(toast alice bagel)',
                             duration={
                                 'ctype': 'controllable',
                                 'lb': 3.0,
                                 'ub': 5.0
                             })
    add_cheese_bagel_ep = Episode(action='(add-cheese alice bagel)',
                                  duration={
                                      'ctype': 'controllable',
                                      'lb': 1.0,
                                      'ub': 2.0
                                  })
    mix_cereal_ep = Episode(action='(mix-cereal alice milk)',
                            duration={
                                'ctype': 'controllable',
                                'lb': 1.0,
                                'ub': 2.0
                            })

    #Actions that the robot performs
    get_grounds_ep = Episode(action='(get grounds robot)',
                             duration={
                                 'ctype': 'controllable',
                                 'lb': 0.5,
                                 'ub': 1.0
                             })
    get_juice_ep = Episode(action='(get juice robot)',
                           duration={
                               'ctype': 'controllable',
                               'lb': 0.5,
                               'ub': 1.0
                           })
    get_milk_ep = Episode(action='(get milk robot)',
                          duration={
                              'ctype': 'controllable',
                              'lb': 0.5,
                              'ub': 1.0
                          })
    get_cheese_ep = Episode(action='(get cheese robot)',
                            duration={
                                'ctype': 'controllable',
                                'lb': 0.5,
                                'ub': 1.0
                            })

    prog = RMPyL()
    prog *= prog.sequence(
        prog.parallel(
            prog.observe(
                {
                    'name': 'observe-utensil',
                    'domain': ['Mug', 'Glass'],
                    'ctype': 'uncontrollable'
                },
                get_mug_ep,
                get_glass_ep,
                id='observe-utensil-ep'),
            prog.decide(
                {
                    'name': 'choose-beverage-ingredient',
                    'domain': ['Grounds', 'Juice'],
                    'utility': [0, 0]
                },
                get_grounds_ep,
                get_juice_ep,
                id='choose-beverage-ingredient-ep')),
        prog.observe(
            {
                'name': 'observe-alice-drink',
                'domain': ['Coffee', 'Juice'],
                'ctype': 'uncontrollable'
            },
            prog.sequence(make_cofee_ep, pour_cofee_ep),
            pour_juice_glass,
            id='observe-alice-drink-ep'),
        prog.parallel(prog.observe(
            {
                'name': 'observe-food',
                'domain': ['Bagel', 'Cereal'],
                'ctype': 'uncontrollable'
            },
            get_bagel_ep,
            get_cereal_ep,
            id='observe-food-ep'),
                      prog.decide(
                          {
                              'name': 'choose-food-ingredient',
                              'domain': ['Milk', 'Cheese'],
                              'utility': [0, 0]
                          },
                          get_milk_ep,
                          get_cheese_ep,
                          id='choose-food-ingredient-ep'),
                      id='parallel-food-ep'),
        prog.observe(
            {
                'name': 'observe-alice-food',
                'domain': ['Bagel', 'Cereal'],
                'ctype': 'uncontrollable'
            }, prog.sequence(toast_bagel_ep, add_cheese_bagel_ep),
            mix_cereal_ep),
        id='breakfast-sequence')

    extra_tcs = [
        TemporalConstraint(
            start=prog.episode_by_id('breakfast-sequence').start,
            end=prog.episode_by_id('observe-utensil-ep').start,
            ctype='controllable',
            lb=0.0,
            ub=0.0),
        TemporalConstraint(
            start=prog.episode_by_id('breakfast-sequence').start,
            end=prog.episode_by_id('choose-beverage-ingredient-ep').start,
            ctype='controllable',
            lb=0.2,
            ub=0.3),
        TemporalConstraint(start=prog.episode_by_id('parallel-food-ep').start,
                           end=prog.episode_by_id('observe-food-ep').start,
                           ctype='controllable',
                           lb=0.0,
                           ub=0.0),
        TemporalConstraint(
            start=prog.episode_by_id('parallel-food-ep').start,
            end=prog.episode_by_id('choose-food-ingredient-ep').start,
            ctype='controllable',
            lb=0.2,
            ub=0.3)
    ]

    for tc in extra_tcs:
        prog.add_temporal_constraint(tc)

    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=7.0)
    prog.simplify_temporal_constraints()

    return prog
Exemplo n.º 17
0
def rmpyl_breakfast():
    """
    Example from (Levine & Williams, ICAPS14).
    """
    #Actions that Alice performs
    get_mug_ep = Episode(action='(get alice mug)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    get_glass_ep = Episode(action='(get alice glass)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})

    make_cofee_ep = Episode(action='(make-coffee alice)',duration={'ctype':'controllable','lb':3.0,'ub':5.0})
    pour_cofee_ep = Episode(action='(pour-coffee alice mug)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    pour_juice_glass = Episode(action='(pour-juice alice glass)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})

    get_bagel_ep = Episode(action='(get alice bagel)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    get_cereal_ep = Episode(action='(get alice cereal)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})

    toast_bagel_ep = Episode(action='(toast alice bagel)',duration={'ctype':'controllable','lb':3.0,'ub':5.0})
    add_cheese_bagel_ep = Episode(action='(add-cheese alice bagel)',duration={'ctype':'controllable','lb':1.0,'ub':2.0})
    mix_cereal_ep = Episode(action='(mix-cereal alice milk)',duration={'ctype':'controllable','lb':1.0,'ub':2.0})

    #Actions that the robot performs
    get_grounds_ep = Episode(action='(get grounds robot)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    get_juice_ep = Episode(action='(get juice robot)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    get_milk_ep = Episode(action='(get milk robot)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})
    get_cheese_ep = Episode(action='(get cheese robot)',duration={'ctype':'controllable','lb':0.5,'ub':1.0})

    prog = RMPyL()
    prog *= prog.sequence(
                prog.parallel(
                    prog.observe(
                        {'name':'observe-utensil','domain':['Mug','Glass'],'ctype':'uncontrollable'},
                        get_mug_ep,
                        get_glass_ep,
                        id='observe-utensil-ep'),
                    prog.decide(
                        {'name':'choose-beverage-ingredient','domain':['Grounds','Juice'],'utility':[0,0]},
                        get_grounds_ep,
                        get_juice_ep,
                        id='choose-beverage-ingredient-ep')),
                prog.observe(
                    {'name':'observe-alice-drink','domain':['Coffee','Juice'],'ctype':'uncontrollable'},
                    prog.sequence(make_cofee_ep,pour_cofee_ep),
                    pour_juice_glass,
                    id='observe-alice-drink-ep'),
                prog.parallel(
                    prog.observe(
                        {'name':'observe-food','domain':['Bagel','Cereal'],'ctype':'uncontrollable'},
                        get_bagel_ep,
                        get_cereal_ep,
                        id='observe-food-ep'),
                    prog.decide(
                        {'name':'choose-food-ingredient','domain':['Milk','Cheese'],'utility':[0,0]},
                        get_milk_ep,
                        get_cheese_ep,
                        id='choose-food-ingredient-ep'),
                    id='parallel-food-ep'),
                prog.observe(
                    {'name':'observe-alice-food','domain':['Bagel','Cereal'],'ctype':'uncontrollable'},
                    prog.sequence(toast_bagel_ep,add_cheese_bagel_ep),
                    mix_cereal_ep),
                id='breakfast-sequence')

    extra_tcs = [TemporalConstraint(start=prog.episode_by_id('breakfast-sequence').start,
                                  end=prog.episode_by_id('observe-utensil-ep').start,
                                  ctype='controllable',lb=0.0,ub=0.0),
                 TemporalConstraint(start=prog.episode_by_id('breakfast-sequence').start,
                                    end=prog.episode_by_id('choose-beverage-ingredient-ep').start,
                                    ctype='controllable',lb=0.2,ub=0.3),
                 TemporalConstraint(start=prog.episode_by_id('parallel-food-ep').start,
                                    end=prog.episode_by_id('observe-food-ep').start,
                                    ctype='controllable',lb=0.0,ub=0.0),
                 TemporalConstraint(start=prog.episode_by_id('parallel-food-ep').start,
                                    end=prog.episode_by_id('choose-food-ingredient-ep').start,
                                    ctype='controllable',lb=0.2,ub=0.3)]

    for tc in extra_tcs:
        prog.add_temporal_constraint(tc)

    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=7.0)
    prog.simplify_temporal_constraints()

    return prog
Exemplo n.º 18
0
                                     'ctype':'uncontrollable','domain':['SUCCESS','FAIL']},
                            halt_func(),
                            try_try_again(prog,action_func,
                                          halt_func,loop_utility,stop_utility,
                                          repetitions-1))),
                    halt_func())


prog = RMPyL()
rob = Robot(name='ResilientRobot')

repetitions = int(sys.argv[1]) if len(sys.argv)==2 else 3

prog*= try_try_again(prog,rob.do_action,rob.stop,loop_utility=1,
                     stop_utility=0,repetitions=repetitions)
prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=10.0)


print('\n***** Start event\n')
print(prog.first_event)

print('\n***** Last event\n')
print(prog.last_event)

print('\n***** Primitive episodes\n')
for i,p in enumerate(prog.primitive_episodes):
    print('%d: %s\n'%(i+1,str(p)))

print('\n***** Events\n')
for i,e in enumerate(prog.events):
    print('%d: %s'%(i+1,str(e)))
Exemplo n.º 19
0
def rmpyl_infeasible():
    prog = RMPyL()
    prog *= Episode(action='(cab-ride)',duration={'ctype':'controllable','lb':10,'ub':20})
    prog.add_overall_temporal_constraint(ctype='controllable',lb=0.0,ub=5.0)
    return prog
Exemplo n.º 20
0
if len(sat_plans) > 0:
    plan = sat_plans[0]
    print('\n##### Plan found!\n')
    for t, action in enumerate(plan):
        print('%d: %s' % (t, action))

    prog = RMPyL(name='run()')
    prog.plan = prog.sequence(*[
        Episode(start=Event(name='start-of-' + op),
                end=Event(name='end-of-' + op),
                action=op,
                duration=rss_duration_func(op)) for op in plan
    ])
    prog.add_overall_temporal_constraint(ctype='controllable',
                                         lb=0.0,
                                         ub=2000.0)
    prog.to_ptpn(filename='rss_pysat_before_stnu_reform.tpn')

    paris = PARIS()
    risk_bound, sc_sched = paris.stnu_reformulation(prog,
                                                    makespan=True,
                                                    cc=0.001)
    if risk_bound != None:
        risk_bound = min(risk_bound, 1.0)
        print(
            '\nSuccessfully performed STNU reformulation with scheduling risk %f %%!'
            % (risk_bound * 100.0))
        prog.to_ptpn(filename='rss_pysat_after_stnu_reform.tpn')

        print('\nThis is the schedule:')
Exemplo n.º 21
0
def rmpyl_icaps14():
    """
    Example from (Santana & Williams, ICAPS14).
    """
    prog = RMPyL()
    prog *= prog.decide(
        {
            'name': 'transport-choice',
            'domain': ['Bike', 'Car', 'Stay'],
            'utility': [100, 70, 0]
        },
        prog.observe(
            {
                'name': 'slip',
                'domain': [True, False],
                'ctype': 'probabilistic',
                'probability': [0.051, 1.0 - 0.051]
            },
            prog.sequence(
                Episode(action='(ride-bike)',
                        duration={
                            'ctype': 'controllable',
                            'lb': 15,
                            'ub': 25
                        }),
                Episode(action='(change)',
                        duration={
                            'ctype': 'controllable',
                            'lb': 20,
                            'ub': 30
                        })),
            Episode(action='(ride-bike)',
                    duration={
                        'ctype': 'controllable',
                        'lb': 15,
                        'ub': 25
                    })),
        prog.observe(
            {
                'name': 'accident',
                'domain': [True, False],
                'ctype': 'probabilistic',
                'probability': [0.013, 1.0 - 0.013]
            },
            prog.sequence(
                Episode(action='(tow-vehicle)',
                        duration={
                            'ctype': 'controllable',
                            'lb': 30,
                            'ub': 90
                        }),
                Episode(action='(cab-ride)',
                        duration={
                            'ctype': 'controllable',
                            'lb': 10,
                            'ub': 20
                        })),
            Episode(action='(drive)',
                    duration={
                        'ctype': 'controllable',
                        'lb': 10,
                        'ub': 20
                    })), Episode(action='(stay)'))

    prog.add_overall_temporal_constraint(ctype='controllable', lb=0.0, ub=30.0)
    return prog