Exemplo n.º 1
0
def add_successors(queue,
                   all_elements,
                   node_points,
                   ground_nodes,
                   heuristic_fn,
                   printed,
                   position,
                   conf,
                   partial_orders=[],
                   visualize=False):
    incoming_from_element = incoming_from_edges(partial_orders)
    remaining = all_elements - printed
    num_remaining = len(remaining) - 1
    #assert 0 <= num_remaining
    #bias_from_element = {}
    # TODO: print ground first
    for directed in randomize(
            compute_printable_directed(all_elements, ground_nodes, printed)):
        element = get_undirected(all_elements, directed)
        if not (incoming_from_element[element] <= printed):
            continue
        bias = heuristic_fn(printed, directed, position, conf)
        priority = (num_remaining, bias, random.random())
        visits = 0
        heapq.heappush(queue, (visits, priority, printed, directed, conf))
Exemplo n.º 2
0
def current_failure_contributors(binding):
    # Alternatively, find unsuccessful streams in cluster and add ancestors
    assert (1 <= binding.visits) or binding.is_dominated()
    failed_result = binding.skeleton.stream_plan[binding.index]
    failed_indices = compute_failed_indices(
        binding.skeleton)  # Use last index?
    partial_orders = get_partial_orders(binding.skeleton.stream_plan)
    incoming = incoming_from_edges(partial_orders)
    failed_ancestors = grow_component([failed_result], incoming)
    for index in reversed(failed_indices):
        if index == binding.index:
            continue
        result = binding.skeleton.stream_plan[index]
        ancestors = grow_component([result], incoming)
        if ancestors & failed_ancestors:
            failed_ancestors.update(ancestors)
    return [failed_ancestors]
Exemplo n.º 3
0
    def __init__(self, queue, stream_plan, action_plan, cost):
        # TODO: estimate statistics per stream_instance online and use to reorder the skeleton
        self.queue = queue
        self.index = len(self.queue.skeletons)
        self.stream_plan = stream_plan
        self.action_plan = action_plan
        self.cost = cost
        self.best_binding = None
        self.improved = False
        self.root = Binding(self, self.cost, history=[], mapping={}, index=0, parent=None, parent_result=None)
        self.affected_indices = [compute_affected_downstream(self.stream_plan, index)
                                 for index in range(len(self.stream_plan))]

        stream_orders = get_partial_orders(self.stream_plan) # init_facts=self.queue.evaluations)
        index_from_result = get_mapping(stream_plan, range(len(stream_plan)))
        index_orders = {(index_from_result[r1], index_from_result[r2]) for r1, r2 in stream_orders}

        preimage = stream_plan_preimage(stream_plan)
        self.preimage_complexities = [[queue.evaluations[evaluation_from_fact(fact)].complexity
                                       for fact in stream.get_domain() if fact in preimage] for stream in stream_plan]
        self.incoming_indices = incoming_from_edges(index_orders)
        self.outgoing_indices = outgoing_from_edges(index_orders)