目前我正在开发一个 Netlogo 程序,我需要使用节点和链接来解决车辆路线问题。(链接在程序中称为街道)
在这里,我遇到了一些实际问题,即如何在另一个节点的表中输入可变链接速度。像 200 这样的常数很好。网上找了一些使用变量的例子,但是不知道为什么一直报如下错误:
预期一个常数。
(或者为什么 netlogo 期望一个常数)
这是相关的代码:
extensions [table]
streets-own [linkspeed linktoll]
nodes-own [netw]
;; In another piece of code linkspeed is assigned successfully to the links
to cheapcalc
;; start conditions set costs very high 300000
;; state 3 unsearched state 2 searching state 1 searched (for later purposes)
ask nodes [
set i 0 set j count nodes set netw table:make
while [i < j][
table:put netw (i) [3000000 3] set i (i + 1)]]
set i 0 let k 0
ask node 35 ;; here i use node 35 as an example.
;; node 35 is connected to node 34, 36, 20 and 50
[table:put netw (35) [0 1] ;; node need to search costs to travel to itself
;; putting constants is ok.
while [i < j]
[ask my-links
[ask both-ends
[if (who != 35) [set color blue
;; set temp ([linkspeed] of street 35 who) ;; here my real goal is to put this in stat of i. but i is easier than linkspeed.
table:put netw (who) [ i 2 ]
]
] ]
set i (i + 1)] ] ;; next node for later, no it is just repetition of the same.
end
我希望有人知道发生了什么...