Hi All
I am trying to move my agents along the roads on a multi destination trip and want to calculate total distance travelled along the road drinng whole run. I am using Path finding model using the A-star algorithm in Netlogo - GMU_roads model
https://github.com/YangZhouCSS/roads/ to get coding help to get roads shapefile in NetLogo and to make my agents move to multiple locations along the roads.
I have a global variable called total-distance-travelled to store total travel distance in one year (= one run). However, my world is quite large (i.e. whole state) as compared to the world in the GMU model (roads withing a university campus). Therefore, I am getting runtime error "your model is too large ....".
Can anyone suggest any other approch or example model that can help me.
I thougt of having a patch variable roads? and assign the values using gis:intersecting but it gives me error (see below my code)
extensions [gis]
globals [ roads-dataset total-distance-travelled ]
turtles-own [
my-home ; patch where turtle is generated randomly
previous-target ; initialize as nobody updated as turtle moves i.e. next-target becomes previous target after one movement
next-target ; turtle finds closest patch with sp-ric value > 0 as next-target
distance-travelled ; distance between previous-target and next-target
patches-own [
roads? ; True is patch intersects roads shapefile
sp-rich ; species richness at the patch randomly assigned between 0 to 9
(set sp-rich random 10)
to setup-turtles
create-
turtles number-of-turtles ; create turtles based on slider
ask
turtles [
setxy random-xcor random-ycor
set color white
set shape "person"
set previous-target nobody
set my-home patch-here
set pcolor brown
]
end
to setup-roads
set roads-dataset gis:load-dataset "data/roads_WA.shp"
gis:set-world-envelope ( gis:envelope-of
roads-dataset )
ifelse ( patch-set gis:intersecting
roads-dataset ) [set roads? true ] [ set roads? false ]
end
to go
if ticks > 365 [ stop]
ask beekeepers [
move
calculate-distance
]
tick
end
to move
ask turtles [
if [sp-rich ] of patch-here = 0
[
ifelse roads? = true
[ fd 1] [ right 360 fd 1 ]
move-to next-target
set distance-travelled distance previous-target next-target
] ]
end
to-report next-target
if previous-target = nobody [
ask turtles [ set next-target min-one-of patches with [ sp-rich > 0] [distance myself] ]
]
end
Highlighted part is not working. I am not sure why.
Not sure how to update total-distance-travelled.
Also, if I want travel-distance calculated for each turtle seperately, total-distance-travelled should be a turtle variable rather than global right?
I would truely appreciate any help with this part of coding.
Thank you
Kind Regards
Vidushi