In NetLogo Behaviour Space, how can I vary two variables in conjunction? - netlogo

I have two agent types.
I want to vary Agent1 from 90-100 and I Agent2 from 0-10.
But I want them to vary 'in step' so as Agent2 increases in number Agent 1 decreases.
How can I code that in behaviour space?
Thanks

Vary Agent2 from 0 to 10, and then include this in your experiment's setup commands:
set Agent1 100 - Agent2

Related

Creating a specific Number of agents with a determined parameter value out of 3 values

I need to create an agent with a parameter "Class" that has 3 possible values. I need to be able to determine the number of agents with each class value at the Simulation screen before the simulation starts, by using a slider that determines the number of Agents.Class=="A", Agents.Class=="B" and so on.
I've tried creating an action chart that uses RandomTrue to assign the class.
The inputs for this action chart are:
A parameter sums the output of the 3 sliders to determine the total n of agents
Another parameter computes the percentage of agents.class=="A" from the total n of agents
A third parameter computes the percentage of the agents.class="B" from the remaining n of agents (n-agents.class=="A")
I'm not allowed to post pictures yet, but see action chart Here .
The issue with this is that when using percentages, it will round here or there and the actual number of agents with desired class may have one more or one less.
How can I make this with an exact number of agents created with each class?
This does not make sense mathematically. If you create 10 agents and the random number splits it using 0.66 and 0.33, then you cannot create 6.66 agents.
So some rounding must happen, unless you create infinite agents.
However, you can decide to round the random number. If you know you will create 100 agents, you could use Math.ceil(uniform(0, randomA)*100.) or similar. If randomA would be 0.66666, you would get 67 as a result.
(Math.floor would give you 66)
It isn't clear to me why you're converting the number to %-ages at all? Are you going to create N agents in total? If so you can just use amounts for class 'A' and class 'B' agents in two separate Source objects (one for each class) to create the agents at the start.

restricted area object capacity be based on available footprint

What is a feasible way to have the restricted area object capacity be based on available footprint for the agents?
I have agents that are produced at the source and have a randomly assigned footprint. The delay object is in a restricted area block. Instead of the capacity be based on the number of agents that it can hold, I would like it to be based on footprint availability. I have two parameters, initial sqft and true sqft. Initial sqft is what is available at the start (how much space is available at the facility). At the entry of the queue, i set the true sqft to initial subtracting the agent's footprint and at the exit i add the agents footprint back to the true sqft. I entered the true sqft evaluation at the queue entry because I want it to wait in the block if there isnt any footprint to delay the agent. When I run it, true sqft exceeds initial sqft, which should be impossible.

NetLogo set random-seed according to the number of repetitions in the Behavior Space

I would like to know whether is it possible in NetLogo to set the random-seed according to the number of repetitions in the Behavior Space.
I know there is the command random-seed behaviorspace-run-number, but it sets a different seed for every run of the model. This is not what I want because I am trying to explore the impact of a variation in the values of a parameter on a specific random network structure. By using random-seed behaviorspace-run-number I get a different network structure for each value of the parameter within the same repetition of the experiment, which is not what I want.
Can anyone help me on this?
Thanks a lot,
Emanuele
There's not a variable that gives you exactly what you want, but BehaviorSpace runs through the parameter sets in a specific order. Say you have 5 repetitions of 20 parameter combinations, so there's 100 runs. It will do the first run of 20 combinations, then the second series etc. So you can do some mathematics or some if/then to go from the behaviorspace-run-number to the random-seed (eg floor behaviorspace-run-number / 20 if you want it to change every 20 runs).

Space between agents in discrete-event simulation

I have a question about space between agents. In my model I have agents generated from a source and then they enter a delay, after the delay the agents go into a a queue with a capacity of 1 but I have a preemption option. The agents that go into the preemption are supposed to move along a circled path (I used a delay block for this) but there should always be a certain space between the agents, e.g. 100 meters. How can I incorporate this in my model to make sure my agents are not too close to each other?
One way you can control the distance between your agents is to move them on a path using a dummy transporter instead of the moveTo block. Transporters allow you to define a minimum distance to obstacle that prevents the agents from getting too close to each other.
Two options if you mean the static queue with agents actually waiting:
1) if your queue size is 500 meters, define the maximum amount of agents allowed in that queue to 6 (so you have 100 meters of distance between each agent)
2) Use the PML settings block from the PML palette and define an initial capacity of animation location equal to 6 (if your queues are 500 meters)... but this applies to all the model, so maybe it won't be good enough.
If you want them to have 100 meters space while they are moving towards their objective through the path that represents the queue, then the answer depends heavily on your model and it cannot be answered with the info provided... you need in this case to control the agent movements adding some logic... but I don't know what logic is suitable for you.

Performance Issues with Calculation during Turtle Procedure

I am building a type of 'honey-bee' model, where the bees are turtle agents and the honey is a patch specific variable. In my model, each patch is assigned a value of 'honey-here' between 1-100 based on a specific distribution.
The model starts with the bees only being able to collect honey from flowers with honey = 1, for which they then receive 1 unit of honey in return. Before the bees can 'target' flowers with honey = 2, they need to occupy (i.e. a bee on a flower) X% of the total flowers with honey = 1. For example, I might require the bees to achieve 80% occupancy, which means if there are 10 flowers total with the variable honey = 1 then the bees need to occupy 8 of those flowers before they are allowed to start looking/targeting flowers with honey = 2. As each bee individually acts, the % occupancy value will change.
I'm having performance issues for the occupancy calculation. Ideally the calculation is updated within a turtle procedure as it needs to be applied to each turtle within the loop. Here's what I currently have to find the value of the variables I need to set current % occupancy before each bee is allowed to act:
ask bees
[
;; set up variable based on ratio of number of turtles occupying target patch size against total number target patch size
;; note -- don't do this in one step to avoid divide by 0
let patch-count-current (count patches with [honey-here = bee-honey-target-size])
;; don't want number of bees, want number of unique patches
let patch-target-occupy count patches with [ (count bees-here > 0) and (honey-here = bee-honey-target-size) ]
...
Later in the code, after checking to make sure patch-count-current isn't 0, I find my % occupancy via patch-target-occupy / patch-count-current
It turns out this is a very expensive hit on my processor performance. Especially as my number of bees grows, which is exponential in my model.
Is there a better way that won't cost me so much processor for each iteration of the loop?
Thanks!
-dp
Given your response to StephenGuerin, you could manually track the counts with global variables. If there is only one bee-honey-target-size at a time, this is pretty simple. Just make a patch-count-current global and a patch-target-occupy. Then, increase them or decrease them as things change.
The Sandpile model (from the models library) uses this technique to keep track of the total amount of sand without having to iterate over the patches. Check out how the total global variable is used.
If you need to keep track of the counts for all bee-honey-target-sizes at once, you could store a list of the counts in a global variable, where the index of the list corresponds to a value of bee-honey-target-size. This is much messier unfortunately, so you would have to write helper functions for sure.
Let me know if any of this needs clarification.
Percentage occupancy is a property of the group and only needs to be calculated once per simulation step. Your performance hit is due to calculating occupancy for every bee in your simulation. The calculation for percentage occupancy for a given 'target-honey' could look like this:
to-report calc-occupancy [target-honey]
report (sum [count turtles-here] of patches with [honey-here = target-honey]) / count turtles
end