Error in setting variables - NaSch model of traffic simulation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in setting variables - NaSch model of traffic simulation

Sara Vicario
Hello,

I am stuck in the first part of the NaSch model for traffic simulation.

I am trying to put into my citizens an initial speed. However, I have a problem setting the variable speed that own the citizens equal to the variable Vmax that own the patches under the road.
I got the following error: Expected number here, rather than a list or a block. I know the meaning it can not set the value because if it is not unique, if not Vmax contains several values, but how can I resolve this issue? or how can I copy the values of Vmax of the patches below of the turtle everytime than they move?to set-Vmax
ask patches gis:intersecting roads [foreach gis:feature-list-of roads [vectorfeature -> set Vmax gis:property-value vectorfeature "roads"]]
ask patches [if Vmax = 50 [set pcolor blue]]
end

to initialize-NasCh-speed
set speed [Vmax of patch-here] - random-float 0.2 * [Vmax of patch-here]
end

Reply | Threaded
Open this post in threaded view
|

Re: Error in setting variables - NaSch model of traffic simulation

Francois Guerrin
Hi,

you got this error because you made syntax errors.

You should write :

|set speed [Vmax] of patch-here - random-float 0.2 * [Vmax] of patch-here
But you should ask your citizens to do that: |
|

|to initialize-NasCh-speed ask citizens [  set speed [Vmax] of patch-here
- random-float 0.2 * [Vmax] of patch-here ]  end If your citizens are
turtles, since Vmax is patch-owned I guess, you can simply write: |
|

|

|to initialize-NasCh-speed ask citizens [  set speed Vmax - random-float
0.2 * Vmax ]  end Or even: |

|

|

|

|to initialize-NasCh-speed ask citizens [  set speed Vmax * (1 -
random-float 0.2) ]|

|

|

|


||

|

|

|


Le 11/04/2018 à 16:11, Sara Vicario [hidden email]
[netlogo-users] a écrit :

> Hello,
>
> I am stuck in the first part of the NaSch model for traffic simulation.
>
> I am trying to put into my citizens an initial speed. However, I have
> a problem setting the variable speed that own the citizens equal to
> the variable Vmax that own the patches under the road.
>
> I got the following error: *Expected number here, rather than a list
> or a block.* I know the meaning it can not set the value because if it
> is not unique, if not Vmax contains several values,
> but how can I resolve this issue? or *how can I copy the values of
> Vmax of the patches below of the turtle everytime than they move?*
> |to set-Vmax ask patches gis:intersecting roads [foreach
> gis:feature-list-of roads [vectorfeature -> set Vmax
> gis:property-value vectorfeature "roads"]] ask patches [if Vmax = 50
> [set pcolor blue]] end to initialize-NasCh-speed set speed [Vmax of
> patch-here] - random-float 0.2 * [Vmax of patch-here] end|
>
>
>

--

SignatureMail-FG.png (33K) Download Attachment