Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/rule #33

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/source/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,66 @@ BOM: Bill Of Materials

解决冲突的过程,即是一个顺排的过程。把所有分布在该资源上的任务根据顺序进行顺排

车间过程1-倒排+顺排
-------------------

先分发冻结期,按锁定期
- 只assign资源和日历
- 检查物料齐套约束,如果物料不齐套,按齐套排程并给出报警消息


再排锁定任务
- 只倒排,如果倒排不可行则返回错误。按优先级
- 非关键工序: 按lead_time、节拍往前排,不考虑齐套时间。
- 关键工序: 如有锁定资源,则按资源情况进行编排。不考虑齐套时间,因为锁定任务是为了确保优先级,物料通过缺料去人工追料
- 共享工序: 共享工序本身取多个job中靠前的时间断。
- 原本已经排过的其他job,前序工序需要以此为新的往前推
- 同时拥有共享工序的job排序适时进行调整,尽量避免以上修改
- 在冻结期且物料约束不满足: 按最早齐套时间进行排产,同时已排工序进行


再根据优先级排产其他任务
- 先倒排
- 第一道关键工序前的非关键工序,先按lead time进行排,后面需要二次更新。
- 关键工序倒排,(task分割会有的)非关键工序则按lead time前推
- 倒排中时间约束都是最晚时间,但物料约束是最早开始时间。如果时间不足以排产,则该工序及之后的工序都转为顺排重排
- 另一个思路是,先直接道排到第一个工序,后续一起按照可开始时间进行顺排。甚至等到推紧时一起顺排是否可行呢
- 遇到共享task,如果之前的共享task被安排的时间更晚,那么剩余工序也转为顺排重排
- 第一步剩余的非关键工序后拉
- 如果任务一步中,资源日历不足则进入下一步
- 倒排有问题则顺排
- 按各个资源最早可用日期开始排 (此时应该选可以最早的资源),非关键工序按lead time排,并需要进行二次更新
- 关键工序顺排
- 如果遇到共享task不满足时间约束
- 第一步剩余的非关键工序前拉
- 如果任何一步中,资源日历不足则返回错误
- 关键工序完全没有设置的job,按无限产能倒排


任务推紧规整
- 所有任务都采用顺排,类似按资源排产的方法。
- 按关键工序设置,“是否可以挪动”。每一个资源的第一道关键工序都可以向前,并跟新后续的可挪动状态与开始时间约束
- 迭代更新


未排任务再次尝试
- 推紧之后,再次尝试将之前未排的任务进行排产


委外/外协的排产
- 委外的指定是针对供应商,排到日历中
- 根据关键工序的产能,按优先级将各委外的部分进行排产


车间过程2-倒排+顺排2
-------------------
仍然是先排锁定任务

把所有任务按照交期和最早开工日期进行倒排或顺排,不考虑资源的约束本身 【带来的问题是:资源优先级的选择】


顺排的时候,按照job优先级 【指定 > 优先级】
- 每一个job都按第一道工序其最早开工日期开始,

可视化
------------
Expand Down
2 changes: 2 additions & 0 deletions docs/source/demand.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
demand
========================================
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Finite Capacity Planning
heuristics
rl
application
demand
api
GitHub <https://github.com/LongxingTan/python-lekin>

Expand Down
17 changes: 13 additions & 4 deletions docs/source/rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,26 @@ SPT—EDD规则
正推方法确定每个任务的最早开始时间和最早完成时间,逆推方法确定每个任务的最晚完成时间和最晚开始时间。





顺排
-------------

顺排和倒排,和其他规则启发式算法一样,一个工序集一个工序集的排。每排一个工序,工序job完成后,更新机器、job状态、后续job状态。
顺排对下一道工序的约束是:最早开始时间

.. code-block:: python
backward(operations, next_op_start_until, with_material_kitting_constraint, align_with_same_production_line, latest_start_time, latest_end_time) -> remaining_operations: list[operations],


.. code-block:: python
assign_op(operation, is_critical, direction: str, ) -> chosen_resource, chosen_production_id, chosen_hours,

在顺排中,排的比较紧密的资源往往就是瓶颈资源。

倒排
---------------

- 每一个MO最早开始时间初始化:max(ESD, today)。确保开始时间不早于今天
每一个MO最早开始时间初始化:max(ESD, today)。确保开始时间不早于今天,或不早于资源日历最早开始时间
倒排对下一道工序的约束是: 最晚结束时间

.. code-block:: python
forward(operations, next_op_start_until, with_material_kitting_constraint, align_with_same_production_line, earliest_start_time, earliest_end_time)
Empty file added lekin/forecast/__init__.py
Empty file.
12 changes: 8 additions & 4 deletions lekin/lekin_struct/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ def __init__(
operation_id: str,
operation_name: str,
quantity: int,
processing_time: Union[int, List[int]],
pre_time=0, # setup times
post_time=0,
lead_time=0,
beat_time: Union[int, List[int], float, List[float]],
processing_time: Union[int, List[int], float, List[float]],
pre_time: float = 0, # setup times
post_time: float = 0,
lead_time: float = 0,
lag_time: float = 0,
route_constraint=None,
available_resource=None,
available_resource_priority=None,
Expand All @@ -26,10 +28,12 @@ def __init__(
self.operation_id = operation_id
self.operation_name = operation_name
self.quantity = quantity
self.beat_time = beat_time
self.processing_time = processing_time
self.pre_time = pre_time
self.post_time = post_time
self.lead_time = lead_time
self.lag_time = lag_time
# self.demand_time = demand_time
self.route_constraint = route_constraint
self.available_resource = available_resource
Expand Down
2 changes: 1 addition & 1 deletion lekin/lekin_struct/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import math
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Type, Union

import numpy as np
import pandas as pd

Expand Down Expand Up @@ -72,7 +73,6 @@ def get_latest_available_time(self, duration=None, end=None):
self.update_continuous_empty_hours()
return max([i + 1 for (i, v) in enumerate(self.continuous_empty_hours[:end]) if v >= duration])


def update_continuous_empty_hours(self):
if len(self.available_hours) != len(self._available_timeslots):
pass
Expand Down
3 changes: 2 additions & 1 deletion lekin/solver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def find_best_resource_and_timeslot_for_operation(
just_in_time_end_time_slot = max([i for i in resource_all_available_end_time if i <= latest_end_time])
print(latest_end_time, just_in_time_end_time_slot)

working_hours = (operation.processing_time[i] * operation.quantity) / 60
if hasattr(operation.beat_time, "__iter__"):
working_hours = (operation.beat_time[i] * operation.quantity) / 60

unoccupied_hours = resource.get_available_time_slots_within_time()
if unoccupied_hours >= working_hours:
Expand Down
149 changes: 0 additions & 149 deletions lekin/solver/construction_heuristics/backward.py

This file was deleted.

Loading
Loading