Forum Discussion
FICO
4 years agoCommunity Manager
Reading problem from .lp file into Julia
I'm reading a problem from .lp into Julia. I've tried various xpress.optimizer params - the problem is infeasible. The reason is b/c the model isn't read exactly as it's defined in the .lp file - some constraints get modified. I've tried enforcing LP format when reading .lp file using:
model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_LP)
MOI.read_from_file(model, probPath)
but then set_optimizer doesn't like that model as a parameter....so that the code doesn’t run:
set_optimizer(model, ()->Xpress.Optimizer(DEFAULTALG = 1, PRESOLVE = 1, logfiset_optimizerle = "lp.log")) - and i've tried different options for the optimizer...
Appreciate experts help!!!
8 Replies
- FICOCommunity Manager
Hi Marina,
would it be possible to share an instance where this happens so that we can check whether this happens on the Julia side (I assume MathOptInterfaceXpress.jl?) or on the Xpress side, either publicly here or privately via email?
- FICOCommunity Manager
Thank you so much, Tristan, for such a quick response. Could you please provide me that private email address? I'll double check with my manager if it's ok to share our simple .lp problem (pretty sure it is, but just in case...).
- FICOCommunity Manager
What happens if you try to solve this LP file using the console optimizer (bin/optimizer.exe on Windows, bin/optimizer on other platforms)? Does it claim infeasible as well?
- FICOCommunity Manager
the problem is perfectly feasible when solved directly in xpress IVE or C# or Python. The issue is with Julia reading the original lp and not preserving constraint rows. I've written the model from Julia back into an lp file - and we've compared the two. Also the lp written back out from Julia is infeasible in IVE.
- FICOCommunity Manager
This seems to be a problem with Julia rather than Xpress. I have tried the following with the attached model file (which is aflow30a from miplib):
using MathOptInterface const MOI = MathOptInterface m = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_LP) MOI.read_from_file(m, "model.lp") print(m)This does not involve any Xpress but already the model looks wrong when printed. For example, the output contains line
0.0 + 1.0 x842 <= 0.0which effectively fixes variable x842. As in your case, trying to solve that model then results in an answer of infeasible.
So it looks like the problem is somewhere in Julia's LP reader and maybe you should take this up with general Julia support.
On the other hand, this works for me:
using Xpress, JuMP model = read_from_file("aflow30a.mps") set_optimizer(model, ()->Xpress.Optimizer(DEFAULTALG = 1, logfile = "lp.log")) optimize!(model)So the MPS reader seems ok at first glance. In order to work around the problem in Julia's LP reader you could create the model as MPS or convert from LP to MPS using the console optimizer (using "readprob" and "writeprob")?
- FICOCommunity Manager
While Julia developers are aware of the bug in MathOptInterface and seem to be working on it - I've got another temporary workaround.
Julia developer Jose Lara suggested to call xpress api directly and once I’ve figured out how to set the logger – to make sure it solves indeed – the following code works with LP!!!
prob = Xpress.XpressProblem()
Xpress.readprob(prob, probPath, "")
Xpress.setlogfile(prob, "lp.log")
Xpress.lpoptimize(prob, "")
But as Daniel Junglas pointed out there are some limitations: LP reader directly under Xpress api does not support indicator constraints, for example.
- FICOCommunity Manager
The limitations are the other way around, if you use the Xpress LP reader you will get the full functionality while the LP reader within the MathOptInterface may not support everything that is supported within Xpress (like, for example, indicators).
- FICOCommunity Manager
Good to know, Tristan!!! And for the purpose of what i needed to be achieved - i got that achieved!!! Thank you for the expert help and guidance!!!
Related Content
Related Content
Problem with reading from an Excel file
I tried to read data from an Excel file into Xpress IVE. However, I get the following error message: "Mosel: E-22: I cannot open file `mmsheet.excel:data.xlsx' for reading (Invalid class string )." ...4 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread4Views0likes2CommentsReading CSV files
I'm not quite sure what it is that I'm doing wrong here, but I've been getting "SHEET: Wrong number of columns (req:3 found:2)" whenever I try to load data from a csv/xlsx file. To elaborate upon t...6 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread6Views0likes2Comments