Skip to content

Commit

Permalink
update jsp problem: add gurobi solver for pulp
Browse files Browse the repository at this point in the history
  • Loading branch information
dothinking committed Oct 2, 2022
1 parent d00b92e commit 9e6f92b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/2021-08-08-作业车间调度问题求解框架.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ https://github.com/dothinking/jsp_framework

- [OR-Tools 约束求解器](2021-08-22-作业车间调度问题求解框架:OR-Tools约束求解器.md)

- [PuLP求解器](2021-08-29-作业车间调度问题求解框架:PuLP求解器.md)
- [PuLP求解器](2021-08-29-作业车间调度问题求解框架:PuLP求解框架.md)

- [基于规则指派](2021-08-28-作业车间调度问题求解框架:基于规则指派求解器.md)
- [基于规则指派](2021-08-28-作业车间调度问题求解框架:规则指派算法.md)


## 参考文献
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ categories: [optimization, mathematics]
tags: [job shop schedule]
---

# 作业车间调度问题求解框架:PuLP 求解器
# 作业车间调度问题求解框架:PuLP 求解框架

---


本文根据作业车间调度问题的数学描述,利用 Python 整数规划包 PuLP 进行建模和求解,并集成到 `jsp_framework` 框架中
本文根据作业车间调度问题的数学描述,利用 Python 整数规划框架 PuLP 进行建模,并分别使用默认的`CBC`求解器及商业求解器`Gurobi`求解

## PuLP

Expand Down Expand Up @@ -165,7 +165,7 @@ class PuLPSolver(JSSolver):

!!! warning "注意"

当前版本采用了默认的 CBC (COIN-OR Branch-and-Cut)求解器。
当前版本支持 CBC(COIN-OR Branch-and-Cut)、SCIP (开源) 和 Gurobi(商业)求解器。其中 CBC 为 Pulp 默认求解器,开箱即用;其余二者需要自行下载安装和授权


### PuLP 建模
Expand Down Expand Up @@ -273,7 +273,8 @@ names = ['ft06', 'la01', 'ft10', 'swv01', 'la38', \
problems = [JSProblem(benchmark=name) for name in names]

# solver
solvers = [PuLPSolver(max_time=300)]
solvers = [PuLPSolver(name=name, solver_name=name, max_time=300) \
for name in ('cbc', 'gurobi')]

# solve
benchmark = BenchMark(problems=problems, solvers=solvers, num_threads=5)
Expand All @@ -286,19 +287,39 @@ benchmark.run(show_info=True)
+----+---------+--------+---------------+--------------+----------+---------+-------+
| ID | Problem | Solver | job x machine | Optimum | Solution | Error % | Time |
+----+---------+--------+---------------+--------------+----------+---------+-------+
| 1 | ft06 | pulp | 6 x 6 | 55 | 55.0 | 0.0 | 3.5 |
| 2 | la01 | pulp | 10 x 5 | 666 | 666.0 | 0.0 | 209.0 |
| 3 | ft10 | pulp | 10 x 10 | 930 | 1034.0 | 11.2 | 301.2 |
| 4 | swv01 | pulp | 20 x 10 | 1407 | 2941.0 | 109.0 | 301.2 |
| 5 | la38 | pulp | 15 x 15 | 1196 | 1769.0 | 47.9 | 301.2 |
| 6 | ta31 | pulp | 30 x 15 | 1764 | 13294.0 | 653.6 | 301.1 |
| 7 | swv12 | pulp | 50 x 10 | (2972, 3003) | 9527.0 | 218.9 | 309.9 |
| 8 | ta42 | pulp | 30 x 20 | (1867, 1956) | 23202.0 | 1113.8 | 507.1 |
| 9 | ta54 | pulp | 50 x 15 | 2839 | 26229.0 | 823.9 | 608.0 |
| 10 | ta70 | pulp | 50 x 20 | 2995 | 36851.0 | 1130.4 | 625.6 |
| 1 | ft06 | cbc | 6 x 6 | 55 | 55.0 | 0.0 | 3.5 |
| 2 | la01 | cbc | 10 x 5 | 666 | 666.0 | 0.0 | 209.0 |
| 3 | ft10 | cbc | 10 x 10 | 930 | 1034.0 | 11.2 | 301.2 |
| 4 | swv01 | cbc | 20 x 10 | 1407 | 2941.0 | 109.0 | 301.2 |
| 5 | la38 | cbc | 15 x 15 | 1196 | 1769.0 | 47.9 | 301.2 |
| 6 | ta31 | cbc | 30 x 15 | 1764 | 13294.0 | 653.6 | 301.1 |
| 7 | swv12 | cbc | 50 x 10 | (2972, 3003) | 9527.0 | 218.9 | 309.9 |
| 8 | ta42 | cbc | 30 x 20 | (1867, 1956) | 23202.0 | 1113.8 | 507.1 |
| 9 | ta54 | cbc | 50 x 15 | 2839 | 26229.0 | 823.9 | 608.0 |
| 10 | ta70 | cbc | 50 x 20 | 2995 | 36851.0 | 1130.4 | 625.6 |
+----+---------+--------+---------------+--------------+----------+---------+-------+
```

计算效果并不理想,只有前两个问题即工序总数 50 以内得到了最优解,其余案例误差较大。由此表明,**PuLP 默认的 CBC 求解器在作业车间调度问题上的性能不如 Google OR-Tools 的约束求解器 CpSolver**
```
+----+---------+--------+---------------+--------------+----------+---------+-------+
| ID | Problem | Solver | job x machine | Optimum | Solution | Error % | Time |
+----+---------+--------+---------------+--------------+----------+---------+-------+
| 1 | ft06 | gurobi | 6 x 6 | 55 | 55.0 | 0.0 | 0.7 |
| 2 | la01 | gurobi | 10 x 5 | 666 | 666.0 | 0.0 | 5.2 |
| 3 | ft10 | gurobi | 10 x 10 | 930 | 930.0 | 0.0 | 60.2 |
| 4 | swv01 | gurobi | 20 x 10 | 1407 | 1757.0 | 24.9 | 301.4 |
| 5 | la38 | gurobi | 15 x 15 | 1196 | 1196.0 | 0.0 | 300.9 |
| 6 | ta31 | gurobi | 30 x 15 | 1764 | 2142.0 | 21.4 | 304.5 |
| 7 | swv12 | gurobi | 50 x 10 | (2972, 3003) | unsolved | n.a. | 308.9 |
| 8 | ta42 | gurobi | 30 x 20 | (1867, 1956) | 2457.0 | 28.5 | 362.8 |
| 9 | ta54 | gurobi | 50 x 15 | 2839 | unsolved | n.a. | 607.6 |
| 10 | ta70 | gurobi | 50 x 20 | 2995 | 4513.0 | 50.7 | 608.2 |
+----+---------+--------+---------------+--------------+----------+---------+-------+
```


`cbc`求解器的计算效果并不理想,只有前两个问题即工序总数 50 以内得到了最优解,其余案例误差较大。`Gurobi`的结果略有改进,前5题结果尚可,后5题或者无法求解或者误差较大,整体不如前文的OR-Tools 约束求解器。

由此表明,对于作业车间调度问题,**混合整数规划求解器**(如CBC、Gurobi)的求解性能不如**约束求解器**(如Google OR-Tools 的CpSolver)。


PuLP 支持其他求解器例如商业求解器 CPLEX 和 GUROBI,有机会可以对比一下结果。

0 comments on commit 9e6f92b

Please sign in to comment.