Batching agents based on arrivalnode - anylogic

In my Anylogic model, my source block generates agents on different nodes based on a database values defining which node the agent has to arrive.
The orders at the same location arrive at the same time (so for example at 7:30, 3 agent orders arrive at node1 and 4 agent order arrive at node2).
Now what I want to do is that the orders at node1 make a batch of 1x2 and 1x1 and I want that the orders at node2 to form a batch 2. These agents than will seize a transporter which transports these batches to the same location and than unbatch.
So my question is how will I create batches based on the arrivallocation loaded from the database.
Thanks.

Create a variable in the agents myNode of type RectangularNode. Store the node the agents are being positioned at in the Source block.
Use a SelectOutput block downstream of the `SourceĀ“ block that splits the agents by their current node.
Then, use batch objects as usual as the arriving agents are now split by their node location.

Related

How to combine transporter related blocks with Delay, Queues and other blocks from Process Modelling Library?

A source is producing "productA". "productA" is moved by a transporter called "agv" from node1 to node2. On the way between the two nodes I want to put several tasks like for example delay or queue. These tasks can be implemented by Process Modelling Library blocks. When using them you have to set an agent type. Which type do I use now? "productA" or "agv"? When using "agv" an error accurs because that type is not equal to the source agent. When using "productA" tasks from the process Modelling blocks are only executed for this agent, not for "agv". How to deal with that? Is there a way to create a new agent which contains "productA" and "agv" and overwrites the source agent? How will that not contradict with the transporter fleet block?
You need to use ProductA as this is the main agent flowing through the blocks. It just "uses" an AGV to be moved around, similar to a resource.
If you want to stop and do things with the product and the AGV, you use the SeizeTransporter block first, this makes your product seize an AGV.
Then, you can make them do anything by dropping blocks: queues, delays, Move By Transporter. Just make sure to finish up with a Release Transporter block when all is done.

Give agents different priorities in a queue

In my AnyLogic simulation model, I have two sources and going through two service blocks in a closed loop. At starting time I inject 1 50T Truck and 2 20T Trucks.
Descriptive image here:
Image of Model
At the second service block, "crusher1", I want the queue to always prioritize the agent "truck50ts" over "truck20ts". How can this be done?
Replace your Service block with Seize, Queue, Delay and Release blocks (same as a Service but more options for you).
in the Queue properties, set the queue priority to "agent comparison".
In the conditional code, write agent1 instanceof Truck_50tons ? true : false as below:
This assumes your 50t truck is an agent of a custom agent type called Truck_50tons (create those at the sources)

Priority based queue in Anylogic

I am using a priority based queue to pick agents from a pallet rack. Priority of agents can be 0 or 1. If there are 10 agents in palletRack, I want to pick all the agents having priority=1 first. My problem in the current flowchart is: Agents with priority=0 are pickup up before agents with priority=1. May be because the agents enter & leave the Queue block one by one, multiple agents aren't present in the Queue block at the same time so that they can be sorted. How to resolve this?
put a hold block between queueStorage2 and pickFromStorage1 and on the on enter action of queueStorage2, you check if all your agents are there, and if they are (with whatever condition you need to check to be sure everything is there) you unblock the hold with hold.unblock();

Can resources carry multiple agents in Anylogic?

In the below image I am using AGV as resources to carry Containers(agents) in the rackStore and rack Pick blocks. By default, one AGV carries only one agent; Is it possible to set agent carrying capacity of resources such that it can carry multiple agents?
Sure. Just use the Batch element before the pickup and batch your containers together. Then, the AGV will pickup a batch, i.e. several containers.

Monitoring rectangular node usage

I move a batch of agents to a node, where they are unbatched. Once the unbatched agents occupy this node, the node is not available for other batches of agents to move there, so I remove that node from a collection of available nodes, AvailableNodes.(There are about 50 nodes total). Each unbatched agent has a parameter that is the node it has been moved to. The question is how to add back a node to AvailableNodes once all unbatched agents have been moved from that node. Do I have a variable associated with each node that I increment or decrement as agents enter/exit the node? If so, how do I associate a unique variable with a node? Or is there a better way?
Oh you are walking in muddy waters with bad practices... your nodes should belong to a resourcepool, meaning that instead of a node, you should have an agent with a node in it... That way you don't need any collection at all.
Another option is to create a small class that will have the node and the availability... and maybe the number of agents currently present in that node. Just create a new class, and add these 3 variables. Then on the start of the model you add instances of that class to the collection availableNodes and you can then just do theClass.numberOfAgents+=1 or -=1 depending on wether agents are being added to the node. To find an available agent you can then do TheClass x=findFirst(availableNodes, a->a.numberOfAgents==0); and then you can send your agents to x.node;
There is also a possibility continuing to do what you are doing... but I won't even go there because it will be a mess.