Overview

Introduces classes to support models for CPLEX in Java applications.

An optimization problem is represented by a set of interconnected modeling objects in an instance of IloCplex or IloCplexModeler. Modeling objects in Concert Technology are objects of type IloNumVar and its extensions, or IloAddable and its extensions. Since these are Java interfaces and not classes, objects of these types cannot be created explicitly. Rather, modeling objects are created using methods of an instance of IloModeler or one of its extensions, such as IloMPModeler or IloCPModeler.

Note:

The class IloCplex extends IloCplexModeler. All the modeling methods in IloCplex derive from IloCplexModeler. IloCplex implements the solving methods.

The class IloCplexModeler, which implements IloMPModeler, makes it possible for a user to build models in a Java application as pure Java objects, without using the class IloCplex.

In particular, a model built with IloCplexModeler using no instance of IloCplex does not require loading of the CPLEX.dll nor any shared library.

Furthermore, IloCplexModeler is serializable. For example, a user may develop a pure Java application that builds a model with IloCplexModeler and sends the model and modeling objects off to an optimization server that uses IloCplex.

The example CplexServer.java shows you how to write an optimization server that accepts pure Java model taking advantage of the class IloCplexModeler in a native J2EE client application.

This discussion concentrates on IloModeler and IloMPModeler because the classes IloCplex and IloCplexModeler implement these interfaces and thus inherit their methods. To create a new modeling object, you must first create the IloModeler which will be used to create the modeling object. For the discussion here, the model will be an instance of IloCplex, and it is created like this:


IloCplex cplex = new IloCplex();

Since class IloCplex implements IloMPModeler (and thus its parent interface IloModeler ) all methods from IloMPModeler and IloModeler can be used for building a model. IloModeler defines the methods to:

  • create modeling variables of type integer, floating-point, or Boolean;

  • construct simple expressions using modeling variables;

  • create objective functions; and

  • create ranged constraints, that is, constraints of the form:

    
    lowerbound ≤ expression ≤ upperbound
     
    
    

Models that consist only of such constructs can be built and solved with any optimizer implementing the IloModeler interface, including IloCplex, which implements the IloMPModeler extension.

The IloMPModeler interface extends IloModeler by adding functionality specific to mathematical programming applications. This functionality includes these additional modeling object types:

  • semi-continuous variables;

  • special ordered sets; and

  • piecewise linear functions.

It also includes these modeling features to support specific needs:

  • change of type for previously declared variables;

  • modeling by column; and

  • general manipulations of model entities.

Table 1 summarizes those observations about the interfaces of CPLEX with Concert Technology for Java users.
Table 1. Modeling classes of CPLEX with Concert Technology for Java users
To Model This Use an Object of This Class or Interface
variable IloNumVar and its extensions IloIntVar and IloSemiContVar
range constraint IloRange with (piecewise) linear or quadratic expressions
other relational constraint IloConstraint of the form expr1 relation expr2, where both expressions are linear or quadratic and may optionally contain piecewise linear terms.
LP matrix IloLPMatrix
linear or quadratic objective IloObjective with (piecewise) linear or quadratic expressions
variable type-conversion IloConversion
special ordered set IloSOS1 or IloSOS2
logical constraints IloOr, IloAnd, and methods such as not

For an explanation of quadratic constraints, see Solving problems with quadratic constraints (QCP). For more information about quadratic objective functions, see Solving problems with a quadratic objective (QP). For examples of piecewise linear constraints, see Using piecewise linear functions in optimization: a transport example. For a description of special ordered sets, see Using special ordered sets (SOS). For more about logical constraints, see Logical constraints in optimization.