0

this code works in small networks (30 vertices) but for a 300 vertices network takes hours! Is there a faster way?

to calculate-duration
  ask act 0 [set color green]
  set pathlist [ ]
  loop [
  if all? deps [color = green] [stop]
  let path [0]
  let i 0
  while [i != count acts - 1][
  ask act i [set path lput [who] of one-of out-link-neighbors path]
   let j i
   set i last path
   ask turtle i [set color green]
   ask dep j i [set color green]
   ]
  let d 0
  foreach path [x -> set d d + ( [duration] of turtle x ) ]
  set path lput d path
  set pathlist lput path pathlist
  ]
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Mehdi Nmz
  • 3
  • 2
  • You're going to have to explain a bit more what this is supposed to do. Are you trying to find (1) the highest weight path possible in the network (2) the highest weight path between two specified nodes (3) calculate the shortest path for each pair of nodes and find the highest value of these (4) something else? – JenB May 15 '20 at 00:41
  • (2) but weight means attribute of turtles not weight of links. – Mehdi Nmz May 15 '20 at 09:23
  • I'm trying to find the critical path on a (AON) Activity on Node network. a path which addition of duration of agents (activities) on it ,is highest – Mehdi Nmz May 15 '20 at 09:27
  • Have a look at the networks extension, see https://ccl.northwestern.edu/netlogo/docs/nw.html. Unfortunately I think it minimises the weighted path so you may have to transform your weights, but I suspect it's a better starting point than what you are doing because it should provide much better performance. – JenB May 15 '20 at 09:42
  • Thanks a lot ,I transformed weights, but problem is that, nw:turtles-on-weighted-path-to and other path and distance primitives are always looking for shortest path, so the result is always a combination of [Transformed Weight] and shortest path. but maybe there is a longer path with smaller weights [Transformed]. – Mehdi Nmz May 15 '20 at 11:33

0 Answers0