coin-or / coin-or/python-mip

Model read .mps file appears to not work

Open
#132 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Linear Programming
Stars
600
Forks
108
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I am using the Model.read function as described in the [Quick Start guide](https://python-mip.readthedocs.io/en/latest/quickstart.html) under "Saving, Loading and Checking Model Properties." The description says that it works to load a .mps file. I have a .mps file describing a model I'd like to use. When I use the function as the directions give, it appears the file isn't loaded. Nothing about the problem is available in the model object, it gives 0 rows, 0 columnst, etc.

**To Reproduce**
My .mps file contents are below. This file type isn't supported to upload, so copy-pasting here instead. Github does some odd things for the formatting... This is a much smaller file that produces the same error, than the one I'd like to eventually load.

NAME SETPAR
ROWS
N OBJ
E c1
E c2
COLUMNS
INT1 'MARKER' 'INTORG'
x1 OBJ 1
x1 c1 1
x2 OBJ 1
x2 c1 1
x3 OBJ 1
x3 c1 1
x4 OBJ 1
x4 c1 1
x5 OBJ 1
x5 c1 1
x6 OBJ 1
x6 c2 1
x7 OBJ 1
x7 c2 1
x8 OBJ 1
x8 c2 1
x9 OBJ 1
x9 c2 1
x10 OBJ 1
x10 c2 1

INT1END 'MARKER' 'INTEND'
RHS
RHS1 c1 1
RHS1 c2 1
ENDATA

Here's the code I use. The attributes that get printed are all 0, as if nothing was loaded from the file. Also, I've noted that in examples "from mip import *" is used. This is not good python programming as we don't know what is loaded by "*" and should be avoided. It would be better to offer a standard like "import mip" since then when functions are called such as "mip.Model()" we know exactly where Model came from.

`# import mip
from mip import *

file_dir = '/my/file/dir/'
f_name = 'testsetpartition.mps'

m = Model()
m.read(file_dir+f_name)

print("Model name:", m.name)
print("Number of variables (columns):", m.num_cols)
print("Number of rows:", m.num_rows)
print("Number of nz:", m.num_nz)
print("Number of :", m.num_int)`

**Expected behavior**
I expected to be able to load the model and so m.numcols, for example should return 10.

**Desktop (please complete the following information):**
- Operating System, version: Windows 10, version 1809
- Python version: 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)]
- Python-MIP version (we recommend you to test with the latest version): 1.10.0

**Additional context**
I just installed this today. This is the first time I'm attempting to use python mip.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.