How to Solve It �4. Classical Methods – Part I
Cong Li
Apr. 10th ~ Sept. 11th, 2021
How to Search Effectively
How to Solve It: 4. Classical Methods - Part I
Problem: 7-11
How to Solve It: 4. Classical Methods - Part I
Typical Search Problem
How to Solve It: 4. Classical Methods - Part I
7-11: Solution (1)
How to Solve It: 4. Classical Methods - Part I
7-11: Solution (2)
How to Solve It: 4. Classical Methods - Part I
7-11: Solution (3)
How to Solve It: 4. Classical Methods - Part I
7-11: Solution (4)
How to Solve It: 4. Classical Methods - Part I
7-11: Solution (5)
How to Solve It: 4. Classical Methods - Part I
Classical Methods
How to Solve It: 4. Classical Methods - Part I
Two Types of Classical Methods (1)
How to Solve It: 4. Classical Methods - Part I
Two Types of Classical Methods (2)
How to Solve It: 4. Classical Methods - Part I
Two Types of Classical Methods (3)
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search (1)
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search (2)
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search (3)
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search: SAT (1)
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search: SAT (2)
How to Solve It: 4. Classical Methods - Part I
Basic Depth-First Search
void Depth-First(Node *pNode)
{
if (pNode is a leaf node)
{
Evaluate(pNode);
return;
}
foreach childnode pChild of pNode
Depth-First(pChild);
}
How to Solve It: 4. Classical Methods - Part I
Improvement on Basic Algorithm
How to Solve It: 4. Classical Methods - Part I
Exhaustive Search: TSP
How to Solve It: 4. Classical Methods - Part I
Local Search (1)
How to Solve It: 4. Classical Methods - Part I
Local Search (2)
How to Solve It: 4. Classical Methods - Part I
Local Search (3)
How to Solve It: 4. Classical Methods - Part I
Local Search: SAT (1)
Solution GSAT()
{
for (int i = 0; i < maxtries; i++)
{
Solution currentSolution = RandomizeSolution();
for (int j = 0; j < maxflips; j++)
{
if (Satisfied(currentSolution))
return currentSolution;
currentSolution = BestFlip(currentSolution);
}
}
return NOSOLUTION;
}
How to Solve It: 4. Classical Methods - Part I
Local Search: SAT (2)
How to Solve It: 4. Classical Methods - Part I
Local Search: TSP (1)
How to Solve It: 4. Classical Methods - Part I
Example of non-adjacent edges
Local Search: TSP (1)
How to Solve It: 4. Classical Methods - Part I
Local Search: TSP (1)
How to Solve It: 4. Classical Methods - Part I
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
A ‘node switch’ to replace an edge in a cycle
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
A last edge in a δ−path
Note that a δ−path has 2 last edges
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
A different switch results in a different δ−path
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
Another example of a switch
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
One can reconstruct a cycle from a δ−path using the other last edge
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
Local Search: TSP (2)
How to Solve It: 4. Classical Methods - Part I
Local Search: NLP (1)
How to Solve It: 4. Classical Methods - Part I
Local Search: NLP (2)
How to Solve It: 4. Classical Methods - Part I
Local Search: NLP (3)
How to Solve It: 4. Classical Methods - Part I
Local Search: NLP (4)
How to Solve It: 4. Classical Methods - Part I
Bracketing Method: Bisection
How to Solve It: 4. Classical Methods - Part I
Bracketing Method: Regula Falsi
How to Solve It: 4. Classical Methods - Part I
Newton’s Method
How to Solve It: 4. Classical Methods - Part I
Remarks on These Methods
How to Solve It: 4. Classical Methods - Part I
Gradient Method (1)
How to Solve It: 4. Classical Methods - Part I
Gradient Method (2)
How to Solve It: 4. Classical Methods - Part I
Remarks on Gradient Method
How to Solve It: 4. Classical Methods - Part I
Linear Programming
How to Solve It: 4. Classical Methods - Part I
Example: Problem
How to Solve It: 4. Classical Methods - Part I
Example: Problem Formulation
How to Solve It: 4. Classical Methods - Part I
Subject to
Linear Programming Problem
How to Solve It: 4. Classical Methods - Part I
Subject to
Simplex: Geometric View
How to Solve It: 4. Classical Methods - Part I
Constraints
Evaluation function
Optimum
Example: Solution (1)
How to Solve It: 4. Classical Methods - Part I
Subject to
Subject to
Problem transformation
Example: Solution (2)
How to Solve It: 4. Classical Methods - Part I
Simplex tableau
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x3 (0) | −1 | −6 | −1 | 0 | 288 |
x4 (0) | −3 | −1 | 0 | −1 | 99 |
eval | 20 | 30 | 0 | 0 | 0 |
Example: Solution (3)
How to Solve It: 4. Classical Methods - Part I
Example: Solution (4)
How to Solve It: 4. Classical Methods - Part I
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x3 (0) | −1 | −6 | −1 | 0 | 288 |
x4 (0) | −3 | −1 | 0 | −1 | 99 |
eval | 20 | 30 | 0 | 0 | 0 |
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x2 (30) | −1/6 | −1 | −1/6 | 0 | 48 |
x4 (0) | −17/6 | 0 | 1/6 | −1 | 51 |
eval | ? | ? | ? | ? | ? |
The latter yields the larger increase on eval
Example: Solution (5)
How to Solve It: 4. Classical Methods - Part I
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x2 (30) | −1/6 | −1 | −1/6 | 0 | 48 |
x4 (0) | −17/6 | 0 | 1/6 | −1 | 51 |
eval | 15 | 0 | −5 | 0 | 1440 |
Example: Solution (6)
How to Solve It: 4. Classical Methods - Part I
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x1 (20) | −1 | 0 | 1/17 | −6/17 | 18 |
x2 (30) | 0 | −1 | −3/17 | 1/17 | 45 |
eval | ? | ? | ? | ? | ? |
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x2 (30) | −1/6 | −1 | −1/6 | 0 | 48 |
x4 (0) | −17/6 | 0 | 1/6 | −1 | 51 |
eval | 15 | 0 | −5 | 0 | 1440 |
The change yields the increase on eval
Example: Solution (7)
How to Solve It: 4. Classical Methods - Part I
| x1 (20) | x2 (30) | x3 (0) | x4 (0) | |
x1 (20) | −1 | 0 | −1/17 | −6/17 | 18 |
x2 (30) | 0 | −1 | 3/17 | 1/17 | 45 |
eval | 0 | 0 | −70/17 | −90/17 | 1710 |
Example: Geometric Explanation
How to Solve It: 4. Classical Methods - Part I
Summary
How to Solve It: 4. Classical Methods - Part I
The End