示例#1
0
    ffm = feasible_found_re.search(line)
    ilm = inc_lambda_re.search(line)

    if ism:
        sol = eval(ism.group(1))
        infeasible_routes[:] = sol2routes(sol)
        labels[:] = ["l1_C=%s, l1_L=%s" % (ism.group(3), ism.group(4))]
        changed = True

    if mdm:
        sol = eval(mdm.group(1))
        infeasible_routes[:] = sol2routes(sol)
        changed = True

    if ffm:
        infeasible_routes[:] = []
        sol = eval(ffm.group(1))
        complete_routes[:] = sol2routes(sol)
        changed = True

    if ilm:
        labels[:] = ["l1_C=%s, l1_L=%s" % (ilm.group(1), ilm.group(2))]

    return changed, newK


if __name__ == "__main__":
    visualize_procedure("lr3opt",
                        selector=VISUALIZE.ALL,
                        make_anim=MAKE_ANIM,
                        process_debug_line_callback=_process_debug_line)
    if imo:
        inserted_node = int(imo.group(1))
        active_nodes[:] = [inserted_node]
        candidate_routes[route_id] = eval(imo.group(2))
        labels[-1] = imo.group(3)
        changed = True
    
    #cmo = constraint_re.search(line)    
    #elif cmo:
    #    # the candidate route was infeasible
    #    infeasible_routes[:] = [candidate_routes[-1]]
    #    candidate_routes[:] = []
    #    changed = True
    
    rco = route_complete_re.search(line) 
    if rco:
        complete_route = eval(rco.group(2))
        infeasible_routes[:] = []
        candidate_routes[:] = []
        active_nodes[:] = []
        complete_routes.append( complete_route )
        labels[-1] = rco.group(3)
        changed = True

    return changed, newK
    
if __name__=="__main__":
    algo_output, problem_name, keep_files = visualize_cli("cheapest_insertion")
    visualize_procedure(algo_output, "cheapest_insertion", problem_name, selector=VISUALIZE.ALL,
              make_anim=MAKE_ANIM, keep_files=keep_files,
              process_debug_line_callback = _process_ci_debug_line)
示例#3
0
    mo = node_re.search(line)
    if mo:
        node = int(mo.group(1))
        if not active_nodes or active_nodes[0] != node:
            # empty the list, but keep the list object and add the node as
            #  the single element
            active_nodes[:] = []
            active_nodes.append(node)
            changed = True

    tsp_match = tsp_re.search(line)
    if tsp_match:
        route = eval(tsp_match.group(2))
        complete_routes.append(route)
        changed = True

    #print "VGV:", line,
    #print "VGV:", changed, newK
    return changed, newK


if __name__ == "__main__":
    algo_output, problem_name, keep_files = visualize_cli("gapvrp")
    visualize_procedure(algo_output,
                        "gapvrp",
                        problem_name,
                        selector=VISUALIZE.ALL,
                        make_anim=MAKE_ANIM,
                        keep_files=keep_files,
                        process_debug_line_callback=_process_gap_debug_line)
示例#4
0
        
    # not improving move
    if "which forms a route" in line or\
       "would have formed a route" in line:
        route_match = route_re.search(line)
        
        if candidate_routes:
            del candidate_routes[-1]
        
        if route_match:
            route = eval(route_match.group(1))
            
        is_infeasible = "would have formed a route" in line
        
        if is_infeasible:
            infeasible_routes[:] = [route]
        else:
            candidate_routes[:] = [route]
        changed = True
        
        print("Active nodes on reject/accept", active_nodes)

    if len(candidate_routes)>1:
        candidate_routes[:] = [candidate_routes[-1]]
    
    return changed, newK

if __name__=="__main__":
    visualize_procedure("gillet_miller_sweep", selector=VISUALIZE.ALL, make_anim=MAKE_ANIM, 
              process_debug_line_callback = _process_debug_line)
示例#5
0
        newK = len(seeds)
        changed = True
    #elif tmo:
    #    prev_tsp_sol = eval(tmo.group(2))
    elif "Initialize route" in line:
        mo = node_re.search(line)
        seed_node = int(mo.group(1))
        active_nodes[:] = [seed_node]
        candidate_routes.append([0, seed_node, 0])
        changed = True
    elif "Check feasibility of inserting" in line:
        mo = node_re.search(line)
        candidate_routes[-1].insert(-1, int(mo.group(1)))
        changed = False
    elif "Sequential route bulding" in line:
        newK = 0

    #print "VGV:", line,
    #print "VGV:", changed, newK
    return changed, newK


if __name__ == "__main__":
    algo_output, problem_name, keep_files = visualize_cli("nearest_neighbor")
    visualize_procedure(algo_output,
                        "nearest_neighbor",
                        problem_name,
                        selector=VISUALIZE.ALL,
                        make_anim=MAKE_ANIM,
                        keep_files=keep_files,
                        process_debug_line_callback=_process_nn_debug_line)
示例#6
0
    if imo:
        inserted_node = int(imo.group(1))
        active_nodes[:] = [inserted_node]
        candidate_routes[route_id] = eval(imo.group(2))
        changed = True

    #cmo = constraint_re.search(line)
    #elif cmo:
    #    # the candidate route was infeasible
    #    infeasible_routes[:] = [candidate_routes[-1]]
    #    candidate_routes[:] = []
    #    changed = True

    rco = route_complete_re.search(line)
    if rco:
        complete_route = eval(rco.group(2))
        infeasible_routes[:] = []
        candidate_routes[:] = []
        active_nodes[:] = []
        #print("XXXXXXXXXXXXXX", complete_route)
        complete_routes.append(complete_route)
        changed = True

    return changed, newK


if __name__ == "__main__":
    visualize_procedure("cheapest_insertion",
                        selector=VISUALIZE.ALL,
                        make_anim=MAKE_ANIM,
                        process_debug_line_callback=_process_debug_line)
示例#7
0
            infeasible_routes[:] = [
                complete_routes[left_route_idx][:0:-1] +
                complete_routes[right_route_idx][-2::-1]
            ]
        elif complete_routes[left_route_idx][-2]==left_merge_node and\
             complete_routes[right_route_idx][1]==right_merge_node:
            infeasible_routes[:] = [
                complete_routes[left_route_idx][:-1] +
                complete_routes[right_route_idx][1:]
            ]
        elif complete_routes[left_route_idx][-2]==left_merge_node and\
             complete_routes[right_route_idx][-2]==right_merge_node:
            infeasible_routes[:] = [
                complete_routes[left_route_idx][:-1] +
                complete_routes[right_route_idx][-2::-1]
            ]
        complete_routes[left_route_idx] = []
        complete_routes[right_route_idx] = []

        #print "REMOVEME", left_route_idx, right_route_idx, infeasible_routes

        changed = True

    return changed, newK


if __name__ == "__main__":
    visualize_procedure("parallel_savings",
                        selector=VISUALIZE.ALL,
                        make_anim=MAKE_ANIM,
                        process_debug_line_callback=_process_debug_line)