exhaustion, branch and bound, divide and conquer

Post on 13-Dec-2015

219 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

• Bin packing

• Maximum Consecutive Sum

• Fast Exponentiation

• Closest Pair

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

• Anyway it is not about violence...

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

Why ExhaustionWhy Exhaustion

• Simple

• Less Error Prone

• …

• But that may take a LONG TIME.

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

• 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:

• 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?

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

for the company

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

• 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?

• 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

TricksTricks

• Pre-process

• Memorization

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

• LCV (Least Constraining Value)

Branch and BoundBranch and Bound

• Basically like exhaustion

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

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?

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

ExamplesExamples

• Bin Packing

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?

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

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

MergesortMergesort

Maximum Consecutive SumMaximum Consecutive Sum

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

Fast ExponentiationFast Exponentiation

Fast ExponentiationFast Exponentiation

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

Closest PairClosest Pair

Closet PairCloset Pair

AppendixAppendix

• Complexity: Master Theorem

top related