FICO Xpress Optimization Examples Repository
 FICO Optimization Community FICO Xpress Optimization Home

Overview of Mosel examples for 'Business Optimization' book

Description

List of FICO Xpress Mosel implementations of examples discussed in the book 'J. Kallrath: Business Optimization Using Mathematical Programming - An Introduction with Case Studies and Solutions in Various Algebraic Modeling Languages' (2nd edition, Springer, Cham, 2021, DOI 10.1007/978-3-030-73237-0).

List of provided model files

(Examples marked with * are newly introduced in the 2nd edition, all other models have been converted from the mp-model versions that were provided with the 1st edition of the book in 1997.)
absval.mos absval2.mos, absval2a.mos bench101.mos bench102.mos Filename Description Section Modeling absolute value terms (linearization) 6.5 * Modeling absolute value as general constraints 6.5 Parkbench production planning problem (solution to Exercise 10.1) 10.9 Parkbench production planning problem, MIP problem (solution to Exercise 10.2) 10.9 Ore blending problem 2.7.1 * Boat renting problem (solution for Exercise 3.3) 1.4.1, 3.7 * Multi-period Boat renting problem 1.6 Dual of the Boat renting problem (solution for Exercise 3.3) 3.7 Brewery production planning (data files: brewery.xlsx, brewdata.dat) 8.3 Generalized assignment problem (solution for Exercise 7.3) 7.10 Small knapsack problem 7.1.1 Bus crew scheduling 7.8.4 Calves and pigs problem 3.3.1 Carton production scheduling problem (data file: carton.dat) 10.3 * Minimal perimeter convex hull for two triangles 10.3 * Contract allocation problem with semi-continuous variables 10.2.1 Feasibility puzzle problem (solution for Exercise 6.5) 6.11 Data envelopment analysis (solution for Exercise 5.2) 5.3 Dual problem for a small LP (solution for Exercise 3.1b) 3.5.1 * Dynamic computation of big-M coefficients for production planning 14.1.2.1 * Production planning problem formulation using indicator constraints 14.1.2.1 * Evolutionary algorithm for supply management 14.1.3.3 Choosing investment projects (solution for Exercise 7.5) 7.10 Flowshop scheduling problem (solution for Exercise 7.7) 7.10 * Fractional programming example 11.1 Generalized assignment problem (solution for Exercise 7.2) 7.10 * Lexicographic Goal Programming 5.4.3 * Lagrange relaxation applied to the GAP 14.1.3.3 Multi-period, multi-site production planning, LP model (solution for Exercise 5.1) 5.3 Multi-period, multi-site production planning, MIP model (solution for Exercise 6.7) 6.11 * Production scheduling problem with SOS formulation (solution for Exercise 6.9) 6.11 Multi-knapsack problem (solution for Exercise 7.4) 7.10 Network flow problem (solution for Exercise 4.3) 4.7 Generic formulation of network flow problem (Exercise 4.3) 4.7 * Newsvendor problem: 2-stage stochastic programming 11.3.2.1 Net present value problem (solution for Exercise 6.8) 6.11 * Optimal breakpoints for piecewise linear approximation 14.2.3 * Multi-stage stochastic portfolio investment model 11.3.2.5 Primal problem for a small LP (solution for Exercise 3.1a) 3.7 Simple production planning example 2.5.2 Project scheduling case study 10.2.3 Linearized quadratic programming example 11.4 * Quadratic programming example solved as NLP 11.4 Set covering problem (solution for Exercise 7.6) 7.10 Simple LP problem (solution for Exercise 2.2) 2.13 Simple LP problem (solution for Exercise 2.3) 2.13 Lifting slabs (solution for Exercise 6.6) 6.11 Sludge production planning example illustrating recursion 11.2.1 * Recursion example solved as NLP 11.2.1 * (solution for Exercise 6.4) 6.11 Trimloss problem LP formulation (solution for Exercise 4.1) 4.1.1 Trimloss problem MIP formulation (solution for Exercise 4.2) 4.1.2 * Trimloss problem formulated as a MINLP problem 13.3 * Alternative NLP solver choice for trimloss problem 13.3 Traveling salesman problem (solution for Exercise 7.1) 7.10 * Vehicle routing - heating oil delivery problem 7.2.3 * (solution for Exercise 2.1) 2.13 Yield management, financial modeling 8.4.2

Source Files

Data Files

tsp.mos

(!*********************************************************************
Mosel Example Problems
======================

file tsp.mos

Travelling salesman problem

Example solution to exercise 7.1 in section 7.10 of
J. Kallrath: Business Optimization Using Mathematical Programming -
An Introduction with Case Studies and Solutions in Various Algebraic
Modeling Languages. 2nd edition, Springer Nature, Cham, 2021

author: S. Heipcke, June 2018

(c) Copyright 2020 Fair Isaac Corporation

you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and

*********************************************************************!)

model 'tsp'
uses "mmxprs"

declarations
N=8
NODES=1..N
C: array(NODES,NODES) of real     ! Distances
d: array(NODES,NODES) of mpvar    ! Selection of arcs travelled
y: array(NODES) of mpvar          ! Aux. subtour elimination variables
end-declarations

C::[1000,185,270,315,124,123,99,180,
185,1000,215,219,187,154,210,190,
270,215,1000,210,220,238,198,150,
315,219,210,1000,218,134,157,149,
124,187,220,218,1000,168,143,129,
123,154,238,134,168,1000,198,201,
99,210,198,157,143,198,1000,180,
180,190,150,149,129,201,180,1000]

! Objective: minimise total cost
Cost:=sum(i in NODES,j in NODES|i<>j) C(i,j) * d(i,j)

forall(j in NODES)
C1(j):=sum(i in NODES|i<>j) d(i,j) = 1      ! Each city is entered
forall(i in NODES)
C2(i):=sum(j in NODES|i<>j) d(i,j) = 1      ! Each city left
forall(i in 2..N,j in 2..N| i<>j)
C3(i,j):=y(i) - y(j) + (N-1)*d(i,j) <= N-2  ! Exclude invalid tours

forall(i in NODES,j in NODES|i<>j) d(i,j) is_binary

! Solve the problem
minimise(Cost)
writeln("Solution: Cost=", getobjval)
firsti:=1
write(firsti)
repeat
nexti:=round(getsol(sum(j in NODES|firsti<>j) j*d(firsti,j)))
write(" -> ",nexti)
firsti:=nexti
until nexti=1
writeln
end-model