Lecture 3 - MIP Modeling (Annotated 2023)
Lecture 3 - MIP Modeling (Annotated 2023)
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
t=6
2. Yes/no decisions (very useful!!!)
Ex: Portfolio optimization
n assets available
Want to maximize expected return of the
stocks.
} 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
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
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
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.
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 2 … t … T-1 T
If we pay
Figure above shows a world tour of 1.9 million cities. Image Courtesy of William Cook
TSP description Data:
n cities
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).
Website
Books
http://www.math.uwaterloo.ca/tsp/
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
Goal:
Find a tour that visits
each city once, at
minimum cost.
Model (variables)
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)
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
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
(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!)