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

Class Function

pddlstream/language/function.py:122–164  ·  view source on GitHub ↗

An external nonnegative function F(i1, ..., ik) -> 0 <= int External functions differ from streams in that their output isn't an object

Source from the content-addressed store, hash-verified

120 return '{}=?{}'.format(str_from_head(self.head), self.external.codomain.__name__)
121
122class Function(External):
123 """
124 An external nonnegative function F(i1, ..., ik) -> 0 <= int
125 External functions differ from streams in that their output isn&#x27;t an object
126 """
127 codomain = float # int | float
128 _Instance = FunctionInstance
129 #_default_p_success = 0.99 # 0.99 | 1 # Might be pruned using cost threshold
130 def __init__(self, head, fn, domain, info):
131 # TODO: function values that act as preconditions (cost must be below threshold)
132 if info is None:
133 # TODO: move the defaults to FunctionInfo in the event that an optimistic fn is specified
134 info = FunctionInfo() #p_success=self._default_p_success)
135 super(Function, self).__init__(get_prefix(head), info, get_args(head), domain)
136 self.head = head
137 opt_fn = lambda *args: self.codomain()
138 self.fn = opt_fn if (fn in DEBUG_MODES) else fn
139 #arg_spec = get_arg_spec(self.fn)
140 #if len(self.inputs) != len(arg_spec.args):
141 # raise TypeError('Function [{}] expects inputs {} but its procedure has inputs {}'.format(
142 # self.name, list(self.inputs), arg_spec.args))
143 self.opt_fn = opt_fn if (self.info.opt_fn is None) else self.info.opt_fn
144 self.num_opt_fns = 0 # TODO: support multiple opt_fns
145 @property
146 def function(self):
147 return get_prefix(self.head)
148 @property
149 def has_outputs(self):
150 return False
151 @property
152 def is_fluent(self):
153 return False
154 @property
155 def is_negated(self):
156 return False
157 @property
158 def is_function(self):
159 return True
160 @property
161 def is_cost(self):
162 return True
163 def __repr__(self):
164 return '{}=?{}'.format(str_from_head(self.head), self.codomain.__name__)
165
166##################################################
167

Callers 1

parse_functionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected