Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prabhas Chongstitvatana1 Las Vegas algorithm The answer obtained is always correct but sometime no answer. Modified deterministic algorithm by using randomness.

Similar presentations


Presentation on theme: "Prabhas Chongstitvatana1 Las Vegas algorithm The answer obtained is always correct but sometime no answer. Modified deterministic algorithm by using randomness."— Presentation transcript:

1 Prabhas Chongstitvatana1 Las Vegas algorithm The answer obtained is always correct but sometime no answer. Modified deterministic algorithm by using randomness in the decision When dead-end restart the algo.

2 Prabhas Chongstitvatana2 Average running time analysis assumes some distribution of problem instances. Robinhood effect LV “steal” time from the “rich” instance -- instances that were solved quickly by deterministic algo. -- to give it to the “poor” instance. Reduce the difference between good and bad instances.

3 Prabhas Chongstitvatana3 Running time analysis RepeatLV each LV call success p(x); expected time t(x) before repeatLV is successful. Must consider success and failure separately

4 Prabhas Chongstitvatana4 RepeatLV each LV call success p(x); expected time t(x) before repeatLV is successful. Must consider success and failure separately p(x) : first call LV(x) succeeds after expected time s(x) 1-p(x) : first call LV(x) fails after expected time f(x) then restart, total expected time f(x) + t(x)

5 Prabhas Chongstitvatana5 t(x) = p(x) s(x) + (1- p(x) )( f(x) + t(x) ) t(x) = s(x) + (1-p(x))/p(x) f(x) This equation guides how to “tune” various parameters.

6 Prabhas Chongstitvatana6 8-queen revisited Backtrack systematic explores k-promising vector implicit tree (search 114 of 2057 for the first soln). Use greedy LV that places queens randomly, if no soln restart Simple

7 Prabhas Chongstitvatana7 p prob. of success, s number of soln explored when success, f number of soln explored when fail. Example s=9, p ~ 0.1293, f ~ 6.971. A soln is obtained more than 1 out of 8. The number of node explored by repeting until success s + (1-p)/p f ~ 55.93 compare to 114 nodes with backtrack which do systematic search.

8 Prabhas Chongstitvatana8 Improve when queenLV fail restart from beginning. Use combination : some random, some backtrack.

9 Prabhas Chongstitvatana9 Actual time backtrack first soln0.45 ms 2 queens fix average time0.14 ms 3 queens fix average time0.21 ms all random average time1.00 ms Why slow down of random ? The time for random number generator consume 71%.

10 Prabhas Chongstitvatana10 Generalize to n-queen n = 39 nodes actual time backtrack11,402,835,41541 hr. queenLV 29:105008.5 ms pureLV150 ms LV gain 20 millions to 1 on the number of nodes explored and 10 millions on actual time

11 Prabhas Chongstitvatana11 Probabilistic selection and sorting The problem of k-th smallest element using divide and conquer, the nearer the pivot is to the median of the element the more efficient.

12 Prabhas Chongstitvatana12 Probabilistic selection and sorting The problem of k-th smallest element using divide and conquer, the nearer the pivot is to the median of the element the more efficient. Simple approach : pivot the first element linear time in average, quadratic in worst case.

13 Prabhas Chongstitvatana13 SelectionLV(T[1..n],s) i = 1; j = n repeat p = T[ uniform(i.. j) ] pivotbis(T[i..j], p, k, l ) if s <= k then j = k else if s >= l then i = l else return p Expected run time is linear

14 Prabhas Chongstitvatana14 Using random pivot, the execution time is independent of the instance. It is always possible that some execution will take quadratic time but the prob. will be small if n is large. Expected run time is linear on all instances with a small hidden constant.

15 Prabhas Chongstitvatana15 quicksortLV(T[i..j] ) if j-i is sufficiently small then insertsort(T[i..j] ) else p = T[ uniform(i..j) ] pivotbis( T[i..j], p, k, l ) quicksortLV(T[i..k] ) quicksortLV(T[l..j] ) Worst-case expected time O(n log n)

16 Prabhas Chongstitvatana16 LV running time is independent of specific instances. Probabilistic approach Deterministic algo. that has excellent average execution time on all instances of some particular size except certain instances. Turn that into LV that is efficient with high probability whatever the instance considered.


Download ppt "Prabhas Chongstitvatana1 Las Vegas algorithm The answer obtained is always correct but sometime no answer. Modified deterministic algorithm by using randomness."

Similar presentations


Ads by Google