> Tutorials > Callable Library Tutorial > Creating a Successful Callable Library Application |
Creating a Successful Callable Library Application |
INDEX
![]() |
Callable Library applications are created to solve a wide variety of problems. Each application shares certain common characteristics, regardless of its apparent uniqueness. The following steps can help you minimize development time and get maximum performance from your programs:
Create a small version of the model to be solved. An algebraic modeling language is sometimes helpful during this step.
By separating the application into smaller parts, you can easily identify the tools needed to complete the application. Part of this process consists of identifying the Callable Library routines that will be called.
In some applications, the Callable Library is a small part of a larger program. In that case, the only ILOG CPLEX routines needed may be for:
In other cases the Callable Library is used extensively in the application. If so, Callable Library routines may also be needed to:
It is often possible to test the procedures of an application in the ILOG CPLEX Interactive Optimizer with a small prototype of the model. Doing so will help identify the Callable Library routines required. The test may also uncover any flaws in procedure logic before you invest significant development effort.
Trying the ILOG CPLEX Interactive Optimizer is an easy way to determine the best optimization procedure and parameter settings.
You must decide which approach to populating the problem object is best for your application. Reading an MPS or LP file may reduce the coding effort but can increase the run-time and disk-space requirements of the program. Building the problem in memory and then calling CPXcopylp
avoids time consuming disk-file reading. Using the routines CPXnewcols
, CPXnewrows
, CPXaddcols
, CPXaddrows
, and CPXchgcoeflist
can lead to modular code that may be more easily maintained than if you assemble all model data in one step.
Another consideration is that if the Callable Library application reads an MPS or LP formatted file, usually another application is required to generate that file. Particularly in the case of MPS files, the data structures used to generate the file could almost certainly be used to build the problem-defining arrays for CPXcopylp
directly. The result would be less coding and a faster, more efficient application. These observations suggest that formatted files may be useful when prototyping your application, while assembling the arrays in memory may be a useful enhancement for a production version.
Once a problem object has been instantiated and populated, it can be solved using one of the optimizers provided by the ILOG CPLEX Callable Library. The choice of optimizer depends on the problem type.
There are also many different possible parameter settings for each optimizer. The default values will usually be the best for linear programs. Integer programming problems are more sensitive to specific settings, so additional experimentation will often be useful.
Choosing the best way to solve the problem can dramatically improve performance. For more information, refer to the sections about tuning LP performance and trouble-shooting MIP performance in the ILOG CPLEX User's Manual.
Using good programming practices will save development time and make the program easier to understand and modify. A list of good programming practices is provided in the ILOG CPLEX User's Manual.
Your program may not run properly the first time you build it. Learn to use a symbolic debugger and other widely available tools that support the creation of error-free code. Use the list of debugging tips provided in the ILOG CPLEX User's Manual to find and correct problems in your Callable Library application.
Once an application works correctly, it still may have errors or features that inhibit execution speed. To get the most out of your application, be sure to test its performance as well as its correctness. Again, the ILOG CPLEX Interactive Optimizer can help. Since the Interactive Optimizer uses the same routines as the Callable Library, it should take the same amount of time to solve a problem as a Callable Library application.
Use the CPXwriteprob
routine with the SAV format to create a binary representation of the problem object, then read it in and solve it with the Interactive Optimizer. If the application sets optimization parameters, use the same settings with the Interactive Optimizer. If your application takes significantly longer than the Interactive Optimizer, performance within your application can probably be improved. In such a case, possible performance inhibitors include fragmentation of memory, unnecessary compiler and linker options, and coding approaches that slow the program without causing it to give incorrect results.
The ILOG CPLEX Callable Library is distributed with a variety of examples that illustrate the flexibility of the Callable Library. The C source of all examples is provided in the standard distribution. For explanations about the examples of quadratic programming problems (QPs), mixed integer programming problems (MIPs) and network flows, see the ILOG CPLEX User's Manual. Explanations of the following examples of LPs appear in this manual:
It is a good idea to compile, link, and run all of the examples provided in the standard distribution.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |