GithubHelp home page GithubHelp logo

jmaerte / pysmps Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 4.0 70 KB

Utilities for parsing MPS and SMPS file formats.

Home Page: https://pypi.org/project/pysmps/

License: MIT License

Python 100.00%
smps linear-optimization stochastic-optimization python

pysmps's Introduction

pysmps

Utilities for parsing MPS and SMPS file formats.

Installation

You can install this package using PyPI with the command

pip install pysmps

After installation you can import the reader as

from pysmps import smps_loader as smps

at the beginning of your python code. For full documentation take a look at the PyPI page, https://pypi.org/project/pysmps/.

TODO

  • Scenario support in sto file parsing.
  • Block support in 2-stage problem casting.

pysmps's People

Contributors

bodono avatar dependabot[bot] avatar jmaerte avatar maertej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pysmps's Issues

Support mixed-integer SMPS instances

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?

Next release?

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!

How do I load the solution of an MPS problem in a list?

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

mps_loader: MPS.add_range - missing index

self.ranges[self.curr_range] = {"lower": 0, "upper": 0}

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}

Include a MPS writer

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

variable bound tag 'BV' ignored

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

Comments in SIF (MPS) files

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

Not loading MPS files correctly

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?

reading MPS slow?

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

Cannot pip install pysmps

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?

load performance issue with concatenate

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.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.