## JOM (Java Optimization Modeler)JOM (Java Optimization Modeler) is a free and open-source Java library targeted to allowing Java programs modeling and solving optimization problems, defining their input parameters, decision variables, objective function, and constraints. Mathematical expressions combining decision variables, constant parameters, operators and functions, are defined using a simple MATLAB-like syntax. JOM allows handling multidimensional arrays of variables and constants. This enables, for instance, defining arrays of constraints in a single line of code. To solve the problem, JOM can interface with installed solvers. Current JOM version can interface with MIPCL (free), GLPK (free), CPLEX (commercial) and XPRESS (commercial) solvers for mixed integer linear problems, and IPOPT (free) for non-linear differentiable problems. Let's see an example to show JOM simplicity. We want to solve a version of the 3-dimensional matching problem (e.g. see). We have three sets \( X, Y, Z \) of \( N \) elements each. We have to create tuples of three elements \( (i,j,k) \) where \( i \in X, j \in Y, k \in Z \), so that no element appears in more than one tuple. Each tuple \( (i,j,k) \) has assigned a benefit given by \( c_{ijk} \). The target is to find the set of tuples that are a matching (no element appears in more than one tuple), and have the maximum possible benefit. The formulation solving this problem is:
\( examples package of the release).
Example
import com.jom.DoubleMatrixND; import com.jom.OptimizationProblem; public class WWW_3DimMatching { public static void main(String[] args) { int N = 5; // number of elements in each set /* Create the optimization problem object */ OptimizationProblem op = new OptimizationProblem(); /* Add the decision variables to the problem */ op.addDecisionVariable("x", true, new int[] { N , N , N }, 0, 1); // name, isInteger, size , minValue, maxValue /* Set value for the input parameter c_{ijk} */ op.setInputParameter("c", new DoubleMatrixND(new int [] { N , N , N} , "random")); /* Sets the objective function */ op.setObjectiveFunction("maximize", "sum(x .* c)"); /* Add the constraints */ op.addConstraint(" sum(sum(x,3),2) <= 1"); // for each i \sum_{jk} x_{ijk} <= 1 op.addConstraint(" sum(sum(x,3),1) <= 1"); // for each j \sum_{ik} x_{ijk} <= 1 op.addConstraint(" sum(sum(x,2),1) <= 1"); // for each k \sum_{ij} x_{ijk} <= 1 /* Call the solver to solve the problem */ op.solve("glpk" , "solverLibraryName" , "glpk_4_47"); if (!op.solutionIsOptimal ()) throw new RuntimeException ("An optimal solution was not found"); /* Print the solution */ DoubleMatrixND sol = op.getPrimalSolution("x"); for (int c1 = 0 ; c1 < N ; c1 ++) for (int c2 = 0 ; c2 < N ; c2 ++) for (int c3 = 0 ; c3 < N ; c3 ++) if (sol.get(new int [] { c1 , c2 , c3}) == 1) System.out.println (c1 + " - " + c2 + " - " + c3); } }
JOM has been thought as a tool to assist the teaching and research activities which are focused on optimization, or where optimization problems are solved. Students/researchers can focus on solving optimization problems and analyzing the solutions obtained, getting rid of the burden of interfacing to the solvers, and making use of the flexibility that Java provides to handle the problem data. JOM is just accessed from standard Java programs, calling the methods in the JOM class Other features in JOM are: - In JOM it is possible to define input parameters to the problem, also as multidimensional arrays (with an arbitrary amount of dimensions). The Java class
`DoubleMatrixND`has been created`to easily create and handle these input parameters. The implementation of this class makes use of the multithreaded version of COLT numerical libraries, called Parallel COLT. Both dense and sparse multidimensional arrays can be handled.` -
Expressions combine variables and input parameters using built-in operators and functions, in a MATLAB-like syntax. Common matrix operations (matrix multiplication, submatrix definitions, transposition, sum, substraction, ...) are included, together with element-wise multiplication, division, etc. Some built-in functions are also included like logarithm, square root, trigonometric functions... JOM integrates also some functions quite specific to optimization of communication networks: for instance, the Erlang-B function for calculating blocking probabilities in circuit-switched networks. The set of implemented functions is expected to grow in each JOM release. -
For linear problems, JOM internally translates the constraints into an efficient internal implementation using a sparse representation (an adapted column-compressed form) of the problem constraint matrix. JOM is able to model problems with up to \( 2^{31}-1 \) decision variables and \(2^{31}-1\) constraints. -
For non-linear problems (convex or not), JOM automatically calculates the gradients of the involved expressions and provides this information to IPOPT solver without any intervention from the user. Note that in non-convex problems, IPOPT solver converges to a local optimum, and global optimality is not guaranteed. JOM is able to model non-linear problems with up to \( 2^{31}-1 \) decision variables. Also, for those problems with non-linear constraints, the number of decision variables multiplied by the number of constraints cannot exceed \( 2^{31}-1 \). This limitation appears since the jacobian of the constraint matrix is internally represented using a `DoubleMatrix2D`object of the Parallel COLT library, where the number of rows by columns is limited to \( 2^{31}-1 \). - After the problem is solved, the user has access to the problem primal and dual solution (Lagrange multiplers of the constraints). The solutions are returned in the form of
`DoubleMatrixND`objects of the appropriate size.
And remember that JOM is |