def perform_experiment_phase_II(infrastructure_file,
                                workload_file,
                                year,
                                phase_I_solution,
                                output_file,
                                frac_gap=None,
                                max_seconds=10*60):

    solution_I = lloovia.SolutionI.load(phase_I_solution)
    if solution_I.solving_stats.status == "aborted":
        # There is no solution of Phase I, so Phase II cannot
        # be performed
        print("Case '%s' has no solution for Phase I. Skipping" %
              (phase_I_solution))
        # Save empty dataframe as solution
        pd.DataFrame().to_pickle(output_file)
        return

    problem = lloovia.Problem(load_infrastructure(infrastructure_file),
                              load_workload(workload_file, year))
    solver = pulp.COIN(threads=2, fracGap=frac_gap,
                       maxSeconds=max_seconds, msg=1)
    phaseII = lloovia.PhaseII(problem, solution_I, solver=solver)

    phaseII.solve_period()
    phaseII.solution.save(output_file)
def perform_experiment_multiregion_phase_II(
                            azure_infrastructure_file,
                            amazon_infrastructure_file,
                            workload_file,
                            year,
                            providers_to_use,
                            phase_I_solution,
                            output_file,
                            frac_gap=None,
                            max_seconds=10*60):

    infrastructure = get_infrastructure_for_providers(
                            providers_to_use,
                            azure_infrastructure_file,
                            amazon_infrastructure_file
                            )
    solution_I = lloovia.SolutionI.load(phase_I_solution)
    if solution_I.solving_stats.status == "aborted":
        print("Case '%s' has no solution for Phase I. Skipping" %
              (phase_I_solution))
        # Save empty dataframe as solution
        pd.DataFrame().to_pickle(output_file)
        return
    problem = lloovia.Problem(infrastructure,
                              load_workload(workload_file, year))
    solver = pulp.COIN(threads=2, fracGap=frac_gap,
                       maxSeconds=max_seconds, msg=1)
    phaseII = lloovia.PhaseII(problem, solution_I, solver=solver)
    phaseII.solve_period()
    phaseII.solution.save(output_file)
def perform_experiment_phase_I(infrastructure_file,
                               workload_file,
                               year,
                               max_bins,
                               output_file,
                               frac_gap=0.01,
                               max_seconds=10*60):
    problem = lloovia.Problem(load_infrastructure(infrastructure_file),
                              load_workload(workload_file, year))
    phaseI = lloovia.PhaseI(problem)
    solver = pulp.COIN(threads=2, fracGap=frac_gap,
                       maxSeconds=max_seconds, msg=1)
    phaseI.solve(max_bins=max_bins, solver=solver)
    phaseI.solution.save(output_file)
Example #4
0
    def prepare_problems(self, workload_phase_i, workload_phase_ii):
        '''Creates a problem for phase I and another for phase II as fields
        of the class. They use the workload from the parameters. The instances
        are stored in self.instances.'''
        ls_us_east = lloovia.LimitingSet("US East (N. California)",
                                         max_vms=20,
                                         max_cores=0)
        ls_us_west_m4 = lloovia.LimitingSet("us_west_m4",
                                            max_vms=5,
                                            max_cores=0)

        ic1 = lloovia.InstanceClass(name="m3.large",
                                    cloud=ls_us_east,
                                    max_vms=20,
                                    reserved=True,
                                    price=2.3,
                                    performance=5)

        ic2 = lloovia.InstanceClass(name="m4.medium",
                                    cloud=ls_us_west_m4,
                                    max_vms=5,
                                    reserved=False,
                                    price=4.5,
                                    performance=6)

        ic3 = lloovia.InstanceClass(name="m4.large",
                                    cloud=ls_us_west_m4,
                                    max_vms=5,
                                    reserved=False,
                                    price=8.2,
                                    performance=7)
        self.instances = [ic1, ic2, ic3]

        self.problem_phase_i = lloovia.Problem(instances=self.instances,
                                               workload=workload_phase_i)
        self.problem_phase_ii = lloovia.Problem(instances=self.instances,
                                                workload=workload_phase_ii)
def perform_experiment_multiregion_phase_I(
                                   azure_infrastructure_file,
                                   amazon_infrastructure_file,
                                   workload_file,
                                   year,
                                   max_bins,
                                   providers_to_use,
                                   output_file,
                                   frac_gap=None,
                                   max_seconds=60*60):

    infrastructure = get_infrastructure_for_providers(
                            providers_to_use,
                            azure_infrastructure_file,
                            amazon_infrastructure_file
                            )
    problem = lloovia.Problem(infrastructure,
                              load_workload(workload_file, year))
    phaseI = lloovia.PhaseI(problem)
    solver = pulp.COIN(threads=2, fracGap=frac_gap,
                       maxSeconds=max_seconds, msg=1)
    phaseI.solve(max_bins=max_bins, solver=solver)
    phaseI.solution.save(output_file)
def perform_experiment_phase_II_od_only(infrastructure_file,
                                        workload_file,
                                        year,
                                        output_file,
                                        frac_gap=None,
                                        max_seconds=10*60):

    infrastructure = load_infrastructure(infrastructure_file)
    only_ondemand = [vm for vm in infrastructure if not vm.reserved]
    only_reserved = [vm for vm in infrastructure if vm.reserved]
    problem = lloovia.Problem(only_ondemand,
                              load_workload(workload_file, year))
    # Create a fake solution from phase I in which all reserved
    # instances are deactivated
    trivial_stats = lloovia.SolvingStatsI(
                                max_bins=None,
                                workload=lloovia.LlooviaHistogram({0: 0}),
                                frac_gap=None,
                                max_seconds=None,
                                creation_time=0.0,
                                solving_time=0.0,
                                status="optimal",
                                lower_bound=None,
                                optimal_cost=0.0
                            )
    # Solution: Zero reserved VMs of each type
    sol = dict((vm, 0) for vm in only_reserved)
    trivial_allocation = pd.DataFrame([sol])[only_reserved]
    trivial_solution = lloovia.Solution(problem, trivial_stats,
                                        allocation=trivial_allocation)
    solver = pulp.COIN(threads=2, fracGap=frac_gap,
                       maxSeconds=max_seconds, msg=1)
    phaseII = lloovia.PhaseII(problem, trivial_solution, solver=solver)

    phaseII.solve_period()
    phaseII.solution.save(output_file)