Model examples by application area
This page lists all examples of Mosel implementations from the book 'Applications of optimization with Xpress-MP' (Dash Associates,
2002). The organization of the examples in the subdirectories follows the
structure of the book, organizing the models according to application areas.
|
| Introductory examples |
|
|
| Introductory examples |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
| approx |
Approximation: Piecewise linear approximation
|
** |
|
SOS-2, Special Ordered Sets, piecewise linear approximation of a nonlinear function, pwlin |
| burglar |
MIP modeling: Knapsack problem: 'Burglar'
|
* |
|
simple MIP model with binary variables, data input from text data file, array initialization, numerical indices, string indices,
record data structure
|
| chess |
LP modeling: Production planning: 'Chess' problem
|
* |
|
simple LP model, solution output, primal solution values, slack values, activity values, dual solution values |
| pricebrai |
All item discount pricing: Piecewise linear function
|
*** |
|
SOS-1, Special Ordered Sets, piecewise linear function, approximation of non-continuous function, step function, pwlin |
| pricebrinc |
Incremental pricebreaks: Piecewise linear function
|
*** |
|
SOS-2, Special Ordered Sets, piecewise linear function, step function |
|
| File(s): |
approx.mos (Sep. 2006), approx2.mos (Jul. 2021), burglar1.mos (Jul. 2002), burglar2.mos (Aug. 2002), burglari.mos (Jul. 2002), burglar_rec.mos (Jul. 2006), chess.mos (Jul. 2002), chess2.mos (Jul. 2002), pricebrai.mos (Sep. 2006), pricebrai2.mos (Jul. 2021), pricebrinc.mos (Sep. 2006), pricebrinc2.mos (Sep. 2006), pricebrinc3.mos (Jul. 2021)
|
| Data file(s): |
burglar.dat, burglar2.dat, burglar_rec.dat |
|
|
|
| A. Mining and process industries |
|
|
| Mining and process industries |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| A‑1 |
Production of alloys: Blending problem
formulation of blending constraints; data with numerical indices, solution printout, if-then, getsol
|
* |
blending_graph.mos |
| A‑2 |
Animal food production: Blending problem
formulation of blending constraints; data with string indices, as, formatted solution printout, use of getsol with linear expressions, strfmt
|
* |
a1alloy.mos |
| A‑3 |
Refinery : Blending problem
formulation of blending constraints; sparse data with string indices, dynamic initialization, union of sets
|
** |
a2food.mos |
| A‑4 |
Cane sugar production : Minimum cost flow (in a bipartite graph) mo
ceil, is_binary, formattext
|
* |
e2minflow.mos, mincostflow_graph.mos
|
| A‑5 |
Opencast mining: Minimum cost flow
encoding of arcs, solving LP-relaxation only, array of set
|
** |
a4sugar.mos |
| A‑6 |
Production of electricity: Dispatch problem
inline if, is_integer, looping over optimization problem solving
|
** |
|
|
| File(s): |
a1alloy.mos (Feb. 2002), a2food.mos (Feb. 2002), a3refine.mos (Feb. 2002), a4sugar.mos (Feb. 2002), a5mine.mos (Feb. 2002), a5mine2.mos (Jan. 2006), a6electr.mos (Mar. 2002), a6electrg.mos (Oct. 2004)
|
| Data file(s): |
a1alloy.dat, a2food.dat, a3refine.dat, a4sugar.dat, a5mine.dat, a5mine2.dat, a6electr.dat |
|
|
|
| B. Scheduling problems |
|
|
| Scheduling problems |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| B‑1 |
Construction of a stadium: Project scheduling (Method of Potentials)
|
*** |
projplan_graph.mos |
|
2 problems; selection with `|', sparse/dense format, naming and redefining constraints, subroutine: procedure for solution printing, forward declaration, array of set |
| B‑2 |
Flow shop scheduling
|
**** |
flowshop_graph.mos |
|
alternative formulation using SOS1 |
| B‑3 |
Job shop scheduling
|
*** |
jobshop_graph.mos |
|
formulating disjunctions (BigM); dynamic array, range, exists, forall-do,array of set, array of list |
| B‑4 |
Sequencing jobs on a bottleneck machine: Single machine scheduling
|
*** |
sequencing_graph.mos |
|
3 different objectives; subroutine: procedure for solution printing, localsetparam, if-then |
| B‑5 |
Paint production: Asymmetric Traveling Salesman Problem (TSP)
|
*** |
|
|
solution printing, repeat-until, cast to integer, selection with `|', round |
| B‑6 |
Assembly line balancing
|
** |
linebal_graph.mos |
|
encoding of arcs, range |
|
| File(s): |
b1stadium.mos (Mar. 2002), b1stadium2.mos (Jan. 2006), b2flowshop.mos (Mar. 2002), b3jobshop.mos (Mar. 2002), b3jobshop2.mos (Mar. 2002), b3jobshop3.mos (Jan. 2006), b4seq.mos (Mar. 2002), b5paint.mos (Mar. 2002), b6linebal.mos (Mar. 2002)
|
| Data file(s): |
b1stadium.dat, b1stadium2.dat, b2flowshop.dat, b3jobshop.dat, b3jobshop2.dat, b3jobshop3.dat, b4seq.dat, b5paint.dat, b6linebal.dat |
|
|
|
| C. Planning problems |
|
|
| Planning problems |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| C‑1 |
Planning the production of bicycles: Production planning (single product)
|
*** |
|
|
modeling inventory balance; inline if, forall-do |
| C‑2 |
Production of drinking glasses: Multi-item production planning
|
** |
prodplan_graph.mos |
|
modeling stock balance constraints; inline if, index value 0 |
| C‑3 |
Material requirement planning: Material requirement planning (MRP)
|
** |
|
|
working with index (sub)sets, dynamic initialization, automatic finalization, as |
| C‑4 |
Planning the production of electronic components: Multi-item production planning
|
** |
c2glass.mos |
|
modeling stock balance constraints; inline if |
| C‑5 |
Planning the production of fiberglass: Production planning with time-dependent production cost
|
*** |
transship_graph.mos |
|
representation of multi-period production as flow; encoding of arcs, exists, create, isodd, getlast, inline if |
| C‑6 |
Assignment of production batches to machines: Generalized assignment problem
|
* |
assignment_graph.mos |
|
| File(s): |
c1bike.mos (Mar. 2002), c2glass.mos (Mar. 2002), c3toy.mos (Mar. 2002), c4compo.mos (Mar. 2002), c5fiber.mos (Mar. 2002), c6assign.mos (Mar. 2002)
|
| Data file(s): |
c1bike.dat, c2glass.dat, c3toy.dat, c4compo.dat, c5fiber.dat, c6assign.dat |
|
|
|
| D. Loading and cutting problems |
|
|
| Loading and cutting problems |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| D‑1 |
Wagon load balancing: Nonpreemptive scheduling on parallel machines
|
**** |
|
|
heuristic solution requiring sorting algorithm, formulation of maximin objective; nested subroutines: function returning heuristic solution value and sorting procedure, ceil, getsize, if-then, break, exit, all loop types (forall-do, repeat-until, while-do), setparam, qsort, cutoff value, loading a MIP start solution |
| D‑2 |
Barge loading: Knapsack problem
|
** |
burglar1.mos, knapsack_graph.mos
|
|
incremental problem definition with 3 different objectives, procedure for solution printing |
| D‑3 |
Tank loading: Loading problem
|
*** |
|
|
2 objectives; data preprocessing, as, dynamic creation of variables, procedure for solution printing, if-then-else |
| D‑4 |
Backing up files: Bin-packing problem
|
** |
binpacking_graph.mos |
|
2 versions of mathematical model, symmetry breaking; data preprocessing, ceil, range |
| D‑5 |
Cutting sheet metal: Covering problem
|
* |
g6transmit.mos, j2bigbro.mos |
|
|
| D‑6 |
Cutting steel bars for desk legs: Cutting-stock problem
|
** |
cutstock_graph.mos |
|
set operation(s) on range sets, set of integer (data as set contents) |
|
| File(s): |
d1wagon.mos (Mar. 2002), d1wagon2.mos (Sep. 2007), d2ship.mos (Mar. 2002), d3tanks.mos (Mar. 2002), d4backup.mos (Mar. 2002), d5cutsh.mos (Mar. 2002), d6cutbar.mos (Mar. 2002)
|
| Data file(s): |
d1wagon.dat, d2ship.dat, d3tanks.dat, d4backup.dat, d5cutsh.dat, d6cutbar.dat |
|
|
|
| E. Ground transport |
|
|
| Ground transport |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| E‑1 |
Car rental: Transport problem
|
*** |
transport_graph.mos |
|
data preprocessing, set operations, sqrt and ^2, if-then-elif |
| E‑2 |
Choosing the mode of transport: Minimum cost flow
|
** |
mincostflow_graph.mos |
|
formulation with extra nodes for modes of transport; encoding of arcs, finalize, union of sets, nodes labeled with strings |
| E‑3 |
Depot location: Facility location problem
|
*** |
facilityloc_graph.mos |
|
modeling flows as fractions, definition of model cuts |
| E‑4 |
Heating oil delivery: Vehicle routing problem (VRP)
|
**** |
vrp_graph.mos |
|
elimination of inadmissible subtours, cuts; selection with `|', definition of model cuts |
| E‑5 |
Combining different modes of transport
|
*** |
|
|
modeling implications, weak and strong formulation of bounding constraints; triple indices |
| E‑6 |
Fleet planning for vans
|
*** |
|
|
maxlist, minlist, max, min |
|
| File(s): |
e1carrent.mos (Mar. 2002), e2minflow.mos (Mar. 2002), e3depot.mos (Mar. 2002), e4deliver.mos (Mar. 2002), e5combine.mos (Mar. 2002), e6vanrent.mos (Mar. 2002)
|
| Data file(s): |
e1carrent.dat, e2minflow.dat, e3depot.dat, e4deliver.dat, e5combine.dat, e6vanrent.dat |
|
|
|
| F. Air transport |
|
|
| Air transport |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| F‑1 |
Flight connections at a hub: Assignment problem
|
* |
assignment_graph.mos, i1assign.mos, c6assign.mos |
|
|
| F‑2 |
Composing flight crews: Bipartite matching
|
**** |
matching_graph.mos |
|
2 problems, data preprocessing, incremental definition of data array, encoding of arcs, logical or (cumulative version) and and, procedure for printing solution, forall-do, max, finalize |
| F‑3 |
Scheduling flight landings: Scheduling problem with time windows
|
*** |
|
|
generalization of model to arbitrary time windows; calculation of specific BigM, forall-do |
| F‑4 |
Airline hub location: Hub location problem
|
*** |
|
|
quadruple indices; improved (re)formulation (first model not usable with student version), union of index (range) sets |
| F‑5 |
Planning a flight tour: Symmetric traveling salesman problem
|
***** |
tsp_graph.mos |
|
loop over problem solving, TSP subtour elimination algorithm; procedure for generating additional constraints, recursive
subroutine calls, working with sets, forall-do, repeat-until, getsize, not
|
|
| File(s): |
f1connect.mos (Mar. 2002), f2crew.mos (Mar. 2002), f3landing.mos (Mar. 2002), f4hub.mos (Mar. 2002), f4hub2.mos (Jul. 2002), f4hub3.mos (Dec. 2008), f5tour.mos (Mar. 2002), f5tour2.mos (Jun. 2002)
|
| Data file(s): |
f1connect.dat, f2crew.dat, f3landing.dat, f4hub.dat, f5tour.dat, f5tour23.dat, f5tour7.dat |
|
|
|
| G. Telecommunication problems |
|
|
| Telecommunication problems |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| G‑1 |
Network reliability: Maximum flow with unitary capacities
|
*** |
maxflow_graph.mos, j1water.mos |
|
encoding of arcs, range, exists, create, algorithm for printing paths, forall-do, while-do, round, list handling |
| G‑2 |
Dimensioning of a mobile phone network
|
** |
|
|
if-then, exit |
| G‑3 |
Routing telephone calls: Multi-commodity network flow problem
|
*** |
multicomflow_graph.mos |
|
encoding of paths, finalize, getsize |
| G‑4 |
Construction of a cabled network: Minimum weight spanning tree problem
|
*** |
spanningtree_graph.mos |
|
formulation of constraints to exclude subcycles |
| G‑5 |
Scheduling of telecommunications via satellite: Preemptive open shop scheduling
|
***** |
openshop_graph.mos |
|
data preprocessing, algorithm for preemptive scheduling that involves looping over optimization, ``Gantt chart'' printing |
| G‑6 |
Location of GSM transmitters: Covering problem
|
* |
covering_graph.mos, d5cutsh.mos, j2bigbro.mos |
|
modeling an equivalence; sparse data format |
|
| File(s): |
g1rely.mos (Mar. 2002), g2dimens.mos (Apr. 2002), g3routing.mos (Apr. 2002), g4cable.mos (Apr. 2002), g5satell.mos (Apr. 2002), g6transmit.mos (Apr. 2002)
|
| Data file(s): |
g1rely.dat, g2dimens.dat, g3routing.dat, g4cable.dat, g5satell.dat, g6transmit.dat |
|
|
|
| H. Economics and finance |
|
|
| Economics and finance |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| H‑1 |
Choice of loans
|
* |
|
|
calculation of net present value |
| H‑2 |
Publicity campaign
|
* |
|
|
forall-do |
| H‑3 |
Portfolio selection
|
** |
h7qportf.mos |
|
sets of integers, second formulation with semi-continuous, parameters |
| H‑4 |
Financing an early retirement scheme
|
** |
|
|
inline if, selection with `|' |
| H‑5 |
Family budget
|
** |
|
|
formulation of monthly balance constraints including different payment frequencies; as, mod, inline if, selection with `|' |
| H‑6 |
Choice of expansion projects
|
** |
capbgt_graph.mos |
|
experiment with solutions: solve LP problem explicitly, ``round'' some almost integer variable and re-solve |
| H‑7 |
Mean variance portfolio selection: Quadratic Programming problem
|
*** |
folioqp_graph.mos |
|
parameters, forall-do, min, max, loop over problem solving |
|
| File(s): |
h1loan.mos (Mar. 2002), h2publ.mos (Mar. 2002), h3portf.mos (Mar. 2002), h4retire.mos (Mar. 2002), h5budget.mos (Mar. 2002), h6expand.mos (Mar. 2002), h7qportf.mos (Aug. 2002)
|
| Data file(s): |
h1loan.dat, h2publ.dat, h3portf.dat, h4retire.dat, h5budget.dat, h6expand.dat, h7qportf.dat |
|
|
|
| I. Timetabling and personnel planning |
|
|
| Timetabling and personnel planning |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| I‑1 |
Assigning personnel to machines: Assignment problem
|
**** |
assignment_graph.mos, c6assign.mos |
|
formulation of maximin objective; heuristic solution + 2 different problems (incremental definition) solved, working with
sets, while-do, forall-do
|
| I‑2 |
Scheduling nurses
|
*** |
|
|
2 problems, using mod to formulate cyclic schedules; forall-do, set of integer, getact |
| I‑3 |
Establishing a college timetable
|
*** |
timetable_graph.mos |
|
many specific constraints, tricky (pseudo) objective function |
| I‑4 |
Exam schedule
|
** |
|
|
symmetry breaking, no objective |
| I‑5 |
Production planning with personnel assignment
|
*** |
|
|
2 problems, defined incrementally with partial re-definition of constraints (named constraints), exists, create, dynamic array |
| I‑6 |
Planning the personnel at a construction site
|
** |
persplan_graph.mos |
|
formulation of balance constraints using inline if |
|
| File(s): |
i1assign.mos (Mar. 2002), i2nurse.mos (Mar. 2002), i3school.mos (Mar. 2002), i4exam.mos (Mar. 2002), i5pplan.mos (Mar. 2002), i6build.mos (Mar. 2002)
|
| Data file(s): |
i1assign.dat, i2nurse.dat, i3school.dat, i4exam.dat, i5pplan.dat, i6build.dat |
|
|
|
| J. Local authorities and public services |
|
|
| Local authorities and public services |
| |
|
| Description: |
| Problem name and type, features |
Difficulty |
Related examples |
| J‑1 |
Water conveyance / water supply management: Maximum flow problem
|
** |
j1water_graph.mos, g1rely.mos |
|
encoding of arcs, selection with `|', record data structure |
| J‑2 |
CCTV surveillance: Maximum vertex cover problem
|
** |
j2bigbro_graph.mos, g6transmit.mos, d5cutsh.mos |
|
encoding of network, exists |
| J‑3 |
Rigging elections: Partitioning problem
|
**** |
j3elect_graph.mos, partitioning_graph.mos
|
|
algorithm for data preprocessing; file inclusion, 3 nested/recursive procedures, working with sets, if-then, forall-do, exists, finalize |
| J‑4 |
Gritting roads: Directed Chinese postman problem
|
**** |
j4grit_graph.mos |
|
algorithm for finding Eulerian path/graph for printing; encoding of arcs, dynamic array, exists, 2 functions implementing Eulerian circuit algorithm, round, getsize, break, while-do, if-then-else, list handling |
| J‑5 |
Location of income tax offices: p-median problem
|
**** |
|
|
modeling an implication, all-pairs shortest path algorithm (Floyd-Warshall); dynamic array, exists, procedure for shortest path algorithm, forall-do, if-then, selection with `|' |
| J‑6 |
Efficiency of hospitals: Data Envelopment Analysis (DEA)
|
*** |
|
|
description of DEA method; loop over problem solving with complete re-definition of problem every time, naming and declaring
constraints
|
|
| File(s): |
j1water.mos (Mar. 2002), j1water2.mos (Jan. 2006), j1water_graph.mos (Jun. 2023), j2bigbro.mos (Mar. 2002), j2bigbro_graph.mos (Jun. 2023), j3elect.mos (Apr. 2002), j3elect_calc.mos (Apr. 2002), j3elect_calc2.mos (Jan. 2006), j3elect_graph.mos (Jun. 2023), j4grit.mos (Mar. 2002), j4grit2.mos (Jan. 2006), j4grit_graph.mos (Mar. 2002), j5tax.mos (Mar. 2002), j6hospit.mos (Mar. 2002)
|
| Data file(s): |
j1water.dat, j1water2.dat, j2bigbro.dat, j3elect.dat, j3elect2.dat, j4grit.dat, j5tax.dat, j6hospit.dat |
|
|
|
| K. Puzzles and pastimes |
|
|
| Puzzles and pastimes |
| |
|
| Description: |
The following models implement solutions to the puzzles
published in the book `Programmation Lineaire' by
C. Gueret, C. Prins, and M. Sevaux (Eyrolles 2000, in French).
Each problem is implemented as a MIP and as a CP model.
| Problem name |
Difficulty |
| K‑1 |
Playing Mastermind
|
** |
| K‑2 |
Marathon puzzle
|
* |
| K‑3 |
Congress puzzle
|
* |
| K‑4 |
Placing chips
|
* |
| K‑5 |
Nephew puzzle
|
** |
| K‑6 |
N-queens problem
|
* |
These models show how to formulate different logical constraints using binary variables (MIP models).
|
| File(s): |
k1masterm.mos, k2marath.mos, k3congress.mos, k4even.mos, k5nephew.mos, k6queens.mos |
|
|
|
|
|