Examples in C using the Callable Library
The following examples are delivered with ILOG CPLEX in yourCPLEXhome/examples/src.
diet.c is a linear program that can be generated by columns (add foods to the diet) or by rows (add requirements to the diet).
foodmanu.c implements a solution to the food production planning problem, well known from the modeling textbook of H. P. Williams; this implementation uses indicator constraints and semi-continuous variables.
lpex1.c is a basic linear programming example, illustrating data population techniques.
lpex2.c is a basic linear programming example with data coming from files.
lpex3.c demonstrates how to add rows to a problem and reoptimize.
lpex4.c illustrates CPLEX callback functions; it is derived from lpex1.c .
lpex5.c illustrates CPLEX message handler; it is derived from lpex1.c .
lpex6.c illustrates loading of bases; it is derived from lpex1.c .
lpex7.c shows how to get column names; it is derived from lpex2.c .
lpex8.c shows another way to build a problem; it is derived from lpex1.c .
mipex1.c is a basic mixed integer programming example, derived from lpex8.c .
mipex2.c is a basic mixed integer programming example, derived from lpex2.c .
mipex3.c illustrates SOS sets and priority orders; it derives from lpex8.c .
fixnet.c uses indicator constraints to avoid numeric difficulty in a fixed-charge network flow problem. (It does not use the conventional CPXNET interface.)
netex1.c is a basic network example.
netex2.c is a basic newtork example, with data coming from files.
qpex1.c is a basic quadratic programming example, derived from lpex8.c .
qpex2.c a quadratic programming example, derives from lpex2.c.
miqpex1.c a mixed integer quadratic programming example, derives from lpex8.c.
adpreex1.c uses advanced presolve to re-optimize with a secondary objective.
admipex1.c uses node and branch callbacks to optimize a MIP.
admipex2.c uses a heuristic callback to optimize a MIP.
admipex3.c uses a branch callback on a MIP with special ordered sets (SOSs).
admipex4.c uses a user-specified cut table for a MIP.
admipex5.c adds cuts through the cut callback for a MIP.
admipex6.c starts a MIP optimization from an LP solution.
admipex7.c uses a solve callback using barrier and dual optimizers.
The steel example consists of four source files:
steeldrv.c is a driver containing the data for the problem, and code to write out a solution.
steelsub.c is a driver that calls CPLEX to load and optimize the problem, and get the solution.
colsteel.c generates the problem in a column-oriented way.
rowsteel.c generates the problem in a row-oriented way.
The application can be built by linking:
steeldrv, steelsub, colsteel
or
steeldrv, steelsub, rowsteel
Both colsteel.c and rowsteel.c contain a function called gensteel that generates the model. It has the same purpose in both colsteel.c and rowsteel.c, but is implemented differently to illustrate model generation by column and model generation by row.
check.c contains routines to check data that will be passed to Callable Library routines.