coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
516 stars 90 forks source link

Parse LP formulation from string #217

Closed mhechthz closed 2 years ago

mhechthz commented 2 years ago

For a project I need to solve lp formulations coming from clients. I want to avoid storing the formulation in a file to get it parsed via model.read("xxx.lp"). Is it possible to hand over just a string containing the lp formulation, e.g. like model.parseLP(myLpFormulationString)?

Sorry, this is not an issue but a question or feature request. Didn't find the reight place for it.

jurasofish commented 2 years ago

Looking at the code, it looks non-trivial to implement reading lp from a string since python-mip simply passes the file path to CBC.

Your easiest solution will probably be to save the lp data to a temporary file and then read it in (if that's possible in your situation)

h-g-s commented 2 years ago

Yes, I don’t think this would be simple, as it would require some integration with the procedures implemented in CoinUtils to parse the LPs. CoinUtils, to the best of my knowledge, does not have a C API.  

From: Michael Jurasovic @.> Reply-To: coin-or/python-mip @.> Date: Thursday, November 18, 2021 at 2:33 PM To: coin-or/python-mip @.> Cc: Subscribed @.> Subject: Re: [coin-or/python-mip] Parse LP formulation from string (Issue #217)

Looking at the code, it looks non-trivial to implement reading lp from a string since python-mip simply passes the file path to CBC.

Your easiest solution will probably be to save the lp data to a temporary file and then read it in (if that's possible in your situation)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mhechthz commented 2 years ago

Yes, saving a temporary file would be the standard solution, but it is definitely not "beautiful". So I didn't want to miss to ask for this. If it is not or only difficult to solve, I go with the standard.

Thank You.