IBM Support

Debugging guide for CPLEX applications that use IBM/ILOG Concert Technology

Question & Answer


Question

Debugging guide for CPLEX applications that use IBM/ILOG Concert Technology

Answer

Here are some debugging tips that may help you correct problems in CPLEX applications that use Concert.





Determine whether the issue involves Concert or the CPLEX Callable Library.
When your program behaves unexpectedly, first try to determine whether the problem really involves Concert, or whether you can reproduce it from within a C program or the CPLEX Interactive Optimizer (also known as the base system). In the latter case, also take a look at the list of general debugging tips for CPLEX in the Programming Considerations section of the CPLEX User's Manual.

Make good use of the example programs that come with the CPLEX distribution.

The CPLEX distribution contains a set of Cand C++ example programs. By using these, you can often determine whether the problem is specific to Concert or not. Also, if you can reproduce unusual behavior in either the original or a slightly modified version of one of these example programs, you have a smaller program with which to work. On the other hand, if you can reproduce the behavior only in a larger, more complex program, focus on the differences between that program and the example program. Try systematically to remove parts of the larger problem until you identify the particular part of the program that causes the problem.


As always, make good use of the debugging tools on your computer.

Tools such as <a href="http://www.ibm.com/software/awdtools/purify/">Purify</a>,
<a href="http://www.parasoft.com">Insure</a>, and BoundsChecker can enable you to identify and resolve problems that might otherwise take weeks to find. Always use these, if available. If not,
check to see whether your compiler includes system calls to check the integrity of the memory heap. If running GNU/Linux, you can also download <a href="http://valgrind.org/">Valgrind</a> for free or make use of the Electric Fence library that comes as part of the operating system. The former is more comprehensive.


As always, enable all possible assert statements.

By default, the NDEBUG macro is off, a setting which means Concert will perform various assertions to trap NULL pointers and other error conditions. When an application is in production mode, you typically want to avoid this overhead by turning these tests off with the -DNDEBUG compiler option. But, only do this at production time; be sure to remove this option whenever you are developing or debugging.


Remember that overloaded operators are functions.

Because overloaded operators in Concert represent mathematical relations used to build expressions and constraints, one can easily forget that, unlike standard operators, they are actually functions. For example, the following two lines create the same constraint, but internally different Concert functions are invoked:


c.add(x <= y);

c.add(x - y <= 0);

That first line invokes the overloaded operator

public IloConstraint operator<=(IloNumExprArg base, IloNumExprArg base2)

while the second line invokes

public IloRange operator<=(IloNumExprArg base, IloNum val)

While typically this distinction has no effect on the program behavior, in some cases subtle differences can arise. For example, certain other Concert methods can operate on IloRanges, but won't operate on IloConstraints, in which case the first operator would work with such a method but the second would not.


Familiarize yourself with the Concepts section of the Concert Reference Manual.

In particular, problems involving unexpectedly high memory usage or long runtime often arise from creation of unnecessary instances of IloExtractable that impose extra overhead. By familiarizing yourself with Concert Concepts (particularly the Handle Classes, Lazy Copy, Deletion of Extractables, and Notification), you can often make slight changes to your code that lead to significant reductions in overhead.


[{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.2;9.1.3;9.1.2;9.1;9.0;8.1;8.0;7.5;7.1;7.0;6.6;12.5;12.4;12.3;12.2;12.1;12.0;11.2.1;11.2;11.1.1;11.1;11.0.1;11.0;10.3;10.2.1;10.2;10.1.1;10.1;10.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF017","label":"Mac OS"}],"Version":"12.2","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

cplex/Document/121

Document Information

Modified date:
16 June 2018

UID

swg21400038