Reporting in a chart the life-cycle of turtles

ε祈祈猫儿з 提交于 2020-02-04 00:43:33

问题


I am working on a task that includes plotting the life-cycle of items. These items are created and added in a list with owners having different breeds (for simplicity I am considering only two breeds). If the number of items in a list is greater than the list's length (perhaps, length = 5), then the last item of the list is deleted. I am doing this because, at a certain point, the item will stop to be shared from turtles, so it will disappear from the plot ( it will be equal to 0 in the y-axis variable, frequency/count).

EXAMPLE: This is how a list looks like:

(woman 0): [(property 21) (property 18) (property 14)]
(man 7): [(property 13) (property 18)]

and so on. The life cycle would be the 'life' of each item included in the list (e.g. for property 13, property 14, property 18, property 21) through time. It would be interesting to compare the life cycle based on the different breeds, but I think this would be asking for more.

APPROACH & CODE: My approach would be to set a label for each item in order to create like a multi-plot that can show all the life cycle of the items created. But this would create a lot of labels for each item created!

After creating the network, I use the go procedure to select one turtle and create another turtle (called properties) to be studied through time. In order to do this, I have thought to assign it a label and plot it in a line chart.

to go
    ask one-of turtles 
  [ hatch-properties random 5  ; create a number of turtles to be associated with the turtle 'parent'
    [ 
      set label who ; assign a label
      let this_property self ; create a local variable to be added to the turtle's list
      ask myself 
       [set my-properties (list this_property)] ; add the property created to the list my-properties
    ]
  ]
  tick ; update the time window
end

As shown in the code above, items (properties) are turtles with their breed-own parameters. The plot should contain as information:

x-axis ticks 
y-axis frequency/count of the items through time.

i.e. something like plotxy ticks count ... Following the example above, I would have: at tick 0, no items is created. At tick 1, let's say that property 13 is created (count 1). At tick 2 property 14 (count 1). At tick 3, property 18 (count 1). At tick 4, property 18 is also in the list of a different turtle (then count 2), and so on.

QUESTION: How could I plot the life cycle of these items (identified by labels) in a chart?

ATTEMPT TO FIND A SOLUTION: In the pen update command I have added the following code:

ask properties with [who = 18] [ plotxy ticks count turtles with [breed = women or breed = men]]

This should select the turtle with who = 18 and plot the number of turtles with breed=women or breed=men that have this item into their own lists (it should return me its frequency through time). But I have a few questions related to the command above:

1) am I selecting a generic property with who = 18 or the property with label who = 18, i.e. property 18?

2) is it right the count of turtles as frequency of the number of items equal to property 18 shared through time by these two breeds? In this way, I am counting all the turtles, not only those ones with property 18 in their own lists.

Any information, help, suggestions will be highly welcomed

来源:https://stackoverflow.com/questions/59697955/reporting-in-a-chart-the-life-cycle-of-turtles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!