-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample1.py
52 lines (49 loc) · 931 Bytes
/
example1.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# http://web.mit.edu/lpsolve/doc/Python.htm
# max 143x + 60y
# 120x + 210y <= 15000
# 110x + 30y <= 4000
# x + y <= 75
# x >= 0, y >= 0
import lpsolve_wrapper as lw
model = lw.Model(
notations={
'x': lw.notation(
lower_bound=0,
),
'y': lw.notation(
lower_bound=0,
)
})
model.add_constr(
coefs=[
lw.coef('x', 120),
lw.coef('y', 210),
],
right_value=15000,
constr_type=lw.LEQ
)
model.add_constr(
coefs=[
lw.coef('x', 110),
lw.coef('y', 30),
],
right_value=4000,
constr_type=lw.LEQ
)
model.add_constr(
coefs=[
lw.coef('x', 1),
lw.coef('y', 1),
],
right_value=75,
constr_type=lw.LEQ
)
objective, notation_list = model.lp_solve(
obj_func={
'x': 143,
'y': 60,
},
minimize=False
)
print('objective:', objective)
print('notations:', notation_list)