Netlogo: error when putting variable in table, only constants allowe??

Posted by Chantal on Stack Overflow See other posts from Stack Overflow or by Chantal
Published on 2010-06-08T08:56:40Z Indexed on 2010/06/08 9:02 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

Hello,

Currently I am working on a Netlogo program where I need to use nodes and links for vehicle routing problem. (links are called streets in the program)

Here I have some practical problems of how to input variable linkspeed in a table with another node. Constants like 200 etc are fine. Online I found some examples where variables are used, but I do not know why I keep getting the following error: Expected a constant. (or why netlogo expects a constant)

Here is the relevant piece of code:

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

I hope somebody knows what is going on...

Kind regards,

Chantal

© Stack Overflow or respective owner

Related posts about table

Related posts about replace