Exemplo n.º 1
0
    def bench(self):
        recipes = []
        for o in self.orderList.orders:
            recipes.append(o.recipe.recipe[:])
            o.recipe.recipe = []

        machines = self.plant.machines[:]
        self.plant.machines = []
        i = self.startValue
        while i <= len(machines):
            pprint("PERF Number of machines = " + str(i), BLUE)
            self.plant.machines = machines[:i]
            for j, o in enumerate(self.orderList.orders):
                o.recipe.recipe = recipes[j][:i]
            optimizer = Optimizer(self.plant, self.orderList,
                                  Simulator(self.plant), Evaluator(self.plant))
            optimizer.populationSize = 10
            optimizer.iterations = 10
            optimizer.indivMutationRate = 0.5
            optimizer.selectionRate = 0.5
            optimizer.mutationRange = 10
            t = time()
            optimizer.run()
            t = time() - t
            t -= optimizer.simulatorTime
            self.addCairoPlotTime(t)
            self.addGnuPlotTime(i, t)
            i += 1
Exemplo n.º 2
0
def optimizerMachinesPerf(plant, orderList, testNum):
    machines = plant.machines[:]
    orders = orderList.orders[:]

    pprint(
        "PERF Starting optimizer benchmark test " + str(testNum) +
        " on machines", BLUE)
    orderList.orders = orders[:]
    recipes = []
    for o in orderList.orders:
        recipes.append(o.recipe.recipe[:])
        o.recipe.recipe = []

    plant.machines = []
    times = [0]

    for i in range(1, len(machines) + 1):
        pprint("PERF Number of machines = " + str(i), BLUE)
        plant.machines = machines[:i]
        for j, o in enumerate(orderList.orders):
            o.recipe.recipe = recipes[j][:i]
        optimizer = Optimizer(plant, orderList, Simulator(plant),
                              Evaluator(plant))
        optimizer.populationSize = 10
        optimizer.iterations = 10
        optimizer.indivMutationRate = 0.5
        optimizer.selectionRate = 0.5
        optimizer.mutationRange = 10
        t = time()
        optimizer.run()
        t = time() - t
        t -= optimizer.simulatorTime
        times.append(t)
        pprint("PERF Time = " + str(t), GREEN)

    try:
        from thirdparty.CairoPlot import dot_line_plot
    except:
        pprint("PERF Will not output to graph.", RED)
        return

    dot_line_plot(
        path.join("benchmarks", "optimizer-machines-" + str(testNum)) + FORMAT,
        times, 800, 800, (255, 255, 255), 5, True, True, True, None, None,
        None, None)
Exemplo n.º 3
0
 def bench(self):
     i = 10
     while i <= 200:
         pprint("PERF Mutation Range = " + str(i), BLUE)
         optimizer = Optimizer(self.plant, self.orderList,
                               Simulator(self.plant), Evaluator(self.plant))
         optimizer.populationSize = 10
         optimizer.iterations = 10
         optimizer.indivMutationRate = 0.5
         optimizer.selectionRate = 0.5
         optimizer.mutationRange = i
         t = time()
         optimizer.run()
         t = time() - t
         t -= optimizer.simulatorTime
         self.addCairoPlotTime(t)
         self.addGnuPlotTime(i, t)
         i += 20
Exemplo n.º 4
0
def optimizerLargeValuesPerf(plant, orderList, testNum):
    machines = plant.machines[:]
    orders = orderList.orders[:]

    pprint(
        "PERF Starting optimizer benchmark test " + str(testNum) +
        " with large values", BLUE)
    orderList.orders = orders[:6]
    plant.machines = machines[:]
    times = [0]

    val = 2

    for i in range(1, 6):
        pprint("PERF Large Value = " + str(i * val), BLUE)
        for o in orderList.orders:
            o.deadline *= val
            for r in o.recipe.recipe:
                r[1] *= val
        optimizer = Optimizer(plant, orderList, Simulator(plant),
                              Evaluator(plant))
        optimizer.populationSize = 5
        optimizer.iterations = 5
        optimizer.indivMutationRate = 0.5
        optimizer.selectionRate = 0.5
        optimizer.mutationRange = 500
        t = time()
        optimizer.run()
        t = time() - t
        t -= optimizer.simulatorTime
        times.append(t)
        pprint("PERF Time = " + str(t), GREEN)

    try:
        from thirdparty.CairoPlot import dot_line_plot
    except:
        pprint("PERF Will not output to graph.", RED)
        return

    dot_line_plot(
        path.join("benchmarks", "optimizer-largevalues-" + str(testNum)) +
        FORMAT, times, 800, 800, (255, 255, 255), 5, True, True, True, None,
        None, None, None)
Exemplo n.º 5
0
 def bench(self):
     orders = self.orderList.orders[:]
     self.orderList.orders = []
     i = self.startValue
     while i <= len(orders):
         pprint("PERF Number of orders = " + str(i), BLUE)
         self.orderList.orders = orders[:i]
         optimizer = Optimizer(self.plant, self.orderList,
                               Simulator(self.plant), Evaluator(self.plant))
         optimizer.populationSize = 10
         optimizer.iterations = 10
         optimizer.indivMutationRate = 0.5
         optimizer.selectionRate = 0.5
         optimizer.mutationRange = 10
         t = time()
         optimizer.run()
         t = time() - t
         t -= optimizer.simulatorTime
         self.addCairoPlotTime(t)
         self.addGnuPlotTime(i, t)
         i += 1
Exemplo n.º 6
0
 def bench(self):
     val = 2
     i = self.startValue
     while i < 10:
         pprint("PERF Large Value = " + str(i * val), BLUE)
         for o in self.orderList.orders:
             o.deadline *= val
             for r in o.recipe.recipe:
                 r[1] *= val
         optimizer = Optimizer(self.plant, self.orderList,
                               Simulator(self.plant), Evaluator(self.plant))
         optimizer.populationSize = 10
         optimizer.iterations = 10
         optimizer.indivMutationRate = 0.5
         optimizer.selectionRate = 0.5
         optimizer.mutationRange = 500
         t = time()
         optimizer.run()
         t = time() - t
         t -= optimizer.simulatorTime
         self.addCairoPlotTime(t)
         self.addGnuPlotTime((i + 1) * val, t)
         i += 1
Exemplo n.º 7
0
def optimizerMutationRangePerf(plant, orderList, testNum):
    machines = plant.machines[:]
    orders = orderList.orders[:]

    pprint(
        "PERF Starting optimizer benchmark test " + str(testNum) +
        " on mutation range", BLUE)
    orderList.orders = orders[:]
    plant.machines = machines[:]
    times = [0]

    for i in range(10, 200, 20):
        pprint("PERF Selection rate = " + str(i), BLUE)
        optimizer = Optimizer(plant, orderList, Simulator(plant),
                              Evaluator(plant))
        optimizer.populationSize = 5
        optimizer.iterations = 5
        optimizer.indivMutationRate = 0.5
        optimizer.selectionRate = 0.5
        optimizer.mutationRange = i
        t = time()
        optimizer.run()
        t = time() - t
        t -= optimizer.simulatorTime
        times.append(t)
        pprint("PERF Time = " + str(t), GREEN)

    try:
        from thirdparty.CairoPlot import dot_line_plot
    except:
        pprint("PERF Will not output to graph.", RED)
        return

    dot_line_plot(
        path.join("benchmarks", "optimizer-mutationrange-" + str(testNum)) +
        FORMAT, times, 800, 800, (255, 255, 255), 5, True, True, True, None,
        None, None, None)