Beispiel #1
0
 def _process_binding(self, binding):
     is_new = False
     if binding.is_dominated():
         return False, is_new
     if binding.is_bound():
         action_plan = bind_action_plan(binding.skeleton.action_plan,
                                        binding.mapping)
         self.store.add_plan(action_plan, binding.cost)
         return False, True
     binding.attempts += 1
     instance = binding.result.instance
     if PRUNE_BINDINGS and not binding.do_evaluate():
         # TODO: causes redudant plan skeletons to be identified (along with complexity using attempts instead of calls)
         # Do I need to reenable this stream in case another skeleton needs it?
         # TODO: should I perform this when deciding to sample something new instead?
         #if instance.enumerated:
         #    return False, is_new
         return None, is_new
     #if not is_instance_ready(self.evaluations, instance):
     #    raise RuntimeError(instance)
     if binding.up_to_date():
         new_results, _ = process_instance(self.store,
                                           self.domain,
                                           instance,
                                           disable=self.disable)
         is_new = bool(new_results)
     for call_idx in range(binding.calls, instance.num_calls):
         for new_result in instance.results_history[
                 call_idx]:  # TODO: don't readd if successful already
             if new_result.is_successful():
                 new_mapping = update_bindings(binding.mapping,
                                               binding.result, new_result)
                 new_cost = update_cost(binding.cost, binding.result,
                                        new_result)
                 new_history = binding.history + [call_idx]
                 new_binding = Binding(binding.skeleton, new_cost,
                                       new_history, new_mapping,
                                       binding.index + 1)
                 binding.children.append(new_binding)
                 heappush(self.queue, new_binding.get_element())
     binding.calls = instance.num_calls
     binding.attempts = max(binding.attempts, binding.calls)
     binding.complexity = None
     readd = not instance.enumerated
     return readd, is_new
Beispiel #2
0
 def action_plan(self):
     return bind_action_plan(self.skeleton.action_plan, self.bindings)
Beispiel #3
0
 def bind_action_plan(self, mapping):
     return bind_action_plan(self.action_plan, mapping)