Algorithmique D'aide À La Décision: Katyanne Farias de Araújo
Algorithmique D'aide À La Décision: Katyanne Farias de Araújo
à la décision
Maître de conférences
Contact
• Email: [email protected]
• Office: F103
Katyanne Farias - Data Science for Industry 4.0 - Part I 2
Course content To download support files:
https://drive.uca.fr/d/e9802584e102489b8275/
1. Mathematical modeling
i. Motivations of modeling
ii. Linear Programming
iii. Integer Linear Programming: classical problems
iv. Solution methods
2. Solving methods for discrete optimization problems
I. Branch-and-Bound
II. Constructive Heuristics
III. Improvement Heuristics
IV. Metaheuristics
3. Cplex solver and heuristic implementation
I. Some examples
II. Mini-project
Katyanne Farias - Algorithmique d'aide à la décision 3
Mathematical modeling
Improve
• Define objective
• Identify constraints
• Select and process data Implement use in
the company
𝑚𝑎𝑥 σ𝑛𝑖=1 𝑐𝑖 𝑥𝑖
s.t.: σ𝑛𝑖=1 𝑎𝑖𝑗 𝑥𝑖 ≤ 𝑏𝑗 , ∀𝑗 ∈ {1, … , 𝑚}
𝑥𝑖 ≥ 0, ∀𝑖 ∈ {1, … , 𝑛}
• The big question is: which items should I buy in the supermarket to keep myself
minimally nourished, spending as little as possible?
𝑚𝑖𝑛(𝑝𝑙 𝑥𝑙 + 𝑝𝑏 𝑥𝑏 + 𝑝𝑓 𝑥𝑓 + 𝑝𝑠 𝑥𝑠 )
s.t.: 𝑞𝐴,𝑙 𝑥𝑙 + 𝑞𝐴,𝑏 𝑥𝑏 + 𝑞𝐴,𝑓 𝑥𝑓 + 𝑞𝐴,𝑠 𝑥𝑠 ≥ 𝑄𝐴
𝑞𝐵,𝑙 𝑥𝑙 + 𝑞𝐵,𝑏 𝑥𝑏 + 𝑞𝐵,𝑓 𝑥𝑓 + 𝑞𝐵,𝑠 𝑥𝑠 ≥ 𝑄𝐵
𝑞𝐶,𝑙 𝑥𝑙 + 𝑞𝐶,𝑏 𝑥𝑏 + 𝑞𝐶,𝑓 𝑥𝑓 + 𝑞𝐶,𝑠 𝑥𝑠 ≥ 𝑄𝐶
𝑥𝑙 , 𝑥𝑏 , 𝑥𝑓 , 𝑥𝑑 ≥ 0
Total cost
Xa 1,31 0,00 2,42 0,00 6.25
Is it a good solution?
Katyanne Farias - Algorithmique d'aide à la décision 20
Linear Programming
Example: Production mix
• A company manufactures 2 types of door: wood and aluminum.
• Each door undergoes 3 operations: cutting, assembly and finishing.
• The time spent on each of these operations for each type of door is known.
• Determine the daily production of each type of door to maximize the
company's profit, respecting the daily availability of time of the machines that
performs each operation.
Assembly Finishing
Cut (h/door) (h/door) (h/door) Profit/door
Wood 1,5 3,0 1,0 € 4,00
Aluminum 4,0 1,5 1,0 € 6,00
Total Profit
Availability 24h 21h 8h € 41,60
Use 24h 16,8h 8h
Katyanne Farias - Algorithmique d'aide à la décision
Is it a good solution? 23
Course content
1. Mathematical modeling
i. Motivations of modeling
ii. Linear Programming
iii. Integer Linear Programming: classical problems
iv. Solution methods
2. Solving methods for discrete optimization problems
I. Branch-and-Bound
II. Constructive Heuristics
III. Improvement Heuristics
IV. Metaheuristics
3. Cplex solver and heuristic implementation
I. Some examples
II. Mini-project
Katyanne Farias - Algorithmique d'aide à la décision 24
Integer Linear Programming
• If some variables are integer, we have a Mixed Integer Linear Program (MILP):
𝒎𝒂𝒙 𝒄𝒙 + 𝒉𝒚
s.t.: 𝑨𝒙 + 𝑮𝒚 ≤ 𝒃
𝒙 ≥ 𝟎, 𝐲 ∈ ℤ+ , where
• G is a m by p matrix,
• h is a p row vector,
• y is a p column-vector of integer variables.
𝑝
𝑚𝑎𝑥 σ𝑛𝑖=1 𝑐𝑖 𝑥𝑖 + σ𝑘=1 ℎ𝑘 𝑦𝑘
𝑝
s.t.: σ𝑛𝑖=1 𝑎𝑖𝑗 𝑥𝑖 + σ𝑘=1 𝑔𝑗𝑘 𝑦𝑘 ≤ 𝑏𝑗 , ∀𝑗 ∈ {1, … , 𝑚}
𝑥𝑖 ≥ 0, ∀𝑖 ∈ 1, … , 𝑛
𝑦𝑘 ∈ ℤ+ , ∀𝑘 ∈ {1, … , 𝑝}
If-then implications
• The production of an item (shipping goods, deciding to take a taxi, using a warehouse,
etc.) implies a fixed cost.
K
• Fixed cost is activated only in case at least one item is produced.
𝐾 = 𝑠𝑦 + 𝑐𝑥
𝑥 ≤ 𝑀𝑦 cx
+
𝑥 ∈ ℤ , 𝑦 ∈ {0,1}
• 𝑥 is the amount produced;
• 𝑠 represents the fixed cost; s
𝑦 = 0 implies 𝑥 = 0
• 𝑐 is the unit cost; 𝑦 = 1 implies 𝑥 > 0
• 𝑀 is a big number. 0 x
If-then implications
• Consider the case that if product 1 is manufactured, then at least m units of product 2
must also be manufactured.
𝑥1 ≤ 𝑀𝑦2 𝑥1 ≥ 0 implies y2 = 1
𝑥2 ≥ 𝑚𝑦2
𝑦2 = 1 implies 𝑥2 ≥ 𝑚
𝑥 ∈ ℤ+ , 𝑦 ∈ {0,1}
• 𝑥 is the amount produced;
• 𝑀 is a big number.
The constraint can be expressed as: Note that if 𝑦=0, 𝑓(𝑥1 , 𝑥2 , … , 𝑥𝑛 ) can take
𝑓(𝑥1 , 𝑥2 , … , 𝑥𝑛 ) ≤ 𝑀(1 − 𝑦) any value up to its limit
Disjunctive constraints
• Sometimes we only want to apply one constraint from a set of constraints.
• Example:
We define a binary variable 𝑦
• I want a car that does 20km/liter;
If 𝑦 = 1, only C1 is active;
• or that reaches 100km/h in 9s. If 𝑦 = 0, only C2 is active
• Define objective
• Identify constraints
• Select and process data Implement use in
the company
Instance
• Number of items: 𝑛
• Set of items: 𝑁 = 1, 2, … , 𝑛
• (Item) values: 𝑣 = [𝑣1 , 𝑣2 , … , 𝑣𝑛 ]
• (Item) weights: 𝑤 = [ 𝑤1 , 𝑤2 , … , 𝑤𝑛 ]
• (Knapsack) capacity: 𝐶
Mathematical formulation
𝑛
(KP) max 𝑣𝑖 𝑥𝑖
𝑖=1
𝑛
s.t. 𝑤𝑖 𝑥𝑖 ≤ 𝐶
𝑖=1
𝑥𝑖 ∈ 0,1 , ∀𝑖 ∈ 𝑁
(MDKP) max 𝑣𝑖 𝑥𝑖
𝑖=1
Instance 𝑛
• Number of items: 𝑛
• Set of items: 𝑁 = 1, 2, … , 𝑛 s.t. 𝑤𝑖,𝑑 𝑥𝑖 ≤ 𝐶𝑑 , ∀𝑑 ∈ 𝐷
• (Item) values: 𝑣 = [𝑣1 , 𝑣2 , … , 𝑣𝑛 ] 𝑖=1
• (Item) weights: 𝑤 = [ 𝑤1 , 𝑤2 , … , 𝑤𝑛 ]
• (Knapsack) capacity: 𝐶 𝑥𝑖 ∈ 0,1 , ∀𝑖 ∈ 𝑁
• Set of dimensions: 𝐷
Instance
• Number of items: 𝑛
• Set of items: 𝑁 = 1, 2, … , 𝑛
• Set of available bins: 𝑀 = [1, 2, … , 𝑛]
• Item weights: 𝑤 = [ 𝑤1 , 𝑤2 , … , 𝑤𝑛 ]
• Bin capacity: 𝐶
1, if bin j is used,
𝑦𝑗 =
0, otherwise.
(BPP) min 𝑦𝑗
𝑗=1
𝑛
s.t. 𝑥𝑖,𝑗 = 1, ∀𝑖 ∈ 𝑁
𝑗=1
𝑛
𝑤𝑖 𝑥𝑖,𝑗 ≤ 𝐶𝑦𝑗 , ∀𝑗 ∈ 𝑁
𝑖=1
𝑦𝑗 ∈ 0,1 , ∀𝑗 ∈ 𝑁
𝑥𝑖,𝑗 ∈ 0,1 , ∀𝑖, 𝑗 ∈ 𝑁
Katyanne Farias - Algorithmique d'aide à la décision 43
Bin Packing Problem
Other variants
1. {2D, 3D} BPP (with rotation);
𝑥𝑖,𝑗 = 1, ∀𝑖 ∈ {1, … , 𝑛}
𝑗=1
Applications:
• School bus service;
• Production Scheduling;
• 3D printing;
• Circuit boards;
• Geographic region monitoring, etc.
Decision variable(s)
𝑥𝑖,𝑗 = 1, ∀𝑖 ∈ 𝑁 (3)
𝑗∈𝑁:𝑗 ≠𝑖
𝑥𝑖,𝑗 ≥ 1, ∀𝑆 ⊂ 𝑁, 𝑆 ≠ ∅ (4)
𝑖∈𝑆 𝑗∉𝑆
𝑥𝑖,𝑗 ∈ 0,1 , ∀𝑖, 𝑗 ∈ 𝑁 (5)
Katyanne Farias - Algorithmique d'aide à la décision 53
Traveling Salesman Problem
Mathematical formulation 2 (Subtour Elimination Constraints)
(TSP−SEC) min 𝑐𝑖,𝑗 𝑥𝑖,𝑗 (1)
𝑖∈𝑁 𝑗∈𝑁
𝑥𝑖,𝑗 = 1, ∀𝑖 ∈ 𝑁 (3)
𝑗∈𝑁:𝑗 ≠𝑖
𝑥𝑖,𝑗 ≤ 𝑆 − 1, ∀𝑆 ⊂ 𝑁, 2 ≤ 𝑆 ≤ 𝑛 − 1 (6)
𝑖∈𝑆 𝑗∈ 𝑆
𝑥𝑖,𝑗 ∈ 0,1 , ∀𝑖, 𝑗 ∈ 𝑁 (5)
Katyanne Farias - Algorithmique d'aide à la décision 54
Traveling Salesman Problem
Mathematical formulation 3 (Miller-Tucker-Zemlin (MTZ))
(TSP−SEC) min σ𝑖∈𝑁 σ𝑗∈𝑁 𝑐𝑖,𝑗 𝑥𝑖,𝑗 • The sets of constraints (4) and (6)
(1)
grow exponentially with n.
σ𝑖∈𝑁:𝑖 ≠𝑗 𝑥𝑖,𝑗 = 1, ∀𝑗 ∈ 𝑁 (2) • Alternatively, they can be replaced
with (7), (8) and (9).
σ𝑗∈𝑁:𝑗 ≠ 𝑖 𝑥𝑖,𝑗 = 1, ∀𝑖 ∈ 𝑁 (3)
𝑢1 = 1 (7)
𝑢𝑖 − 𝑢𝑗 + 𝑛𝑥𝑗,𝑖 ≤ 𝑛 − 1, ∀𝑖, 𝑗 ∈ 𝑁\{1}, 𝑖 ≠ 𝑗 (8)
2 ≤ 𝑢𝑖 ≤ 𝑛, ∀𝑖 ∈ 𝑁\{1} (9)
𝑥𝑖,𝑗 ∈ 0,1 , ∀𝑖, 𝑗 ∈ 𝑁 (5)
Exhaustive Search: process that enumerates every possible solution and then
returns the optimal (best) one.
Exact methods
• Guarantee the optimality of the solution (i.e., an associated solution at the
maximum or minimum of the objective function).
• Usually require a high computational effort.
Heuristics
• Motivated by the need to develop an approach to obtain high-quality solutions, but
optimality cannot be guaranteed.
• It is a method which seeks good (i.e., near-optimal) solutions at a reasonable
computation cost without being able to guarantee optimality, and possibly not
feasibility.
• Unfortunately, it may not even be possible to state how close to optimality a
particular heuristic solution is.
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
In a minimization problem:
• Dual bound: lower bound for solving the problem.
• Primal bound: upper bound for solving the problem.
Discrete optimization
1. Branch-and-Bound
2. Branch-and-Cut
3. Branch-and-Price
4. Etc.
𝑚𝑎𝑥(4.0𝑥𝑤 + 6.0𝑥𝑎 )
s.t.: 1.5𝑥𝑤 + 4.0𝑥𝑎 ≤ 24 (Cut)
3.0𝑥𝑤 + 1.5𝑥𝑎 ≤ 21 (Assembly)
1.0𝑥𝑤 + 1.0𝑥𝑎 ≤ 8 (Finishing)
𝑥𝑤 , 𝑥𝑎 ∈ ℤ+
Since we found an integer solution in P2, P1 and P2 were solved, we can update the
we can update the primal (lower) bound: dual (upper) bound by doing:
𝑧𝑃 = 𝑧2ҧ = 40.0 • 𝑧𝐷 = max 𝑧1ҧ , 𝑧2ҧ = max 𝟒𝟏. 𝟐𝟓; 40.0
Since we found an integer solution in P2, P1 and P2 were solved, we can update the
we can update the primal (lower) bound: dual (upper) bound by doing:
𝑧𝑃 = 𝑧2ҧ = 40.0 • 𝑧𝐷 = max 𝑧1ҧ , 𝑧2ҧ = max 𝟒𝟏. 𝟐𝟓; 40.0
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑚𝑎𝑑 = 4,0 𝑥ҧ𝑎𝑙 = 4,0 P4 𝑥ҧ𝑚𝑎𝑑 = 4,0 𝑥ҧ𝑎𝑙 = 4,0
𝑧0ҧ = 40,0 𝑧0ҧ = 40,0
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 2,667 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 36.0 𝑧4ҧ = 40.667
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 2,667 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 36.0 𝑧4ҧ = 40.667
Although in P3 we found an integer solution, P3 and P4 were solved, we can update the
we do not update the primal (lower) bound: dual (upper) bound:
𝑧3 ≤ 𝑧𝑃ҧ = 40.0 • 𝑧𝐷 = max 𝑧3ҧ , 𝑧4ҧ = max 36.0; 40.667
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 2,667 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 36.0 𝑧4ҧ = 40.667
𝑥𝑤 ≤ 2 𝑥𝑤 ≥ 3
P5 𝑥ҧ𝑤 = 2,0 𝑥ҧ𝑎 = 5,25 P6 𝑥ҧ𝑚𝑎𝑑 = 2,667 𝑥ҧ𝑎𝑙 = 5,0
𝑧5ҧ = 39,5 Infeasible
Katyanne Farias - Algorithmique d'aide à la décision 103
Branch-and-Bound
Example: Production mix
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 2,667 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 36.0 𝑧4ҧ = 40.667
𝑥𝑤 ≤ 2 𝑥𝑤 ≥ 3
P5 𝑥ҧ𝑤 = 2,0 𝑥ҧ𝑎 = 5,25 P6 𝑥ҧ𝑚𝑎𝑑 = 2,667 𝑥ҧ𝑎𝑙 = 5,0
𝑧5ҧ = 39,5 Infeasible
Katyanne Farias - Algorithmique d'aide à la décision 104
Branch-and-Bound Optimal solution: P2
• 4 doors of each must be produced
Example: Production mix generating a profit of $40.
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 2,667 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 36.0 𝑧4ҧ = 40.667
𝑥𝑤 ≤ 2 𝑥𝑤 ≥ 3
P5 𝑥ҧ𝑤 = 2,0 𝑥ҧ𝑎 = 5,25 P6 𝑥ҧ𝑚𝑎𝑑 = 2,667 𝑥ҧ𝑎𝑙 = 5,0
𝑧5ҧ = 39,5 Infeasible
Katyanne Farias - Algorithmique d'aide à la décision 105
Branch-and-Bound
Example: Problem with a minimization objective function
P1 P2
Since we found an integer solution in P2, P1 and P2 were solved, we can update the
we can update the primal (upper) bound: dual (lower) bound by doing:
𝑧𝑃 = 𝑧2ҧ = 61.0 • 𝑧𝐷 = 𝑚𝑖𝑛 𝑧1ҧ , 𝑧2ҧ = 𝑚𝑖𝑛 𝟓𝟕. 𝟑; 61.0
Since we found an integer solution in P2, P1 and P2 were solved, we can update the
we can update the primal (upper) bound: dual (lower) bound by doing:
𝑧𝑃 = 𝑧2ҧ = 61.0 • 𝑧𝐷 = 𝑚𝑖𝑛 𝑧1ҧ , 𝑧2ҧ = 𝑚𝑖𝑛 𝟓𝟕. 𝟑; 61.0
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 P4
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
We did not find a new integer solution, so we P3 and P4 were solved, we can update the
do not update the primal (upper) bound dual (lower) bound:
Now, we know that: 𝟔𝟏. 𝟎 ≤ 𝒛∗ ≤ 𝟓𝟗.6 • 𝑧𝐷 = 𝑚𝑖𝑛 𝑧3ҧ , 𝑧4ҧ = 𝑚𝑖𝑛 59.6; 60.25
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
Also, note that the optimal solution of 𝑃4 This fact indicates that if we create two
has 𝑧4ҧ = 60.25 new subproblems from 𝑃4, the best integer
solution we can find will have 𝑧 ≥ ⌈𝑧4ҧ ⌉
Katyanne Farias - Algorithmique d'aide à la décision 121
Branch-and-Bound
Example: Problem with a minimization objective function
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
Also, note that the optimal solution of 𝑃4 This fact indicates that if we create two
has 𝑧4ҧ = 60.25 new subproblems from 𝑃4, the best integer
solution we can find will have 𝑧 ≥ ⌈60.25⌉
Katyanne Farias - Algorithmique d'aide à la décision 122
Branch-and-Bound
Example: Problem with a minimization objective function
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
Also, note that the optimal solution of 𝑃4 This fact indicates that if we create two
has 𝑧4ҧ = 60.25 new subproblems from 𝑃4, the best integer
solution we can find will have 𝑧 ≥ 61
Katyanne Farias - Algorithmique d'aide à la décision 123
Branch-and-Bound
Example: Problem with a minimization objective function
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
So, we cannot improve our current best integer solution (𝑧𝑝 = 61) by
oppening new nodes from P4 .
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
So, we cannot improve our current best integer solution (𝑧𝑝 = 61) by
oppening new nodes from P4 .
• Thus, we mark P4 as a closed node.
Katyanne Farias - Algorithmique d'aide à la décision 125
Branch-and-Bound
Example: Problem with a minimization objective function
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
𝑥𝑤 ≤ 3 𝑥𝑤 ≥ 4
P5 P6
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
𝑥𝑎 ≤ 4 𝑥𝑎 ≥ 5
P3 𝑥ҧ𝑤 = 3.75 𝑥ҧ𝑎 = 4.0 P4 𝑥ҧ𝑤 = 3.5 𝑥ҧ𝑎 = 5.0
𝑧3ҧ = 59.6 𝑧4ҧ = 60.25
𝑥𝑤 ≤ 3 𝑥𝑤 ≥ 4
P5 𝑥ҧ𝑤 = 3.0 𝑥ҧ𝑎 = 4.0 P6 𝑥ҧ𝑚𝑎𝑑 = 2,667 𝑥ҧ𝑎𝑙 = 5,0
𝑧5ҧ = 62.0 Infeasible
Katyanne Farias - Algorithmique d'aide à la décision 128
Branch-and-Bound
Branching strategies
• Given a set of nodes not yet explored, how to choose the next node to
explore?
Deep-first search
• Choose the active node that is deepest in the tree.
• Last node has been generated.
• To find the first feasible solution faster.
Breadth-first search
• Choose the active node that is the further up to
the tree.
• The oldest unexplored node.
Katyanne Farias - Algorithmique d'aide à la décision 129
Branch-and-Bound
Branching strategies
• Given a set of nodes not yet explored, how to choose the next node to
explore?
Best-node first
• Choose the active node with the best bound.
• To minimize the total number of nodes evaluated.
• Thus, a B&P algorithm is a B&B algorithm in which each node of the tree is
solved by using a CG algorithm.
Concepts
• Local Optimum: is a point in the search space where all neighboring solutions are
worse than the current solution.
• Global Optimum: is a point in the search space where all other points in the search
space are worse than (or equal to) the current one.
Procedure LocalSearch_heuristic(𝑠):
while 𝑠 is not locally optimal do
Find 𝑠 ′ ∈ 𝑁(𝑠) with 𝑓 𝑠 ′ < 𝑓(𝑠);
𝑠 ← 𝑠′;
End LocalSearch_heuristic
k j
𝑑𝑖𝑗 𝑑𝑗𝑜
i
o
𝑑𝑖𝑜
𝑑𝑘𝑗
k j
𝑑𝑖𝑗 𝑑𝑗𝑜
𝑑𝑘𝑖
i
o
𝑑𝑖𝑜
• Constructive heuristics
1. Next-Fit (NF).
2. First-Fit (FF).
3. Best-Fit (BF).
4. Next-Fit Decreasing (NFD).
5. First-Fit Decreasing (FFD).
6. Best-Fit Decreasing (BFD).
Procedure LocalSearch_heuristic(𝑠):
while 𝑠 is not locally optimal do
Find 𝑠 ′ ∈ 𝑁(𝑠) with 𝑓 𝑠 ′ < 𝑓(𝑠);
𝑠 ← 𝑠′;
End LocalSearch_heuristic
01 11
00 10
010 011
110
111
001
000
100 101
0010 0011
0110
0111
0001
0000
0100 0101
1010 1011
1110
1111
1001
1000
1100 1101
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 168
Improvement Heuristics
Neighborhood Operators 1 4 3 2 6 7 5 1
Example: TSP
1
• Swap 5 with 4
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 169
Improvement Heuristics
Neighborhood Operators 1 4 3 2 6 7 5 1
Example: TSP
1
• Swap 3 with 2
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 170
Improvement Heuristics
Neighborhood Operators 1 4 2 3 6 7 5 1
Example: TSP
1
• Swap 3 with 2
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 171
Improvement Heuristics
Neighborhood Operators 1 4 2 3 6 7 5 1
Example: TSP
1
• Swap 3 with 6
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 172
Improvement Heuristics
Neighborhood Operators 1 4 2 6 3 7 5 1
Example: TSP
1
• Swap 3 with 6
4
5
2
3
7
6
Katyanne Farias - Algorithmique d'aide à la décision 173
Improvement Heuristics
Neighborhood Operators: Reinsertion
Example: TSP
• Let 𝑣𝑒𝑐 be a solution vector for a TSP instance with 𝑛 cities.
• Ex: Let 𝑛 = 5 and 𝑣𝑒𝑐 = [1 3 5 4 2 1].
• The costs of all solutions in the or-opt neighborhood can be
assessed/evaluated by the algorithm below:
• Defining 0 as the first index of a vector: 𝑣𝑒𝑐[0] is the first element of the vector 𝑣𝑒𝑐.
Procedure OrOpt(𝑣𝑒𝑐)
1: for 𝑖 = 1 … 𝑛 − 1 do
2: for 𝑝 = 1 … 𝑛 do
3: if 𝑝 ≠ 𝑖 and 𝑝 ≠ 𝑖 + 1 then
4: 𝑛𝑒𝑤𝑐𝑜𝑠𝑡 = 𝑐𝑢𝑟𝑟𝑒𝑛𝑡𝑐𝑜𝑠𝑡
5: −𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖−1 ,𝑣𝑒𝑐[𝑖] − 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖 ,𝑣𝑒𝑐[𝑖+1] + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖−1 ,𝑣𝑒𝑐[𝑖+1]
6: −𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑝−1 ,𝑣𝑒𝑐 𝑝 + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑝−1 ,𝑣𝑒𝑐 𝑖 + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖 ,𝑣𝑒𝑐[𝑝]
Katyanne Farias - Algorithmique d'aide à la décision 174
Improvement Heuristics
Neighborhood Operators: Swap
Example: TSP
• Let 𝑣𝑒𝑐 be a solution vector for a TSP instance with 𝑛 cities.
• Ex: Let 𝑛 = 5 and 𝑣𝑒𝑐 = [1 3 5 4 2 1].
• The costs of all solutions in the swap neighborhood can be
assessed/evaluated by the algorithm below:
• Defining 0 as the first index of a vector: 𝑣𝑒𝑐[0] is the first element of the vector 𝑣𝑒𝑐.
Procedure Swap(𝑣𝑒𝑐)
1: for 𝑖 = 1 … 𝑛 − 2 do
2: for j = 𝑖 + 1 … 𝑛 − 1 do
3: 𝑛𝑒𝑤𝑐𝑜𝑠𝑡 = 𝑐𝑢𝑟𝑟𝑒𝑛𝑡𝑐𝑜𝑠𝑡
4: −𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖−1 ,𝑣𝑒𝑐 𝑖 − 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖 ,𝑣𝑒𝑐 𝑖+1 + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖−1 ,𝑣𝑒𝑐 𝑗 + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑗 ,𝑣𝑒𝑐[𝑖+1]
5: −𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑗−1 ,𝑣𝑒𝑐 𝑗 − 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑗 ,𝑣𝑒𝑐 𝑗+1 + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑗−1 ,𝑣𝑒𝑐[𝑖] + 𝑑𝑖𝑠𝑡𝑣𝑒𝑐 𝑖 ,𝑣𝑒𝑐[𝑗+1]
Procedure Best_Improvement_Method(𝑠):
Choose 𝑠 ′ with best 𝑓 𝑠 ′ ∀𝑠 ′ ∈ 𝑁(𝑠)
While 𝑓 𝑠 ′ is better than 𝑓 𝑠 do
𝑠 ← 𝑠′
Choose 𝑠 ′ with best 𝑓 𝑠 ′ ∀𝑠 ′ ∈ 𝑁 𝑠
EndWhile
End Best_Improvement_Method
Katyanne Farias - Algorithmique d'aide à la décision 178
Improvement Heuristics
Best Improvement Method (BIM)
Cost
Local optimum
Solution space
Katyanne Farias - Algorithmique d'aide à la décision 179
Improvement Heuristics
First Improvement Method (FIM)
• 𝑠 is a initial solution.
• 𝑁(𝑠) is the set of neighbor solutions.
• Choose first neighbor 𝑠′ that is better than 𝑠.
• This procedure is repeated until there is no neighbor better than 𝑠.
Procedure First_Improvement_Method(𝑠):
• In contrast to the previous method, While 𝑓 𝑠 ′ is better than 𝑓 𝑠 do
the FIM avoid an exhaustive 𝑖 = 1; 𝑠 ← 𝑠′
While (𝑓 𝑠 is better than 𝑓 𝑖 or 𝑖 < |𝑁|) do
exploration of the neighborhood.
𝑖++
EndWhile
𝑠′ ← 𝑖
EndWhile
End First_Improvement_Method
Katyanne Farias - Algorithmique d'aide à la décision 180
Course content
1. Mathematical modeling
i. Motivations of modeling
ii. Linear Programming
iii. Integer Linear Programming: classic problems
iv. Solution methods
2. Solving methods for discrete optimization problems
I. Branch-and-Bound
II. Constructive Heuristics
III. Improvement Heuristics
IV. Metaheuristics
3. Cplex solver and heuristic implementation
I. Some examples
II. Mini-project
Katyanne Farias - Algorithmique d'aide à la décision 181
Metaheuristics
• Metaheuristics are procedures designed to find a good solution,
eventually the optimal one, consisting in the application, in each step,
of a subordinate heuristics, which have to be modeled for each specific
problem.
• They are general in nature and provided with mechanisms to avoid
getting stuck in optimal locations possibly far from global optimal.
• Metaheuristics differ from each other basically by the mechanism used
to get out of the traps of great places.
Procedure ILS(𝑆𝑡𝑜𝑝𝐶𝑟𝑖𝑡𝑒𝑟𝑖𝑎)
1: 𝑠0 ← 𝐺𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑆𝑜𝑙𝑢𝑡𝑖𝑜𝑛()
2: 𝑠 ← 𝐿𝑜𝑐𝑎𝑙𝑆𝑒𝑎𝑟𝑐ℎ(𝑠0 )
3: While 𝑆𝑡𝑜𝑝𝐶𝑟𝑖𝑡𝑒𝑟𝑖𝑎 not attended do
4: 𝑠′ ← Perturbation (historic, s)
5: 𝑠′′ ← LocalSearch(s′)
6: 𝑠 ← AcceptanceCriteria(𝑠, 𝑠′′,historic)
7: EndWhile
End ILS
1 1
𝑒 −1 = = = 0.3679
𝑒 2.7183
0
0 10 20 30 40 50 Temperature 𝑇
• Define objective
• Identify constraints
• Select and process data Implement use
in the company