forked from mckib2/scikit-glpk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
38 lines (33 loc) · 871 Bytes
/
test.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
'''Basic example showing usage of scikit-glpk.'''
import numpy as np
from scipy.optimize import linprog
from glpk import glpk, GLPK
if __name__ == '__main__':
c = [-1, 8, 4, -6]
A_ub = [[-7, -7, 6, 9],
[1, -1, -3, 0],
[10, -10, -7, 7],
[6, -1, 3, 4]]
b_ub = [-3, 6, -6, 6]
A_eq = [[-10, 1, 1, -8]]
b_eq = [-4]
bnds = None
res = glpk(
c, A_ub, b_ub, A_eq, b_eq, bnds,
message_level=GLPK.GLP_MSG_OFF,
maxit=100,
timeout=10,
solver='mip',
basis_fac='btf+cbg',
simplex_options={
'init_basis': 'adv',
'method': 'dual',
'presolve': True,
'exact': True,
})
print('GLPK:')
print(res)
print('\n\n')
print('linprog:')
res = linprog(c, A_ub, b_ub, A_eq, b_eq, bnds)
print(res)