Where to find the CPLEX examples

Describes where to find the examples illustrating the use of OPL as a modeling and scripting language in the CPLEX Studio distribution.

This section presents examples that show how to use OPL as a modeling language and IBM ILOG Script for OPL as a scripting language. First look at the following tables, then find the examples you need from the following categories of problems.

Note:

The examples used in this documentation are designed to illustrate the features of the product. They should not be viewed as recommended methods or approaches for these problems.

All examples illustrating the use of OPL as a modeling and scripting language are in

<Install_dir>/opl/examples/opl

More optimization problems expressed as OPL models are available in

<Install_dir>/opl/examples/opl/models

and described in OPL model library.

The table titled Mathematical programming code examples presents an overview of the examples specifically written to illustrate OPL.

Legend:

  • The Problem column lists the types of problems in alphabetical order.

  • The Technique column specifies what kind of mathematical programming is applied in these models.

  • The Features column points out interesting characteristics or issues that OPL, as a modeling language, addresses in these examples.

  • The Project Location column specifies the directory that contains the corresponding project, model, and data files.

  • The Model File Name column provides direct links to the model files displayed in HTML format.

Abbreviations

Table 1. Mathematical Programming (MP) abbreviations
Abbreviation Full form of the abbreviation
IP Integer Programming
LP Linear Programming
MILP Mixed Integer Linear Programming
MIP Mixed Integer Programming
MIQP Mixed Integer Quadratic Programming
PWL Piecewise Linear Programming
QCP Quadratically Constrained Programming
QP Quadratic Programming
Table 2. Mathematical programming examples
Problem Technique Features Project Location Model File Name
Blending problems MILP

Branch and bound

Logical constraints

examples/opl/blending

examples/opl/foodmanufact

examples/opl/oil

blending.mod

foodmanufact.mod

oil.mod

Commodity flow problems (transportation) MIP

Sparsity

Preprocessing script

examples/opl/transp

transp1.mod

transp2.mod

transp3.mod

transp4.mod

Covering problems IP Resource Allocation examples/opl/covering covering.mod
Cutting stock problems IP

Column Generation

Flow control scripting

Relaxation

examples/opl/cutstock

cutstock.mod

cutstock-sub.mod

cutstock_change.mod

cutstock_main.mod

cutstock_int_main.mod

Fixed-charge production problems IP Production expressed as integers

examples/opl/fixed

examples/opl/prodmilp

fixed.mod

prodmilp.mod

Inventory problems PWL Piecewise linear function examples/opl/sailco

sailco.mod

sailcopw.mod

Knapsack problems IP

CPLEX priorities

External knapsack algorithm

examples/opl/knapsack

knapsack.mod

knapsackp.mod

javaknapsack.mod

Miscellaneous examples IP int-to-float and float-to-int conversion of variables examples/opl/convert_example convert_example.mod
IP Setting an initial solution to the solver examples/opl/warmstart warmstart.mod
  Setting user’s preferences for conflict search examples/opl/conflictIterator conflictIterator.mod
  Setting user’s preferences for relaxation of conflicts examples/opl/relaxationIterator relaxationIterator.mod
MIP Quick start from OR to OPL examples/opl/pmedian pmedian.mod
  External function calls examples/java/externaldataread

externaldataread.mod

callexternaldataread.mod

MIP Multiple optimization of different models in a single environment examples/opl/LagrangianRelaxation LagrangianRelaxation.mod
Product mix problems MILP Data initialized in model file

examples/opl/gas

examples/opl/volsay

gas.mod

gas1.mod

volsay.mod

Production problems

MILP

LP

Tuples

Named data

Flow control script

Spreadsheet, reading and writing data

examples/opl/production

examples/opl/mulprod

examples/opl/xsteel

production.mod

product.mod

mulprod.mod

mulprod_change_main.mod

mulprod_main.mod

xsteel.mod

Profiling MILP Better time and memory consumption examples/opl/profiler profiler.mod
Quadratic problems

QP

MIQP

QP

QCP

 

examples/opl/lifegameip

examples/opl/miqpex1

examples/opl/qpex1

examples/opl/qcpex1

lifegameip.mod

miqpex1.mod

qpex1.mod

qcpex1.mod

Relaxation of infeasible models MIP

Scheduling

Feasibility and relaxation

examples/opl/nurses nurses.mod
Warehouse location problems MIP

Internal data

Scalability

examples/opl/warehouse

warehouse.mod

scalableWarehouse.mod

The following  table provides a synoptic view in which the examples are sorted by industry. Each table entry provides a link to a description of each type of problem.

The following table orders the examples by type of mathematical programming.

Table 4. OPL model library, by MP technique
Integer Programming Linear Programming Mixed Integer Linear Programming Mixed Integer Programming Quadratic Programming
examples/opl/convert_example examples/opl/mulprod examples/opl/blending examples/opl/nurses examples/opl/lifegameip
examples/opl/covering examples/opl/xsteel examples/opl/foodmanufact examples/opl/pmedian examples/opl/miqpex1
examples/opl/cutstock   examples/opl/gas examples/opl/transp examples/opl/qpex1
examples/opl/fixed   examples/opl/oil examples/opl/warehouse examples/opl/qcpex1
examples/opl/knapsack   examples/opl/production    
examples/opl/prodmilp   examples/opl/profiler    
examples/opl/sailco   examples/opl/volsay    
examples/opl/warmstart