Re: [netlogo-devel] Movement of turtles - observer context error

104 views
Skip to first unread message

Bryan Head

unread,
Apr 4, 2018, 10:30:36 AM4/4/18
to Sara Alonso Vicario, netlogo-devel

Hi Sara,

It’s awesome that you’re working in NetLogo. However, this list is reserved for discussing technical matters regarding how NetLogo’s build and operations. For modeling questions, the best resources are the netlogo-users Yahoo group and/or asking a question on Stackoverflow.

As a quick answer though: the problem is that this line isn’t being run in a turtle context: if (sex = 0 and age = 1 and employment = 0 and household-size = 0) [move-work], since I assume sex and age are citizen variables. But simply putting those in the ask citizens won’t work since move-work already ask citizens, so you’d get all citizens asking all citizens to do stuff, which you obviously don’t want. So, instead of putting ask citizens in Do_7AM_9AM, start-movement, or move-work, I recommend changing your go procedure to do ask citizens [ find-day-activities ].

Best,
Bryan


On Wed, Apr 4, 2018 at 4:57 AM Sara Alonso Vicario <saralons...@gmail.com> wrote:
Hi, 

I am working on a model in NetLogo to move citizens around a city to different places in different schedules. I just starting and I am trying to move the citizens which particular characteristics to a patch grey (that represents a work area). However, I have a problem with the find-day-activities command. The error is the following: You can not use find-day-activities in observer context, because find-day-activities is turtles only.

I already checked on internet solutions and I know it is related to the context, for this reason, I included ask citizens command to Do_7AM_9AM, start-movement and move-work to move from turtle context to observer context but the error persists.

Here is my code, someone could help me?

Thank you in advance,

Sara

to go
set-timekeeper
find-day-activities
end

to set-timekeeper
tick ;Advances the tick counter by one and updates all plots.
let counter ticks ;Reports the current value of the tick counter.
  if (counter = 1) [set timekeeper 1] ;Before 7:00 AM
  if (counter = 2) [set timekeeper 2] ;From 7:00 AM to 9:00 AM
  if (counter = 3) [set timekeeper 3] ;From 9:00 AM to 13:00 PM
  if (counter = 4) [set timekeeper 4] ;From 13:00 AM to 14:30 PM
  if (counter = 5) [set timekeeper 5] ;From 14:30 AM to 17:00 PM
  if (counter = 6) [set timekeeper 6] ;From 17:00 AM to 20:30 PM
  if (counter = 7) [set timekeeper 7] ;After 20:30 PM
end

to find-day-activities
if (timekeeper = 2) [Do_7AM_9AM]
end

to Do_7AM_9AM
ask citizens 
[start-movement]
if (sex = 0 and age = 1 and employment = 0 and household-size = 0) [move-work]
end
   
to start-movement
ask citizens
[let nearest-node min-one-of nodes [distance myself]
set slocation nearest-node
move-to slocation]
end

to move-work
ask citizens 
[let work-patches (patch-set patches with [pcolor = grey])
let new-location one-of [link-neighbors] of (patch-set patches with [pcolor = grey])
move-to new-location
set slocation new-location]
end 



--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sara Alonso Vicario

unread,
Apr 4, 2018, 1:30:02 PM4/4/18
to netlogo-devel
Thank you, sorry. I will ask in the other group!

u...@northwestern.edu

unread,
Apr 4, 2018, 2:31:34 PM4/4/18
to Sara Alonso Vicario, netlogo-devel
Hi Sara,
Glad that the shape file issue was resolved.
For queries such as the one copied below, we suggest users send to netlog...@yahoogroups.com, a much larger group of users, who can answer such questions.

All the Best,

—Uri

Uri Wilensky





Reply all
Reply to author
Forward
0 new messages