Xpress Optimizer examples
Examples of using the Optimizer library
|
| Calling the library from C |
|
|
| The travelling salesman problem: Using Xpress callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solves the classic travelling salesman problem as a MIP,
where sub-tour elimination constraints are added
only as needed during the branch-and-bound search.
|
| File(s): |
tsp.c |
|
|
| Cut Generation for an economic lot-sizing (ELS) problem: Using the cut round callback and adding cutting planes.
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
The two programs demonstrate two methods for adding cutting planes
using a cut round callback. They both formulate and solve an economic
lot-sizing problem and adds valid (l-S)-inequalities as cutting planes
within a cut round callback.
els_addcuts.c uses XPRSaddcuts to directly
add the new cutting planes to a node problem of the branch-and-bound
search. The cutting planes must be presolved first before they can be added.
els_managedcuts.c uses XPRSmanagedcuts to provide
cutting planes to the Optimizer, which will managed these cuts automatically.
The cutting planes can be provided in the original space and do not need to be presolved.
|
| File(s): |
els_addcuts.c, els_managedcuts.c |
|
|
| Branching rule branching on the most violated Integer/Binary: Using the change branch callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the Xpress Optimizer change branch callbacks |
| File(s): |
mostviolated.c |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimise
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
fixbv.c |
| Data file(s): |
coco.mps |
|
|
| Perform objective function parametrics on a MIP problem: Saving/loading bases, changing objective coefficients
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
BEN(3), the benefit per month from finishing Project 3.
The program increments BEN(3) from 8 to 15, and for each of these
values revises the objective coefficients of the variables x(3,t),t=1:2
and finds the best integer solution. Note that, for each t, the
coefficient of x(3,t) is BEN(3)*(3-t) = BEN(3)*(6-t-4+1).
The results are displayed on screen and the problem statistics stored
in a log file.
|
| File(s): |
globjpar.c |
| Data file(s): |
pplan.mps |
|
|
| Perform RHS parametrics on a MIP problem: Changing RHS coefficients, working with bases
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
the RHS element RESMAX(2), the resources available in Month 2.
The program decrements RESMAX(2) from 6 to 1, and for each of these
values assesses the feasibility of the revised problem and, where
possible, finds the best integer solution.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
glrhspar.c |
| Data file(s): |
pplan.mps |
|
|
| Apply a primal heuristic to a knapsack problem: Using the MIP log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the MIP log callback.
We take the knapsack problem stored in burglar.mps and initiate a
tree search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
knapsack.c |
| Data file(s): |
burglar.mps |
|
|
| Apply an integer fixing heuristic to a MIP problem: Changing bounds
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which
seeks to optimise the operating pattern of a group of electricity
generators. We solve this MIP with a very loose integer tolerance
and then fix all binary and integer variables to their rounded
integer values, changing both their lower and upper bounds. We then
solve the resulting LP.
The results are displayed on screen and the problem statistics
stored in a logfile.
|
| File(s): |
roundint.c |
| Data file(s): |
hpw15.mps |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
loadlp.c |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and tree search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mps and initiate a tree
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other tree search information, are displayed
on screen.
|
| File(s): |
savesol.c |
| Data file(s): |
burglar.mps |
|
|
| Adding MIP solutions to the Optimizer: Using the optnode callback, saving/loading bases, changing bounds
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
At each node of the tree search a variable fixing heuristic is applied to a copy of the problem. If an integer solution is
found for the modified (sub)problem then this solution is added to the original problem.
|
| File(s): |
addmipsol.c |
| Data file(s): |
addmipsol.mps |
|
|
| Solve LP, displaying the initial and optimal tableau: Retrieve basic variables and their names, btran
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Inputs an MPS matrix file and required optimization sense, and
proceeds to solve the problem with lpoptimize. The simplex
algorithm is interrupted to get its intial basis, and a tableau is
requested with a call to function showtab. Once the solution is
found, a second call produces the optimal tableau.
Function showtab retrieves the pivot order of the basic variables,
along with other problem information, and then constructs (and
displays) the tableau row-by-row using the backwards transformation,
btran.
Note that tableau should only be used with matrices whose MPS names
are no longer than 8 characters.
|
| File(s): |
tableau.c |
| Data file(s): |
tablo.mps, tablobig.mps |
|
|
| Modify problem: add an extra variable within an additional constraint: Adding rows and columns, branching directives
|
| |
|
| Type: |
Cutting stock |
| Rating: |
3 (intermediate) |
| Description: |
We take the trimloss problem described in
trimloss.mps, in which each integer variable x(p) represents
the number of rolls cut to pattern p. We define a new
integer variable y=SUM(p)x(p) and add the associated
constraint
x(1)+x(2)+...+x(N)-y = 0
We do this by first adding a row containing the (unitary)
coefficients of the x(p), and then a column corresponding
to y. We output the revised matrix to a file and then solve
the revised MIP, giving y the highest branching priority.
Finally, we output the solution, both to the screen and to
an ASCII solution file. |
| File(s): |
trimloss.c |
| Data file(s): |
trimloss.mps |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
mipsolenum.c |
| Data file(s): |
hpw15.mps |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
mipsolpool.c |
| Data file(s): |
hpw15.mps |
|
|
| Repairing infeasibility: Using repairinfeas
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the repairinfeas utility,
prints a relaxation summary and
creates the relaxed subproblem.
|
| File(s): |
repair.c |
|
|
| Goal programming: Lexicographic goal programming using the Xpress multi-objective API
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
This example tries to construct a production plan which meets four different
goals in order of priority.
|
| File(s): |
goalprog.c |
|
|
|
| Calling the library from C# |
|
|
| Burglar - Formulating logical constraints: MIP, indicator constraints
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
1 (simple) |
| Description: |
This example shows how to setup a simple knapsack type problem in which an item
selection should be made maximally profitable under some weight restriction.
We first solve a pure knapsack problem. Then, we refine the constraints by
explicitly forbidding certain item combinations, thereby showing multiple ways
how to create indicator constraints.
|
| File(s): |
BinBurglar.cs, BinBurglar.csproj |
|
|
| Constraint types - Logical, general, SOS, quadratic: Defining different types of constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Small examples showing how to define special constraint types:
- Stating logic clauses that resemble SAT-type formulations (BoolVars).
- Formulating some constraints on the minimum and absolute values
of linear combinations of variables (GeneralConstraints).
- Using the 'pwl' construct to formulate a piecewise linear cost function (PiecewiseLinear).
- Formulation of a small quadratic programming problem (QuadraticProgramming).
- Approximation of a nonlinear function by a special ordered set of type 2 (SpecialOrderedSets) and of a quadratic function
in 2 variables by special ordered sets of type 2 (SpecialOrderedSetsQuadratic).
|
| File(s): |
BoolVars.cs, BoolVars.csproj, GeneralConstraints.cs, GeneralConstraints.csproj, PiecewiseLinear.cs, PiecewiseLinear.csproj, QuadraticProgramming.cs, QuadraticProgramming.csproj, SpecialOrderedSets.cs, SpecialOrderedSets.csproj, SpecialOrderedSetsQuadratic.cs, SpecialOrderedSetsQuadratic.csproj |
|
|
| Boxes - Nonlinear constraints: Nonlinear constraints
|
| |
|
| Type: |
Production Planning |
| Rating: |
2 (easy-medium) |
| Description: |
Stating a small production planning problem with nonlinear constraints to determine the size of objects to be produced. |
| File(s): |
Boxes02.cs, Boxes02.csproj |
|
|
| Capital budgeting - Using multi-objective optimization: Multi-objective solving
|
| |
|
| Type: |
Capital budgeting |
| Rating: |
2 (easy-medium) |
| Description: |
Capital budgeting example, solved using three multi-objective approaches:
- Lexicographic approach, solving first to minimize capital expended
and second to maximize return
- Blended approach, solving a weighted combination of both objectives
simultaneously
- Lexicographic approach, with the objective priorities reversed
|
| File(s): |
CapitalBudgeting.cs, CapitalBudgeting.csproj, CapBgt2l.cs, CapBgt2l.csproj |
|
|
| Catenary - Solving a QCQP: Stating quadratic constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
This model finds the shape of a hanging chain by
minimizing its potential energy.
|
| File(s): |
Catenary.cs, Catenary.csproj |
|
|
| Contract - Semi-continuous variables: Defining semi-continuous variables
|
| |
|
| Cutstk - Column generation for a cutting stock problem: Working with subproblems, modifying constraints
|
| |
|
| Type: |
Column generation |
| Rating: |
4 (medium-difficult) |
| Description: |
This example features iteratively adding new variables,
basis in/output and working with subproblems. The column
(=cutting pattern)
generation algorithm is implemented as a loop over the
root node of the MIP problem.
|
| File(s): |
CuttingStock.cs, CuttingStock.csproj |
|
|
| Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristics: Looping of optimization, using the cut manager
|
| |
|
| Type: |
Economic lot-sizing |
| Rating: |
5 (difficult) |
| Description: |
The version 'ELS' of this example shows how to implement cut-and-branch (= cut
generation at the root node of the MIP search) and 'ELSCut' implements a
branch-and-cut (= cut generation at the MIP search tree nodes)
algorithm using the cut manager.
|
| File(s): |
ELS.cs, ELS.csproj, ELSCut.cs, ELSCut.csproj, ELSManagedCuts.cs, ELSManagedCuts.csproj |
|
|
| Facility location problem - Data as collections: Collections data structure
|
| |
|
| Folio - Examples from 'Getting Started': MIP modeling, binary fixing heuristic, quadratic constraints, infeasibility handling
|
| |
|
| 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 (FolioInit)
- 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, MIQP, QCQP problems (FolioQP, FolioQC)
- heuristic solution of a MIP problem (FolioHeuristic)
Advanced modeling and solving tasks:
- enlarged version of the basic MIP model (Folio, to be used with data set folio10.cdat)
- defining an integer solution callback (FolioCB, to be used with data set folio10.cdat)
- retrieving IIS (FolioIIS, FolioMipIIS, to be used with data set folio10.cdat)
|
| File(s): |
Folio.cs, Folio.csproj, FolioCB.cs, FolioCB.csproj, FolioHeuristic.cs, FolioHeuristic.csproj, FolioIIS.cs, FolioIIS.csproj, FolioInit.cs, FolioInit.csproj, FolioMip1.cs, FolioMip1.csproj, FolioMip2.cs, FolioMip2.csproj, FolioMipIIS.cs, FolioMipIIS.csproj, FolioQC.cs, FolioQC.csproj, FolioQP.cs, FolioQP.csproj |
|
|
| Multi-knapsack - Constraint formulation alternatives: Constraint formulation options
|
| |
|
| Type: |
Multiple knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
The problem asks for assigning a set of items to multiple knapsacks with
the objective to maximize profit while respecting the per-knapsack weight
restrictions. Each knapsack has a capacity that limits the weight of items
that can be put into it. The capacity can be extended by a constant at a
fixed cost. The model shows several formulation options depending on
whether data is provided by arrays or by collections.
|
| File(s): |
MultipleKnapsack.cs, MultipleKnapsack_Arrays.csproj, MultipleKnapsack.cs, MultipleKnapsack_Collections.csproj |
|
|
| Polygon - Defining nonlinear constraints: Nonlinear constraints
|
| |
|
| Type: |
Nonlinear Programming |
| Rating: |
3 (intermediate) |
| Description: |
Maximize the area of polygon of N vertices and diameter of 1. This example demonstrates how to build nonlinear formulae from
strings and token sequences.
|
| File(s): |
PolygonObjects.cs, PolygonObjects.csproj |
|
|
| Project planning - Defining SOS: Binary variables, SOS definition
|
| |
|
| Multi-period, multi-site production planning: Formulation of resource constraints and
material balance constraints
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
Multi-period production planning for multiple production facilities, including opening/closing decisions for sites. Implementation
of helper routines for enumeration of arrays with multiple indices.
|
| File(s): |
ProductionPlanning_Index.cs, ProductionPlanning_Index.csproj |
|
|
| Purchase - Definition of SOS-2: Defining SOS-2, pwl, piecewise linear constarints
|
| |
|
| Type: |
Purchasing with pricebreaks |
| Rating: |
3 (intermediate) |
| Description: |
A model for optimal purchasing with price-breaks featuring a
complex MIP model, and formulation options using piecewise linear constraints (PurchasePWL) or SOS-2 (PurchaseSOS2).
|
| File(s): |
PurchasePWL.cs, PurchasePWL.csproj, PurchaseSOS2.cs, PurchaseSOS2.csproj |
|
|
| Solving a non-linear problem by recursion: Iterative solving, modify constraint definitions
|
| |
|
| Type: |
Recursion |
| Rating: |
3 (intermediate) |
| Description: |
A non-linear problem (quadratic terms in the constraints) is
solved via successive linear
programming (SLP, also referred to as recursion). The constraint coefficients are changed iteratively.
|
| File(s): |
RecursiveFinancialPlanning.cs, RecursiveFinancialPlanning.csproj |
|
|
| Sangraal - Scheduling problem with indicator constraints: Formulation of a scheduling problem with indicator constraints
|
| |
|
| Type: |
Scheduling |
| Rating: |
3 (intermediate) |
| Description: |
When the Sangraal (Holy Grail) is almost won the hero arrives at a castle where he finds 8 imprisoned knights. He is facing
the task to bring the largest possible number of knights for the arrival of the Sangraal in twenty minutes' time. The time
required for freeing a knight depends on his state of binding. A freed knight then needs a given amount of time to wash and
recover himself physically. For every knight, the durations of freeing and preparing are given.
|
| File(s): |
Sangraalind.cs, Sangraalind.csproj |
|
|
| Wagon - MIP start solution heuristic: Loading a MIP start solution
|
| |
|
| Type: |
Loading problem |
| 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 the MIP solver.
|
| File(s): |
Wagon.cs, Wagon.csproj |
|
|
| The travelling salesman problem: Using Xpress callbacks
|
| |
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimise
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
FixBV.cs, FixBV.csproj |
| Data file(s): |
coco.mps |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Apply a primal heuristic to a knapsack problem: Using the MIP log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the MIP log callback.
We take the knapsack problem stored in burglar.mps and initiate a
tree search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
Knapsack.cs, Knapsack.csproj |
| Data file(s): |
burglar.mps |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
LoadLP.cs, LoadLP.csproj |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.cs, MipSolEnum.csproj |
| Data file(s): |
hpw15.mps |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.cs, MipSolPool.csproj |
| Data file(s): |
hpw15.mps |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and tree search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mps and initiate a tree
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other tree search information, are displayed
on screen.
|
| File(s): |
SaveSol.cs, SaveSol.csproj |
| Data file(s): |
burglar.mps |
|
|
| Goal programming: Lexicographic goal programming using the Xpress multi-objective API
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
This example tries to construct a production plan which meets four different
goals in order of priority.
|
| File(s): |
GoalProg.cs, GoalProg.csproj |
|
|
|
| Calling the library from Java |
|
|
| Burglar - Formulating logical constraints: MIP, indicator constraints
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
1 (simple) |
| Description: |
This example shows how to setup a simple knapsack type problem in which an item
selection should be made maximally profitable under some weight restriction.
We first solve a pure knapsack problem. Then, we refine the constraints by
explicitly forbidding certain item combinations, thereby showing multiple ways
how to create indicator constraints.
|
| File(s): |
BinBurglar.java |
|
|
| Constraint types - Logical, general, SOS, quadratic: Defining different types of constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Small examples showing how to define special constraint types:
- Stating logic clauses that resemble SAT-type formulations (BoolVars).
- Formulating some constraints on the minimum and absolute values
of linear combinations of variables (GeneralConstraints).
- Using the 'pwl' construct to formulate a piecewise linear cost function (PiecewiseLinear).
- Formulation of a small quadratic programming problem (QuadraticProgramming).
- Approximation of a nonlinear function by a special ordered set of type 2 (SpecialOrderedSets) and of a quadratic function
in 2 variables by special ordered sets of type 2 (SpecialOrderedSetsQuadratic).
|
| File(s): |
BoolVars.java, GeneralConstraints.java, PiecewiseLinear.java, QuadraticProgramming.java, SpecialOrderedSets.java, SpecialOrderedSetsQuadratic.java |
|
|
| Boxes - Nonlinear constraints: Nonlinear constraints
|
| |
|
| Type: |
Production Planning |
| Rating: |
2 (easy-medium) |
| Description: |
Stating a small production planning problem with nonlinear constraints to determine the size of objects to be produced. |
| File(s): |
Boxes02.java |
|
|
| Capital budgeting - Using multi-objective optimization: Multi-objective solving
|
| |
|
| Type: |
Capital budgeting |
| Rating: |
2 (easy-medium) |
| Description: |
Capital budgeting example, solved using three multi-objective approaches:
- Lexicographic approach, solving first to minimize capital expended
and second to maximize return
- Blended approach, solving a weighted combination of both objectives
simultaneously
- Lexicographic approach, with the objective priorities reversed
The model version Capbgt2l demonstrates the formuation of logical constraints.
|
| File(s): |
CapitalBudgeting.java, Capbgt2l.java |
|
|
| Catenary - Solving a QCQP: Stating quadratic constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
This model finds the shape of a hanging chain by
minimizing its potential energy.
|
| File(s): |
Catenary.java |
|
|
| Contract - Semi-continuous variables: Defining semi-continuous variables
|
| |
|
| Type: |
Contract allocation |
| Rating: |
3 (intermediate) |
| Description: |
A small MIP-problem example demonstrating how to define semi-continuous variables. |
| File(s): |
ContractAllocation.java |
|
|
| Cutstk - Column generation for a cutting stock problem: Working with subproblems, modifying constraints
|
| |
|
| Type: |
Column generation |
| Rating: |
4 (medium-difficult) |
| Description: |
This example features iteratively adding new variables,
basis in/output and working with subproblems. The column
(=cutting pattern)
generation algorithm is implemented as a loop over the
root node of the MIP problem.
|
| File(s): |
CuttingStock.java |
|
|
| Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristics: Looping of optimization, using the cut manager
|
| |
|
| Type: |
Economic lot-sizing |
| Rating: |
5 (difficult) |
| Description: |
The version 'ELS' of this example shows how to implement cut-and-branch (= cut
generation at the root node of the MIP search) and 'ELSCut' implements a
branch-and-cut (= cut generation at the MIP search tree nodes)
algorithm using the cut manager.
|
| File(s): |
ELS.java, ELSCut.java, ELSManagedCuts.java |
|
|
| Facility location problem - Data as arrays or collections: Data structures arrays and collections
|
| |
|
| Folio - Examples from 'Getting Started': MIP modeling, binary fixing heuristic, quadratic constraints, infeasibility handling
|
| |
|
| 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 (FolioInit)
- 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, MIQP, QCQP problems (FolioQP, FolioQC)
- heuristic solution of a MIP problem (FolioHeuristic)
Advanced modeling and solving tasks:
- enlarged version of the basic MIP model (Folio, to be used with data set folio10.cdat)
- defining an integer solution callback (FolioCB, to be used with data set folio10.cdat)
- retrieving IIS (FolioIIS, FolioMipIIS, to be used with data set folio10.cdat)
|
| File(s): |
Folio.java, FolioCB.java, FolioHeuristic.java, FolioIIS.java, FolioInit.java, FolioMip1.java, FolioMip2.java, FolioMipIIS.java, FolioQC.java, FolioQP.java |
|
|
| General constraints - Minimium value and absolute value: Minimum value constraints and absolute value constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
A simple example that formulates some constraints on the minimum and absolute values
of linear combinations of variables.
|
| File(s): |
GeneralConstraints.java |
|
|
| Hang glider trajectory: Nonlinear constraints, trapezoidal discretization
|
| |
|
| Type: |
NLP |
| Rating: |
4 (medium-difficult) |
| Description: |
Maximize the total horizontal distance a hang glider flies subject to different configurable wind conditions. |
| File(s): |
Glidert.java |
|
|
| Multi-knapsack - Constraint formulation alternatives: Constraint formulation options
|
| |
|
| Type: |
Multiple knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
The problem asks for assigning a set of items to multiple knapsacks with
the objective to maximize profit while respecting the per-knapsack weight
restrictions. Each knapsack has a capacity that limits the weight of items
that can be put into it. The capacity can be extended by a constant at a
fixed cost. The model shows several formulation options depending on
whether data is provided by arrays or by collections.
|
| File(s): |
MultipleKnapsack_Arrays.java, MultipleKnapsack_Collections.java |
|
|
| Multi problems - Modifying constraint and variable definitions: Constraint redefinition, multiple problems
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Working with multiple problems, changing bounds, constraint operations. |
| File(s): |
MultipleProblems.java |
|
|
| Polygon - Defining nonlinear constraints: Nonlinear constraints
|
| |
|
| Type: |
Nonlinear Programming |
| Rating: |
3 (intermediate) |
| Description: |
Maximize the area of polygon of N vertices and diameter of 1. This example demonstrates how to build nonlinear formulae from
strings and token sequences.
|
| File(s): |
PolygonObjects.java |
|
|
| Project planning - Defining SOS: Binary variables, SOS definition
|
| |
|
| Type: |
Project planning |
| Rating: |
2 (easy-medium) |
| Description: |
Alternative formulations using either binary variables (Pplan) or SOS-1 (Pplan2) |
| File(s): |
Pplan.java, Pplan2.java |
|
|
| Multi-period, multi-site production planning: Formulation of resource constraints and
material balance constraints
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
Multi-period production planning for multiple production facilities, including opening/closing decisions for sites. Implementation
of helper routines for enumeration of arrays with multiple indices.
|
| File(s): |
ProductionPlanning_Index.java |
|
|
| Purchase - Definition of SOS-2: Defining SOS-2, pwl, piecewise linear
|
| |
|
| Type: |
Purchasing with pricebreaks |
| Rating: |
3 (intermediate) |
| Description: |
A model for optimal purchasing with price-breaks featuring a
complex MIP model, and formulation options using piecewise linear constraints (PurchasePWL) or SOS-2 (PurchaseSOS2).
|
| File(s): |
PurchasePWL.java, PurchaseSOS2.java |
|
|
| Solving a non-linear problem by recursion: Iterative solving, modify constraint definitions
|
| |
|
| Type: |
Recursion |
| Rating: |
3 (intermediate) |
| Description: |
A non-linear problem (quadratic terms in the constraints) is
solved via successive linear
programming (SLP, also referred to as recursion). The constraint coefficients are changed iteratively.
|
| File(s): |
RecursiveFinancialPlanning.java |
|
|
| Sangraal - Scheduling problem with indicator constraints: Formulation of a scheduling problem with indicator constraints
|
| |
|
| Type: |
Scheduling |
| Rating: |
3 (intermediate) |
| Description: |
When the Sangraal (Holy Grail) is almost won the hero arrives at a castle where he finds 8 imprisoned knights. He is facing
the task to bring the largest possible number of knights for the arrival of the Sangraal in twenty minutes' time. The time
required for freeing a knight depends on his state of binding. A freed knight then needs a given amount of time to wash and
recover himself physically. For every knight, the durations of freeing and preparing are given.
|
| File(s): |
Sangraalind.java |
|
|
| Wagon - MIP start solution heuristic: Loading a MIP start solution
|
| |
|
| Type: |
Loading problem |
| 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 the MIP solver.
|
| File(s): |
Wagon.java |
|
|
| Adding the message callback in Java: Using the message callback
|
| |
|
| Type: |
Adding callbacks |
| Rating: |
1 (simple) |
| Description: |
The examples demonstrates how to define a messaging callback for the Xpress Optimizer in Java. |
| File(s): |
Callback.java |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)
|
| File(s): |
IISExample.java |
| Data file(s): |
iisexample.mps |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.java |
| Data file(s): |
hpw15.mps |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.java |
| Data file(s): |
hpw15.mps |
|
|
| Collecting all solutions with the MIP solution pool: Modify a problem by adding extra rows and columns
|
| |
|
| Type: |
Trim Loss |
| Rating: |
3 (intermediate) |
| Description: |
We take a trimloss problem in which each integer variable x(p)
represents the number of rolls cut to pattern p.
We define a new integer variable y=SUM(p)x(p) and add the associated
constraint
x(1)+x(2)+...+x(N)-y = 0
We do this by first adding a row containing the (unitary)
coefficients of the x(p), and then a column corresponding to y.
We output the revised matrix to a file and then solve the revised
MIP, giving y the highest branching priority. Finally, we output
the solution, both to the screen and to an ASCII solution file.
|
| File(s): |
Trimloss.java |
| Data file(s): |
pplan.mps |
|
|
| Goal programming: Lexicographic goal programming using the Xpress multi-objective API
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
This example tries to construct a production plan which meets four different
goals in order of priority.
|
| File(s): |
GoalProg.java |
|
|
| The travelling salesman problem: Using Xpress callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solves the classic travelling salesman problem as a MIP,
where sub-tour elimination constraints are added
only as needed during the branch-and-bound search.
|
| File(s): |
TravelingSalesPerson.java, TSP.java |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimise
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
FixBV.java |
| Data file(s): |
coco.mps |
|
|
| Apply a primal heuristic to a knapsack problem: Using the MIP log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the MIP log callback.
We take the knapsack problem stored in burglar.mps and initiate a
tree search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
Knapsack.java |
| Data file(s): |
burglar.mps |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
LoadLP.java |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and tree search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mps and initiate a tree
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other tree search information, are displayed
on screen.
|
| File(s): |
SaveSol.java |
| Data file(s): |
burglar.mps |
|
|
| Adding MIP solutions to the Optimizer: Using the optnode callback, saving/loading bases, changing bounds
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
At each node of the tree search a variable fixing heuristic is applied to a copy of the problem. If an integer solution is
found for the modified (sub)problem then this solution is added to the original problem.
|
| File(s): |
AddMipSol.java |
| Data file(s): |
addmipsol.mps |
|
|
| Solve LP, displaying the initial and optimal tableau: Retrieve basic variables and their names, btran
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Inputs an MPS matrix file and required optimization sense, and
proceeds to solve the problem with lpoptimize. The simplex
algorithm is interrupted to get its intial basis, and a tableau is
requested with a call to function showtab. Once the solution is
found, a second call produces the optimal tableau.
Function showtab retrieves the pivot order of the basic variables,
along with other problem information, and then constructs (and
displays) the tableau row-by-row using the backwards transformation,
btran.
Note that tableau should only be used with matrices whose MPS names
are no longer than 8 characters.
|
| File(s): |
Tableau.java |
| Data file(s): |
tablo.mps, tablobig.mps |
|
|
| Branching rule branching on the most violated Integer/Binary: Using the change branch callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the Xpress Optimizer change branch callbacks |
| File(s): |
MostViolated.java |
|
|
| Repairing infeasibility: Using repairinfeas
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the repairinfeas utility,
prints a relaxation summary and
creates the relaxed subproblem.
|
| File(s): |
Repair.java |
|
|
| Apply an integer fixing heuristic to a MIP problem: Changing bounds
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which
seeks to optimise the operating pattern of a group of electricity
generators. We solve this MIP with a very loose integer tolerance
and then fix all binary and integer variables to their rounded
integer values, changing both their lower and upper bounds. We then
solve the resulting LP.
The results are displayed on screen and the problem statistics
stored in a logfile.
|
| File(s): |
RoundInt.java |
| Data file(s): |
hpw15.mps |
|
|
| Perform objective function parametrics on a MIP problem: Saving/loading bases, changing the objective
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Perform objective function parametrics on a global problem.
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
BEN(3), the benefit per month from finishing Project 3.
The program increments BEN(3) from 8 to 15, and for each of these
values revises the objective coefficients of the variables x(3,t),t=1:2
and finds the best integer solution. Note that, for each t, the
coefficient of x(3,t) is BEN(3)*(3-t) = BEN(3)*(6-t-4+1).
The results are displayed on screen and the problem statistics stored
in a log file.
|
| File(s): |
GlobalObjectiveParametrics.java |
| Data file(s): |
pplan.mps |
|
|
| Perform RHS parametrics on a MIP problem: Saving/loading bases, changing right-hand side values
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
the RHS element RESMAX(2), the resources available in Month 2.
The program decrements RESMAX(2) from 6 to 1, and for each of these
values assesses the feasibility of the revised problem and, where
possible, finds the best integer solution.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
GlobalRHSParametrics.java |
| Data file(s): |
pplan.mps |
|
|
|
| Calling the library from C++ |
|
|
| Burglar - Formulating logical constraints: MIP, indicator constraints
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
1 (simple) |
| Description: |
This example shows how to setup a simple knapsack type problem in which an item
selection should be made maximally profitable under some weight restriction.
We first solve a pure knapsack problem. Then, we refine the constraints by
explicitly forbidding certain item combinations, thereby showing multiple ways
how to create indicator constraints.
|
| File(s): |
BinBurglar.cpp |
|
|
| Constraint types - Logical, general, SOS, quadratic: Defining different types of constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Small examples showing how to define special constraint types:
- Stating logic clauses that resemble SAT-type formulations (BoolVars).
|
| File(s): |
BoolVars.cpp |
|
|
| Boxes - Nonlinear constraints: Nonlinear constraints
|
| |
|
| Type: |
Production Planning |
| Rating: |
2 (easy-medium) |
| Description: |
Stating a small production planning problem with nonlinear constraints to determine the size of objects to be produced. |
| File(s): |
Boxes02.cpp |
|
|
| Capital budgeting - Using multi-objective optimization: Multi-objective solving
|
| |
|
| Type: |
Capital budgeting |
| Rating: |
2 (easy-medium) |
| Description: |
Capital budgeting example, solved using three multi-objective approaches:
- Lexicographic approach, solving first to minimize capital expended
and second to maximize return
- Blended approach, solving a weighted combination of both objectives
simultaneously
- Lexicographic approach, with the objective priorities reversed
The model version Capbgt2l demonstrates the formuation of logical constraints.
|
| File(s): |
CapitalBudgeting.cpp, Capbgt2l.cpp |
|
|
| Catenary - Solving a QCQP: Stating quadratic constraints
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
This model finds the shape of a hanging chain by
minimizing its potential energy.
|
| File(s): |
Catenary.cpp |
|
|
| Contract - Semi-continuous variables: Defining semi-continuous variables
|
| |
|
| Type: |
Contract allocation |
| Rating: |
3 (intermediate) |
| Description: |
A small MIP-problem example demonstrating how to define semi-continuous variables. |
| File(s): |
ContractAllocation.cpp |
|
|
| Cutstk - Column generation for a cutting stock problem: Working with subproblems, modifying constraints
|
| |
|
| Type: |
Column generation |
| Rating: |
4 (medium-difficult) |
| Description: |
This example features iteratively adding new variables,
basis in/output and working with subproblems. The column
(=cutting pattern)
generation algorithm is implemented as a loop over the
root node of the MIP problem.
|
| File(s): |
CuttingStock.cpp |
|
|
| The travelling salesman problem: Using Xpress callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solves the classic travelling salesman problem as a MIP,
where sub-tour elimination constraints are added
only as needed during the branch-and-bound search.
|
| File(s): |
TravelingSalesPerson.cpp, tsp.cpp |
|
|
|
| Calling the library from VB.NET |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimise
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
FixBV.vb |
| Data file(s): |
coco.mps |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)
|
| File(s): |
GetBreakers.vb |
| Data file(s): |
infeas.lp |
|
|
| Apply a primal heuristic to a knapsack problem: Using the MIP log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the MIP log callback.
We take the knapsack problem stored in burglar.mps and initiate a
tree search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
Knapsack.vb |
| Data file(s): |
burglar.mps |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
LoadLP.vb |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.vb |
| Data file(s): |
hpw15.mps |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mps which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.vb |
| Data file(s): |
hpw15.mps |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and tree search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mps and initiate a tree
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other tree search information, are displayed
on screen.
|
| File(s): |
SaveSol.vb |
| Data file(s): |
burglar.mps |
|
|
|
|
|