Can NetLogo handle millions of agents? - netlogo

For a project we need to decide between NetLogo and RepastS.
We will model a network of institutions with people moving between them. People enter and exit these institutions that are implemented as black boxes. We see no problem using NetLogo for this. An extension of this project will have explicit implementations of institutions with interacting agents. These interactions occur at a different time scale than updates on the macro level (movement between institution).
1) Can NetLogo handle potentially millions of agents (moving between institutions and interacting inside them) and 2) can NetLogo handle agents that operate on different time scales and granularity?

1) See NetLogo FAQ on how big models can be and how to increase it's memory capabilities.
Millions of agents is definitely possible, but far from common. I've heard of a lab that uses around 7 million agents in their simulation (running on a cluster).
On my laptop, after increasing the memory limit (see the FAQ), I was able to easily create several millions of agents and ask them to do trivial things. Each ask at 3-4 million too about a 1-1.5 seconds.
2) Absolutely! Check out the LevelSpace extension (bundled with NetLogo) for this. It allows NetLogo models to open up and interact with other NetLogo models. So in your case, you'd create a model for within-institution interaction and then another model for the traveling between institutions that has a number of the institution models open that it adds agents to and removes agents from. Then, you can run the within-institution models at whatever scale you want relative to your main model.
Also, distributing the agents among models via LevelSpace should generally run a bit faster. LevelSpace will automatically parallelize operations when calling to multiple models.

Related

Simulation stuck while producing the agents in AnyLogic

I have 100 cubic meter tank and I have 133,333 bottles to fill. When tank get fill I am using
source.injact(133,333)
My first issue was a lack of memory, which I resolved, and now agents are being produced; however, once the source began producing, the simulation stuck and run very slow. How can I solve this issue?
if you have 100,000 agents and if all of them are using the fluid library, there's a chance that things will be very slow.
That's all i can say with the information provided.
I wouldn't use the fluid library inside a bottle agent... I would model that differently (if you are doing that, which i don't know if you are)
It can also be that your computer is slow

AnyLogic - How to define and redefine Agent's Parameters?

We’re generating the data that we might get from a shop floor to run, test, and validate our machine learning models. We first have here a discrete event simulation model for our manufacturing system. Each production order is seen as an agent, which then goes through different processes with a queue (waiting time) and delays (firstly production time, secondly logistics time).
enter image description here
But sometimes we have one process, for example, printing (code 5A, after the second Select5Output), with three different machines, which do not have a particular capacity. It’s time when we divide our order into parts and send them to those machines (very randomly, subjectively).
The data we take is from flowchart_process_states_log in Database.
The data we take is from flowchart_process_states_log in Database.
My questions here are:
How can we define the number of products in each order? Ex. we’re printing card, for one order it may be 10k, for another 8k or 33k. Can we define it as agent’s parameter? Then how can we vary them (stochastically, no exact number needed).
How can we split those 10k cards into three different machines? And then how to get back an complete agent with 10k? The Agent ID should remain the same as we trace and analyse them in ML model. Is it reasonable to see an order as an agent?
How can we multiply the number of our agent after a process? Ex. After cutting 10k pieces we have 20k.
We have the distribution for delay ex. triangle distribution. But we want some disturbances, when it suddenly takes 2 days for that delay instead of 3-4 hours as normal. How to do it?
Thank you in advance for your effort. Every help is highly appreciated, because we're here and learning together. Thank you !!

How to i make agents in AnyLogic avoid another moving agent?

I am trying to model an agent based model where a certain agent population of people avoid to get close to a single agent, a random moving VIP.
I have tried to useif (distanceTo(main.vip < restrictedArea)) ;moveTo(uniform(500),uniform(500))
The agent will, most of the time, move to its new random destination through the restricted area which i want to avoid
Either you use the Material-handling library (where the transporters have build-in collision avoidance).
Or you model it youself. For that, you need a cyclic event in your agent that constantly checks the distance to whatever other agent you are interested in. If below some threshold, you tell the agent to move elsewhere.
Note: the first option can be quite slow. The second is not trivial to implement. Less due to coding skills, more because having intelligent collision avoidance algorithms is not trivial

Generic modeling of an energy supply chain with Anylogic

I have been working with Anylogic for about 6 months now and my goal is to model a generic energy supply chain for an energy demand (e.g. storm and heat for a house). As a result I want to evaluate how suitable the components in the energy supply chain are to meet the energy demand.
My idea would be to model the components (Ex. PV->Battery Storage->House) as agents. I would have modeled the energy flow in the agents with SD and individual events of the components (e.g. charging and discharging at the battery) via state diagrams.
Currently I have two problems:
Which possibilities are there to create a variable interconnection of my components (agents). For example, if I do not want to evaluate the scenario PV->Battery Storage->House, but PV->Electrolysis->Tank->Fuel Cell->House. My current approach would be to visually connect the agents with ports and connectors and then pass input and output variables for DS calculation via set and get functions. Are there other possibilities, e.g. to realize such a connection via an input Excel? I have seen a similar solution in the video: "How to Build a True Digital Twin with Self-Configuring Models Using the Material Handling Library" by Benjamin Schumann, but I am not sure if this approach can be applied to SD.
To evaluate the energy supply chain, I would like to add information to the energy flow, for example the type (electricity, heat), generation price (depending on which components the energy flow went through) and others. Is there a way to add this information to a flow in SD? My current approach would be to model the energy flow as an agent population with appropriate parameters and variables. Then agents could die when energy is consumed or converted from electricity to heat type. However, I don't know if this fits with the SD modeling of the energy flow.
Maybe you can help me with my problems? I would basically be interested in the opinion of more experienced Anylogic users if my approaches would be feasible or if there are other or easier approaches. If you know of any tutorial videos or example models that address similar problems, I would also be happy to learn from them.
Best
Christoph
Sounds like what you need is a model that combine agent-based and system dynamics approaches with Agents populating the stocks (in your case energy that then gets converted into heat) depending on their connection. There is an example of AB-SD combination model in 'Example' models and I also found one on cloud.anylogic.com, although it is from a different domain.
Perhaps if you can put together a simple example and share then I'll be able to provide more help.

How to make Anylogic simulations run faster?

I have a model with agents: cars, passengers and petrol stations. The population size of the cars is 500 and there are 5 petrol stations. The passengers here are generated randomly and I have capped the passengers on the map to be at a maximum of 500 at any point in time (the limit here is set to be the same as the population size of the cars).
However, the simulation speed is running really slow (like 1-2s/sec) on virtual mode. Could this be due to the complicated model built or are there any ways on how we can speed up the running time of the simulation?
Many factors can slow your model, here are just some ideas:
Do you use Pedestrian agent types for your passengers? Try not to, unless ped dynamics are crucial
do you use conditional transitions? They are evualated at every event in the model and can slow it. You can always replace them with message-based transitions easily
Do you use the road traffic library? Again, only apply it if car dynamics are really necessary, else revert to the process library
Do you read/write a lot of data during the sim run to the dbase or an external file? Avoid that and do it at the start/end
Also, it could just be inefficient coding. You can check that using a Java profiler. Easiest is to use the one that comes with any Java JDK.
Good luck