9

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?

J Fabian Meier
  • 1,110
  • 8
  • 17
  • 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. – Mark L. Stone Jun 20 '19 at 09:04
  • @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. – J Fabian Meier Jun 20 '19 at 14:02

4 Answers4

9

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.

Mark H
  • 550
  • 3
  • 11
5

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

Geoffrey De Smet
  • 4,851
  • 10
  • 34
  • 1
    Certainly interesting. – J Fabian Meier Jun 21 '19 at 11:05
  • 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. – Cary Swoveland Feb 17 '24 at 05:34
  • 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. – Geoffrey De Smet Feb 19 '24 at 07:37
2

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.

1

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

swe_vie
  • 11
  • 2