9
$\begingroup$

I would like to solve mixed integer programs in Java. I need an approach that relies purely on software that is free (not only for academic use, but also for people outside academia).

What would be the best approach for that?

$\endgroup$
2
  • $\begingroup$ Get a lot of money, then hire a team from Gurobi or CPLEX to build a MIP solver under JAVA, and release it to the world as free software. Then you will have a top performing MIP solver which is free for everyone. $\endgroup$ Commented Jun 20, 2019 at 9:04
  • $\begingroup$ @MarkL.Stone Your comment was probably just a joke, but to make this point clear: I do not expect a free solver to have the performance of CPLEX or Gurobi, not even to come close to one of those. I just want to solve MIPs in Java. If CPLEX is 100x faster, this is fine for me. $\endgroup$ Commented Jun 20, 2019 at 14:02

4 Answers 4

9
$\begingroup$

Of the open source LP and MILP solvers, I would recommend investigating the COIN-OR based solvers CLP and CBC.

These are C++ based libraries, though work has been done to make them more accessible from Java. See

https://spartanideas.msu.edu/2016/06/01/using-clp-with-java/

for example.

$\endgroup$
2
5
$\begingroup$

Timefold (previous OptaPlanner) is an open source constraint solver in Java. It's:

  • Used across the globe in governments, Fortune 500 and other companies, startups, nonprofits, ...
  • 100% pure java - just a jar
  • compatible with Kotlin too
  • open source (Apache License), so you can modify/redistribute without fees

That being said, it has a OO/FP approach, which is very different if you're coming from a traditional MIP model approach. But it pays off if you need to scale to bigger datasets and want to integrate with other Java technologies.

Other open source alternatives in Java/JVM include Choco, Oscar (= scala), the COIN-OR solvers, eclipse, jacop, ... IIRC

$\endgroup$
3
  • 1
    $\begingroup$ Certainly interesting. $\endgroup$ Commented Jun 21, 2019 at 11:05
  • $\begingroup$ It appears that OptaPlanner is not guaranteed to produce optimal solutions, but is a heuristic that hopes to generate "good" solutions, but "how good" is generally unknown. $\endgroup$ Commented Feb 17 at 5:34
  • $\begingroup$ True. Metaheuristics are not guaranteed to deliver the optimal solution - and on small datasets that is sometimes a problem (in a vanilla implementations). That being said, on large datasets (for example a VRP with 5k visits), metaheuristics consistently deliver better results than other algorithms in reasonable calculation time (which can be anything from a minute to a week), as shown in production and also by various academic competitions. $\endgroup$ Commented Feb 19 at 7:37
2
$\begingroup$

The JOpt Mixed Integer Program Optimization Package Wrapper:

What is JOpt?

JOpt is an open source Java wrapper that provides objects like Variable, Constraint, and Term and lets you express your linear or mixed integer programs in a natural manner, while remaining agnostic to the details of the solver backend. JOpt is not a solver. Rather, it requires a solver such as CPlex or the free LPSolve to operate.

It is open-source and allows you to do the following.

Why JOpt?

  • You do linear/quadratic or mixed integer programming, but want to think in terms of simple variables and constraints, not a complex solver-specific api.

  • You want to automatically distribute and load balance your problems to one or more solver machines (when compiled for this support).

The latest version for CPLEX 12 was released in 2017 and can be accessed here.


For a software that also relies on a free solver, try Java ILP which can be used with GLPK.

$\endgroup$
3
  • $\begingroup$ Thank you for the interesting hint, but unfortunately, JOpt will not help me without a free solver. $\endgroup$ Commented Jun 19, 2019 at 19:06
  • $\begingroup$ @J.FabianMeier I have added another one at the end. What do you think? $\endgroup$
    – TheSimpliFire
    Commented Jun 19, 2019 at 19:11
  • $\begingroup$ Thank you, so you would recommend Java ILP with GLPK? Or is JOpt still on the table? Maybe you could edit out the "non-free" part of your answer, then I could follow it better. $\endgroup$ Commented Jun 19, 2019 at 19:46
1
$\begingroup$

I once made CBC work from JAVA with Google's OR-Tools. From the "free" category, it should also allow to use GLPK.

$\endgroup$
1
  • 1
    $\begingroup$ Please consider Provide context for links for answers that are little more than just a link. This will make your answer much more valuable for future visitors, especially as links rot. $\endgroup$ Commented Jun 21, 2019 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.