How to constrain agents to a specific GIS Region? - simulation

I currently have a two populations of agents. One for customers and one for service trucks. There are multiple customers and trucks and their initial location is being determined via an imported excel database with lat/long coordinates.
I would like to have the trucks service customers as needed (ideally at specific times throughout the day). However, I would like to create a set of multiple regions that would enclose my customers. The service trucks would then be assigned a region and only address customers that fall within their region. I have a statechart that currently exists to enable trucks service customers, however, I'm not sure how to tied in the different regions to the agents. I believe once I have the region information tied to the agent, I should be able to update the statechart to handle the updated logic.
So, given I have multiple regions, how can assign a region to the customer (ensuring that the customer actually lies within the boundary of the region) and then assign different regions to the trucks and have them only address those customers.
The program being used is Anylogic.

On creation of your customer agents, make them check which region they are in (using myRegion.contains(lat, lon) with your agent coordinates). You need to loop through all GIS regions as they may overlap, of course.
Store the region found in a variable in your agent (set it to the type GISRegion).
Now, you can assign your trucks specific regions as well (same approach) and only make them go to agents of the same region

Related

Mean statistics about agents in Anylogic

I'm working on a family practitioner model, my goal is to model the population of a city and all of the family practitioners in that given city by taking into account the distribution of the treatment time and the arrival schedule of patients etc... So far i've managed to create an agent that contains a bloc diagram to model the whole process
With a source and a delay bloc to generate patients according to a fixed schedule, a service bloc and two sinks.
Now i've put a population of this agent "process" in the main and i've simulated the model for 3 months.
Lets say i've started with a population of 10 process which represents the number of practitioners. My goal now to to collect some Mean statistics, like the Mean number of treated patients (treated patients goes to the sink "Served") of the 10 practitioners, the Mean waiting time of patients at the service bloc, the mean utilization ratio of the resource of the service bloc...
I want to also know if is it possible to limit the total number of Patients (or to at least count them), for exemple, instead of simulating the model for 3 months, i wanna limit the total number of patients that goes to the 10 process to 10k and i want to know how much time does it take to serve all of them. (is it possible with this architecture of the model or do i have to make major changes)
Thank you

Gathering statistics on a resourcePool

I want to get some statistics on some of the resources I have in AnyLogic. For instance, I have a forklift agent and a resourcePool of forklift and I want to get the hourly utilization and the total distance traveled by all forklifts in the pool. I know I can click on the resourcePool icon and see the utilization, but I want to get that with the traveled distance updated and saved every hour.
Sorry I'm new to this and took me few months of learning to get my model straight
Thank you
First, you must create an agent type for your resources. With that in place, you can record anything anytime using datasets or default AnyLogic logging capability.
See some example models using resource pools with custom agent types such as "Lead acid battery production" and many more.
PS: Recording distance travelled is done automatically if you apply default logging but it is a bit more involved if you want to do it manually.

Usage of IF condition in anylogic

I am trying to create model in which i want to collect the specific colored(RED) agents at a specific location (A). I am using a transfer table to divert the flow from one conveyor to other.
Can any body help me how to divert the flow based on the colors of agent.
attached snaps of discrete event diagram. Please let me know if you require more information.
discrete eve dia 1
image showing collection
A transfer table cannot actively steer where agents go. Instead, you have to manage where agents should be transfered in the "Convey" block as below. Put in a condition based on the agent color and send them to the respective end nodes or conveyors.
Hope this helps

Gathering statistics on agent population

I have some issues with gathering statistics on the population level in a model I've been working with.
In the model I have an agent type Company and RawMaterial. Within Company a process flow exists, where on some blocks costs are assigned to a variable in Company upon entry of RawMaterial (e.g. cost = gamma(3, 125, 0);)
To calculate the Company-level cumulative costs I use a Statistics object with cost in the value field of this object.
So far so good it seems.
However, when I want to sum the cumulative costs of all Company agents into one value I run into trouble. Ideally, I want the cumulative costs for each Company agent to be plotted in Main.
I've looked at the Help file (section "Functions to collect statistics on agent population") with no success.
what about doing this in main? (you can even put this function in your time plot)
sum( companies, c->c.cost );
This function calculates the sum of the costs of all company agents (as long as you have a population of agents called companies in main, and not only an agent type)
If you don't have companies as a population of agents, you have to create it, otherwise it's very difficult to calculate anything. How to create it depends on your model.

how to make live scoreboard in netlogo?

i am working on the simulation of coalition in agent society. Agents (turtles) form coalition dynamically and after some times they left current coalition and joined other one. Hence, number of members (turtles) in the coalition vary on every tick. Some times because of no member in the coalition, coalition vanishes and some times two or more than two members (turtles) form the new coalition. I want to have live score board in simulation, which gives updated stats about the coalition and its members. For instance, how many coalition currently exist, what are the names of the coalition and how many members in each coalition. Could any one guide me which feature should i use to develop the live score board? Any guidance would be highly appreciated.
The monitor widget is the best option for current count of coalition membership (or plot if you want it over time). For more detailed information, have a look at using the output area with commands such as output-show to provide the information.