jmaerte / pysmps Goto Github PK
View Code? Open in Web Editor NEWUtilities for parsing MPS and SMPS file formats.
Home Page: https://pypi.org/project/pysmps/
License: MIT License
Utilities for parsing MPS and SMPS file formats.
Home Page: https://pypi.org/project/pysmps/
License: MIT License
In SMPS the tags 'INTORG' and 'INTEND' are used to mark which of the variables are integer in the .cor file. That could be used to return a list of which variables are integer/ binary?
Hello!
Thanks for this library. We'd like to add it as dependency in PuLP (https://github.com/coin-or/pulp/) but I do not want to have to add numpy as dependency. In fact, we maintain an numpy-free version of your mps reader: https://github.com/coin-or/pulp/blob/9a71ae08e9416a6dc37c702dab1dd752e6bb0d00/pulp/mps_lp.py#L31
I'd have no issue in helping with a PR if needed.
in any case, thanks again!
Hello, I wonder when is there gonna be a next release for the package. I'm currently installing it from the repo website but it would be nice if we could have a new release on pypi. Thanks!
Hello - Thank you for making this code available, it is extremely helpful. I think there may be an incorrectly labeled attribute, in particular in mps_loader.py on L195 should the attribute constraint
be constraints
, so that the line reads:
elif self.constraints[constr]["type"] == "E":
Running pip3 install pysmps
yields the following error for me:
Collecting pysmps
Using cached https://files.pythonhosted.org/packages/18/e7/9334c53ef8487377c7efbbee823d661f9617277d0d545fdc8c13c315e472/pysmps-1.5.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-kl7a9R/pysmps/setup.py", line 3, in <module>
with open('requirements.txt', "r") as reader:
IOError: [Errno 2] No such file or directory: 'requirements.txt'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kl7a9R/pysmps/
Did I do something wrong or is this an error on your side?
Hi,
I'm reading a MIP instance from MIPLIB2017, set3-09.mps.gz, which is 75072 bytes when compressed, 528046 bytes when uncompressed.
I'm using Python 3.10.6_1 on my recent MacBook Pro M1Max (Darwin localmachine 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64).
This is not a huge instance, so I would expect pysmps to read it very fast if not instantly. In fact, it takes
real 0m32.953s
user 0m10.456s
sys 0m24.843s
which is very puzzling. I think 10s of user time is a lot, but I'm also surprised by 24s of system time.
Thanks for your attention
Yours,
Leo Liberti
Line 197 in aacdfc2
Hello - Thank you for making this code available, it is very helpful. I think there may be a missing [constr]
index on L197 (referenced above), and I propse that the corrected line should read:
self.ranges[self.curr_range][constr] = {"lower": 0, "upper": 0}
See the attached image of the profiler output. You can see that most of the import time is np.concatenate. Can we not figure out the correct dimensions early on, by the time we're adding the column data? If not, we might need to append to lists and then generate the final array at the end. The rest of the time is in the list indexer because you're relying on exceptions. Don't ever rely on an exception. They tend to be two orders of magnitude slower than an if
statement.
Hello again!
It'd be awesome to have some unittests integrated in this package. If you need examples of projects, you can go check the PuLP unittests for some example problems: https://github.com/coin-or/pulp/blob/master/pulp/tests/test_pulp.py
Hi,
Upon reading the MIPLIB2017 instance pb-market-split8-70-4.mps.gz , I noticed that pysmps declares variables as general integers unbounded above, whereas the .MPS declares them as "BV" bounds, which means "binary variables" (check http://plato.asu.edu/cplex_mps.pdf on page 9). Does pysmps ignore this tag? Why?
Thanks
Yours
Leo Liberti
Hi, thanks for your great work btw!
I used your library to parse netlib test problems
(http://www.numerical.rl.ac.uk/cute/netlib.html)
and ran into the problem, that your library doesn't ignore the comments prefixed by *
. I don't know, whether it is common-style to have comments in MPS files, but I thought I tell you about it :).
Having comments in there, I get the following error:
Traceback (most recent call last):
File "./generate-test-files-from-mps.py", line 3, in <module>
result = loader.load_mps("80BAU3B.SIF")
File "smps_loader.py", line 352, in load_mps
if line[0] == "ENDATA":
IndexError: list index out of range
The documentation in the pypi website says that it can open .mps
files. However, when I try it it fails because it expects a .cor
file?
>>> smps.load_smps("stein9inf.mps")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/vladimir/micromamba/envs/zapata/lib/python3.8/site-packages/pysmps/smps_loader.py", line 462, in load_smps
name, objective_name, row_names, col_names, col_types, types, c, A, rhs_names, rhs, bnd_names, bnd = load_mps(path + ".cor")
File "/Users/vladimir/micromamba/envs/zapata/lib/python3.8/site-packages/pysmps/smps_loader.py", line 355, in load_mps
with open(path, "r") as reader:
FileNotFoundError: [Errno 2] No such file or directory: 'stein9inf.mps.cor'
Why isn't it opening my .mps
file?
I am using the mps_loader submodule to load an MPS problem. How do I load the solution? e.g. a file containing:
=obj= 202.3499999999979
X0 19.99999999999996
X1 0
X2 25
X3 0
X4 0
X5 0
X6 0
X7 29.99999999999902
X8 0
X9 0
X10 0
X11 5.000000000000002
X12 14.99999999999999
X13 0
X14 0
X15 0
X16 5
X17 0
X18 0
X19 0
X20 0
X21 14.99999999999969
X22 0
X23 0
Y0 1
Y1 0
Y2 0.9999999999999998
Y3 -0
Y4 -0
Y5 -0
Y6 0
Y7 0.9999999999999674
Y8 0
Y9 0
Y10 0
Y11 1
Y12 1
Y13 0
Y14 -0
Y15 0
Y16 1
Y17 -0
Y18 -0
Y19 -0
Y20 0
Y21 0.9999999999999696
Y22 -0
Y23 0
In PuLP we have python code to write mps files. Since we're in the process to integrate pysmps to read these files, it only makes sense to also migrate the writing of the mps files here.
This way, other applications could benefit from this code and it would be more likely that it would be compatible with other systems.
Ideally, I would also like to move the writing of LP files (and potentially adding reading support) but that would probably involve a package name change.
More information on how we do MPS writing:
https://github.com/coin-or/pulp/blob/master/pulp/mps_lp.py#L189
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.