示例#1
0
def simulatorOrdersPerf(plant, orderList, testNum):
    machines = plant.machines[:]
    orders = orderList.orders[:]

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

    for i in range(1, len(orders) + 1):
        pprint("PERF Number of orders = " + str(i), BLUE)
        orderList.orders = orders[:i]
        optimizer = Optimizer(plant, orderList, Simulator(plant),
                              Evaluator(plant))
        schedule = optimizer.initialIndividual()
        t = time()
        simulator = Simulator(plant)
        simulator.simulate(schedule)
        t = time() - t
        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", "simulator-orders-" + str(testNum)) + FORMAT,
        times, 800, 800, (255, 255, 255), 5, True, True, True, None, None,
        None, None)
示例#2
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
示例#3
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))
         schedule = optimizer.initialIndividual()
         t = time()
         simulator = Simulator(self.plant)
         simulator.simulate(schedule)
         t = time() - t
         self.addCairoPlotTime(t)
         self.addGnuPlotTime(i, t)
         i += 1
示例#4
0
 def optimize(self):
     simulator = Simulator(self.plant)
     evaluator = Evaluator.fromXmlFile(self.configFilename, self.plant)
     optimizer = Optimizer.fromXmlFile(self.configFilename, self.plant,
                                       self.orderList, simulator, evaluator)
     result = optimizer.run()
     best = bestSolution(result)
     best.unNormalize(self.normValue)
     print best
示例#5
0
 def bench(self):
     val = 4
     i = self.startValue
     while i <= 6:
         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))
         schedule = optimizer.initialIndividual()
         t = time()
         simulator = Simulator(self.plant)
         simulator.simulate(schedule)
         t = time() - t
         self.addCairoPlotTime(t)
         self.addGnuPlotTime((i + 1) * val, t)
         i += 1
示例#6
0
 def optimize(self):
     simulator = Simulator(self.plant)
     evaluator = Evaluator.fromXmlFile(self.configFilename, self.plant,
                                       self.normValue)
     optimizer = Optimizer.fromXmlFile(self.configFilename, self.plant,
                                       self.orderList, simulator, evaluator)
     result = optimizer.run()
     best = bestSolution(result)
     best.unNormalize(self.normValue)
     #		for item in best:
     #			if "kettle" in item[1]:
     #				print item[0], item[2]
     print best
示例#7
0
def simulatorLargeValuesPerf(plant, orderList, testNum):
    machines = plant.machines[:]
    orders = orderList.orders[:]

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

    val = 4

    for i in range(1, 7):
        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))
        schedule = optimizer.initialIndividual()
        t = time()
        simulator = Simulator(plant)
        simulator.simulate(schedule)
        t = time() - t
        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", "simulator-largevalues-" + str(testNum)) +
        FORMAT, times, 800, 800, (255, 255, 255), 5, True, True, True, None,
        None, None, None)
示例#8
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))
            schedule = optimizer.initialIndividual()
            t = time()
            simulator = Simulator(self.plant)
            simulator.simulate(schedule)
            t = time() - t
            self.addCairoPlotTime(t)
            self.addGnuPlotTime(i, t)
            i += 1
示例#9
0
    def run(self):
        simulator = Simulator(self.plant)
        evaluator = Evaluator.fromXmlFile(self.configFilename, self.plant)
        optimizer = Optimizer.fromXmlFile(self.configFilename, self.plant,
                                          self.orderList, simulator, evaluator)
        scheduler = Scheduler(self.plant, self.orderList)

        result = scheduler.start()
        if result != None:
            solutions = parseSolutions(result, self.plant, self.orderList)
            for s in solutions:
                s.loadStartTimes(self.plant)
            result = optimizer.run(solutions)
            best = bestSolution(result)
            best.unNormalize(self.normValue)
            print best
示例#10
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)
示例#11
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
示例#12
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)
示例#13
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
示例#14
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
示例#15
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)