netlogo tie-mode "fixed" fails to maintain link-length in graphs with medium-level degree

146 Views Asked by At

I am trying to create a network that moves through the environment as a "static" unit, i.e. nothing in the simulation changes except the position and orientation of the whole, the position and orientation of the individual turtles relative to one another are fixed by their links. Turtles are connected via undirected links, which are tied and set to tie-mode "fixed".

The problem is that in certain situations the links fail to remain fixed and link-lengths begin to change. Initially I noticed that, where the average network degree is relatively low or the network is a complete graph, the tie primitive works. However, when links were created to produce a graph that is moderately connected the link-lengths between the turtles begins to change. Upon further experimentation I can create a network with the same number of links and turtles but with different configurations i.e. the network structure is different, that sometimes maintain the positions and link-lengths but in other situations fail to do so.

How do I get the network to move as a unit no matter how connected the network is or what the configuration of the network is? See example code below, I have added code at the end where you can run multiple configurations of a network with 6 turtles and 6 links to see the issue for yourself, try running at least a half dozen iterations. Thanks!

this produces a network that moves as a unit

to setup
create-turtles 10
ask turtles [fd 2]

ask turtles [create-links-with other turtles [tie] ]

ask links [set tie-mode "fixed"]
reset-ticks 

create-turtles 10
ask turtles [fd 2]
ask turtles [create-links-with other turtles [tie] ]
ask links [set tie-mode "fixed"]
reset-ticks 
end

to go
ask turtles [lt 1 fd 1]
end

This produces a network whose links are still tied and set to tie-mode "fixed", but change their link-lengths. The more links that are asked to die, the more the link-lengths change.

to setup
clear-all
create-turtles 10
ask turtles [fd 2]
ask turtles [create-links-with other turtles [tie] ]
ask links [set tie-mode "fixed"]
ask one-of links [die]
reset-ticks 
end

to go
ask turtles [lt 1 fd 1]
end

Here is additional code showing a specific instance of link-length change. Please input the seed 659269695 when prompted by the button "use-seed-from-user". Apologies if the code is clunky, first time using random-seed. "Print-lengths" button is to confirm that lengths change.

;USE seed: 659269695

to use-new-seed
let my-seed new-seed            ;; generate a new seed
output-print word "Generated seed: " my-seed  ;; print it out
random-seed my-seed             ;; use the new seed
reset-ticks
end

;; Use a seed entered by the user
to use-seed-from-user
loop [
let my-seed user-input "Enter a random seed (an integer):"
carefully [ set my-seed read-from-string my-seed ] [ ]
ifelse is-number? my-seed and round my-seed = my-seed [
  random-seed my-seed ;; use the new seed
  output-print word "User-entered seed: " my-seed  ;; print it out
  reset-ticks
  stop
] [
  user-message "Please enter an integer."
]
]

end

to setup
clear-all
create-turtles 6 
ask turtles [
fd 5
set shape "circle"
set size 1
set color yellow
if count links < 7 [ask one-of turtles [create-link-with one-of other turtles 
[tie]]]]
reset-ticks
end

to go
ask turtles [lt 1 fd 1]
end

to print-lengths
print sort-by < [precision link-length 2] of links 
end
1

There are 1 best solutions below

3
JenB On

I slightly revised your code so that the go procedure includes breaking a link. I also got rid of the explicit setting of tie-mode since that is done by setting the link to tie and added a tick so I could plot. So the code looks like this:

to setup
  clear-all
  create-turtles 10 [fd 2]
  ask turtles [create-links-with other turtles [tie] ]
  reset-ticks 
end

to go
  ask one-of links [die]
  ask turtles [lt 1 fd 1]
  tick
end

As far as I can see, the turtles move as a unit until it fragments with the loss of links.

I added a monitor for mean [link-length] of links, which is what I think you are asking about and also a plot of the same calculation. Yes, it is true that the average link length changes, but remember that the links are not all the same length. If a longer one dies, then the average length will reduce, and if a shorter one dies then the average will increase. The plot wanders a little, but it is basically flat until fragmentation.