-
Notifications
You must be signed in to change notification settings - Fork 3
/
Linear_Programming.py
38 lines (32 loc) · 998 Bytes
/
Linear_Programming.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
_ _
| | (_)_ __ ___ __ _ _ __
| | | | '_ \ / _ \/ _` | '__|
| |___| | | | | __/ (_| | |
|_____|_|_| |_|\___|\__,_|_|
____ _
| _ \ _ __ ___ __ _ _ __ __ _ _ __ ___ _ __ ___ (_)_ __ __ _
| |_) | '__/ _ \ / _` | '__/ _` | '_ ` _ \| '_ ` _ \| | '_ \ / _` |
| __/| | | (_) | (_| | | | (_| | | | | | | | | | | | | | | | (_| |
|_| |_| \___/ \__, |_| \__,_|_| |_| |_|_| |_| |_|_|_| |_|\__, |
|___/ |___/
@author: Jonathan Wang
@coding: utf-8
@environment: Manjaro 18.1.5 Juhraya
@date: 19th Jan., 2020
"""
'''
max: z = 4x1 + 3x2
st: 2x1 + 3x2<=10
x1 + x2 <=8
x2 <= 7
x1,x2 > 0
'''
from scipy.optimize import linprog
c = [4, 3]
A = [[2, 3], [1, 1]]
b = [10, 8]
x1_bound = [0, None]
x2_bound = [0, 7]
res = linprog(c, A, b, bounds=(x1_bound, x2_bound))
print(res)