Simulation with agent processing in different time dimensions

74 views
Skip to first unread message

Nicolas Sprotti

unread,
Aug 17, 2022, 10:29:56 PM8/17/22
to netlogo-users
Hi everyone,

I expert in supply chain engineering.

In supply chain when we go up an echelon we often go up in the time dimension. Like a store may order bread every day to the bakery but the bakery order the flower (to make the bread) every other week type thing.

While you order every other week or every day the logic is the same, independent of the time dimension. One agent may leave in a weekly simulation the other in a daily simulation. They still need to talk to each other.

It is a basic example and can get more complicated.

Does anyone have experience in building simulation where agents talk to each other while operating on different time unit?

Thank you!
Nico Sprotti


Michael Tamillow

unread,
Aug 17, 2022, 11:55:36 PM8/17/22
to Nicolas Sprotti, netlogo-users
Time has a conversion between these different units, so 1 week equals 7 days. That’s how you work with any metrics that are comparable but at different scales. Then you can use basic operations, such as multiplication to cancel out the units. So 7 days per week * 2 weeks and the weeks cancel out on numerator and denominator to leave you with 14 days. 

Pretty sure I learned that in introductory chemistry and physics for calculating moles in a substance by weight and position/velocity changes based on time and acceleration. It is surprisingly useful across disciplines as it generalizes well even to abstract units that you might construct for fields like economics and sociology.

Sent from my iPhone

On Aug 17, 2022, at 9:29 PM, Nicolas Sprotti <nicolas...@gmail.com> wrote:

Hi everyone,
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/CABiSjse7-gECKy3%2BZGyQWGOtLDiYWqD6YppPz6pbo8g9aNehvA%40mail.gmail.com.

John Chen

unread,
Aug 18, 2022, 12:44:43 AM8/18/22
to Michael Tamillow, Nicolas Sprotti, netlogo-users
A way to think of this is to utilize the Time extension which allows you to schedule discrete events. Therefore you could easily have timed events on a mixed daily/weekly basis. 

Pradeesh Kumar K V

unread,
Aug 18, 2022, 3:14:39 AM8/18/22
to netlogo-users
Hello Nico,

"One agent may leave in a weekly simulation the other in a daily simulation. They still need to talk to each other."

Could you please clarify what you mean when you say that one agent may leave in a weekly simulation and the other in a daily simulation? Are you referring to two separate models, one with week as time unit and the other with day as time unit and you need interaction between these two models? If yes, have you considered a single model with agents making their decisions at different intervals?

Best,

Pradeesh

Michael Tamillow

unread,
Aug 18, 2022, 7:11:50 AM8/18/22
to Pradeesh Kumar K V, netlogo-users
I think he meant “live” instead of “leave”.

And yes, I was implying what Pradeesh made explicit. Technically all things live in a single simulation we call reality, where many, many factors are overlapping. There are modular advantages of using a tool like levelspace to isolate interacting units of complexity, but in the end it is all one giant mess, existence, I mean.

Sent from my iPhone

On Aug 18, 2022, at 2:14 AM, Pradeesh Kumar K V <prade...@gmail.com> wrote:



James Steiner

unread,
Aug 18, 2022, 1:29:42 PM8/18/22
to Nicolas Sprotti, netlogo-users
Just like in the real world, in such a simulation, all agents are operating within the same time line, and there exists some smallest useful division of that time. 

Whatever that smallest division is, you can use your own local variable to count it, or use the Netlogo tick. In your example, one tick is one day.

The model's main loop, typically named "go" is run from a "forever" button.

Each run of that procedure is the activities of that smallest unit. 

Agent activities can be scheduled on multiples of that unit. As a simple example, give each kind of agent an -owned  variable called "dimension". 

For bakeries, the dimension is 1. For flour Suppliers, the dimension is 7, for importers, maybe the dimension is 30. For growers, the dimension is 360.

In GO, each agent might use the MOD operation with the current "time" (the tick) and its dimension. MOD returns the remainder after integer division. So, if the dimension is 7, (ticks mod dimension) equals zero when ticks is a multiple of 7.  

When (0 = (ticks MOD dimension)) is true, it is time for the agent to perform its activity. That is, every 7 days. 

In a more complex model, each kind of agent may have many possible activities, each with a different dimension. 

At that point it becomes a data management problem: how to store the dimensions and related activities within each agent?

The dimension is a number. The activity could be stored as a string naming the activity, used in a complex if-else to determine action, or the activity could be stored as an anonymous procedure, so that the agent only needs to "run" the stored activity when (ticks mod dimension = 0)

This pair of values could be stored in a list of lists. Awful. Terrible. 

If could be stored in a netlogo Table (aka dictionary or hash-tables). Ok, but not ideal. 

Or, the activity could be stored in a variable owned by a link between the agent and another breed of agent that represents the time dimension, where the link stores the times activity. 

 Let's call these timing agents "intervals". An interval is a breed of turtles that also owns a number, dimension,  that represents how often it will cause other agents to act. It may also have a number, phase, that changes where in that dimension the act occurs. 

When an agent is created, it may have activities assigned to it. This is done by linking the agent to the required  dimension and assigning an anonymous procedure to the links activity variable .

The links are used by the interval  to cause their linked agents to run the activity, if the interval's (ticks mod dimension ) is zero.

This is a nice structure, it means that no matter how many agents there are, it takes only a few tests to find the agents that will act that tick, and likewise make them act, as each dimension can access the related links and agents using the link-neighbors and other-end primitives. 

Breed [ intervals interval ]
Intervals-own 
[ Dimension
   Offset
]

Undirected-link-breed [ connectors connector ]
Connectors-own
[ Activity ]

Breed [ actors actor ]
Actors-own
[ Kind
   Etc
]

;; Assume some procedures that define the different kinds of  actors activities..

Setting up an actor may look like this: 

To setup-bakers
Create-actors baker-count
[ Set kind "Baker"
   Let this-dimension 7
   Let this-offset 0
  Let this-interval one-of intervals with [ dimension= this-dimension and offset = this-offset ]
if not is-link? this-interval
[  Setup-interval this-dimension this-offset ]
  Create-connection-with this-interval
   [ Set activity 
      [ -> 
         Bake-bread
         Order-flour
     ]
  ]
]
End

The main part of the go loop looks like this:

To go
   Ask intervals with [ offset = (tick mod dimension) ] 
    [ Ask my-links 
       [ Ask other-end
          [ Run [ activity ] of myself 
           ]
         ]
      ]
End

Just got back from whirlwind road trip, so there may be many bugs. 

--James

Muhammad Asif Jaffer

unread,
Nov 27, 2022, 2:57:43 PM11/27/22
to netlogo-users
Salaam Friends
Can somebody share some code example for making links with other agents who are close to the agent in its attribute values. For example, if agent is male, young, white, and tall, the connection (link) to be established with other n agents who are close to this agent in these attributes, That is, to all who have all same values, then to those who have three matching values, and then 2 etc. Sort of homophily network

James Steiner

unread,
Nov 27, 2022, 3:17:27 PM11/27/22
to Muhammad Asif Jaffer, netlogo-users
To keep things clean, Please make a new message with your question, rather than replying to an unrelated question.

Thank you!

Wade Schuette

unread,
Nov 27, 2022, 7:51:58 PM11/27/22
to netlogo-users
If you're not concerned about efficiency, you could have a basic  
   "ask agents [ ask other agents [ if (condition) [ make a bidirectional link]]"
but before getting more specific, what do you mean "then" ?  Are there a limited number of links you want to create?   What difference does it make in your mind what order the links are created?

It would help if you could say what you plan to do with the links once you have them. Maybe that would change the best way to code this.

Wad
"

Stephen Guerin

unread,
Nov 28, 2022, 1:44:25 AM11/28/22
to Wade Schuette, netlogo-users
Hello Muhammed,

Here's one strategy of connecting all the turtles, calculating the similarity based on color, size, and shape then pruning out the bottom 70%

links-own [similarity]

to setup
  ca
  crt 10 [fd 8 set size one-of [1 2 3 ] set shape one-of ["person" "bug" "cow" ]]
  ask turtles [create-links-with other turtles]
  ask links [
    set similarity sum (map [[x y] -> ifelse-value x = y [1] [0]] [(list color size shape)] of end1 [(list color size shape)] of end2)
    set label similarity]
  ask min-n-of (0.7 * count links) links [similarity] [die]   ; keep the top 30% of links
end


--- -. .   ..-. .. ... ....   - .-- ---   ..-. .. ... ....
Stephen...@Redfish.com
1600 Lena St #D1, Santa Fe, NM 87505
office: (505) 995-0206  mobile: (505) 577-5828   
tw: @redfishgroup  skype: redfishgroup
zoom.redfish.com


drasif...@gmail.com

unread,
Dec 1, 2022, 2:44:45 PM12/1/22
to Wade Schuette, netlogo-users

I want certain agent interactions to be based on homophily based on blaw space. That is, agents interact with only random X agents with same color, shape and size. Can somebody help an efficient way to do such interactions?

Stephen Guerin

unread,
Dec 1, 2022, 3:38:01 PM12/1/22
to drasif...@gmail.com, Wade Schuette, netlogo-users
I assume you're trying to implement this:
"The organizing force in Blau space is the homophily principle, which argues that the flow of information from person to person is a declining function of distance in Blau space. Persons located at great distance in Blau space are very unlikely to interact, which creates the conditions for social differences in any characteristic that is transmitted through social communication. The homophily principle thus localizes communication in Blau space, leading to the development of social niches for human activity and social organization."
https://en.wikipedia.org/wiki/Blau_space#:~:text=The%20organizing%20force%20in%20Blau,of%20distance%20in%20Blau%20space.

Given that we created local links based on homophily above, I believe the resulting social graph is a Blau Space. As turtles interact with their link neighbors, flow of information will effectively decline with social distance (network hops) and connectivity.

-Stephen


--- -. .   ..-. .. ... ....   - .-- ---   ..-. .. ... ....
Stephen...@Redfish.com
1600 Lena St #D1, Santa Fe, NM 87505
office: (505) 995-0206  mobile: (505) 577-5828   
tw: @redfishgroup  skype: redfishgroup
zoom.redfish.com

Michael Tamillow

unread,
Dec 1, 2022, 7:57:35 PM12/1/22
to stephen...@redfish.com, drasif...@gmail.com, Wade Schuette, netlogo-users
Hmmm, never heard of Blau space, but it does make me consider how powerful a paradigm driving policy can be.

If taken too literally, it is dehumanizing. We have, as a species, become nothing more than the data we generate.

Sent from my iPhone

On Dec 1, 2022, at 2:37 PM, Stephen Guerin <stephen...@redfish.com> wrote:



drasif...@gmail.com

unread,
Dec 9, 2022, 1:51:57 AM12/9/22
to stephen...@redfish.com, Wade Schuette, netlogo-users

Hi Stephen

I am trying the code you suggested. I will appreciate if you can cite some paper wherein networking algorithm contained such a code so that I can include that citation as an argument in my work.

Thank you for your help so far and for your valuable inputs

Stay blessed

Asif

Reply all
Reply to author
Forward
0 new messages