| 35 | #self.order = 0 |
| 36 | |
| 37 | class FunctionResult(Result): |
| 38 | def __init__(self, instance, value, optimistic=True): |
| 39 | super(FunctionResult, self).__init__(instance, opt_index=0, call_index=0, optimistic=optimistic) |
| 40 | self.instance = instance |
| 41 | self.value = value |
| 42 | self._certified = None |
| 43 | # TODO: could add empty output_objects tuple |
| 44 | @property |
| 45 | def certified(self): |
| 46 | if self._certified is None: |
| 47 | self._certified = [Equal(self.instance.head, self.value)] |
| 48 | return self._certified |
| 49 | def get_certified(self): |
| 50 | return self.certified |
| 51 | def get_action(self): |
| 52 | return FunctionAction(self.name, self.input_objects) |
| 53 | def remap_inputs(self, bindings): |
| 54 | #if not any(o in bindings for o in self.instance.get_all_input_objects()): |
| 55 | # return self |
| 56 | input_objects = apply_mapping(self.instance.input_objects, bindings) |
| 57 | new_instance = self.external.get_instance(input_objects) |
| 58 | return self.__class__(new_instance, self.value, self.optimistic) |
| 59 | def is_successful(self): |
| 60 | return True |
| 61 | def __repr__(self): |
| 62 | #from pddlstream.algorithms.downward import get_cost_scale |
| 63 | #value = math.log(self.value) # TODO: number of digits to display |
| 64 | return '{}={:.3f}'.format(str_from_head(self.instance.head), self.value) |
| 65 | |
| 66 | class FunctionInstance(Instance): |
| 67 | _Result = FunctionResult |
nothing calls this directly
no outgoing calls
no test coverage detected