Skip to content

Commit

Permalink
update requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
LongxingTan committed Sep 16, 2023
1 parent 878d82e commit 628c18b
Show file tree
Hide file tree
Showing 10 changed files with 1,735 additions and 1,533 deletions.
53 changes: 53 additions & 0 deletions docs/source/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,59 @@ BOM: Bill Of Materials

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

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

先排冻结期
- 只assign资源和日历


排锁定任务
- 只倒排,如果倒排不可行则返回错误。按锁定期、按优先级
- 非关键工序: 按节拍往前排,不考虑齐套时间
- 关键工序: 如有锁定资源,则按资源情况进行编排


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


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


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


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


车间过程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
Empty file added lekin/forecast/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions lekin/solver/construction_heuristics/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,11 @@ def optimize_resource_selection(self, resources, operation):
scored.append((score, resource))
best = max(scored, key=lambda x: x[0])
return best[1]


class Backward(object):
def __init__(self):
pass

def run(self):
pass
72 changes: 72 additions & 0 deletions lekin/solver/construction_heuristics/mix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import heapq


class JobScheduler:
def __init__(self, available_slots, jobs, routes, operations, resources):
self.available_slots = available_slots
heapq.heapify(self.available_slots) # Convert the list into a min heap
self.jobs = jobs
self.routes = routes
self.operations = operations
self.resources = resources

def backward_schedule(self):
# Implement your initial backward scheduling pass here
pass

def assign_resource(self, operation, available_resources):
# Implement resource assignment logic based on availability and scoring
pass

def analyze_schedule_density(self):
# Implement schedule density analysis
pass

def identify_bottleneck_resources(self):
# Identify bottleneck resources limiting density
pass

def push_operations_closer(self, bottleneck_resources):
# Push operations closer on bottleneck resources
pass

def rescore_operations(self):
# Rescore operations based on priority and slack time
pass

def reassign_operations(self):
# Reassign operations to reduce gaps
pass

def reevaluate_routes(self, critical_jobs):
# Re-evaluate routes for critical jobs
pass

def reschedule_operations(self, critical_jobs):
# Reschedule operations on preferred resources for critical jobs
pass

def push_dense(self):
# Iteratively push operations closer system-wide
# while True:
# self.backward_schedule()
# density = self.analyze_schedule_density()
# if density is not improved:
# break
pass

def final_tweaking(self):
# Fine-tune schedules of critical jobs and leverage flexibilities
pass

def optimize_schedule(self):
self.push_dense()
critical_jobs = self.identify_critical_jobs()
self.reevaluate_routes(critical_jobs)
self.reschedule_operations(critical_jobs)
self.final_tweaking()
return self.schedule

def identify_critical_jobs(self):
# Identify critical jobs on the schedule
pass
Empty file added lekin/solver/utils/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions lekin/solver/utils/push_dense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def push_dense(schedule):
changed = True

while changed:
changed = False

for resource in schedule.resources:
slots = sorted(resource.slots, key=lambda x: x.start_time)

for i in range(len(slots) - 1):
curr_slot = slots[i]
next_slot = slots[i + 1]

if curr_slot.end_time < next_slot.start_time:
# Gap exists between operations

gap = next_slot.start_time - curr_slot.end_time

if next_slot.operation.can_start_early(gap):
# Update slots
next_slot.start_time -= gap
next_slot.end_time -= gap

curr_slot.end_time = next_slot.start_time

changed = True

return schedule
Loading

0 comments on commit 628c18b

Please sign in to comment.