我试图运行这个模型,但它没有开始,我不明白" nw"延期。我安装了netlogo 5.2.1和" nw"扩展捆绑已经。 Netlogo在第48行显示错误(nw:快照节点链接)。错误消息为"没有任何名称为NW:SET-SNAPSHOT已定义为" 。请帮忙。整个代码是
extensions [gis nw table array]
breed [leavers leaver]
breed [followers follower]
breed [officers officer ]
breed [ nodes node ]
turtles-own [voisins]
leavers-own [ cur-link speed path-end current start to-node from-node origin destin]
globals [network walls itc itc-dataset walls-dataset officer_walkspeed leaver_walkspeed follower_walkspeed interaction_time person_size max_preevacuation_delay loaded ticks_per_sec arr-e v path1 next-node distance100 distance200]
undirected-link-breed [ friendships friendship ]
to startup ;; called when first loaded
read-gis-datasets
end
to setup
clear-all-but-globals ;; don't loose datasets
ask patches [set pcolor white]
setup-world-envelope
draw-world
setup-paths-graph
ask nodes [setxy xcor ycor
if show_names? = True [show-names]]
setup-leavers
end
to clear-all-but-globals reset-ticks ct cp cd clear-links clear-all-plots clear-output end
to read-gis-datasets
;set walls gis:load-dataset "walls.shp"
set network gis:load-dataset "BRT.shp"
;set itc gis:load-dataset "itc.shp"
end
to setup-world-envelope
let world ( gis:envelope-of network ) ;; [ minimum-x maximum-x minimum-y maximum-y ]
gis:set-world-envelope (world)
end
to setup-paths-graph
set-default-shape nodes "circle"
foreach polylines-of network 3 [
(foreach butlast ? butfirst ? [ if ?1 != ?2 [ ;; skip nodes on top of each other due to rounding
let n1 new-node-at first ?1 last ?1
let n2 new-node-at first ?2 last ?2
ask n1 [create-link-with n2]
]])
]
ask nodes [hide-turtle]
nw:set-snapshot nodes links
end
to-report polylines-of [dataset decimalplaces]
let polylines gis:feature-list-of dataset ;; start with a features list
set polylines map [first ?] map [gis:vertex-lists-of ?] polylines ;; convert to virtex lists
set polylines map [map [gis:location-of ?] ?] polylines ;; convert to netlogo float coords.
set polylines remove [] map [remove [] ?] polylines ;; remove empty poly-sets .. not visible
set polylines map [map [map [precision ? decimalplaces] ?] ?] polylines ;; round to decimalplaces
;; note: probably should break polylines with empty coord pairs in the middle of the polyline
report polylines ;; Note: polylines with a few off-world points simply skip them.
end
to-report new-node-at [x y] ; returns a node at x,y creating one if there isn't one there.
let n nodes with [xcor = x and ycor = y]
ifelse any? n [set n one-of n] [create-nodes 1 [setxy x y set size 2 set n self]]
report n
end
to show-names
ifelse label = ""
[set label (word who " ")]
[set label ""]
end
to draw-world
gis:set-drawing-color [255 0 0] gis:draw network 1
end
to setup-leavers
set-default-shape leavers "person"
set leaver_walkspeed 1
create-leavers num-leaver [
set size 1
set origin one-of nodes
if origin = 100 or origin = 200
[show origin
set origin one-of nodes]
move-to origin
show origin
ask origin [set distance100 nw:distance-to node 110]
ask origin [set distance200 nw:distance-to node 210]
ifelse distance100 > distance200
[ask origin [set path1 nw:turtles-on-path-to node 210]]
[ask origin [set path1 nw:turtles-on-path-to node 110]]
;[set destin node 200]
;[set destin node 100]
let a array:from-list path1
set destin array:item a 1
]
end
to go
tick
ask leavers
[
if distance destin < 0.01 ;; round off error fix
[ set origin destin
move-to origin
ask origin [set distance100 nw:distance-to node 110]
ask origin [set distance200 nw:distance-to node 210]
ifelse distance100 > distance200
[ask origin [set path1 nw:turtles-on-path-to node 210]]
[ask origin [set path1 nw:turtles-on-path-to node 110]] ;[set destin node 200]
let a array:from-list path1
if array:length a > 1
[set destin array:item a 1 ]
;origin array:item a 1 ;set next-node one-of [link-neighbors] of to-node face to-node destin] ]
]
face destin
fd 0.01
]
end
to create-shortest-path
ask nodes [set color green]
if Origin = Destin [user-message "Please select two different nodes" stop]
ask node Origin [set color blue]
ask node Destin [set color blue]
;ask node origin [ show nw:path-to node Destin]
ask node origin [ show nw:turtles-on-path-to node destin ]
output-show [ nw:distance-to node destin ] of node origin ;=> 1
end