How to quick solve LP by LPSOLVE from JAVA

99 views
Skip to first unread message

J J

unread,
Feb 6, 2024, 4:22:59 AMFeb 6
to lp_solve
HEllo to all! 
I have a LP problem witch is constructing from JAVA code. For my conveniences I create LP directly as LP file in my code. To create LP file, I do not use a matrix, but directly write linear equations into a text variable, which then save to  LP file (this is more convenient for me of later checking the spelling).

But when using this method, I have to first write the LP to a file via FileWriter writer, and then comb it through lpSolve solver = lpSolve.readLp(.... and actually solve via solver.solve();
Or maybe there is a way to solve this system of equations without writing and then reading from a file (to make the process a little faster)?

Mark Streich

unread,
Feb 6, 2024, 9:09:59 AMFeb 6
to lp_solve
You can directly call the API to set up the model and solve it.  You don't get your text file for debugging, but you get a fast solution.

As I wasn't sure which solver I was going to end up using, I also use JavaILP (https://javailp.sourceforge.net/) to build my model, and then it has connections/conversions to various LP solvers, including LPSolve.  

J J

unread,
Feb 7, 2024, 1:01:13 AMFeb 7
to lp_solve
Thanks! But my general question was about the name of  LPSolveAPI function of which helps me to solve my LP problem  without waiting and reading text file.
I see LPSolve examples in help file when I construct my equation system by matrix functions, and I ask how to solve It when I construct My system direct in *.lp file format without writing and reading it. Or it's impossible.

Java ILP  is an interesting jar. I'll watch it. Thanks

вторник, 6 февраля 2024 г. в 17:09:59 UTC+3, str...@gmail.com:

Tim Chippington Derrick

unread,
Feb 7, 2024, 4:30:08 AMFeb 7
to J J, lp_solve
Just to add my perspective. I have been using a variety of LP and MILP solvers for almost 30 years, and almost always create the model directly into the solver using one of the APIs from Java, C# or C++
I have often used some export functions from some of those solvers to output a copy of the model as an LP file, but that is just for checking or debugging what I have put into the solver using an API.
I definitely would not ever construct my model as a text file (in LP or MPS format or whatever) or even in a (large) text string structure to read into a solver. It would seem crazy to render the structures of the model into a text form, and then make the solver parse that text to recover the model again.
By far the simplest and most efficient approach is to directly enter all your variables and constraints directly into the solver using one of the APIs.

Tim
Tim Chippington Derrick
Tel: +44 01276 508949
Mob: +44 07971 997948


--
You received this message because you are subscribed to the Google Groups "lp_solve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lp_solve+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lp_solve/743eb2ee-1a9e-4b64-adc9-6cd5dc64c940n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

J J

unread,
Feb 7, 2024, 4:40:59 AMFeb 7
to lp_solve
Thanks! I understand you 

среда, 7 февраля 2024 г. в 12:30:08 UTC+3, Tim Chippington Derrick:

Sanjay Banerji

unread,
Feb 7, 2024, 4:54:59 AMFeb 7
to lp_s...@googlegroups.com
A wise choice in case you are good at Java, C# or C++.  Python.  Even perhaps C.

However, not a solution if you are not proficient in those languages.

With feelings of regret.

Sanjay Banerji


------ Original Message ------
From "Tim Chippington Derrick" <t...@chippingtonderrick.co.uk>
Cc "lp_solve" <lp_s...@googlegroups.com>
Date 07-02-2024 14:59:51
Subject Re: How to quick solve LP by LPSOLVE from JAVA

Reply all
Reply to author
Forward
0 new messages