現在、車両のルーティングの問題にノードとリンクを使用する必要がある 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
誰かが何が起こっているのか知っていることを願っています...