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

Function check_problem

pddlstream/algorithms/algorithm.py:41–66  ·  view source on GitHub ↗
(domain, streams, obj_from_constant)

Source from the content-addressed store, hash-verified

39 return obj_from_constant
40
41def check_problem(domain, streams, obj_from_constant):
42 for action in (domain.actions + domain.axioms):
43 for p, c in Counter(action.parameters).items():
44 if c != 1:
45 raise ValueError('Parameter [{}] for action [{}] is not unique'.format(p.name, action.name))
46 # TODO: check that no undeclared parameters & constants
47 #action.dump()
48
49 undeclared_predicates = set()
50 for stream in streams:
51 # TODO: domain.functions
52 facts = list(stream.domain)
53 if isinstance(stream, Stream):
54 facts.extend(stream.certified)
55 for fact in facts:
56 name = get_prefix(fact)
57 if name not in domain.predicate_dict:
58 undeclared_predicates.add(name)
59 elif len(get_args(fact)) != domain.predicate_dict[name].get_arity(): # predicate used with wrong arity: {}
60 print('Warning! predicate used with wrong arity in stream [{}]: {}'.format(stream.name, fact))
61 # for constant in stream.constants:
62 # if constant not in obj_from_constant:
63 # raise ValueError('Undefined constant in stream [{}]: {}'.format(stream.name, constant))
64 if undeclared_predicates:
65 print('Warning! Undeclared predicates: {}'.format(
66 sorted(undeclared_predicates))) # Undeclared predicate: {}
67
68def reset_globals():
69 # TODO: maintain these dictionaries in an object

Callers 1

parse_problemFunction · 0.85

Calls 3

get_prefixFunction · 0.90
get_argsFunction · 0.90
addMethod · 0.80

Tested by

no test coverage detected