Hello, I have a huge stochastic optimization model and JuMP is not fast enough to deal with it. I want to write the lp model in a file and then solve it.
Does JuMP have a method like read_LP(“file.lp”)? Or is there a better approach to my problem?
A quick search of the documentation doesn’t show a readLP function. JuMP is primarily a domain-specific language for defining an optimization problem. If you are already writing the relevant .lp file, it would probably be more efficient to feed this directly into the solver and then read the solution into Julia. I’ve gone full-circle before, specifying a linear program in JuMP, using writeLP to get the .lp file, then solving using CPLEX on a computer that didn’t have Julia installed, and then reading in the resulting .sol, which is just an XML file for postprocessing and visualization.
The fowllowing should do the trick. Though there is no guarantee that it will be faster than creating the model in JuMP.
using CPLEX
import MathProgBase
const MPB=MathProgBase # shorthand for long module name
"This function takes an optional solver and loades a model from an LP file "
function loadLP(filename,solver=CplexSolver())
model=buildlp([-1,0],[2 1],'<',1.5, solver) # create dummy model with correct solver
MPB.loadproblem!(model,filename) # load what we actually want
return model
end
lp = loadLP("file.lp")
MPB.optimize!(lp)
I’m trying to do the same thing of reading LP files. Thanks to your posts, I can read an LP file as a CplexMathProgModel. However, I would like to have a dictionary that maps the variables in the CplexMathProgModel to the variables in the LP file. I don’t think the variables in CplexMathProgModel have names. I wonder if you know some workaround that can get this done.