Mosel modeling examples
This directory contains a set of introductory
examples that show how to write models using the Mosel language, including the formulation of simple LP, MIP, and QP problems,
basic data handling tasks, and the use of various types of discrete variables.
|
| Basic LP tasks: problem statement and solving; solution analysis: LP solving, solution printout, array and set data structures
|
| |
|
| Type: |
Production planning |
| Rating: |
1 (simple) |
| Description: |
The first model (file chess.mos) is a small, introductory
problem to modeling with Mosel that shows the basic
features of the Mosel language:
- formulation of a simple LP/IP problem
- solving an optimization problem
- solution printout
The second model (file chess2.mos) shows some more
advanced features of Mosel, namely the data structures
set and array:
- formulating and solving a simple LP problem
- defining a set of variables and an array of descriptions for the variables (to be used in the output printing)
Detailed solution information for MIP problems as may be
required when performing sensitivity analysis, such as
dual and reduced cost values (file chessfixg.mos) or
ranging information for variables and constraints (file
chessrng.mos), is not immediately available during or after
the branch-and-bound search. The following procedure
needs to be used to generate the sensitivity analysis data:
- Solve the MIP problem.
- Fix all discrete variables to their solution values.
- Re-solve the remaining LP problem.
- Retrieve the solution information.
|
| File(s): |
chess.mos, chess2.mos |
|
|
| Basic MIP tasks: binary variables; logic constraints: MIP solving, binary variables, index set types, logic constraints
|
| |
|
| Type: |
Knapsack |
| Rating: |
1 (simple) |
| Description: |
We wish to choose among items of different value and
weight those that result in the maximum total value for
a given weight limit.
- small MIP problem
- alternative use of number-valued ranges and sets of strings for indexing variables and data
- definition of binary variables
- forall statement
- formulation of logic constraints using indicators (burglarl.mos)
|
| File(s): |
burglar.mos, burglari.mos, burglarl.mos |
|
|
| Blend: A model for mineral blending: simple LP problem, formulation of blending constraints
|
| |
|
| Type: |
Blending |
| Rating: |
1 (simple) |
| Description: |
Several ores are blended to a final product that must
have a certain quality ('grade'). We wish to determine
the quantity of every ore to be used in the blend with
the objective to maximize the total profit (calculated
as sales revenues - raw material cost).
- simple LP problem
- data input from file
- bounds on variables
|
| File(s): |
blend.mos |
| Data file(s): |
blend.dat |
|
|
| Coco: The Coco productional planning problem: LP problem, formulation of resource constraints and
material balance constraints, formatted solution printing
|
| |
|
| Type: |
Production planning |
| Rating: |
2 (easy-medium) |
| Description: |
The company Coco has two plants that can produce two types
of cocoa powder. The plant capacities are limited.
It is possible to store raw materials and finished product
from one time period to the next. Raw material prices,
sales revenues, and the maximum amount that may be sold
depend on the time period. Raw material storage capacity
is limited.
Storing product between time periods incurs storage costs.
Some product is held in stock at the beginning of the
planning period.
The objective function of maximizing the total profit is
to maximize the sales revenues, minus the cost of production,
buying raw material, and storing finished products and raw
material.
- complete problem, data defined in the model definition
- if-then, if-then-else, if-then-elif statements
|
| File(s): |
coco.mos |
|
|
| Firestns: A set-covering model for emergency service provision: logical conditions in constraint definition
|
| |
|
| Type: |
Set covering |
| Rating: |
1 (simple) |
| Description: |
Minimize the total number of firestations that are required to service a set of towns within a specified permissible travel
time.
- simple LP problem
- definition of Booleans
- logical conditions in constraint definition
|
| File(s): |
fstns.mos |
|
|
| LCSP: Labour constrained scheduling problem: Dynamic creation of variables, formulation of resource constraints
|
| |
|
| Type: |
Resource constrained scheduling |
| Rating: |
3 (intermediate) |
| Description: |
Schedule the processing of a set of jobs with resource usage profiles subject to precedence constraints between certain pairs
of jobs. The objective is to minimize the makespan (completion time of last job).
- difficult MIP problem
- dynamic creation of variables
- constraint definitions with logical conditions
- using parameters in the optimization function
- if-then-else statement
|
| File(s): |
lscp1.mos |
|
|
| Basic set operations: Initializing sets, set operations, set comparison
|
| |
|
| Type: |
Pogramming |
| Rating: |
2 (easy-medium) |
| Description: |
Example 'setops':
- declaring constant and dynamic sets
- assigning and adding elements to sets
- using predefined set operations: union, intersection, subtraction
- printing sets
Example 'setcomp':
- comparison operators for sets
|
| File(s): |
setops.mos |
|
|
| Pplan: A project planning problem: Alternative formulation with SOS-1, formulation of resource use profiles
|
| |
|
| Type: |
Project planning |
| Rating: |
3 (intermediate) |
| Description: |
Over the next 6 months we have three projects which can
be done. Each of these projects has a profile of manpower
requirements over its lifetime, and a benefit which accrues
each month when the project has been completed.
Our problem is to determine when each project is to start,
subject to the constraint that in no month can we try to
use more manpower than is available.
- simple MIP problem
- alternative formulation using binary variables or SOS-1
- if-then-else statement
|
| File(s): |
pplan.mos |
|
|
| Purchase: A model for optimal purchasing with price-breaks: Modeling a piecewise linear function with SOS-2
|
| |
|
| Type: |
Purchasing with price breaks |
| Rating: |
3 (intermediate) |
| Description: |
There are three suppliers of a good, and they have quoted
various prices for various quantities of product. We want
to buy at least total cost, yet not buy too much from any
one supplier. Each supplier offers decreasing prices for
increased lot size, in the form of incremental discounts.
We wish to buy 600 items in total.
- complex MIP model
- data input from file, including parameters for dimensioning
- splitting the declaration section to read first the parameters that are used to declare the data arrays
- using SOS-2
|
| File(s): |
purch.mos |
| Data file(s): |
purch.dat |
|
|
| Catenary: Determine chain shape: QCQP problem
|
| |
|
| Type: |
Nonlinear |
| Rating: |
2 (easy-medium) |
| Description: |
Find the shape of a hanging chain by minimising its potential energy.
The problem is formulated as a QCQP problem (linear objective, convex quadratic constraints).
|
| File(s): |
catenary.mos |
|
|
| Transportation problem with piecewise linear cost expressions: MIP problem
|
| |
|
| Type: |
MIP with general constraints |
| Rating: |
2 (easy-medium) |
| Description: |
Formulating piecewise linear cost functions via pwlin constraints.
|
| File(s): |
transpl2.mos |
| Data file(s): |
transpl2.dat |
|
|
| Approximating nonlinear univariate functions via piecewise linear constraints: MIP problem
|
| |
|
| Type: |
MIP with general constraints |
| Rating: |
2 (easy-medium) |
| Description: |
Approximating nonlinear univariate functions using
piecewise linear constraints.
|
| File(s): |
piecewise_linear.mos |
|
|
| MAXSAT solving via MIP: MAXSAT model
|
| |
|
| Type: |
MAXSAT |
| Rating: |
2 (easy-medium) |
| Description: |
Using boolvar with and/or/not constraints, retrieving the associated mpvar for the formulation of the objective function,
solution reporting for boolvar.
|
| File(s): |
nrm_10_4_1.mos |
|
|
|