|
|
| |
BCL C examples
This directory contains three sets of examples illustrating the use of BCL:
IntrExpl: small introductory examples
AdvExpl: advanced examples
UGExpl: examples from the 'Xpress BCL Reference Manual'
and from 'Getting started with BCL'
|
| Introductory examples |
|
|
| Chess - Composing constraints and solving: Simple LP problem, termwise constraint definition, LP solving
|
| |
|
| Type: |
Production planning |
| Rating: |
1 (simple) |
| Description: |
A tiny LP problem concerning the manufacture of chess
boards. The example composes constraints term by term and
then solves the problem.
|
| File(s): |
xbchess.c |
|
|
| Workshop - Displaying solution information: Retrieving and displaying solution values and ranging information; real value printing format, number output format
|
| |
|
| Type: |
Production planning |
| Rating: |
1 (simple) |
| Description: |
A small planning problem. The example composes constraints, LP solves the problem and then prints the variables.
Model version 'xbworkrng' shows how to retrieve ranging information for variables and
constraints and how to change the number-printing format.
|
| File(s): |
xbworks.c, xbworkrng.c |
|
|
| Contract - Semi-continuous variables, predefined constraint functions, combine BCL with Xpress Optimizer: Defining semi-continuous variables, MIP solving
|
| |
|
| Type: |
Contract allocation |
| Rating: |
3 (intermediate) |
| Description: |
A small MIP-problem example demonstrating how to define semi-continuous variables, use predefined constraint functions and
retrieve the problem status.
Two modified versions (documented in the 'BCL Reference Manual') show how to (1) combine BCL problem input with problem
solving in Xpress Optimizer and (2) use an Xpress Optimizer solution callback with a BCL model.
|
| File(s): |
xbcontr.c |
|
|
| Chgprobs - Working with multiple problems: Handling multiple problems
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
This example defines 3 very small problems, making changes to the problem definition after matrix generation and retrieving
solution information. It also shows BCL warnings.
|
| File(s): |
xbexpl.c |
|
|
| Setops - Index sets: Using index sets, set operations
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
A example showing the use of index sets and in particular, creating the union and intersection of index sets. |
| File(s): |
xbsetops.c |
|
|
| Burglar - Use of index sets, formulating logical constraints: Index an array of variables by an index set, defining indicator constraints
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
Several versions of a simple knapsack problem:
- xbburg: standard formlation
- xbburgi: shows how to index an array of variables by an index set
- xbburgl: adds several indicator constraints to state logical conditions
|
| File(s): |
xbburg.c, xbburgi.c, xbburgl.c |
|
|
| Coco - A full production planning example: Data input from text files
|
| |
|
| Type: |
Production planning |
| Rating: |
2 (easy-medium) |
| Description: |
The Coco productional planning problem: multi-item,
multi-period, multi-site production planning. A sequence
of model versions show how the model
was developed, to (a) use more sophisticated modeling features
and (b) to extend the model, taking it from a simple linear model
to one with fixed prices and logical decisions.
- xbcoco1: initial formulation, data, variables and constraints fixed
- xbcoco2: use parameters, data tables and subscripted variables.
read data tables in from text data files (short-term planning).
- xbcoco3: like xbcoco2.c, but several time periods (mid-term planning).
- xbcoco : complete problem, data defined in the model definition (long-term planning).
|
| File(s): |
xbcoco1.c, xbcoco2.c, xbcoco3.c, xbcoco.c |
| Data file(s): |
rev.dat, cmake.dat, cbuy.dat, req.dat, maxsell.dat, mxmake.dat, revt.dat, cbuyt.dat, maxsellt.dat, pstock0.dat, rstock0.dat |
|
|
| Delivery - Data input from file; infeasibility analysis: LP model, data input from file, retrieving IIS
|
| |
|
| Type: |
Network flow |
| Rating: |
2 (easy-medium) |
| Description: |
A simple supply and demand network example showing data
input from file and the use of "views": incremental
definition of arrays of variables. Also uses constraint
templates with the arrays of variables.
A second version of this model (file xbdlvriis) has
modified data making the problem infeasible. This example
shows how to analyze infeasibility with the help of IIS
(irreducible infeasible sets), it retrieves the IIS
and prints out their contents.
It is possible to retrieve more detailed information on
the IIS, such as isolation rows or bounds, using
Xpress Optimizer functions (file xbdlvriis2iso) or to use
the infeasibility repair functionality of the Optimizer
(file xbdlvriis2rep) with models defined in BCL.
|
| File(s): |
xbdelvr.c, xbdlvriis.c, xbdlvriis2iso.c, xbdlvriis2rep.c |
| Data file(s): |
ifvan.dat, cost.dat |
|
|
| Purchase - Definition of SOS-2: Data input from file, using SOS-2
|
| |
|
| Type: |
Purchasing with pricebreaks |
| Rating: |
3 (intermediate) |
| Description: |
A model for optimal purchasing with price-breaks featuring a
complex MIP model, data input from file and using SOS-2.
|
| File(s): |
xbpurch.c |
| Data file(s): |
params.dat, maxperc.dat, required.dat, pricebk.dat |
|
|
| Portfolio - Quadratic Programming with discrete variables: Quadratic objective function
|
| |
|
| Type: |
Portfolio optimization |
| Rating: |
2 (easy-medium) |
| Description: |
Quadratic Mixed Integer Programming example demonstrating Quadratic Programming with discrete variables. |
| File(s): |
xbportf.c |
| Data file(s): |
pfqcost.dat, pfubds.dat, pflcost.dat |
|
|
| Catenary - Solving a QCQP: Stating quadratic constraints
|
| |
|
| Type: |
Hanging chain |
| Rating: |
2 (easy-medium) |
| Description: |
This model finds the shape of a hanging chain by
minimizing its potential energy.
|
| File(s): |
xbcatena.c |
|
|
|
| Advanced examples |
|
|
| Cutstk - Column generation for a cutting stock problem: Working with subproblems, modifying constraints
|
| |
|
| Type: |
Cutting stock |
| Rating: |
4 (medium-difficult) |
| Description: |
This example features iteratively adding new variables,
basis in/output and working with subproblems. The column
generation algorithm is implemented as a loop over the
root node of the MIP problem.
|
| File(s): |
xbcutstk.c |
|
|
| Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristics: Looping of optimization, using the cut manager
|
| |
|
| Type: |
Lot-sizing |
| Rating: |
5 (difficult) |
| Description: |
The version 'xbels' of this example shows how to implement cut-and-branch (= cut
generation at the root node of the MIP search) and 'xbelsc' implements a
branch-and-cut (= cut generation at the MIP search tree nodes)
algorithm using the cut manager.
|
| File(s): |
xbels.c, xbelsc.c |
|
|
| Fixbv - A binary fixing heuristic: Changing bounds, saving and loading bases, saving and loading start solutions
|
| |
|
| Type: |
Production planing |
| Rating: |
3 (intermediate) |
| Description: |
Implements a binary fixing heuristic for the complete Coco Problem
(see the introductory example 'Coco').
The program changes bounds directly in the Optimizer and shows how
to save and re-load bases. Model version 'xbfixbvls' adds saving and loading of MIP solutions.
|
| File(s): |
xbfixbv.c, xbfixbvls.c |
|
|
| Recurse - A successive linear programming model: Iterative solving, modify constraint definitions
|
| |
|
| Type: |
Recursion |
| Rating: |
3 (intermediate) |
| Description: |
A non-linear problem (quadratic terms in the constraints) is
modeled as a successive linear
programming (SLP) model. (SLP is also known as 'recursion'.)
The constraint coefficients are changed iteratively. Shows
how to save and re-load an LP basis.
|
| File(s): |
xbrecurs.c |
|
|
| MT2 - Solving two problems in parallel in a thread-safe environment: Parallel computing
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Parallel problem solving using multiple threads. Accessing
Xpress Optimizer functions for a BCL problem.
|
| File(s): |
xbmt2.c |
|
|
| GoalObj - Archimedian and pre-emptive goal programming using objective functions: Multicriteria optimization, multi-objective decision making
|
| |
|
| Type: |
Goal Programming |
| Rating: |
3 (intermediate) |
| Description: |
A small linear problem with multiple objectives is solved
by Archimedian and pre-emptive goal programming. The example
uses functions to access information about constraints and
shows how to solve a problem repeatedly with a modified
objective function.
|
| File(s): |
xbgoalobj.c |
|
|
| Wagon - MIP start solution heuristic: Loading MIP start solution, 'solnotify' callback
|
| |
|
| Type: |
Load balancing |
| Rating: |
3 (intermediate) |
| Description: |
Load balancing of train wagons. A heuristic solution obtained via a Longest processing time heuristic is loaded as start solution
into Xpress Optimizer.
|
| File(s): |
xbd1wagon2.c |
|
|
|
| User Guide examples |
|
|
| UG - Examples from 'BCL Reference Manual': MIP modeling, error handling, using Xpress Optimizer with BCL
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
The following examples are discussed in detail in the 'BCL User Guide and Reference Manual':
- modeling and solving a small MIP scheduling problem (xbexpl1.c version BASIC)
- using variable arrays and constraint templates (xbexpl1.c versions ARRAY and ARRAYC)
- definition of SOS-1 (xbexpl1 version SOS)
- data input from file, index sets (xbexpl1i)
- user error handling, output redirection (xbexpl3)
- solving multiple scenarios of a transportation problem in parallel (xbexpl2: standard, single thread version; xbscenar: defining
multiple problems, each in a separate thread)
- cut generation / adding cuts at MIP tree nodes (xbcutex)
- quadratic programming (quadratic objective: xbqpr12, quadratic constraints: xbairport)
- combine BCL problem input with problem solving in Xpress Optimizer (xbcontr1)
- use an Xpress Optimizer solution callback with a BCL model (xbcontr2s: single MIP thread; xbcontr2: multiple MIP threads)
|
| File(s): |
xbexpl1.c, xbexpl1i.c, xbexpl3.c, xbexpl2.c, xbscenar.c, xbcutex.c, xbqpr12.c, xbairport.c, xbcontr1.c, xbcontr2.c, xbcontr2s.c |
| Data file(s): |
durations.dat |
|
|
| Folio - Examples from 'Getting Started': MIP modeling, quadratic constraints, infeasibility handling, solution enumeration
|
| |
|
| Type: |
Portfolio optimization |
| Rating: |
3 (intermediate) |
| Description: |
Different versions of a portfolio optimization problem.
Basic modelling and solving tasks:
- modeling and solving a small LP problem (foliolp, using variable arrays: folioarr)
- performing explicit initialization (folioinit*)
- data input from file, index sets (foliodata, requires foliocpplp.dat)
- modeling and solving a small MIP problem with binary variables (foliomip1)
- modeling and solving a small MIP problem with semi-continuous variables (foliomip2)
- modeling and solving QP and MIQP problems (folioqp, requires foliocppqp.dat)
- modeling and solving QCQP problems (folioqc, requires foliocppqp.dat)
- heuristic solution of a MIP problem (folioheur)
Advanced modeling and solving tasks:
- enlarged version of the basic MIP model (foliomip3 with include file readfoliodata.c_, to be used with data sets folio5.cdat,
folio10.cdat)
- defining an integer solution callback (foliocb)
- using the MIP solution pool (foliosolpool)
- using the solution enumerator (folioenumsol)
- handling infeasibility through deviation variables (folioinfeas)
- retrieving IIS (folioiis, foliomiis)
- using the built-in infeasibility repair functionality (foliorep)
|
| File(s): |
foliolp.c, folioarr.c, folioinit.c, folioinit2.c, foliodata.c, foliomip1.c, foliomip2.c, folioqp.c, folioqc.c, folioheur.c, foliomip3.c, readfoliodata.c_, foliocb.c, foliosolpool.c, folioenumsol.c, folioinfeas.c, folioiis.c, foliomiis.c, foliorep.c |
| Data file(s): |
foliocpplp.dat, foliocppqp.dat, folio5.cdat, folio10.cdat |
|
|
|
|
|
|