Randomizing the order an agent calls a procedure? - netlogo

I have an 5 procedures I'd like an agent to perform but I need them to randomize the order in which they perform them.
For example:
1) possible ordering
ask turtles [ move eat breed search spawn]
2) another possible ordering
ask turtles [spawn eat move search breed]
3) another possible ordering:
ask turtles [search breed eat move spawn]
and so on. Is there there an efficient way to execute the procedures in random order?

You could make a list of tasks, shuffle the list, then run each task in the list:
let procedures (list (task spawn) (task eat) (task move) (task search) (task breed))
ask turtles [foreach shuffle procedures [run ?]]

Related

Is there a way to use the material handling Library to assign a randomly generated list of items to a worker to collect from storage shelves

Essential, I aim to model the picker process in a warehouse. In my scenario a worker is given a randomly generated list of items to complete an order. The worker goes to the storage and complete the order. In my model each agent/worker only collects a single item per run and I'd like to know how to set each worker to randomly collect multiple items(say ten) in one run
I added the storage shelves and added the retrieval block and assigned worker agents to it. I did not know how to set up the picker scenario
If you use a RackSystem as shelves, so you can use the function myRackSystem.randomAgent() to select a random pallet from the RackSystem.
If when you generate your pallets you put them into a population, So you can use the function randomWhere( pallets, p -> p.weight > 1000 ) to select a random agent from a population and satisfying the specified condition.
Good luck!

How to compare conditions of an agent with all connected agents in statechart

I am working on my thesis associated with modeling farmers' behaviors in a river basin. I am having 6
agents that contain different populations of farmers. These farmers have been located on the GIS map as the environment (main) in anylogic. I also defined the connection between populations of 6 agents by coding on the main startup and using "Link to Agent". Now, I'd like to define agents' behaviors through statecharts. But I have some difficulties. I have to compare the income of each farmer to the income of all connected farmers. How can I do that? What I have tried to define condition transition and write (for example if the income of each farmer is less than the income of all connected farmers in its network then do specific action):
IncomeT<ALL_CONNECTED.IncomeT
but it didn't work. Got any suggestions?
Thanks.
not quite clear who is your agent for which you are designing your state chart. Is it some entity (say Area) which contains a population of farmers? If yes, then why would you connect/link one Area to another? If you agent is a famer (which is not how you described it, but seems logical) then you would just store (and update) "minimum population income" in some variable and compare individual income with that stored value.
Alternatively you can use min() function. More on that: https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fdata%2Fcollections-statistics-api.html

What code should I write in Drop off? ANYLOGÄ°C

What code should I write in Drop off?
The Simulation Scenario is as follows: There are 7 passenger stroke riding stops in total. There are also passenger arrivals to all 7 stops. Every two minutes a bus arrives and takes the passengers from the stop, lowering the passengers who want to get off. My problem starts exactly here. For example, how will I determine the passengers to land at the 3rd stop? I want 10% of passengers boarding at the first stop to drop 30% of passengers boarding at the second stop.
I did not know what to write in the drop off section to do so.
I tried this way. I have appointed passengers from each stop as agents separately. Maybe I could write it that way, but it gave an error when writing to drop off.
general view error location
Thanks for the clarifications.
Easiest way would be to store where pedestrians were picked up. Add a variable "myPickUpStation" to your pedestrian agent type (ensure to have a custom type).
Also, add a collection "myPedestrians" to your bus agent type. Fill it in the pickup so the bus knows who he has.
Then at dropoff, you can first query all peds in the bus who were picked up at station 1:
findAll(container.myPedestrians, p -> p.myPickUpStation == 1) (1 is just an example)
And then, take 10% of that group's size:
0.1 * findAll(container.myPedestrians, p -> p.myPickUpStation == 1).size()
Obviously, you will need to round that to a proper int

Netlogo - BehaviorSpace - reporter for measuring runs failed to report a result

In my model, I have 3 producers and after each run, they each have 2 values for the profit and sale earned from their vehicle sold in the market. The model needs to run 100 times. I followed the steps for the behaviorspace tool, but I was uncertain what to add for the "Measure runs using reporters" section. I found this post enter link description here . Following that, I used this
[(list who profit)] of producers [(list who sale)] of producers in order to see the number for "who" and the corresponding profit and sale. This has an error saying that "reporter for measuring a run fails to report result - NULL". How can I resolve this issue? I should also mention that in the code there is no to-report without a return, but the returned things are not what I want to collect.
Thanks
Can you include your breed and breed-specific variable declarations? Your reporter syntax works for me, as long as it's on two lines in the Measure runs using these reporters field.
Also, you can simplify your output to a single reporter, if you want- using this toy setup as a test:
breed [ producers producer ]
producers-own [ profit sale ]
to setup
ca
create-producers 3
reset-ticks
end
to go
ask producers [
set profit profit + random 50
set sale sale + random 5
]
end
And a BehaviorSpace experiment that looks like:
Your output (with the 'Table' option) should look like:
Does that work for you?

NetLogo: is it possible to access variables of not yet created turtles?

I am writing a piece of code in which investment simulations for different types of factories are run. To calculate if an investment is worth the try, the to-be-build factory (say, steel-factory) is analyzed for revenues and costs in the future. To do that, the turtle (e.g. a company) calculating the investment needs to know the production capacity of the steel-factory.
to test
let future-steel-production ([max-processing-capacity * operational-time] of one-of steel-factories
end
But if no steel-factory is build yet (i.e. created), I get the error code:
OF expected input to be an agent or agentset but got NOBODY instead.
Is there any way to access an agent's variable, when the agent hasn't been created yet?
Is there any way to access an agent's variable, when the agent hasn't been created yet?
No. That's a logical impossibility.
But that doesn't mean that you can't figure out the future values of these variables.
You need to ask yourself how you would initialize these variables if you were to actually create the agent. These values (max-processing-capacity and operational-time) have to come from somewhere, right? Do you some have some definition of factory types stored in a file? Accessed via a reporter or some global variable?
If you were to create a factory with something like:
create-factories 1 [
set max-processing-capacity ???
set operational-time ???
]
...what would you replace ??? with? That's your answer. You need to use whatever you would use at factory creation time when calculating future steel production.