netlogo - How can I increase speed up simulation of my least-cost path model -


Using the network extension, the following code creates the least number between two polygons (made up of several patches): < / P>

  to calculate -LCP [id-polygon-1 id-polygon-2] Let's [path] path-cost -1; ;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;; ;;;;;;;;;;;;; ;; Define polygonal edges [playlabel! Ask with id = polygon-1] [Ask for neighbor [playbel = id-polygon-1] [Ask nodes - set here [color red]] [pabel! = ID-Polygon-2] [Ask Neighbors [Platel = ID-Polygon-2] [Ask nodes - here [red color]]; ;;;;;;;;;;;;;;; 2 ;;;;;;;;;;;; ;;; ;; Ask at least cost nodes with [color = red] with the [[id-polygon = id-polygon-1] nudge-patch of anterior type, [node-on-polygon-1] [id-polygon = Node-polygon-2] [node-on-polygon-2] Ask node-on-polygon-1 [cost nw: weighted-distance-node-on-polygon-2 "with fibroid type = id-polygon-2] Link-Cost "if path-cost = -1 or cost & lt; Route-cost [routing cost set path nw: weighted-path-to-node-on-polygon-2 "link-cost"]]]] ;;;;;;;;;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;; Draw a low-cost path leading path [;; Ask the least cost way? [Set color red set thickness 0.2]]  

I have implemented this code with two polygons which were represented by black rectangles in the data By using Profiler Expansion, this code lasted for 14 minutes.

Enter image details here

For each wolf, I would like to build the least path between a polygon where the wolf and all the polygons are located in the radius of 3 km around the wolf. My code here:

  Asked wolves [my-list-of-polygons-in-buffer] (set the [plabel] of the patch in radius 3-my-list-of-polygons Set -in -buffer-delete-duplicate-set my-list-of-polygons-in-buffer Remove my-list-of-polygons-in-buffer [plabel] Patch's here-my-list-of-polygons Remove the multi-fold-in-buffer foreach my-list-of-polygons-in-buffer in the list of -in-buffer set my-polygon-in-buffer [ID-polygon-in-buffer? Ask patch with [Plabel = ID-polygon-in-buffer] [LCP Calculation - ID-polygon-in-buffer of LCP [Mary-ID-Polygon]]] << The problem is that my process "calculation-LCP" is very slow to define a minimum-cost path in the buffers around the wolf (in my model 100 wolves) very slow How can I increase my speed to speed up my model?  

Thank you very much for your help.

Only you nw: set-snapshot turtles link The network set if a load is changed, or any links or nodes are added or removed, you must call it again. This will make your code very fast.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -