Read LP files


#1

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?

Thanks a lot


#2

Without looking at the docs: I’m guessing that JuMP has no such method, but the individual solver backends probably have it.


#3

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.


#4

Try building your model without JuMP.

Use linprog() method

http://mathprogbasejl.readthedocs.io/en/latest/linprog.html?highlight=MathProgBase%20


#5

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)

#6

The correct way to generate an empty MPB model in this context is MPB.LinearQuadraticModel(solver).