def global_routes(topology, bound, is_gravity): generate_sol(topology, bound, is_gravity) global_opt_cplex_output = "global_opt_cplex_output.sol" global_opt_upper_bound = xml.get_object(global_opt_cplex_output) print("Upper Bound is %f" % global_opt_upper_bound) global_opt_routes = xml.get_route(global_opt_cplex_output) #print(global_opt_routes) return global_opt_routes
def global_routes(topology): # Init remove_all_lp_or_sol_or_txt = "del *.lp *.sol *.txt >> log" remove_all_lp_or_sol = "del *.lp *.sol >> log" os.system(remove_all_lp_or_sol_or_txt) # Get the upper bound of performance ratio for specific topology # Only be run once global_opt_cplex_input = "global_opt_cplex_input.lp" global_opt_cplex_output = "global_opt_cplex_output.sol" cplex.generate_cplex_lp_file(topology, global_opt_cplex_input) global_opt_cplex_cmd = 'cplex -c "read %s" "optimize" "write %s" >> log' % \ (global_opt_cplex_input, global_opt_cplex_output) os.system(global_opt_cplex_cmd) global_opt_upper_bound = xml.get_object(global_opt_cplex_output) print("Upper Bound is %f" % global_opt_upper_bound) global_opt_routes = xml.get_route(global_opt_cplex_output) #print(global_opt_routes) return global_opt_routes
tmp = ls ls = ld ld = tmp if (ls, ld) not in link_order: print "Wrong" if path[len(path) - 1] != d: print "Wrong" if __name__ == '__main__': #topology = '../topology/final/geant-final-topology-12-base' topology_base = '../topology/final/geant-final-topology-15-base' #solutions = 'abilene-connected-cplex.xml' solutions = 'geant-connected-cplex.xml' routes = xml.get_route(solutions) remove_file_base = '../topology/remove/geant-remove-12-links-base' #remove_file = '../topology/remove/abilene-remove-4-links' demand_file = '../demand/gravity-abilene/1000.txt' f = open(remove_file_base) removes = [] line = f.readline() while line: s = line.rstrip().split(' ') s = [int(i) for i in s] ls = s[0] ld = s[1] if ld < ls: tmp = ls ls = ld
files = 100 fix_num = 100 loop = 1 remove_links_n = {'abilene': 2, 'geant': 5} for t in ['abilene', 'geant']: connected_topology = connected_topology_template % t solution = solution_template % t #solution = solution_default result_file = result_file_template % (t) #common.generate_sol(connected_topology, [0, 1.5], is_gravity) print xml.get_object(solution) global_routes = xml.get_route(solution) link_order = xml.get_link_order_with_attr(solution, connected_topology) for alpha in range(remove_links_n[t], remove_links_n[t] + 1): final_topology = final_topology_template % (t, alpha) remove_links = remove_links_template % (t, alpha) final_topology_base = final_topology_base_template % (t, alpha) remove_links_base = remove_links_base_template % (t, alpha) # Generate the global routes for traffic sets # Calculate the global maximum utilization for specific traffic matrix sets global_routes_copy = deepcopy(global_routes) link_order_copy = deepcopy(link_order) new_global_routes = adjust.adjust_route(final_topology, remove_links, global_routes_copy, link_order_copy)
if ls > ld: tmp = ls ls = ld ld = tmp if (ls, ld) not in link_order: print "Wrong" if path[len(path) - 1] != d: print "Wrong" if __name__ == '__main__': #topology = '../topology/final/geant-final-topology-12-base' topology_base = '../topology/final/geant-final-topology-15-base' #solutions = 'abilene-connected-cplex.xml' solutions = 'geant-connected-cplex.xml' routes = xml.get_route(solutions) remove_file_base = '../topology/remove/geant-remove-12-links-base' #remove_file = '../topology/remove/abilene-remove-4-links' demand_file = '../demand/gravity-abilene/1000.txt' f = open(remove_file_base) removes = [] line = f.readline() while line: s = line.rstrip().split(' ') s = [int(i) for i in s] ls = s[0] ld = s[1] if ld < ls: tmp = ls ls = ld
files = 1000 fix_num = 1 loop = 1 remove_links_n = {'abilene':5, 'geant':16} for t in ['abilene', 'geant']: connected_topology = connected_topology_template % t solution = solution_template % t #solution = solution_default result_file = result_file_template % (t) #common.generate_sol(connected_topology, [0, 1.5], is_gravity) print xml.get_object(solution) global_routes = xml.get_route(solution) link_order = xml.get_link_order_with_attr(solution, connected_topology) for alpha in range(0, remove_links_n[t]): final_topology = final_topology_template % (t, alpha) remove_links = remove_links_template % (t, alpha) final_topology_base = final_topology_base_template % (t, alpha) remove_links_base = remove_links_base_template % (t, alpha) # Generate the global routes for traffic sets # Calculate the global maximum utilization for specific traffic matrix sets global_routes_copy = deepcopy(global_routes) link_order_copy = deepcopy(link_order) new_global_routes = adjust.adjust_route(final_topology, remove_links, global_routes_copy, link_order_copy) global_routes_base_copy = deepcopy(global_routes)