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

Function parse_constants

pddlstream/algorithms/algorithm.py:21–39  ·  view source on GitHub ↗
(domain, constant_map)

Source from the content-addressed store, hash-verified

19# TODO: rename file to parsing
20
21def parse_constants(domain, constant_map):
22 obj_from_constant = {}
23 for constant in domain.constants:
24 if constant.name.startswith(Object._prefix): # TODO: check other prefixes
25 raise NotImplementedError('Constants are not currently allowed to begin with {}'.format(Object._prefix))
26 if constant.name not in constant_map:
27 raise ValueError('Undefined constant {}'.format(constant.name))
28 value = constant_map.get(constant.name, constant.name)
29 obj_from_constant[constant.name] = Object(value, name=constant.name) # TODO: remap names
30 # TODO: add object predicate
31
32 for name in constant_map:
33 for constant in domain.constants:
34 if constant.name == name:
35 break
36 else:
37 raise ValueError('Constant map value {} not mentioned in domain :constants'.format(name))
38 del domain.constants[:] # So not set twice
39 return obj_from_constant
40
41def check_problem(domain, streams, obj_from_constant):
42 for action in (domain.actions + domain.axioms):

Callers 1

parse_problemFunction · 0.85

Calls 1

ObjectClass · 0.90

Tested by

no test coverage detected