Distribution network finding v0

Distribution network finding v0 preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Jorge Laval (Author)

Tags

distribution networks 

Tagged by Jorge Laval about 1 month ago

logistics 

Tagged by Jorge Laval about 1 month ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 60 times • Downloaded 3 times • Run 0 times
Download the 'Distribution network finding v0' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This is a model based on the Paths model in the documentation, extended to have a single warehouse and demand points that need to be served. The original model is about how paths emerge along commonly traveled routes. People tend to take routes that other travelers before them have taken, making them more popular and causing other travelers to follow those same routes. This can be used to determine an ideal set of routes between a set of points of interest without needing a central planner. Paths emerge from routes that travelers share.

HOW IT WORKS

Each of the turtles in the model starts somewhere in the world, and is trying to get to another random location. Turtles prefer to move along the gray patches, representing established paths, if those patches are on the way to their destination. But as each turtle moves, it makes the path that it takes more popular. Once a certain route becomes popular enough, it becomes an established route (shown in gray), which attracts yet more turtles en route to their destination.

On setup, each turtle chooses a destination at random. On each tick, a turtle looks to see if there is a gray patch on the way to its destination, and walks toward it if there is. If there no gray patch, it walks directly towards its destination instead. With each step, a turtle makes each patch it walks on more popular. If a turtle causes the patch to pass a certain popularity threshold, it turns gray to indicate the presence of an established route. On the other hand, if no turtle has stepped on a patch in quite a while, its popularity will decrease over time and it will eventually become green again.

You can interact with this model by placing points of interest for the turtles to travel between. While "go" runs, click on a patch in the model to turn that into a point of interest. Once you have placed two or more such points, turtles will travel only between those locations. To remove a location, click it a second time.

HOW TO USE IT

  • popularity-decay-rate controls the rate at which grass loses popularity in the absence of a turtle visiting it.
  • popularity-per-step controls the amount of popularity a turtle contributes to a patch of grass by visiting it.
  • minimum-route-popularity controls how popular a given patch must become to turn into an established route.
  • walker-count controls the number of turtles in the world.
  • walker-vision-dist controls how far from itself each turtle will look to find a patch with an established route to move it closer to its goal.
  • show-popularity? allows you to color more popular patches in a lighter shade of green, reflecting the fact that lots of people have walked on them, and showing the paths as they form.

THINGS TO TRY

Try increasing and decreasing walker-vision-dist? When you set it to smaller and larger values, how does the evolution of the model change?

popularity-decay-rate and popularity-per-step balance one another. What happens when the popularity-decay-rate is too high relative to popularity-per-step? What happens when it is too low?

Can you find a way to measure whether the route network is "finished"? Does that change between runs or does it stay relatively constant? How does changing the walker-count affect that?

How does changing the world-wrap effect the shape of the paths that the turtles make?

EXTENDING THE MODEL

See what happens if you set up specific destinations for the turtles instead of having them move at random. You might have start off by moving to a particular patch, or have each turtle move in a unique loop.

Come up with a way of plotting how much of each journey a turtle spends on an established route. Try plotting that value against the distance a turtle goes out of its way on a given journey to stay on an established route. How do the two quantities relate to one another?

Modify turtles to sometimes remove established routes instead of just creating them. Which route patches are best to remove? Do the resulting shapes generated by the model change?

Turtles select a new patch to move toward each turn. This isn't a particularly efficient way for a turtle to move and sometimes leads to some awkward routes. Can you come up with a more realistic path-finding scheme?

RELATED MODELS

  • CCL Cities has some information on city simulation, including other models where "positive feedback" figures prominently.

CREDITS AND REFERENCES

Inspired by Let pedestrians define the walkways.

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the original model itself:

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Copyright 2015 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [ buildings building ]
breed [ walkers walker ]
walkers-own [ goal returning? ]
patches-own [ popularity ]
globals [ mouse-clicked? ]

to move-walkers
  ask walkers [
    ifelse patch-here = goal [
      ifelse returning? [
        ; If the walker is returning to the factory, set the goal to a demand point
        set goal [ patch-here ] of one-of buildings with [ color = red ]
        set returning? false
      ] [
        ; Otherwise, if the walker is at a demand point, set the goal to the factory
        set goal [ patch-here ] of one-of buildings with [ color = black ]
        set returning? true
        die
      ]
    ] [
      ; If the walker is not yet at the goal, continue moving towards it
      walk-towards-goal
    ]
  ]
end 

to reappear
  create-walkers (walker-count - count turtles) [
          setxy 0 max-pycor
          set goal [ patch-here ] of one-of buildings with [ color != red ]
          set returning? true
          set color yellow
          set size 2
        ]
end 

to ini-conds
  create-walkers walker-count [
    setxy random-xcor random-ycor
    set goal [ patch-here ] of one-of buildings with [ color != black ]
    set returning? false
    set color yellow
    set size 2
  ]
end 

to setup
  clear-all
  set-default-shape buildings "house"
  ask patches [ set pcolor green ]
  setup-patches
  reappear
  reset-ticks
end 

to setup-patches
  ask patches [
    if pycor = max-pycor and pxcor = 0 [
      toggle-building black ; Factory at the top center
    ]
    if pycor = min-pycor [
      toggle-building red ; Demand points at the bottom
    ]
  ]
end 

to go
  check-building-placement
  move-walkers
  reappear
  decay-popularity
  recolor-patches
  tick
end 

to check-building-placement
  ifelse mouse-down? [
    if not mouse-clicked? [
      set mouse-clicked? true
      ask patch mouse-xcor mouse-ycor [ toggle-building red ]
    ]
  ] [
    set mouse-clicked? false
  ]
end 

to toggle-building [ clr ]
  let nearby-buildings buildings in-radius 2
  ifelse any? nearby-buildings [
    ask nearby-buildings [ die ]
  ] [
    sprout-buildings 1 [
      set color clr
      set size 4
    ]
  ]
end 

to decay-popularity
  ask patches with [ not any? walkers-here ] [
    set popularity popularity * (100 - popularity-decay-rate) / 100
    if popularity < 1 [ set pcolor green ]
  ]
end 

to become-more-popular
  set popularity popularity + popularity-per-step
  if popularity >= minimum-route-popularity [ set pcolor gray ]
end 

to walk-towards-goal
  if pcolor != gray [
    ask patch-here [ become-more-popular ]
  ]
  face best-way-to goal
  fd 1
end 

to-report best-way-to [ destination ]
  let visible-patches patches in-radius walker-vision-dist
  let visible-routes visible-patches with [ pcolor = gray ]
  let routes-that-take-me-closer visible-routes with [
    distance destination < [ distance destination - 1 ] of myself
  ]

  ifelse any? routes-that-take-me-closer [
    report min-one-of routes-that-take-me-closer [ distance self ]
  ] [
    report destination
  ]
end 

to recolor-patches
  ifelse show-popularity? [
    let max-value (minimum-route-popularity * 3)
    ask patches with [ pcolor != gray ] [
      set pcolor scale-color green popularity (- max-value) max-value
    ]
  ] [
    ask patches with [ pcolor != gray ] [
      set pcolor green
    ]
  ]
end 

There is only one version of this model, created about 1 month ago by Jorge Laval.

Attached files

File Type Description Last updated
Distribution network finding v0.png preview Preview for 'Distribution network finding v0' about 1 month ago, by Jorge Laval Download

This model does not have any ancestors.

This model does not have any descendants.