Clara Ns

8
1 CLARANS CLARANS

description

example

Transcript of Clara Ns

  • CLARANS

  • data1042969549981540880416282967322Algorithm CLARANS1.Input parameters numlocal and maxneighbor.Initialize i to 1, and mincost to a large number.k = 3numlocal = 10maxneighbor = 5i = 1mincost = 9999

  • DatacostK#1043.1623329426902542.236139932812.23613542.23613086.08282803.162334101621.41423821.41423963.605637303222.23611Algorithm CLARANS2.Set current to an arbitrary node in Gn,k.3.Set j to 1.Step 2. current = Gn,k. = {(4,1), (6,9), (7,3)}cost(current) = 34.7856Step 3. j = 1note: S1 and S2 are neighbors if and only if |S1 S2| = k-1

  • Algorithm CLARANS4.Consider a random neighbor S of current, andbased on Equation (5) calculate the cost differential of the two nodes.5.If S has a lower cost, set current to S, and go toStep (3).6. Otherwise, increment j by 1. If j
  • Algorithm CLARANS4.Consider a random neighbor S of current, andbased on Equation (5) calculate the cost differential of the two nodes.5.If S has a lower cost, set current to S, and go toStep (3).6. Otherwise, increment j by 1. If j
  • Algorithm CLARANS4.Consider a random neighbor S of current, andbased on Equation (5) calculate the cost differential of the two nodes.5.If S has a lower cost, set current to S, and go toStep (3).6. Otherwise, increment j by 1. If j
  • Algorithm CLARANS3.Set j to 1.4.Consider a random neighbor S of current, andbased on Equation (5) calculate the cost differential of the two nodes.5.If S has a lower cost, set current to S, and go toStep (3).6. Otherwise, increment j by 1. If j
  • current = {(4,1), (2,9), (7,3)} cost(current) = 34.263j = 1random S = {(4,1), (2,9), (9,6)}cost(S) = 38.121j = 2random S = {(4,1), (2,9), (10,4)}cost(S) = 38.087j = 3random S = {(4,1), (5,4), (7,3)}cost(S) = 40.888j = 4random S = {(4,1), (9,9), (7,3)}cost(S) = 39.16j = 5random S = {(2,2), (2,9), (7,3)}cost(S) = 37.422j = 6 j > maxneighbor goto step 7Step 7. cost(current) < mincostmincost = cost(current) = 34.263bestnode = current = {(4,1), (2,9), (7,3)} Step 8. i = i + 1 , i = 2i < numlocal goto step (2) random set ? current ?Algorithm CLARANS7. Otherwise, when j > maxneighbor, compare thecost of current with mincost. If the former is lessthan mincost, set mincost to the cost of current,and set bestnode to current.8. Increment i by 1. If i > numlocal, outputbestnode and halt. Otherwise, go to Step (2).