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

Developing #22

Merged
merged 7 commits into from
Jun 24, 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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2023] [Longxing Tan]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.PHONY: style test docs

check_dirs := lekin examples tests
Expand All @@ -8,8 +7,8 @@ check_dirs := lekin examples tests
style:
black --preview $(check_dirs)
isort $(check_dirs)
flake8
pre-commit run --all-files
flake8 $(check_dirs)
pre-commit run --files $(check_dirs)

# run tests for the library

Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@

- accelerate by
- Changeover Optimization
- Ready for demo, research and production
- Ready for demo, research and maybe production

# DRATFING- NOT FINISHED AND DON'T USE IT NOW!

## Feature

- constrained optimization
- route
- production
- material kit
- together

- soft constrained optimization
- objective


## Tutorial

**Installation**
Expand Down Expand Up @@ -67,6 +80,7 @@ In real world, Lekin integrates with MES to deploy production plans on the shop

- Construction heuristics
- [SPT]()
- [critical path]()

- Meta heuristics
- [local search]()
Expand Down
16 changes: 14 additions & 2 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@

**[文档](https://python-lekin.readthedocs.io)** | **[教程](https://python-lekin.readthedocs.io/en/latest/tutorials.html)** | **[发布日志](https://python-lekin.readthedocs.io/en/latest/CHANGELOG.html)** | **[English](https://github.com/LongxingTan/python-lekin/blob/master/README.md)**

**python-lekin**是一个数字化车间智能排产调度工具,名字来源于[教育工具Lekin](https://web-static.stern.nyu.edu/om/software/lekin/)
**python-lekin**是一个APS智能排产调度工具,名字来源于[Lekin](https://web-static.stern.nyu.edu/om/software/lekin/)。在考虑实际约束的前提下,动态调整计划排程,高效响应客户订单承诺。

## 特征

- 支持工艺路线约束
- 支持产能约束
- 支持物料齐套约束
- 支持顺排、倒排等方法


## 快速入门

### 安装

``` shell
$ pip install python-lekin
$ pip install lekin
```

### 使用
Expand All @@ -57,8 +64,13 @@ scheduler.draw()
- Route

## 示例
在实际APS系统开发中,

- 按工艺路线拆分工序
- 按BOM拆分物料

## 引用

```
@misc{python-lekin2022,
author = {Longxing Tan},
Expand Down
Binary file added docs/source/_static/backward-scheduling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/forward-scheduling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/_static/network-backward-algorithm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/_static/simple-backward-algorithm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ API

scheduler
solver
struct
lekin_struct
21 changes: 19 additions & 2 deletions docs/source/application.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Application
===========

Data Requirement
数据
----------------

MRP: Material Requirements Planning
Expand All @@ -10,9 +10,26 @@ MRP: Material Requirements Planning
BOM: Bill Of Materials


Function requirement
功能
------------------------

一个完善的APS系统包含以下模块。
- 需求中心
- 排程中心
- 排程工作台
- 物料中心


理解
----------

实际APS会涉及到各个车间,各个工序的复杂区分,以及BOM中涉及到多工厂的部分。
- 其实和APS关系不大,APS只要把最后一层工序展开,最后一层BOM展开,按实际的资源约束进行计算,最后只是展现形式上的区别

首先解决m个工序、n个机器的车间排产问题,然后把实际问题往车间问题靠。


可视化
------------
- 资源在时间线上的计划情况
- 按订单,在时间线上的操作情况
2 changes: 0 additions & 2 deletions docs/source/constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ Constraints
subject to:

.. math:: \alpha{}_t(i) = P(O_1, O_2, … O_t, q_t = S_i \lambda{})


9 changes: 8 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ python-lekin documentation
<a class="github-button" href="https://github.com/LongxingTan/python-lekin" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star LongxingTan/python-lekin on GitHub">GitHub</a>


**python-lekin** is a Flexible Job shop Scheduler Library, named after and inspired by `Lekin <https://web-static.stern.nyu.edu/om/software/lekin/>`_.
**python-lekin** 是一个工厂智能排产调度工具,名字来源于`Lekin <https://web-static.stern.nyu.edu/om/software/lekin/>`_.

快速入门
---------

排产是一个分配任务,将有限的资源分配给需求。因此需求需要有优先级,约束主要有产能约束与物料约束。产能约束,将订单中的成品按工艺路线分解为工序,而每一道工序有对应的生产机器;物料约束,将订单的成品按BOM(bill of materials)展开为原材料需求,每一道工序开始前需要对应原材料齐套。


Finite Capacity Planning

Expand All @@ -20,6 +26,7 @@ Finite Capacity Planning

tutorials
models
constraints
application
api
CHANGELOG
Expand Down
39 changes: 39 additions & 0 deletions docs/source/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,42 @@ SPT—EDD规则
2)计算所有任务的总流程时间。
3)查找方案中,预定交贷期(di)大于总流程时间的生产任务(不惟一),按SPT规则,将其中加工时间最大者排于最后。
4)舍弃第3步能排定的最后任务者及其后序任务,回到第2步重复。


关键路径法
-------------

关键路径是决定项目完成的最短时间,关键路径可能不止一条。

其基本概念:
最早开始时间 (Early start)
最晚开始时间 (Late start)
最早完成时间 (Early finish)
最晚完成时间 (Late finish)
松弛时间 (slack)

正推方法确定每个任务的最早开始时间和最早完成时间,逆推方法确定每个任务的最晚完成时间和最晚开始时间。


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

- 每一个MO最早开始时间初始化:max(ESD, today)。确保开始时间不早于今天


正排
-------------




禁忌搜索
------------


遗传算法
-------------


强化学习
-------------
2 changes: 1 addition & 1 deletion lekin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# from lekin.lekin_struct.operation import Operation
# from lekin.lekin_struct.route import Route
from lekin.scheduler import Scheduler
from lekin.solver.dispatching_rules import Rules
from lekin.solver.construction_heuristics import Rules
from lekin.solver.meta_heuristics import Heuristics

__all__ = ["Job", "Machine", "Route", "Operation", "Scheduler", "get_data"]
Expand Down
1 change: 1 addition & 0 deletions lekin/dashboard/pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import streamlit as st
11 changes: 9 additions & 2 deletions lekin/lekin_struct/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"""
https://gitee.com/EnCode/APS?_from=gitee_search#%E5%BB%BA%E6%A8%A1

工厂:订单
车间:工单
班组:工序
操作动作:动作

"""

from lekin.lekin_struct.job import Job
from lekin.lekin_struct.machine import Machine
from lekin.lekin_struct.operation import Operation
from lekin.lekin_struct.machine import Machine # 机器
from lekin.lekin_struct.operation import Operation # 工序
from lekin.lekin_struct.order import Order
from lekin.lekin_struct.route import Route
4 changes: 4 additions & 0 deletions lekin/lekin_struct/material.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
物料检查
- 物料可以锁定,可以占用,可以空闲
"""
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class Rules(object):
def __init__(self, name):
def __init__(self):
pass
12 changes: 12 additions & 0 deletions lekin/solver/construction_heuristics/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Rules(object):
def __init__(self, name):
pass

def run(self):
pass

def _init(self):
return

def _update(self):
return
11 changes: 11 additions & 0 deletions lekin/solver/construction_heuristics/epst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Earliest Possible Start Time
Forward scheduler
正排"""


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

def solve(self):
pass
11 changes: 11 additions & 0 deletions lekin/solver/construction_heuristics/lpst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Latest Possible STart Time
Backward scheduler
倒排"""


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

def solve(self):
pass
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Shortest Processing Time"""

from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

# from collections import sorteddict


class SPT(object):
""" """

def __init__(self):
self.time = {}
self.waiting_operations = {}
Expand Down Expand Up @@ -64,7 +65,7 @@ def solve(self, job_list: List, machine_list: List):

del self.time[t]
break
self.time = SortedDict(self.time)
self.time = OrderedDict(self.time)
return self.jobs_list_to_export

def get_waiting_operations(self, job_list, time, machine_list, current_time_on_machines):
Expand Down
6 changes: 6 additions & 0 deletions lekin/solver/meta_heuristics/critical_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Critical path"""


class CriticalPath(object):
def __init__(self):
pass
6 changes: 6 additions & 0 deletions lekin/solver/meta_heuristics/hill_climbing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Hill climbing"""


class HillClimbing(object):
def __init__(self):
pass
6 changes: 0 additions & 6 deletions lekin/solver/meta_heuristics/local_search.py

This file was deleted.

9 changes: 9 additions & 0 deletions lekin/solver/meta_heuristics/tabu_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Local search
https://towardsdatascience.com/optimization-techniques-tabu-search-36f197ef8e25
"""


class TabuSearch(object):
def __init__(self):
pass
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""variable neighborhood search"""
"""Variable neighborhood search"""
3 changes: 0 additions & 3 deletions lekin/solver/operation_research/job_shop.py

This file was deleted.

Empty file.
19 changes: 19 additions & 0 deletions lekin/solver/reinforcement_learning/models/graphcnn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import torch
import torch.nn as nn
import torch.nn.functional as F


class MLP(nn.Module):
def __init__(self, num_layers, input_dim, hidden_dim, output_dim):
super().__init__()

def forward(self, x):
return


class GraphCNN(nn.Module):
def __init__(self):
super().__init__()

def forward(self, x, graph_pool, adj):
return
Loading
Loading