Exemple #1
0
        if len(match) == 1:
            nodes_by_degree = su.get_nodes_by_degree()

            cdn_nodes = offline.core.sla.weighted_shuffle(nodes_by_degree.keys(), nodes_by_degree.values(), rs)[
                        :rs.randint(int(match[0][0]), int(match[0][1]) + 1)]
            logging.debug("random cdn nodes: %s" % " ".join(cdn_nodes))

    if start_nodes is None:
        start_nodes = args.start

    if cdn_nodes is None:
        cdn_nodes = args.cdn

    sla = create_sla(start_nodes, cdn_nodes, args.sourcebw, su=su, rs=rs)
    service, count_embedding = optimize_sla(sla, vhg_count=args.vhg,
                                            vcdn_count=args.vcdn,
                                            automatic=args.auto, use_heuristic=not args.disable_heuristic)

    if os.path.exists("winner"):
        shutil.rmtree("winner")
    shutil.copytree(os.path.join(RESULTS_FOLDER, str(service.id)), "winner")

    if service.mapping is not None:

        if args.json:
            output = {}
            output["price"] = {'total_price': service.mapping.objective_function, "vhg_count": service.vhg_count,
                               "vcdn_count": service.vcdn_count}
            output["mapping"] = service.mapping.to_json()
            if args.b64:
                sys.stdout.write(base64.b64encode(json.dumps(output)))
Exemple #2
0
                list(nodes_by_degree.keys()),
                [30 - i for i in list(nodes_by_degree.values())],
                rs)[:rs.randint(int(match[0][0]),
                                int(match[0][1]) + 1)]
            logging.debug("random cdn nodes: %s" % " ".join(cdn_nodes))

    if start_nodes is None:
        start_nodes = args.start

    if cdn_nodes is None:
        cdn_nodes = args.cdn

    sla = create_sla(start_nodes, cdn_nodes, args.sourcebw, su=su, rs=rs)
    service, count_embedding = optimize_sla(
        sla,
        vhg_count=args.vhg,
        vcdn_count=args.vcdn,
        automatic=args.auto,
        use_heuristic=not args.disable_heuristic)

    if os.path.exists("winner"):
        shutil.rmtree("winner")
    shutil.copytree(os.path.join(RESULTS_FOLDER, str(service.id)), "winner")

    if service.mapping is not None:

        if args.json:
            output = {}
            output["price"] = {
                'total_price': service.mapping.objective_function,
                "vhg_count": service.vhg_count,
                "vcdn_count": service.vcdn_count
Exemple #3
0
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:
        logging.debug("heuristic")
        service_yes_heuristic, count_embedding_yes_heuristic = optimize_sla(sla, automatic=True, use_heuristic=True)
        service_yes_heuristic_mapping_objective_function = service_yes_heuristic.mapping.objective_function

    except ValueError as e:
        service_yes_heuristic_mapping_objective_function = float("nan")

    try:
        logging.debug("dummy random")
        service_yes_heuristic11, count_embedding_yes_heuristic11 = optimize_sla(sla, automatic=True,
Exemple #4
0
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:
        logging.debug("heuristic")
        service_yes_heuristic, count_embedding_yes_heuristic = optimize_sla(
            sla, automatic=True, use_heuristic=True)
        service_yes_heuristic_mapping_objective_function = service_yes_heuristic.mapping.objective_function

    except ValueError as e:
        service_yes_heuristic_mapping_objective_function = float("nan")

    try:
        logging.debug("dummy random")