Example #1
0
def loadPlantAndOrderList(args):
    plantName = args[0]
    orderListName = args[1]
    configName = args[2]

    plant = Plant.fromXmlFile(plantFileExists(plantName))
    orderList = OrderList.fromXmlFile(orderListExists(orderListName), plant)

    return plant, orderList
Example #2
0
def optimize(args):
    """
	Runs the Scheduler with the OrderList from orderListName on the Plant
	with plantName.
	"""
    plantName = args[0]
    orderListName = args[1]

    plant = Plant.fromXmlFile(plantFileExists(plantName))
    orderList = OrderList.fromXmlFile(orderListExists(orderListName))
    optimizer = Optimizer(plant, orderList)
    optimizer.run()
Example #3
0
def schedule(args):
    """
	Runs the Scheduler with the OrderList from orderListName on the Plant
	with plantName.
	"""
    plantName = args[0]
    orderListName = args[1]

    plant = Plant.fromXmlFile(plantFileExists(plantName))
    orderList = OrderList.fromXmlFile(orderListExists(orderListName))
    scheduler = Scheduler(plant, orderList)
    evaluator = Evaluator(plant)
    evaluator.evaluate(parseSolutions(scheduler.start(), orderList))
Example #4
0
def loadPlantAndOrderList(plantName, orderListName):
    plant = Plant.fromXmlFile(plantFileExists(plantName))
    orderList = OrderList.fromXmlFile(orderListExists(orderListName), plant)

    for i, m in enumerate(plant.machines):
        for o in orderList.orders:
            if o.recipe[m.name] == None:
                o.recipe.recipe.insert(i, [m.name, 0])

    for o in orderList.orders:
        assert len(plant.machines) == len(o.recipe.recipe)

    normValue = normalizeValues(plant, orderList)

    return plant, orderList, normValue
Example #5
0
def addMachine(args):
    """
	Adds a Machine to a Plant with plantName.
	"""
    plantName = args[0]
    machineName = args[1]
    machineQuantity = args[2]
    machineDelay = args[3]
    machineCanUnhook = args[4]

    plantFilename = plantFileExists(plantName)
    plant = Plant.fromXmlFile(plantFilename)
    plant.addMachine(
        Machine(name=machineName,
                quantity=int(machineQuantity),
                minDelay=int(machineDelay),
                canUnhook=strToBool(machineCanUnhook)))
    plant.toXmlFile(plantFilename)
Example #6
0
def addOrder(args):
    """
	Adds an Order along with its Recipe to an OrderList.
	"""
    orderListName = args[0]
    plantName = args[1]
    orderId = args[2]
    orderDeadline = args[3]

    plant = Plant.fromXmlFile(plantFileExists(plantName))
    order = Order(id=int(orderId), deadline=int(orderDeadline))
    recipe = Recipe()

    for m in plant.machines:
        print "Time for", m.name + ":",
        time = int(input())
        recipe[m.name] = time
    order.recipe = recipe

    orderListFilename = orderListExists(orderListName)
    orderList = OrderList.fromXmlFile(orderListFilename)
    orderList.addOrder(order)
    orderList.toXmlFile(orderListFilename)
Example #7
0
def showPlant(args):
    """
	Print the XML description of a Plant from plantName.
	"""
    print Plant.fromXmlFile(plantFileExists(args[0])).toXml().toprettyxml()