示例#1
0
def process_instance(store, domain, instance, disable=True):
    if instance.enumerated:
        return []
    new_results, new_facts = instance.next_results(verbose=store.verbose)
    if disable:
        instance.disable(store.evaluations, domain)
    for result in new_results:
        add_certified(store.evaluations, result) # TODO: only add if the fact is actually new?
    if disable:
        remove_blocked(store.evaluations, instance, new_results)
    add_facts(store.evaluations, new_facts, result=None, complexity=0) # TODO: record the instance
    return new_results
示例#2
0
 def accelerate_best_bindings(self, **kwargs):
     # TODO: more generally reason about streams on several skeletons
     # TODO: reset the complexity values for old streams
     for skeleton in self.skeletons:
         if not skeleton.improved:
             continue
         skeleton.improved = False
         for result in skeleton.best_binding.recover_bound_results():
             # TODO: just accelerate the facts within the plan preimage
             #print(result, result.compute_complexity(self.evaluations, **kwargs))
             result.call_index = 0 # Pretends the fact was first
             #print(result.compute_complexity(self.evaluations, **kwargs))
             add_certified(self.evaluations, result, **kwargs) # TODO: should special have a complexity of INF?
示例#3
0
 def accelerate_best_bindings(self):
     # TODO: reset the values for old streams
     for skeleton in self.skeletons:
         for _, result in sorted(
                 skeleton.best_binding.bound_results.items(),
                 key=itemgetter(0)):
             # TODO: just accelerate the facts within the plan preimage
             for fact in result.get_certified():
                 evaluation = evaluation_from_fact(fact)
                 if evaluation in self.evaluations:  # In the event the fact is returned twice
                     del self.evaluations[evaluation]
             result.call_index = 0  # Pretends the fact was first
             add_certified(self.evaluations, result)
示例#4
0
def process_instance(instantiator,
                     store,
                     instance,
                     verbose=False):  #, **complexity_args):
    if instance.enumerated:
        return []
    start_time = time.time()
    new_results, new_facts = instance.next_results(verbose=verbose)
    store.sample_time += elapsed_time(start_time)

    evaluations = store.evaluations
    #remove_blocked(evaluations, instance, new_results)
    for result in new_results:
        complexity = result.compute_complexity(evaluations)
        #complexity = instantiator.compute_complexity(instance)
        for evaluation in add_certified(evaluations, result):
            instantiator.add_atom(evaluation, complexity)
    fact_complexity = 0  # TODO: record the instance or treat as initial?
    for evaluation in add_facts(evaluations,
                                new_facts,
                                result=UNKNOWN_EVALUATION,
                                complexity=fact_complexity):
        instantiator.add_atom(evaluation, fact_complexity)
    if not instance.enumerated:
        instantiator.push_instance(instance)
    return new_results
示例#5
0
def process_instance(store, domain, instance):
    success = False
    if instance.enumerated:
        return success
    new_results, new_facts = instance.next_results(accelerate=1, verbose=store.verbose)
    instance.disable(store.evaluations, domain)
    for result in new_results:
        success |= bool(add_certified(store.evaluations, result))
    remove_blocked(store.evaluations, instance, new_results)
    success |= bool(add_facts(store.evaluations, new_facts, result=None, complexity=0)) # TODO: record the instance
    return success
示例#6
0
def process_instance(instantiator, evaluations, instance, verbose=False): #, **complexity_args):
    if instance.enumerated:
        return False
    new_results, new_facts = instance.next_results(verbose=verbose)
    #remove_blocked(evaluations, instance, new_results)
    for result in new_results:
        complexity = result.compute_complexity(evaluations)
        #complexity = instantiator.compute_complexity(instance)
        for evaluation in add_certified(evaluations, result):
            instantiator.add_atom(evaluation, complexity)
    fact_complexity = 0 # TODO: record the instance or treat as initial?
    for evaluation in add_facts(evaluations, new_facts, result=None, complexity=fact_complexity):
        instantiator.add_atom(evaluation, fact_complexity)
    if not instance.enumerated:
        instantiator.push_instance(instance)
    return True