From 4a045d650b4e313f391a264de6176362c2d96601 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 19 Apr 2021 03:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=80=BB=E8=BE=91=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime.py | 8 +++++--- scheduling.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/runtime.py b/runtime.py index e079455..8a6b79a 100644 --- a/runtime.py +++ b/runtime.py @@ -7,12 +7,13 @@ class RuntimeProduct: def __init__(self, product, amount): self.ddl: datetime = datetime.today() + self.start: datetime = datetime.today() self.product: model.Product = product self.amount: int = amount - def set_ddl(self, ddl: datetime): + def set_ddl_start(self, ddl: datetime, start: datetime): self.ddl = ddl - pass + self.start = start class ProductLine: @@ -71,4 +72,5 @@ class RuntimeProcess: def __init__(self, runtime_product: RuntimeProduct, process: model.Process): self.runtime_product = runtime_product self.process = process - self.start_ddl = self.runtime_product.ddl - timedelta(minutes=process.pdt_time) + self.ddl = runtime_product.ddl + self.delay = self.runtime_product.ddl - timedelta(minutes=process.pdt_time) diff --git a/scheduling.py b/scheduling.py index 413fddb..d0ad9e3 100644 --- a/scheduling.py +++ b/scheduling.py @@ -15,7 +15,7 @@ def orders_processor(orders: Dict[str, model.Order]) -> List[runtime.RuntimeProd for sorted_order in sorted_orders_list: for item in sorted_order.products: runtime_product = runtime.RuntimeProduct(item["product"], item["amount"]) - runtime_product.set_ddl(sorted_order.latest_end_time) + runtime_product.set_ddl_start(sorted_order.latest_end_time, sorted_order.earliest_start_time) products_lines.add_runtime_product(runtime_product) runtime_product = products_lines.pop_runtime_product() @@ -41,7 +41,7 @@ def search_semi_products(floor, produce_tree, produce_list, runtime_product): for item in runtime_product.product.semi_products: runtime_semi_product = runtime.RuntimeProduct(item["semi_product"], item["amount"]) - runtime_semi_product.set_ddl(runtime_product.ddl) + runtime_semi_product.set_ddl_start(runtime_product.ddl, runtime_product.start) # print("C", runtime_semi_product.product.product_id, runtime_semi_product.ddl) @@ -60,7 +60,13 @@ def products_processor(runtime_products: List[runtime.RuntimeProduct]): processes_list.append(runtime_process) + processes_list = sorted(processes_list, key=lambda rt_pcs: (rt_pcs.ddl, rt_pcs.delay)) + + for runtime_process in processes_list: + print(runtime_process.process.pcs_id, runtime_process.delay) + if __name__ == "__main__": - orders, products, processes, resources = dataset_importer.import_dataset() - orders_processor(orders) \ No newline at end of file + m_orders, m_products, m_processes, m_resources = dataset_importer.import_dataset() + produce_list = orders_processor(m_orders) + products_processor(produce_list) \ No newline at end of file