Question

Hi i formulated a linear programing problem using java

and i want to send it to be solved by lpsolve without the need to create each constraint seperatlly.

i want to send the entire block (which if i insert it to the ide works well) and get a result

so basically instead of using something like

problem.strAddConstraint("", LpSolve.EQ, 9);
problem.strAddConstraint("", LpSolve.LE, 5);

i want to just send as one string

min: 0*x11 + 0*x12 + 0*x13

x11 + x12 + x13= 9;
x12 + x12<5;

can it be done if so how?

Was it helpful?

Solution

LpSolve supports LP files as well as MPS files. Everything is thoroughly detailed in the API documentation (see http://lpsolve.sourceforge.net/5.5/).

You can do your job like this in java :

lp = LpSolve.readLP("model.lp", NORMAL, "test model");
LpSolve.solve(lp)

What is sad with file based approaches is that you will not be able to use warm start features. I would not suggest you to use such approach if you want to optimize successive similar problems.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top