forked from mckib2/scikit-glpk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for reading mps files into matrices or glp_prob structs
- Loading branch information
Showing
3 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
from ._glpk import glpk | ||
from ._utils import mpsread, mpswrite | ||
from ._glpk_defines import GLPK | ||
from ._set_env import glpk_set_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'''Example showing how to use mpsread/write.''' | ||
|
||
from scipy.optimize import linprog | ||
|
||
from glpk import mpsread | ||
|
||
if __name__ == '__main__': | ||
|
||
libpath = '/home/nicholas/Downloads/glpk-4.65/src/.libs/libglpk.so' | ||
|
||
filename = '~/Documents/HiGHS/check/instances/25fv47.mps' | ||
|
||
lp = mpsread(filename, libpath=libpath) | ||
c, A_ub, b_ub, A_eq, b_eq, bounds = lp | ||
|
||
if A_ub is not None: | ||
print(A_ub.nnz) | ||
A_ub = A_ub.todense() | ||
print(A_ub) | ||
print(len(b_ub), c.shape) | ||
print(A_ub.shape) | ||
if A_eq is not None: | ||
A_eq = A_eq.todense() | ||
|
||
res = linprog(c, A_ub, b_ub, A_eq, b_eq, bounds) | ||
print(res) |