Your plan doesn't sound to me like it would help performance. It sounds just as likely to make things slower as faster.
Have you tried using the profiler extension to see which procedures are the ones using the most CPU? http://ccl.northwestern.edu/netlogo/5.0/docs/profiler.html
UPDATE: (now that code has been provided)
links with [end2 = mySelf]
is slow because it has to check every link to see whether it satisfies the given condition. I think you mean [my-in-links] of myself
; primitives like my-in-links
return answers immediately, without having to check every link.
Similarly, you have any? links with [end1 = Self_Agent and End2 = Other_Agent]
. Again, using with
means every link has to be checked if satisfies the condition. Instead, write [out-link-neighbor? Other_Agent] of Self_Agent
. out-link-neighbor?
can check for the existence of a link directly, without having to scan every link.
I have a hunch that eliminating unnecessary uses of with
will fix your performance problems. But, one additional, less important note:
Why foreach sort sss
? Why not just ask sss
? Is there some reason it needs to run in sorted order? ask
is faster than foreach
plus sort
plus ?
.