Why is NetLogo in radius so slow, is there a faster way around it?

I found that my model works very slowly, and I narrowed it down to a team in the radius where the turtles work. The bottom line is that of the two procedures below, test1 checks [var] for each patch, but works faster than test2, which should only check a small subset of 8 patches.

set patches-of-interest (patch-set patches with [var > 1])   

to test1
  ask min-one-of other patches-of-interest with-max [var][distance myself][set pcolor red]
end

to test2
  ask min-one-of other patches-of-interest in-radius 1.5 with-max [var][distance myself][set pcolor yellow]
end

You can check their speed using the Profiler extension and the following code:

profiler:start         
repeat 100 [ 
ask one-of turtles [test1 test2]
 ]      
profiler:stop         
print profiler:report  
profiler:reset    

Firstly, why is test2 slower? And secondly, is there an alternative to test2 that does roughly the same thing, but more efficiently?

I found a couple of discussions on the Netlogo list about this, but they are a bit old, so they may be outdated: https://github.com/NetLogo/NetLogo/issues/402

http://netlogo-users.18673.x6.nabble.com/Re-in-radius-efficiency-question-td5003840.html

EDIT: , -, "". , . , , , test2 , , 2.

+4
1

@bryan-head , ( - ). , - Netlogo.

, , , , . binaryvar,

ask patches [ifelse var > 1 [ set binaryvar 1][set binaryvar 0]
to test3
  ask min-one-of other patches-of-interest in-radius 1.5 with-max [var * binaryvar][distance myself][set pcolor yellow]
end

, , var = 0...

+2

All Articles