0% found this document useful (0 votes)
16 views98 pages

Lecture 3 - MIP Modeling (Annotated 2023)

Uploaded by

Manuel Andersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views98 pages

Lecture 3 - MIP Modeling (Annotated 2023)

Uploaded by

Manuel Andersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

DIIIO06 –Lecture 2

MIP Modeling
1. Basics of MIP modeling
2. Some MIP examples
3. Modeling: Logical constraints
4. More MIP modeling examples
5. (More on Logical constraints)
1.
Basics of MIP modeling
General LP model

c: nx1 vector, b: mx1 vector and A : mxn


matrix.
General MILP model

c: nx1 vector, d: px1 vector, b: mx1 vector, A : mxn matrix


and G: mxp matrix.
Modeling real problems by using linear models
We want to model problems arising from real
applications using linear optimization.

(For now we do not care how to solve these problems.)

You have learned how to model by using LPs.

Now we will learn how to model problems by


using MILPs.
Why do we need integer variables? (some reasons)
We can model:
1. Discreteness.
2. Yes/no decisions.
3. Logical relations
1. Discreteness (the obvious one!!!)

Sometimes fractional values do not


make sense and we need integer
variables.
Ex: whole numbers, indivisible objects, etc.
Ex: workers schedule

t=6
2. Yes/no decisions (very useful!!!)
Ex: Portfolio optimization
n assets available
Want to maximize expected return of the
stocks.

At most M stocks can be held in the portfolio.

Initial budget is $B.


Portfolio optimization (variables and more
data)

r_i: expected return of asset i.


Data:
p_i: price of asset i.
Portfolio optimization (MILP model)

} Expected
return

} Maximum
stocks
number of

} Budget constraint
} variables
Binary
3. Logical relations (very useful!!!)
Ex: Production planning + fixed cost
On each period t we have:
amount produced in t

inventory
at the
beginning
t demand
in t + setup cost
in period t
of t
inventory at the end of t
Setup cost in period t
“If we produce in period t, the we pay a fixed cost of f_t.”

If we pay

This can be modeled by using


integer variables!!! (coming soon)
LP vs MILP (trade-off)
MILPs models are more powerful in terms
of modeling, but they are also more
difficult to solve (important trade-off!).
But in practice, we are able to solve large-scale integer
optimization problems with millions of variables and
constraints.
2. Some MIP
examples:
•A power plant problem
•The facility location problem
2.a A power plant problem: generation of electricity using boilers and
turbines
The model
2b. The
facility
location
problem
First model:
The uncapacitated
facility location
problem
The facility location
problem: data (1)

n potential
facility
locations

m clients; must
be served by
one facility
The facility location
problem: data (2)

fi cost of
opening
cij
facility i fi

cij cost of facility


i serving client j
(if facility is opened)
The facility location
problem: variables

yi = 1 if
facility i is
opened, 0 xij
else yi

xij = 1 if facility i
serves client j (if
facility is opened), 0
else
The model
The model (better alternative version)
Comparison to the assignment problem
The facility location problem is an “assignment
problem”, but
• Each client must be assigned to exactly one
facility
• Facilities can serve more than one client
• Cannot use facilities that are not opened
• Costs of opening facilities and serving clients
Second model:
The capacitated
facility location
problem
The capacitated facility
location problem: data (1)

n potential
facility
locations; with ui
capacity ui
m clients with
demand dj; can dj
be served by
more than one
facility
The capacitated facility
location problem: data (2)

fi cost of
opening
cij
facility i fi

cij cost of facility i dj


serving one unit of
demand to client j
(if facility is opened)
The capacitated facility
location problem: variables

yi = 1 if
facility i is
opened, 0 xij
else yi

xij = fraction of dj
demand served by
facility i to client j
(if facility is opened)
The model
3. Logical
constraints
Logical constraints appear often
in practice.

We will see some examples by


looking at the uncapacitated
facility location problem
Reminder: The Uncapacitated
facility location problem

yi = 1 if
facility i is
opened, 0 xij
else yi

xij = 1 if facility i
serves client j (if
facility is opened), 0
else
How to model the following conditions?
1. If facility 1 is opened, then facility 2 must be opened.
2. If facility 1 is opened, then facility 2 cannot be opened.
3. If facility 1 is opened, then either facility 2 or facility 3
must be opened.
4. If facility 1 is opened, then either facility 2 or facility 3
must be opened, but not both.
5. If facility 1 or facility 2 are opened, then we need to
pay $100 of penalty.
How to model the following conditions? (in
terms of the variables)

1. If y1=1, then y2=1.


2. If y1=1, then y2=0.
3. If y1=1, then either y2=1 or y3=1.
4. If y1=1, then either y2=1 or y3=1, but y2+y3≤1.
5. If y1=1 or y2=1 then we need to pay $100 of penalty.
How to model
these logical
constraints?
1. If facility 1 is opened, then facility 2 must
be opened (If y1=1, then y2=1).
2. If facility 1 is opened, then facility 2 cannot be
opened (If y1=1, then y2=0).
3. If facility 1 is opened, then either facility 2 or
facility 3 must be opened (If y1=1, then either y2=1 or
y3=1).
4. If facility 1 is opened, then either facility 2 or
facility 3 must be opened, but not both (If y1=1, then
either y2=1 or y3=1, but y2+y3≤1).
5. If facility 1 or facility 2 are opened, then we
need to pay $100 of penalty (If y1=1 or y2=1 then we
need to pay $100 of penalty).
Bonus 1: If facility 1 is opened, then at most one
among facilities 2,3,4,5,6,7 can be opened (If y1=1,
then y2 + y3 + y4 + y5 + y6 + y7 ≤1).
Bonus 2: If facility 1 is opened, then client 3 must
be served by either facility 2 or facility 3 (If y1=1, then
either x23= 1 or x33= 1.
One application:
Production
planning+fixed
costs
Example: Production planning + fixed cost
Data:
• T: number of periods • pt: unit production cost in t
• dt: demand in t • ft: setup cost in t
• s0: initial inventory

1 2 … t … T-1 T

To decide: production (xt) and inventory levels (st) at the


end of each period t=1,2,…,T.
Setup cost in period t
“If we produce in period t, the we pay a fixed cost of ft.”

If we pay

This can be modeled by using


logical constraints.
The if-then constraint for the setup cost
The model

Note: xt and st could be constrained to


be integer if the product is “discrete”.
4. More MILP modeling examples:
a. TSP
b. Single-Machine Job
Scheduling
4a. Traveling Salesman Problem (TSP)

Figure above shows a world tour of 1.9 million cities. Image Courtesy of William Cook
TSP description Data:
n cities

cij= cost of traveling


between city i and city
j.

Goal:
Find a tour that visits
each city once, at
minimum cost.
TSP: example of tour (n=13)
Nice!!!
TSP is HARD
n! different possible tours (Note: n! >> 2n).

(Source: In pursuit of the traveling salesman - Bill Cook - Chapter, page 8)

Extremely difficult problem!!!


TSP Comic

(http://imgs.xkcd.com/comics/travelling_salesman_problem.png -- comic by Randall Munroe)


More applications:
Aiming
Drilling
Road trips Telescopes, circuit
X-rays and
Mapping lasers boards
genomes Scheduling
Test for Jobs
Organizing microprocessors
data ...and many more.
More information

Website
Books
http://www.math.uwaterloo.ca/tsp/

(I will post the first chapter in Webcursos)


The Traveling Salesman Problem: Postcards from the Edge of
Impossibility

Link: https://www.youtube.com/watch?v=5VjphFYQKj8
TSP
Star tours (http://www.math.uwaterloo.ca/tsp/star/index.html)
TSP description (again) Data:
n cities

cij= cost of traveling


between city i and city
j.

Goal:
Find a tour that visits
each city once, at
minimum cost.
Model (variables)

(for all pairs of cities i,j =1,...,n, i≠j .)


Model (some constraints)

i
(Only one city
out)
j
(Only one
city in)
(Binary
variables)
Do we need more constraints?

YES!!!
(In order to avoid subtours)
Example of subtours ( n=13)

WTQ?!?!
Subtour elimination constraints (idea)
To avoid
subtours we
S need at least
one connection
between cities in
S and cities not
in S.
S: subset of
(For every
cities.
subset S!!!)
Subtour elimination constraints (constraints)

Remark : There is an exponential number of these constraints


(~2n).
The DFJ formulation
Remark: TSP minus “subtour constraints”=
assignment problem
Assignment problem is very
easy.

TSP is extremely difficult.

Thus, adding only a set of


constraints may considerable
affect the difficulty of the
problem.
Another model of the TSP, the MTZ
formulation may be used later…

It can be proved that DFJ is a better


formulation of the TSP polytope than MTZ.
A generalization: Vehicle Routing Problem
(VRP)
Some links related to TSP and VRP

http://ruteo.cmm.uchile.cl/

https://vrpsolver.math.u-bordeaux.fr/

https://arthur.maheo.net/implementing-lin-kernighan-in-python/

https://developers.google.com/optimization/routing/vrp
4b. Single-
Machine Job
Scheduling
Single-Machine Job Scheduling: the problem

• Jobs 1, … , 𝑛 must be processed on a single machine.


• Each job is available for processing after a certain time, called release
time.
• For each job 𝑖, we are given
• its release time 𝑟𝑖 ,
• its processing time 𝑝𝑖 and
• its weight 𝑤𝑖 .
• Formulate as an integer linear program the problem of sequencing
the jobs without overlap or interruption so that the sum of the
weighted completion times is minimized.
Single-Machine Job Scheduling: the model
5. (More on
Logical
constraints)
Either-or
constraints
Ex: the feasible region of an LP
Ex: the feasible region of an either-or problem
Ex: the MILP version of the either-or problem
(the model)
Analysis of the MILP model (y=0)

Redundant We obtain first


part of the
“or”!!!
Analysis of MILP model (y=1)

Redundant We obtain
second part of
the “or”!!!
Ex: the MILP version of the either-or problem (in
the plane, R2)
The general case (some notation)

Variables

Constants/real
numbers
The general case (either-or constraints)
The general case (the MILP model)
Remarks

1. M1 and M2 must be numbers such that


we have:
WARNING: no need to memorize these formulas, M1
and M2 , in general can be computed relatively easily
Remarks (cont.) from the model, e.g. , from the meaning of the
variables.

2. For instance, we can take:


Remarks (cont.)

3. Any “large” enough numbers M1 and M2


would work, but we want the smallest
possible, for computational/numerical
reasons.
If-then
constraints
Logic review
if p, then q
is equivalent to

(not p) or q
Logic review (examples)
“if p, then q” “(not p) or q”
if midterm 2 average is (midterm 2 average is
1. less than 80, then we greater or equal than 80)
will be sad. or we will be sad
if today is Tuesday, (Today is not Tuesday)
2. then the class will or the class will be
be cancelled. cancelled.
3.
The general case (some notation)
Variables

Constants/real
numbers
The general case (if-then constraints)
The general case (if-then constraints to either-or
constraints)
The general case (the MILP model)
Integer programming case
Ex:

(Inequality form!)

You might also like