Overview of the Java interface

Presents a high-level overview of the OPL Java interface.

The Java interface offers basically the same functionality as the C++ one.

The Java API is split into several packages:

  • The ilog.concert package contains the Concert modeling API, for modifying models.

  • The ilog.cp package contains the CP Optimizer control API, for controlling the solving process of constraint programming models.

  • The ilog.cplex package contains the CPLEX control API, for controlling the solving process of mathematical programming models.

  • The ilog.opl package contains the OPL control API, for loading and accessing models.

The Java API is written as a JNI wrapper on the equivalent C++ libraries; it offers the same functionality as the C++ API.

Each call to a method of the API goes through a wrapping layer. This may result in a slight performance overhead while the model is created, compared to using the C++ API, depending on the number of API function calls. Since you call only few API functions to load and solve your model, the overhead is negligible in usual cases, but it may become important if you use the low-level Concert, CP Optimizer, or CPLEX API for a complete model creation (for example, constructing a matrix line by line using IloNumExpr APIs or adding IloConstraint objects one by one to an IloModel using the API). It is therefore recommended to use the OPL language to model your problems whenever possible, and use only the low-level Concert APIs for the parts that need it (runtime additions, etc.).

Once created, the model is still solved fully in C++, so there is no loss of performance when solving models, whatever language you choose.