Limitations of the language

Explains how limitations of OPL lead to developing external functions.

The purpose of external functions is to provide alternatives to some limitations of OPL as a language.

Note:
  • Calling external functions is not possible if the application is statically linked with the OPL libraries (like oplrunsample). This is because the Java™ OPL library uses the shared library version of OPL (oplxx.dll/.so) which cannot be mixed with the static version. You can use an external call to Java in the CPLEX® Studio IDE, in oplrun, and in custom OPL or ODM Enterprise applications launched from Java.

The Optimization Programming Language (OPL) is a powerful language to write optimization models. It offers powerful aggregate constructs and slicing filters to describe complex problems in a compact form. Moreover, because it supports JavaScript, OPL enables you to manipulate complex data (preprocessing), results (postprocessing), and models (flow control). However, IBM® ILOG® Script is not as powerful, complete, and efficient as a programming language. As its purpose is to be simple and accessible for non-programmers, more complex software engineering parts are not supported and should be kept outside of OPL.

However, OPL offers a way to interact with external code written in other programming languages. This external functionality can be plugged into OPL in an easy to use and reuse manner.

This feature allows you to:

  • write a complex dedicated OR algorithm (such as a shortest path or flow algorithm) to be used as one step of a decomposed application

  • connect your OPL model or data to other external tools such as tools for statistical analysis, to modify your input data or report your results

  • connect your OPL data to other sources or destinations that are currently not supported as default sources by the language

  • connect CPLEX callbacks to your search (not described in this tutorial)

All this is possible by calling external functions from OPL. In OPL 5.1 and later, you can call functions written in the Java programming language. Note that the Java language itself also offers ways to interact with other programming languages.