def load_exising_experiment(link_id): session = Session() # first, if data_sum is already present, try with it tenant = session.query(Tenant).filter(Tenant.name == link_id).one() su = session.query(Substrate).one() rs = RandomState(seed=5) logging.debug("Data logged from DB") return tenant, su, rs
def create_new_experiment(link_id): session = Session() logging.info("Unexpected error:", sys.exc_info()[0]) logging.debug("Failed to read data_sum from DB, reloading from file") if link_id == "dummy": print("powerlaw graph selecteds") rs, su = clean_and_create_experiment(("powerlaw", (50, 2, 0.3, 1, 500000000, 20, 200,)), seed=5) else: print("links %s graph selected" % link_id) rs, su = clean_and_create_experiment(("links", (link_id,)), 5) tenant = Tenant(name=link_id) session.add(tenant) session.add(su) session.flush() return tenant, su, rs
def create_sla(client_count, cdn_count, vcdn_count): slas = generate_random_slas(rs, su, count=1, user_count=1000000, max_start_count=client_count, max_end_count=cdn_count + vcdn_count, tenant=tenant, min_start_count=client_count - 1, min_end_count=cdn_count + vcdn_count - 1) session = Session() session.add_all(slas) session.flush() logging.debug("SLA saved") sla = slas[0] return sla
default=1) parser.add_argument('--vcdnratio', help="the share of source traffic toward vcdn (default 0.35)", default=0.35, type=float) parser.add_argument('--sourcebw', help="cumulated source bw from every source (default 100 bits) ", default=100000000, type=int) parser.add_argument('--topo', help="specify topo to use", default=('grid', ["5", "5", "100000000", "10", "200"]), type=valid_topo) parser.add_argument('--disable-heuristic', dest="disable_heuristic", action="store_true") parser.add_argument('--dest_folder', help="destination folder for restults", default=RESULTS_FOLDER) args = parser.parse_args() # create the topology rs, su = clean_and_create_experiment(args.topo, args.seed) session = Session() tenant = Tenant() session.add(tenant) slas = generate_random_slas(rs, su, count=args.sla_count, user_count=1000, max_start_count=args.max_start, max_end_count=args.max_cdn, tenant=tenant,min_start_count=args.min_start, min_end_count=args.min_cdn) for sla in slas: try: logging.debug("full") service_no_heuristic, count_embedding_no_heuristic = optimize_sla(sla, automatic=True, use_heuristic=False) service_no_heuristic_mapping_objective_function = service_no_heuristic.mapping.objective_function except ValueError as e: service_no_heuristic_mapping_objective_function = float("nan") try:
parser = argparse.ArgumentParser(description='1 iteration for solver') parser.add_argument('--svg', dest='dosvg', action='store_true') parser.add_argument('--dest', help="destination for the SVG file", default=os.path.join(RESULTS_FOLDER, "./res.svg")) parser.add_argument('--service_link_linewidth', default=5, type=int) parser.add_argument('--net', dest='net', action='store_true', help="print only the network") parser.add_argument('--view', dest='view', action='store_true') parser.add_argument("-s", '--serviceid', type=int) args = parser.parse_args() # if not args.net: # graphiz_exe="neato" # else: # graphiz_exe="dot" session = Session() service = session.query(Service).order_by(Service.id.desc()).all() if len(service)>0 : service = service[0] service_id = str(service.id) # service.slas[0].substrate.write(path=str(args.serviceid)) dosvg = args.dosvg plotsol_from_db(service_link_linewidth=args.service_link_linewidth, net=args.net, service=service) if not dosvg: file = tempfile.mkstemp(".pdf")[1] subprocess.Popen( ["neato", os.path.join(RESULTS_FOLDER, service_id, "../substrate.dot"), "-Tpdf", "-o", file]).wait() if args.view: subprocess.Popen(["evince", file]).wait() else:
parser = argparse.ArgumentParser(description='1 iteration for solver') parser.add_argument('--svg', dest='dosvg', action='store_true') parser.add_argument('--dest', help="destination for the SVG file", default=os.path.join(RESULTS_FOLDER, "./res.svg")) parser.add_argument('--service_link_linewidth', default=5, type=int) parser.add_argument('--net', dest='net', action='store_true', help="print only the network") parser.add_argument('--view', dest='view', action='store_true') parser.add_argument("-s", '--serviceid', type=int) args = parser.parse_args() # if not args.net: # graphiz_exe="neato" # else: # graphiz_exe="dot" session = Session() service = session.query(Service).order_by(Service.id.desc()).all()[0] service_id = str(service.id) # service.slas[0].substrate.write(path=str(args.serviceid)) dosvg = args.dosvg plotsol_from_db(service_link_linewidth=args.service_link_linewidth, net=args.net, service=service) if not dosvg: file = tempfile.mkstemp(".pdf")[1] subprocess.Popen( ["neato", os.path.join(RESULTS_FOLDER, service_id, "./substrate.dot"), "-Tpdf", "-o", file]).wait() if args.view: subprocess.Popen(["evince", file]).wait() else: file = args.dest subprocess.Popen(
parser.add_argument('--topo', help="specify topo to use", default=('grid', ["5", "5", "100000000", "10", "200"]), type=valid_topo) parser.add_argument('--disable-heuristic', dest="disable_heuristic", action="store_true") parser.add_argument('--dest_folder', help="destination folder for restults", default=RESULTS_FOLDER) args = parser.parse_args() # create the topology rs, su = clean_and_create_experiment(args.topo, args.seed) session = Session() tenant = Tenant() session.add(tenant) slas = generate_random_slas(rs, su, count=args.sla_count, user_count=1000, max_start_count=args.max_start, max_end_count=args.max_cdn, tenant=tenant, min_start_count=args.min_start, min_end_count=args.min_cdn) for sla in slas: try: logging.debug("full")