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
or the free LPSolve to operate.
This means that any program written with JOpt
will work for any of serveral solvers used by the end
- 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
- Simple interface
- Agnostic of underlying solver
- Exposes various solver parameters directly
- Sophisticated Threading support
- Support for providing solving hints
- Support for the IIS functionality
useful in debugging
- Support for multiple solutions (solution pools) under CPlex.
- Support for MIQCQP under CPlex
- Client/server support with load balancing (when compiled for it)
- The Gurobi solver has not
currently been integrated, though this would be straightforward to
do (contributions welcome).
All pre-compiled versions, including historical versions are
available here. Documentation for
prior versions is available here
(some of which is still relevant).
Jopt is now housed on Github. The repository can be
found at https://github.com/blubin/jopt.
Download and install the software. You can do this either via
Maven, or simply by downloading and placing the jopt.jar
in your project, then including it in your classpath. You can of
course also obtain the source code from the github repository, but it is possible to use
JOpt directly from the pre-compiled jar file.
For simple examples of how to use JOpt, see:
For more infomration see the package javadoc, available here
More detailed documentation, but generated for prior versions of
the software, is
Some information on specific features is provided in the FAQ below.
JOpt has been used in many projects to date. Of note:
If you use JOpt in a project, please let us know!
Benjamin Lubin is the
primary author of JOpt, and the contact point for JOpt
- Does JOpt support multi-threading?
- Yes, JOpt is intended to be re-entrant. You can solve multiple
concurrent MIPs/LPs in separate threads using JOpt, even
using a single machine. JOpt will maintain of pool of
connections to the underlying solver and reuse these, lowering the
overhead of creating and destroying these connections in every
thread/call. This pool has a maximum size, which controls the
maximum number of concurrent solve calls that will execute
concurrently on the same machine (you can of course use multiple
machines to parallelize beyond this point).
for details. Some solvers, e.g. CPlex, use parallelism intermally
within a single solve. Use of multiple threads can be controlled
For best results, one should pay attention to how many Cores
are being used internally by the solver, and how many solvers are
being run. Solver Threads * Number of concurrent solvers should be
roughly the same as the number of cores in the machine.
- How do I control the solver behavior?
- JOptExposes many of the underyling solver parameters
class. See the documentation for the settings available. Note that
not all underlying parameters are currently made available in the
interface, you can add more using the existing ones as an
- Does JOpt support multiple solutions per solve?
- Yes, via the CPlex SolutionPool infrastructure. See
and related settings in SolveParam.java.
- Does JOpt support CPlex Infeasibility analysis?
- CPlex now includes infeasibility analysis; JOpt can be
configured to exploit this. See
in the Javadoc documentation.
- Can you propose solution values to JOpt to provide a bootstrap/hint of the search?
- CPlex supports this, and JOpt includes API to pass this
information through to CPlex. See
and related functions.
- What is the JOpt load balancer?
- JOpt ships as a single jar file contains both a
server-side component (which runs the actual solver) and a
client-side component (which you integrate with your
program). Jopt actually runs in one of two modes:
- Unified Mode: There is no server, the client API
connects to the underlying solver directly. JOpt is
operating as a thin translation API, providing a clean interface
to the underlying solver. Most users operate in this mode. This
mode is also appropriate if you have very large MIPs/LPs, as it
avoids serialization overhead. You must have a local solver
(e.g. CPlex or LPSolve) to run in this mode.
- Client/Server Mode: A server machine (or several
machines) has the solver software installed. A JOpt Server is
run on each of these machines. A JOpt client, on a separate
machine can request a MIP to be solved on a given server machine.
JOpt also includes a Round-robin load-balancer that can be
configured to spread the load over several machines. Each server
can be solving instances in parallel. While the client server
can be configured over the open internet, doing so may violate
your license agreement for your solver; running the client/server
on your protected local network may resolve this. Be sure
to consult your solver licensing agreement before using
client/server mode. This mode can be very helpful if you
have many compact MIPs you want run on many machines. It may
also be helpful if you want a powerful backend server machine to
solve MIPs for a program running on a laptop development/UI
machine etc. There is a serialization penalty as your MIP gets
moved across the wire to the server machine before execution. If
your MIPs/LPs are small in formulation size (number of
constraints, variables) but long in solve time, this overhead
will be managemable, but it may not be in all cases.
- What is the status of JOpt client/server and load balancer?
- Opt provides a round-robin load balancer. If you solve multiple
concurrent LP/MIPs, and have access to multiple machines with a
solver, JOpt can take advantage of all of your machines.
Communication occurs via standard Java RMI, and requires
compiling using RMIC. The new Maven build process does not
perform RMIC. So you will need to download from source and run
RMIC yourself if you want to use this mode. See
the historical documentation
for further information.