MCPcopy Create free account
hub / github.com/caelan/pddlstream / create_problem

Function create_problem

examples/temporal/run.py:48–111  ·  view source on GitHub ↗
(max_t=20., n_foods=3, n_stoves=2)

Source from the content-addressed store, hash-verified

46##################################################
47
48def create_problem(max_t=20., n_foods=3, n_stoves=2):
49 constant_map = {}
50 stream_map = {
51 # TODO: compute the sequence of times and/or length
52 'add': from_fn(lambda t1, dt: Output(t1 + dt) if (t1 + dt <= max_t) else None),
53 'ge': from_test(lambda t1, t2: t1 >= t2),
54 'Elapsed': lambda dt: dt,
55 'Difference': lambda t2, t1: t2 - t1,
56 }
57
58 foods = ['f{}'.format(i) for i in range(n_foods)]
59 stoves = ['s{}'.format(i) for i in range(n_stoves)]
60
61 t0 = 0.
62 goal_t = 5
63 #wait_dt = 0.5
64 #discretize_dt = 1./3
65 discretize_dt = None # TODO: set to None if not all times are StartTimes
66 # TODO: iteratively increase max_t and/or discretize_dt
67
68 # TODO: min_dt is the min of all the durations
69 # TODO: sample the duration for actions
70 # TODO: add epsilon after every action start
71
72 init = [
73 ('CanWait',),
74 ('Time', t0),
75 ('StartTime', t0),
76 ('AtTime', t0),
77 #('Duration', wait_dt), # T
78 ('Time', goal_t),
79 ]
80 if discretize_dt is not None:
81 for t in np.arange(t0, max_t, step=1./3):
82 t = round(t, 3)
83 init.extend([
84 ('Time', t),
85 ('StartTime', t),
86 ])
87
88 # TODO: extract all initial times as important times
89 # TODO: support timed initial literals
90
91 cook_dt = 2.
92 for food, stove in product(foods, stoves):
93 init.extend([
94 ('Food', food),
95 ('Stove', stove),
96 ('CookDuration', cook_dt, food, stove),
97 ('Duration', cook_dt),
98 ])
99
100 goal_expressions = [
101 #Exists(['?t'], And(('GE', '?t', goal_t),
102 # ('AtTime', '?t'))),
103 ]
104 for food in foods:
105 goal_expressions.append(('Cooked', food))

Callers 1

mainFunction · 0.70

Calls 5

from_fnFunction · 0.90
OutputFunction · 0.90
from_testFunction · 0.90
AndFunction · 0.90
read_pddlFunction · 0.90

Tested by

no test coverage detected