Python examples
These examples in Python use the Callable Library.
The following examples are delivered with CPLEX in IBM ILOG CPLEX Optimization Studio.
| admipex9.py | uses a generic callback involving a heuristic to optimize a MIP. |
| admipex8.py | demonstrates how to add lazy constraints and user cuts with the generic callback. |
| admipex6.py | an advanced application, it solves a mixed integer programming (MIP) problem starting from an LP solution. |
| admipex5.py | an advanced application, shows how to add cuts for a MIP by means of a cut callback. |
| admipex4.py | demonstrates how to add lazy constraints and user cuts. |
| admipex3.py | an advanced application, uses a branch callback on a MIP with special ordered sets (SOS). |
| admipex2.py | an advanced application, uses a heuristic callback to optimize a MIP. |
| admipex1.py | an advanced application, uses node and branch callbacks to optimize a MIP. |
| benders.py | demonstrates a Benders decomposition. |
| bendersatsp.py | demonstrates legacy lazy constraint callbacks to separate integer feasible LP solutions and legacy user cut callbacks to separate fractional infeasible LP solutions in a do-it-yourself Benders decomposition of an asymmetric traveling salesperson problem. |
| bendersatsp2.py | demonstrates generic callbacks to separate integer feasible LP solutions in a context of lazy constraints and generic callbacks to separate fractional infeasible LP solutions in a context of user cuts, all in a do-it-yourself Benders decomposition of an asymmetric traveling salesperson problem. |
| blend.py | solves a blending problem. |
| conflictex1.py | demonstrates how to use the conflict refiner. |
| cutstock.py | solves a cutting stock problem, where a maximum number of patterns should be cut from stock with minimum waste. The model illustrates column-generation. |
| diet.py | is an implementation in Python of the classic diet problem; a linear program that can be generated by columns (add foods to the diet) or by rows (add requirements to the diet); optionally, demonstrates how to model a multiobjective problem by creating a second objective. |
| multiobjex1.py | demonstrates how to read in and optimize a multiobjective problem. |
| etsp.py | is an implementation in Python of an early-tardy scheduling problem that uses indicator constraints. |
| facility.py | solves a facility-location problem where warehouses have limited storage and must meet distribution needs. This example also offers an option to use Benders decomposition and algorithm. |
| fixcost1.py | solves a production planning problem with fixed costs. |
| fixnet.py | uses indicator constraints to avoid numeric difficulty in a fixed-charge network flow problem. |
| foodmanu.py | 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. |
| genericbranch.py | demonstrates how to perform customized branching using the generic callback. |
| globalqpex1.py | shows how to read a convex or nonconvex quadratic programming model (QP) and solve it for a first order or global optimum. |
| indefqpex1.py | shows how to solve an indefinite quadratic programming example to a local optimum. |
| inout1.py | a production planning problem aiming to minimize cost, where goods may be manufactured internally or purchased from outside sources. |
| inout3.py | a production planning problem with additional constraints on costs. |
| lpex1.py | is a basic linear programming example, illustrating data population techniques by rows, by columns, by coefficients. |
| lpex2.py | is a basic linear programming example with data coming from files. |
| lpex3.py | demonstrates how to add rows to a problem and re-optimize; the examples begins with a network flow model, uses the network optimizer to solve it, adds additional constraints, and invokes the dual simplex optimizer to resolve the new model. |
| lpex4.py | illustrates CPLEX callback functions; it is derived from lpex1.py. |
| lpex5.py | illustrates message handling. |
| lpex6.py | shows how to load a basis. |
| lpex7.py | shows how to access names of columns. |
| mipex1.py | solves a basic mixed integer programming (MIP) problem. |
| mipex2.py | solves a basic MIP with data from files. |
| mipex3.py | illustrates SOS sets and priority orders. |
| mipex4.py | demonstrates how to use the Aborter class to
interrupt optimization and how to use informational callbacks for
logging, timing, or setting a node limit. |
| miqpex1.py | solves a mixed integer programming problem (MIP) with a quadratic term in the objective function. |
| populate.py | shows how to generate and store multiple solutions in the solution pool. |
| qcpex1.py | optimizes a quadratically constrained model. |
| qpex1.py | solves a model with a quadratic term in the objective function. |
| qpex2.py | solves a model with a quadratic term in the objective function and reads data from a file. |
| rates.py | is a planning problem using semi-continuous variables. |
| socpex1.py | shows how to access dual values and reduced costs in SOCP models. |
| qcpdual.py | shows how to access dual values and reduced costs in quadratically constrained programming models (QCP). |
| steel.py | solves the model known as steelT.mod in the AMPL book by Fourer, Gay, and Kernighan. |
| transport.py | uses a piecewise linear cost function. |
| warehouse.py | is a warehouse-location problem, using semi-continuous integer variables. |