Linear Programming - loading LP or MPS file?

122 views
Skip to first unread message

Craig E Larson

unread,
Sep 1, 2015, 10:00:39 AM9/1/15
to sage-support
I see that there are methods for saving a LP as and LP or MPS file in Sage. Is it possible to *load* an LP from one of these file types? The online help that I've found doesn't mention this or give examples of how to do it.

Thanks!

Craig

Dima Pasechnik

unread,
Sep 1, 2015, 12:49:55 PM9/1/15
to sage-support


On Tuesday, 1 September 2015 07:00:39 UTC-7, Craig E Larson wrote:
I see that there are methods for saving a LP as and LP or MPS file in Sage. Is it possible to *load* an LP from one of these file types? The online help that I've found doesn't mention this or give examples of how to do it.

Not that I know. Write one, it will be a valuable addition to Sage...
(There should be Python code out there on the next that can be adapted, surely...)

Dima

Thanks!

Craig

Stephen Hartke

unread,
Sep 1, 2015, 5:08:01 PM9/1/15
to sage-s...@googlegroups.com
> On Tuesday, 1 September 2015 07:00:39 UTC-7, Craig E Larson wrote:
>> I see that there are methods for saving a LP as and LP or MPS file in
>> Sage. Is it possible to *load* an LP from one of these file types? The
>> online help that I've found doesn't mention this or give examples of how to
>> do it.

On Tue, Sep 1, 2015 at 10:49 AM, Dima Pasechnik <dim...@gmail.com> wrote:
> Not that I know. Write one, it will be a valuable addition to Sage...
> (There should be Python code out there on the next that can be adapted, surely...)

Most (all?) of the LP/IP libraries have functions for reading in LP
and MPS files, so it might be simpler to make Python wrappers around
that function in each of the backends.

Best wishes,
Stephen

Dima Pasechnik

unread,
Sep 1, 2015, 11:22:05 PM9/1/15
to sage-support

How would it solve the issue of communicating with the frontend?
 

Best wishes,
Stephen

Nathann Cohen

unread,
Sep 2, 2015, 1:55:39 AM9/2/15
to Sage Support
> How would it solve the issue of communicating with the frontend?

For this I expect that we should be able to write a function
LP_from_file that returns both a MixedIntegerLinearProgram object and
a MIPVariable object, and that we will have to hack the MIPVariable
object a bit so that it matches the right variables in the MILP
object. Should not be much more involved than just force the integer
ID associated with a label.

Nathann

Dima Pasechnik

unread,
Sep 2, 2015, 1:59:26 AM9/2/15
to sage-support
isn't it a bit too much code to have this for each backend, rather than just something that communicates with the
frontend only?

 
Nathann

Nathann Cohen

unread,
Sep 2, 2015, 2:05:44 AM9/2/15
to Sage Support
> isn't it a bit too much code to have this for each backend, rather than just
> something that communicates with the
> frontend only?

Indeed. Were you thinking of something like that?

1) Use GLPK to load a LP/MPS from a file
2) Read the MILP at Python-level
3) Use the info to create a new MILP object, and return it along with
the MIPVariable

Nathann

Dima Pasechnik

unread,
Sep 2, 2015, 1:40:24 PM9/2/15
to sage-support

It seems that 3) should disregard MIPVariable. Otherwise, how do you use a
backend different from GLPK?

I think something like "from_file=..." argument in MixedIntegerLinearProgram() should be implemented,
and it ought to be compatible with "solver=...".
Behind the curtains it can talk to GLPK, no problem...

Dima

Nathann
Reply all
Reply to author
Forward
0 new messages