def main(args): set_seed(args) dataset_train, dataset_val, dataset_test = get_datasets(args) optimizer = get_optimizer(args) obj = get_objective(args, optimizer.hparams) xp = get_xp(args, optimizer) for i in range(args.epochs): xp.Epoch.update(1).log() train(obj, optimizer, dataset_train, xp, args, i) test(obj, optimizer, dataset_val, xp, args, i) test(obj, optimizer, dataset_test, xp, args, i) print_total_time(xp)
label_delay[l] = round(links.delay[l]) # label_delay = links.delay # pos = nx.shell_layout(NG) pos = nx.spring_layout(NG, iterations=100) nx.draw_networkx_nodes(NG, pos, node_color="red") nx.draw_networkx_labels(NG, pos, font_size=12) # nx.draw_networkx_edge_labels(NG, pos, edge_labels=label_delay, label_pos = 0.4, font_size=4) nx.draw_networkx_edges(NG, pos) plt.axis("off") plt.savefig(str(scenario) + "_netgraph.pdf") # plt.show() # solve with MIP; optimizing one objective and bounding the others elif method == "pareto": # get objective and bounds from arguments obj = objective.get_objective(sys.argv[3]) # bounds have to be ordered: over-sub, changed, resources, delay (without the one that's optimized) bounds = (float(sys.argv[4]), float(sys.argv[5]), float(sys.argv[6])) # run with specified objective and bounds model = tep_extended.solve(nodes, links, templates, prev_embedding, sources, fixed, scenario, obj, bounds) writer.write_mip_result(model, scenario, nodes, links, obj, sources, bounds=bounds) # solve with heuristic elif method == "heuristic":