exhaustion, branch and bound, divide and conquer

25
Exhaustion, Exhaustion, Branch and Bound, Branch and Bound, Divide and Conquer Divide and Conquer

Upload: percival-rich

Post on 13-Dec-2015

219 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Exhaustion, Branch and Bound, Divide and Conquer

Exhaustion,Exhaustion,Branch and Bound,Branch and Bound,Divide and ConquerDivide and Conquer

Page 2: Exhaustion, Branch and Bound, Divide and Conquer

• Bin packing

• Maximum Consecutive Sum

• Fast Exponentiation

• Closest Pair

Page 3: Exhaustion, Branch and Bound, Divide and Conquer

• 窮舉 /窮尋 /暴力法• Also called Brute Force

• Anyway it is not about violence...

Page 4: Exhaustion, Branch and Bound, Divide and Conquer

Why ExhaustionWhy Exhaustion

• Sometimes it’s the only way out.

• Case Study 1• Irreversible Transform• Given a transform H, you can calculate y = H

(x)• But given y, you cannot easily calculate x such

that y = H(x), we call H is irreversible• Given y, tell me how many x can be transforme

d to y

Page 5: Exhaustion, Branch and Bound, Divide and Conquer

Why ExhaustionWhy Exhaustion

• Simple

• Less Error Prone

• …

• But that may take a LONG TIME.

Page 6: Exhaustion, Branch and Bound, Divide and Conquer

Not that simpleNot that simple

• The way you exhaust matters• Case Study 2

• Narrow Range Broadband • Given all clients’ positions as well as the

profits that can be made from each of them• You can only setup one server station with limited transmission distance• Give the best possible position and

the profit for the company

Page 7: Exhaustion, Branch and Bound, Divide and Conquer

• Case Study 2• Give the best possible position and the profit f

or the company• Any definite answer, first?• The more the clients it covers, the better?• Map size: at most 100 x 100 (w x h)• Number of clients: at most 1000 (n)• Maximum distance: 200 (d)• Manhatten Distance:

Page 8: Exhaustion, Branch and Bound, Divide and Conquer

• Case Study 2• Give the best possible position and the profit f

or the company

• Solution 1• Each position can be the best• For each position

• Find from its reachable distance• Add profit if that position is a client

• Complexity?

Page 9: Exhaustion, Branch and Bound, Divide and Conquer

• Case Study 2• Give the best possible position and the profit

for the company

• Solution 1• Complexity? • Can we be faster?

Page 10: Exhaustion, Branch and Bound, Divide and Conquer

• Case Study 2• Give the best possible position and the profit for t

he company

• Solution 2• A client is served if a server can reach

it within d units• Similarly, if a client can reach the server d units, it

is served• By exploiting the fact that distance is symmetric,

one can achieve an algorithm• Any faster algorithm?

Page 11: Exhaustion, Branch and Bound, Divide and Conquer

• Summary• If you cannot figure out fast way to solve a

given problem (may or may not exist), try brute force

• For small case (usually 30%~50%), they are designed for brute force purposes

• Exhaust in a smart way

Page 12: Exhaustion, Branch and Bound, Divide and Conquer

TricksTricks

• Pre-process

• Memorization

• MRV (Minimum Remaining Values)– Aka. MCV (Most Constrained Variables)

• LCV (Least Constraining Value)

Page 13: Exhaustion, Branch and Bound, Divide and Conquer

Branch and BoundBranch and Bound

• Basically like exhaustion

• Try to be faster– Prune sub-optimal searching early

Page 14: Exhaustion, Branch and Bound, Divide and Conquer

Branch and BoundBranch and Bound

• Idea: “Estimate” the best solution of the current Search Tree with a heuristic function

• If the estimation says this search tree will not produce better result, give up on it…

• Well… is it possible that we miss the optimal solution if we give up on some search tree?

Page 15: Exhaustion, Branch and Bound, Divide and Conquer

Branch and BoundBranch and Bound

• An admissible heuristic function is a heuristic function that never over-estimates

• It can be proved that if a admissible heuristic function is used, the result is always optimal

Page 16: Exhaustion, Branch and Bound, Divide and Conquer

ExamplesExamples

• Bin Packing

Page 17: Exhaustion, Branch and Bound, Divide and Conquer

Divide and ConquerDivide and Conquer

• Three steps – Divide, Conquer, and Combine– Divide: Breaks the problem into some sub-problems– Conquer: Solve individual sub-problems– Combine: Use solutions to sub-problems to

construct a solution to the original problem

• Question: How are sub-problems solved?

Page 18: Exhaustion, Branch and Bound, Divide and Conquer

Examples (D&C)Examples (D&C)

• Finding Max and Min in a list of numbers• Merge Sort• Quick Sort• L-Block

Page 19: Exhaustion, Branch and Bound, Divide and Conquer

MergesortMergesort

Page 20: Exhaustion, Branch and Bound, Divide and Conquer

Maximum Consecutive SumMaximum Consecutive Sum

• Given a sequence of numbers, find a consecutive subsequence, such that its total sum is largest.

Page 21: Exhaustion, Branch and Bound, Divide and Conquer

Fast ExponentiationFast Exponentiation

Page 22: Exhaustion, Branch and Bound, Divide and Conquer

Fast ExponentiationFast Exponentiation

Page 23: Exhaustion, Branch and Bound, Divide and Conquer

• Given a plane of points, find the distance of the closest pair

Closest PairClosest Pair

Page 24: Exhaustion, Branch and Bound, Divide and Conquer

Closet PairCloset Pair

Page 25: Exhaustion, Branch and Bound, Divide and Conquer

AppendixAppendix

• Complexity: Master Theorem