AnyLogic - Place Agents in Point Node Collection - anylogic

I created a network consisting of paths and point nodes. Some of the nodes are part of an arraylist collection with the element type PointNode. On model startup I generate a population of agents with the number of agents equal to the size of the collection of point nodes.
I now want set the agents location so that each point node of the collection contains exactly one newly created agent. What would be a good way to do this?

Ok I got it. In case anyone else is wondering:
On model startup the following code is executed in the main agent:
//set locations for agents
for (int j=0; j< agents.size(); j++)
{
agents(j).location = collectionOfPointNodes.get(j);
agents(j).jumpTo(agents(j).location);
}

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!

Batching multiple agents based on location of agent

In my model I only want to batch agent which are at the same location. So my source block generates the agents according to a database to a specific node (which is sometimes different for agents), now I want the agents that occur at the same node to batch in sizes of 2 and the one that are left over need to be batched alone.
How can I model this, I know that I can use the selectoutput (which says for example if location=node1 use this output etc) option, but do I than have to add for example manually 100 outputs if I've 100 different locations where the agents start or is there a more simple solution for this problem?
Added later:
Or is there another way to model my idea:
So I'm simulating an hospital environment, where logistic employees (in this case the transporter) based on predefined times collects the thrash on certain areas for example the databaserow I show in the picture below:
At 9:50, the thrash at thrash collection point at LAB_Office_2_H_T_N can be collected by the logistic employee.
So in my model I create this 2 agents (which are 2 containers, last column) based on this time and seize a transporter to collect this thrash. Since a logistic employee is able to collect 2 thrash in one time I want to batch it and let the logistic employee collect 2 thrash containers at once.
After that he transports it to the thrash dump area and is released.
The colors changed after the added information. You can use pickup and dropoff blocks instead. You can define your node requirements in the condition cell. You can use local variables like container and agent to code whatever you want. Or use "Quantity (if available)" option. There you can programmatically define how many units will be picked up by using your own function.

Is there any built in function to get the list of nodes (point node) within a certain diameter range in anylogic?

When a person agent is absorbing one node, I am trying to find the list/array of other nodes (point node) around him within a certain diameter range (let's say 10feet). Is there any built-in function to sort those nodes around the agent? I was trying "agentInRange", "getNearestAgent" but those aren't actually the right ones for my need as these functions return a list of person agent within the range not the list of nodes around him. How I can get the list of nodes (point node) around an agent? Thanks.
Not that I know of.
But you can easily put all nodes in your model into a collection, then let your agents loop across that collection to check. Something like this, will need to be adjusted to your needs and conditions
for (PointNode currentNode : col_AllNodes) {
if (currentNode.getX() ...) { // check your condition
return true;
}
}
You can easily put all nodes into a collection by selecting them all, right-click and then selected "create collection" as below:

Anylogic: How can you link a population with a source

how is it possible that the sourceof a process model only creates the agents out of a population and in best case at once? In my model the source is creating more agents than the size of the population.
thx in advance
Using a Source it is not possible to output already existing Agents of a population from it, as the source is always creating them at the time of output.
You have two possibilities:
Instead of a Source, use the Process Modelling element Enter at
the start of your process flow. Using the function
enter.take(myPopulation.get(index)) you can input your already
existing population members. This way you can also input them "at once".
In the Source properties under Advanced - Population select your
custom population. Whenever the source creates a new Agent, it will
get added to this population. Note: The Agent type of the population
must be the same as the Agent type defined in the Source.

Already Batched Agents' Properties in Anylogic

I have a very short question regarding the batching process in Anylogic.
I would like to print out the IDs of the agents that already exited the previous batch element where they were batched together. As a result, they are at a different element (Release to be precise) and I am struggling to reach their ID inside the batch. The only idea I have is to first unbatch and then print out the IDs.
Is there a way to do it without unbatching them?
Thank you very much in advance.
Kind regards
All batched (not permanently) or picked up agents are stored in the collection named 'contents' inside a batch/container agent.
So, you can access IDs of the agents stored in this collection using the code like:
for(int i = 0; i < agent.contents().size(); i++)
traceln(((MyAgent)agent.contents().get(i)).id);