Create an .lp file from an AMPL object after data has been loaded
pjcpjc opened this issue · comments
This issue is very similar to #7. In fact, once #7 is complete then there is a "not entirely Python" path for creating an .lp file. I.e.
- Create a .dat, .mod file pair. (The former requires #7).
- Create the .lp file using AMPL scripting. (I.e.
ampl: option gurobi_auxfiles rc; ampl: option gurobi_options "writeprob=test_gurobi.lp"; ampl: solve;
).
However, this path requires opening an ampl prompt, which might be hard to do from a pure Python platform like Opalytics. To fully enable .lp functionality, it would be nice if the amplpy.AMPL
object provided a routine similar to the one being created for #7 to create a .lp file.
This issue is not very high priority, and #7 is clearly more important.
Currently AMPL only supports the generation of MPS files. In https://github.com/ampl/amplpy/blob/testing/amplpy/ampl.py#L947 there is a method AMPL._exportGurobiModel which starts by exporting an MPS model. Would that help?
That method creates a gurobipy model, which I believe should allow you to do the following:
model = ampl._exportGurobiModel()
model.write('model.lp')
Excellent suggestion, I love this kind of thinking!
If #9 is closed then we can close this.
Alternately, if its easier to make the .lp
file (with names) without invoking gurobipy
, then just do that.
Closed because #9 looks good.