Solver4J is a free library implemented in pure java programming language that addresses the solution of minimization problems with both equality and inequality constraints:

minimize x f 0 (x) s.t.
f i (x) ≤ 0, i=1,...,m
Ax = b,

where f 0 ,...,f m : R nR are convex and twice continuously differentiable multivariate real functions, and A ∈ R pXn with rank A = p < n.
This is given the name of convex optimization and, for example, LP, QP, QCQP, SOCP, SDP are special cases of it.

Solver4J is thread-safe and can be used in both standalone applications and J2EE environments. One of its primary goals is to fill the gap of a pure-Java optimizer, as many market libraries run in an external process, which is not always feasible, especially when deploying in a J2EE server environment. Its internal linear algebra is based on the open-source libraries Commons Math and Colt , while its theoretical foundation is based on the work "Convex Optimization" by S. Boyd and L. Vandenberghe.

The use of Commons Math and Colt is restricted to the internal level of Solver4J, so you, as a user, don't need to learn these APIs to adopt it. Client code can be written using any linear algebra API. In the "test" source folder, you can find code examples with Commons Math and Colt , as well as examples using only the standard JSE API.


Usage

There are two ways of solving a given convex optimization problem:

  1. Use the class Solver4J : it works with every kind of problem, and internally it switches over the optimizer that best addresses the structure of that problem.
  2. Use the optimizer that's appropriate for the type of the problem. Based on the work of S.Boyd and L.Vandenberghe, "Convex Optimization" , the library implements the following optimizers that you can directly invoke (refer to "Convex Optimization" for a thorough explanation):

You compose the problem as an instance of OptimizationRequest , after that you call the optimize method of the optimizer in order to get an OptimizationResponse .\ In the "test" source folder you can find source code examples for every kind of optimizers.
Please note that Solver4J is a general purpose library, in the sense that it does not exploit any special structure of the problem (at least at a very high level with an appropriate choice of the class for the functions involved): in many cases it might be necessary to deep leverage the structure of the problem in order to increase the precision and the speed of the solution. You can do this via an ad-hoc extension of the library classes, or feel free to contact us at Solver4J Team


Algorithms

Depending on the type of the (convex) problem it has to be solved, you have to choose the right method of solution. Solver4J comes with a complete set of algorithms that can be used to address a given convex minimization: you can engage directly one of them (see "Convex Optimization" for an in-depth reference), or simply invoke Solver4J that will take the choice for you. As regards the two proposed interior-point methods, they are mutually exclusives: default is the primal-dual method, but you can freely specify the barrier method in your optimization request.


Problems

The fields of applications of convex optimization are really vaste. Depending on the type of problem it has to be solved, convex optimizations can be categorized in a series of typologies, we just summarize some of them:


Maven

Follow these steps in order to use Solver4j into your maven project:

1. Add the solver4j Nexus repository

Insert this inside your pom.xml:

				<repositories>
				  <repository>
				    <id>solver4j-nexus</id>
				    <url>https://repo.solver4j.com/repository/maven-releases/</url>
				  </repository>
				</repositories>
				  

2. Declare the dependency

Then add the dependency to your project:

				<dependency>
				  <groupId>com.solver4j</groupId>
				  <artifactId>solver4j</artifactId>
				  <version>2.0.10</version>
				</dependency>
				  

Citation

Please use the Harvard format for citations:
Waverly, O. (2025) 'Solver4j - The Java Solver', Solver4j, <Day Month>. Available at: https://www.solver4j.com (Accessed: <Day Month Year>).

Back to top

Reflow Maven skin maintained by Olivier Lamy.