approximation algorithms n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
APPROXIMATION ALGORITHMS PowerPoint Presentation
Download Presentation
APPROXIMATION ALGORITHMS

Loading in 2 Seconds...

play fullscreen
1 / 20

APPROXIMATION ALGORITHMS - PowerPoint PPT Presentation


  • 244 Views
  • Uploaded on

APPROXIMATION ALGORITHMS. Dario Fanucchi. Why Approximate?. Exact Solution Exists. But Searching…. Takes time. Outline. Specific Algorithms : Bin Packing Real Valued Knapsack Traveling Salesperson Graph Colouring Systems of Equations General Considerations

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'APPROXIMATION ALGORITHMS' - niveditha


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
why approximate
Why Approximate?

Exact Solution Exists

But Searching…

Takes time

outline
Outline

Specific Algorithms:

  • Bin Packing
  • Real Valued Knapsack
  • Traveling Salesperson
  • Graph Colouring
  • Systems of Equations

General Considerations

  • Trimming an exhaustive search
  • Time-outs and implementation
packing the rubbish
Packing the Rubbish
  • The Problem:
    • n real numbers {s1, s2, .., sn} in [0;1]
    • pack them into minimum number of bins of size 1.

Exact Algorithm = O(nn/2)

Approximate Algorithm(FFD) = O(n2)

At most 0.3n extra bins used.

ffd strategy
FFD Strategy

First Fit Decreasing Strategy

  • Sort the values of si
  • Pack values into first bins they fit in.

S = {0.2, 0.4, 0.3, 0.4, 0.2, 0.5, 0.2, 0.8}

Sorted: {0.8, 0.5, 0.4, 0.4, 0.3, 0.2, 0.2, 0.2}

0.2(s6 )

0.2(s7 )

0.4(s3 )

0.3(s5 )

0.8(s1 )

0.5(s2 )

0.4(s4 )

0.2(s9 )

packing the bags
Packing the Bags
  • The Problem:
    • Knapsack: real (weight, value) pairs
    • Find a combination of maximal value that fits in boundry weight C.

Problem is NP-complete

Many Approximations: Time vs. Accuracy Tradeoff…

the algorithm
The Algorithm
  • sKnapk Algorithm
  • Choose k
  • Generate k-subsets of items
  • Greedily add to subsets
  • Take maximum
how close are we
How close are we?
  • sKnapk accuracy
  • Ratio of 1+1/k to optimal!!
  • O(knk+1)
  • Choose k wisely!
world tour
World Tour
  • The Problem:
    • Traveling Salesperson Problem
    • Find minimal tour of the graph that visits each vertex exactly once.

Famous NP-complete problem

Several Approximation strategies exist

But none is very accurate

nearest neighbour
Nearest Neighbour
  • Start at an arbitrary vertex
  • At each step add the shortest edge to the end of the path
  • No guarantee of being within a constant bound of accuracy.

20

1

2

15

35

10

25

4

3

12

shortest link
Shortest-Link
  • Works like Kruskal’s Algorithm
  • Find shortest edges
  • Ensure no cycles
  • Ensure no vertex with 3 edges
  • Add edge

20

1

2

15

35

10

25

4

3

12

salesperson s dilemma
Salesperson’s Dilemma
  • Exact = Time Drain?
  • Approximate = only a guess?
  • Solution: Branch and Bound?
colouring in
Colouring in
  • The Problem:
    • Graph colouring problem
    • Exhibit a colouring of vertices with the smallest number of colours such that no edge connects two vertices of the same colour

NP-Complete problem

Like TSP, approximations are unbounded

the greedy one
The Greedy One
  • Sequential Colouring Strategy
  • Assign minimum possible colour to each vertex that is not assigned to one of it’s neighbours.
widgerson arrives
Widgerson Arrives
  • Recursive Algorithm
  • Base Case: 2 Colourable Graphs
  • Find the subgraph of the Neighbourhood of a given vertex, recursively colour this subgraph.
  • At most 3n colours for an n-colourable graph.
trace of widgerson
Trace of Widgerson
  • First run recursively on highest degree vertex
  • Then run SC on the rest of the graph, deleting edges incident to N(v)
solving systems of equations in linear time
Solving Systems of Equations in Linear Time
  • Exact Algorithm = Gaussian Elimination: O(n3)
  • Approximate Algorithm=Jacobi Method: Faster
  • x[m+1]=D-1[b-(L+U)x[m]]
  • xk[m+1] =(1/akk)(bk-ak1x1[m]-…-aknx1[m])
gardening
Gardening
  • Trimming exhaustive search
  • Branch&Bound
  • Backtracking
  • Mark a node as infeasible, and stop searching that point.
leave while you re ahead
Leave while you’re ahead
  • Keep track always of the best solution so far
  • Write this out when time is up
  • Keeping track of time (C++)

#include<ctime>

clock_t t1, t2;

t1 = clock();

//do stuff

t2 = clock();

double Time;

Time=double(t1)-double(t2);

Time/=CLOCKS_PER_SEC;

in summation
In Summation
  • When exact code takes too long (and there are marks for being close to correct) approximate.
  • Trade-off: Time vs. Accuracy
  • Search for simplifications to problems that do not need Approx. Solutions.