15

Does anyone know of such a library that performs mathematical optimization (linear programming, convex optimization, or more general types of problems)? I'm looking for something like MATLAB, but with the ability to handle larger problems. Do I have to write my own implementations, or buy one of those commercial products (CPLEX and the like)?

David Nehme
  • 20,665
  • 7
  • 73
  • 114
Zach Scrivena
  • 27,585
  • 10
  • 60
  • 72

7 Answers7

11

A good answer is dependent on what you mean by "convex" and "more general" If you are trying to solve large or challenging linear or convex-quadratic optimization problems (especially with a discrete component to them), then it's hard to beat the main commercial solvers, gurobi, cplex and Dash unless money is a big issue for you. They all have clean JNI interfaces and are available on most major platforms.

The coin-or project has several optimizers and have a project for JNI interface. It is totally free (EPL license), but will take more work to set-up and probably not give you the same performance.

David Nehme
  • 20,665
  • 7
  • 73
  • 114
5

There is a linear optimization tool called lpsolve. It's written in C (I think) but comes with a Java/JNI wrapper (API is not very OO but it does the job). It's pretty easy to use and I have had it running quite happily and stably in a live system for the last year.

oxbow_lakes
  • 129,207
  • 53
  • 306
  • 443
2

OptaPlanner (Java, open source, ASL) can handle large problems and doesn't have an constraint type limitations (such as linear vs convex).

Geoffrey De Smet
  • 22,431
  • 8
  • 59
  • 106
  • These concepts are gaining lot of traction in the recent days. It would be great to know if there are there any new set of libraries or APIs in this area in java. – Gana Jun 13 '17 at 16:44
  • Yes, there's Choco, jacop, jsprit, etc. OptaPlanner is by far the most downloaded one afaik (I am biased though). The recently released version 7.0 targets Java 8 & 9 (lamba's etc). – Geoffrey De Smet Jun 15 '17 at 17:42
  • Do OptaPlanner guarantee optimality? – renan-eccel Aug 26 '20 at 13:47
  • No (unless branch and bound is used), but it finds the best solution (a near optimal one) **in the time you have available** (more is better), especially when scaling out. An optimal solution that takes years to find is useless. Perfect is the enemy of good. – Geoffrey De Smet Aug 26 '20 at 14:58
2

You may try JOptimizer, open source and suitable for general convex optimization problems (linear programming, quadratic programming, qcqp, cone programming, semidefinite programming, ect

este
  • 21
  • 1
1

You may want to look at JScience, it looks pretty complete. (Mathematical structures, linear algebra solving, etc.)

Ryan
  • 13,976
  • 6
  • 46
  • 49
1

IPOPT has an interface for Java. You may also be able to adapt the APMonitor modeling language for Java. I develop this platform so I'll be glad to work with someone if they'd like to create a new interface to Java. It already has a Python API and MATLAB interface and includes solvers such as IPOPT, APOPT, BPOPT, and others that can handle large-scale systems.

John Hedengren
  • 6,310
  • 12
  • 20
0

Look into AMPL. The basic edition is free, but it costs money for larger problems. You don't pay for the language; you pay for solvers. It is also possible to upload your code and have it run on their servers.

Scottie T
  • 10,481
  • 9
  • 43
  • 59