Chapter 8 Modelling
Chapter 8 Modelling
OPTIMIZATION
Modelling
CONTENT
• Optimization problems
• Modelling overview
• Examples
Optimization problems
• Maximize or minimize some function relative to some set (range of
choices)
• The function represents the quality of the choice, indicating which
is the “best”
Modelling overview
• Modelling consists of specifying
• Decision variables
• Constraints
• Objective functions
• A problem can be modelled in different ways (how to define
variables)
• Take into account the modelling languages of software tools
• Constraint Programming solvers: constraints can be stated in
flexible ways
Constraint linearization
• Motivation
• Linear Programming solvers are very efficient
• Examples
• How to model X = min{x1,x2} ?
Constraint linearization
• Motivation
• Linear Programming solvers are very efficient
• Examples
• How to model X = min{x1,x2} ?
• Examples
• How to model (x = 1) (z y) where x is binary variable, y and z
are real variables ?
Constraint linearization
• Examples
• How to model (x = 1) (z y) where x is binary variable, y and z
are real variables ?
Solution:
• Let M be a very big constant,
• Introduce a binary variable t {0,1}:
• t = 1 indicates that x > 0, and t = 0 indicates that x = 0
• Equivalent linear constraints
• x ≤ M.t
• z + (1-t)M y
Balanced Course Assignment Problem
• At the beginning of the semester, the head of a computer science
department D have to assign courses to teachers in a balanced way.
The department D has m teachers T={0, 2, ..., m-1} and n courses C={0,
2,..., n-1}.
• Each teacher tT has a preference list which is a list of courses
he/she can teach depending on his/her specialization. The
preference information is represented by a 0-1 matrix Am x n in which
A(t,c) = 1 indicates that teacher t can teach the course c and A(t,c) =
0, otherwise
• We know a set B of pairs of conflicting two courses that cannot be
assigned to the same teacher as these courses have been already
scheduled in the same slot of the timetable.
• The load of a teacher is the number of courses assigned to her/him.
How to assign n courses to m teacher such that each course
assigned to a teacher is in his/her preference list, no two conflicting
courses are assigned to the same teacher, and the maximal load
among teachers is minimal.
Balanced Course Assignment Problem
• Example
Conflicting
Course 0 1 2 3 4 5 6 7 8 9 10 11 12 courses
credits 3 3 4 3 4 3 3 3 4 3 3 4 4
0 2
Teachers Preference Courses 0 4
0 0, 2, 3, 4, 8, 10 0 8
1 0, 1, 3, 5, 6, 7, 8 1 4
2 1, 2, 3, 7, 9, 11, 12 1 10
3 7
3 9
5 11
5 12
6 8
6 12
Balanced Course Assignment Problem
• Example
Conflicting
Course 0 1 2 3 4 5 6 7 8 9 10 11 12 courses
credits 3 3 4 3 4 3 3 3 4 3 3 4 4
0 2
Teachers Preference Courses 0 4
0 0, 2, 3, 4, 8, 10 0 8
1 0, 1, 3, 5, 6, 7, 8 1 4
2 1, 2, 3, 7, 9, 11, 12 1 10
3 7
Teacher Assigned courses Load 3 9
0 2, 4, 8, 10 15 5 11
1 0, 1, 3, 5, 6 15 5 12
2 7, 9, 11, 12 14 6 8
6 12
Balanced Course Assignment: CP model
• Decision variables
• X(i): teacher assigned to course i, i C, domain D(X(i)) = {t T |
A(t,i) = 1}
• Y(i): load of teacher i, domain D(Y(i)) = {0,1,…,n-1}
• Z: maximum load among teachers
• Constraints
• X(i) X(j), (i,j) B
• Y(i) = σ𝑗 C(𝑋 𝑗 = 𝑖), i T
• Z Y(i), i T
• Objective function to be minimized: Z
Balanced Course Assignment: ILP model
• Decision variables
• X(i,j) = 1: teacher i is assigned to course j, and X(i,j) = 0, otherwise,
i T, j C, domain D(X(i,j)) = {0,1}
• Y(i): load of teacher i, domain D(Y(i)) = {0,1,…,n}
• Z: maximum load among teachers
• Constraints
• σ𝑖T 𝑋 𝑖, 𝑗 = 1, , j C
• X(t,i) + X(t,j) ≤ 1, (i,j) B, t T
• Y(i) = σ𝑗 C 𝑋 𝑖, 𝑗 , i T
• Z Y(i), i T
• Objective function to be minimized: Z
Travelling Salesman Problem (TSP)
• A salesman departs from point 1, visiting N-1 points 2, …, N and comes
back to the point 1. The travelling distance from point i and point j is
d(i,j), i,j = 1,…,N. Compute the route of minimal total travelling distance
Travelling Salesman Problem (TSP)
• Decision variables
• Binary variable X(i,j) = 1 if the route traverses from point i to point j,
and X(i,j) = 0, otherwise.
• Constraints
• σ𝑁𝑗=1 𝑋 𝑖, 𝑗 = σ𝑗=1 𝑋 𝑗, 𝑖 = 1, i{1,2,…,N}
𝑁
5 7 1 0 2 3 4 3 3 3 3
1 3 2 4 0 2 6 1 1 1 1
3 2 4 0 2 1 1 1 1
4 5 7 7 0 4 4 4 4
4 2
5 3 1 5 7 0 0 0 0
6 8 6 3 1 5 7 0 0 0 0
7 3 1 5 7 0 0 0 0
8 3 1 5 7 0 0 0 0
1 2 3 4
r 4 3 6 5
1 2
c 10 10
Capacitated Vehicle Routing Problem
• Notations
• B = {1,…, N+2K}
• F1 = {(i, k+N) | i B, k {1,…,K}}
• F2 = {(k+K+N, i) | i B, k {1,…,K}}
• F3 = {(i, i) | i B}
• A = B2 \ F1\ F2 \ F3
• A+(i) = { j | (i, j) A}, A-(i) = { j | (j, i) A}
• Decision variables
• X(k,i,j) = 1 if truck k travel from point i to point j, k = 1,…,K, (i,j) A
• Y(k,i): number of items on truck k after leaving point i, k = 1,…,K,
i = 1,…,N+2K
• Z(i): index of truck visiting point i, i = 1,2,…, N+2K
Capacitated Vehicle Routing Problem
• Constraints
• σ𝐾 𝑘=1 𝑗A−(𝑖 ) 𝑋(𝑘, 𝑗, 𝑖, ) = 1, 𝑖 = 1,…, N
σ σ𝐾 σ
𝑘=1 𝑗A (𝑖 )
+ 𝑋(𝑘, 𝑖, 𝑗) =
• σ𝑗A+(𝑖 ) 𝑋(𝑘, 𝑖, 𝑗) =σ𝑗A−(𝑖 ) 𝑋(𝑘, 𝑗, 𝑖), i = 1,…,N, k = 1,…, K
• σ𝑁 𝑗=1 𝑋(𝑘, 𝑗, 𝑘 + 𝐾 + 𝑁) = 1, k = 1,…, K
σ 𝑁
𝑗=1 𝑋(𝑘, 𝑘 + 𝑁, 𝑗) =
• M(1-X(k,i,j)) + Z(i) Z(j), (i,j) A, k = 1,…,K
• M(1-X(k,i,j)) + Z(j) Z(i), (i,j) A, k = 1,…,K
• M(1-X(k,i,j)) + Y(k,j) Y(k,i) + r(j), (i,j) A, k = 1,…,K
• M(1-X(k,i,j)) + Y(k,i) + r(j) Y(k,j), (i,j) A, k = 1,…,K
• Y(k,k+K+N) ≤ c(k), k = 1,…,K
• Y(k,k+N) = 0, k = 1,…,K
• Z(k+N) = Z(k+K+N) = k, k = 1,…,K
Capacitated Vehicle Routing Problem
• Objective function
• 𝑓 𝑋, 𝑌, 𝑍 = σ𝐾 𝑘=1 σ(𝑖,𝑗)A 𝑋 𝑘, 𝑖, 𝑗 𝑑(𝑖, 𝑗) → min
MultiCast Routing Problem
• Given a network V = {1,…,N} is the set of
nodes, E V2 is the set of links between
nodes. A node s V is the source node which
will transmit a package to others nodes. A
node receiving the package can continue
transmit this package to adjacent nodes.
• t(i,j) and c(i,j) are transmission time and
transmission cost when transmitting the 1 2
package from node i to node j
• Compute the set of links used for 7
broadcasting the package from the source 4 3
node to all other nodes such that
• Total transmission time from s to any 6
5
node cannot exceed a given value L
• Total transmission cost is minimal
MultiCast Routing Problem
• Denote A(i) = {j V | (i,j) E }, M is a big constant
• Decision variables
• Binary variable X(i,j) = 1 if the package is transmitted from node i to
node j, and X(i,j) = 0, otherwise, (i,j)E
• Y(i): time-point when the package arrives at node i, iV
• Constraints
• σ𝑖𝐴(𝑗) 𝑋(𝑖, 𝑗) = 1, jV\{s}
• Y(i) + t(i,j) + M(1-X(i,j)) Y(j), (i,j)E
• Y(i) + t(i,j) + M(X(i,j)-1) ≤ Y(j), (i,j)E
• Y(i) ≤ L, jV\{s}
• Y(s) = 0
• Objective function to be minimized
f(X) = σ(𝑖,𝑗)𝐸 𝑐 𝑖, 𝑗 𝑋(𝑖, 𝑗)
Facility Location
• There are M sites 1, 2, …, M that can be used to open facility for
servicing N customers 1, 2, …, N.
• f(i) is the cost for opening the site i
• Q(i) is the capacity of site i (maximum amount of good it can serve
customers)
• c(i,j) is the cost for transporting unit of good from site i to customer j
• d(j) is the total demand (amount of goods) of customer j
• Compute a planning (which site to be opened and amount of good each
opened site serves a customer) such that
• Capacity constraint is satisfied
• Total cost is minimal
Facility Location
• Decision variables
• Y(i) – binary variable, Y(i) = 1 means that the site i is opened, and
Y(i) = 0, otherwise
• X(i,j) – amount of good site i serves customer j
• Constraints
• σ𝑀𝑖=1 𝑋(𝑖, 𝑗) = d(j), j = 1,…, N
• σ𝑁𝑗=1 𝑋(𝑖, 𝑗) ≤ Q(i)Y(i), i = 1,…, M
• 0 ≤ X(i,j) ≤ d(j)Y(i), i = 1,…, M, j = 1,…, N
• Objective functions
σ𝑀 𝑀
𝑖=1 𝑓 𝑖 𝑌(𝑖) + σ𝑖=1 σ𝑁
𝑗=1 𝑐 𝑖, 𝑗 𝑋(𝑖, 𝑗) → min
Exercises
• Resource constrained shortest path problem
• Degree constrained minimum spanning tree problem
Thank you
for your
attentions!