What is the best practice to construct and read LP solve matrix equations?

62 views
Skip to first unread message

J J

unread,
Jun 15, 2024, 3:30:50 AM6/15/24
to lp_solve

Hello to all. I Try to use Lpsolve from java via lpsolve Api. I read lp solve help and found an example to construct simplest LP problem like:

// Create a problem with 4 variables and 0 constraints

      LpSolve solver = LpSolve.makeLp(0, 4);

       // add constraints

      solver.strAddConstraint("3 2 2 1", LpSolve.LE, 4);

      solver.strAddConstraint("0 4 3 1", LpSolve.GE, 3);

       // set objective function

      solver.strSetObjFn("2 3 -2 3");

 

But it seems to me that this way is too complex because I don’t see variables names and I need to construct long array zero vectors and add to them variable coefficients. For example, for one binary variable I need to construct a long array, then found binary variable array position and then change this element to one then convert this array to String line with spaces and add it to solver Constraint.

Do you have any practice experience of simple constructing LP solve matrix from program code?

Reply all
Reply to author
Forward
0 new messages