Advertisement
Guest User

initiative résolution fail test retour dépôt

a guest
Jun 13th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 2.08 KB | None | 0 0
  1. function checkInsertion(solution,nRoute,idRequest,posI,posJ)
  2.     instance = solution.instance
  3.     road = solution.routes[nRoute].route
  4.     posP = -1
  5.     posD = -1
  6.     cost = 0
  7.    
  8.     ####### ICI
  9.     ## Cas spécial de avant le retour au noeud dépôt
  10.     if (road[posI+1] == 1)
  11.         solution.fts[road[posI+1]] = instance.nodes[1].latest
  12.     end
  13.     if (road[posJ+1] == 1)
  14.         solution.fts[road[posJ+1]] = instance.nodes[1].latest
  15.     end
  16.     #######
  17.  
  18.     state = false # If the request can be inserted at this position.
  19.     pP = instance.requests[idRequest].pickup
  20.     pD = instance.requests[idRequest].delivery
  21.     qR = instance.requests[idRequest].qte
  22.     if (qR <= instance.capacity - solution.maxLoad[road[posI+1],road[posJ]])
  23.         #Time a vehicle passes through a node. We assume it as soon as possible.
  24.         h = solution.schedule ## earlyStart(solution,nRoute)[2] : Earliest Service Start
  25.         t1 = max(h[road[posI]]+instance.nodes[road[posI]].serviceTime+getDistance(solution,road[posI],pP),instance.nodes[pP].earliest)
  26.         if (t1 <= instance.nodes[pP].latest)
  27.             t2 = max(instance.nodes[road[posI+1]].earliest,t1+instance.nodes[pP].serviceTime+getDistance(solution,pP,road[posI+1]))
  28.             delta = t2 - h[road[posI+1]]
  29.             if (delta<=solution.fts[road[posI+1]])
  30.                 t3 = max(h[road[posJ]]+instance.nodes[road[posJ]].serviceTime+getDistance(solution,road[posJ],pD),instance.nodes[pD].earliest) + delta
  31.                 if (t3<=instance.nodes[pD].latest+delta)
  32.                     t4 = max(instance.nodes[road[posJ+1]].earliest,t3+instance.nodes[pD].serviceTime+getDistance(solution,pD,road[posJ+1]))
  33.                     deltaPrim = t4-h[road[posJ+1]]
  34.                     if (deltaPrim <= solution.fts[road[posJ+1]])
  35.                             posP = posI
  36.                             posD = posJ
  37.                             cost = distDelta(instance,road,posI,posJ,pP,pD)
  38.                             state = true
  39.                     end
  40.                 end
  41.             end
  42.         end
  43.     end
  44.     return state,posP,posD,cost
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement