Commit 3227ccaa authored by Jérome Perrin's avatar Jérome Perrin

execution plugin to compare the impact of a new order

It runs two scenarios, one with the order and another one without.
parent e0c3a1ff
......@@ -102,6 +102,36 @@ class DefaultExecutionPlugin(ExecutionPlugin):
data["result"]["result_list"][-1]["key"] = "default"
return data
class NewOrderExecutionPlugin(ExecutionPlugin):
""" Execution plugin that compares the result with or with the new order.
The new order is identified must have "new" in its id.
"""
def removeNewOrder(self, data):
data = deepcopy(data)
data['input']['BOM']['productionOrders'] = [order for order in
data['input']['BOM']['productionOrders'] if not "new" in order['id'].lower()]
for node in data['graph']['node'].values():
if node.get('wip'):
node['wip'] = [part for part in node['wip'] if not "new" in part['capacityProjectId'].lower()]
return data
def run(self, data):
"""Run simulation and return result to the GUI.
"""
# before new order
data["result"]["result_list"].extend(self.runOneScenario(self.removeNewOrder(data))['result']['result_list'])
data["result"]["result_list"][-1]["score"] = 0
data["result"]["result_list"][-1]["key"] = "before_new_order"
data["result"]["result_list"][-1]["name"] = "Before New Order"
# with the new order
data["result"]["result_list"].extend(self.runOneScenario(data)['result']['result_list'])
data["result"]["result_list"][-1]["score"] = 0
data["result"]["result_list"][-1]["key"] = "with_new_order"
data["result"]["result_list"][-1]["name"] = "With New Order"
return data
class PluginRegistry(object):
"""Registry of plugins.
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment