extract agents stored as a parameter inside one agent in anylogic - anylogic

[extract agents from a parameter]
[1]: https://i.stack.imgur.com/sXoOk.jpg
I have an agent (shipment) with amount parameter. I want to make decisions according to every single shipment to decide where to go. the problem i've struggled with is how to transform my one agent per arrival to many agents equals to the parameter (amount) after he gets out of the queue, queue1 .I used unbatch block to illustrate what i am trying to do.

you can't unbatch things if you haven't batched them before..instead to achieve the same thing you can use a split block
With the split block you can define the number of copies based on that amount parameter and you can define the type of agent copied as well

Related

Different delay time for different agents in Anylogic

I'd like to know a very simple function of the software Anylogic: I have to set different delay times for different agents in a model, but the software let me see only one boxe and there's no possibilities to specificate what kind of delay time I prefer for every agents. How could I do? Thank you
I tried with some code of Java script but I think that scripture could be available only for the section "Actions" in the different boxes
This is one of the most basic functionalities so check the tutorials as well, but here goes:
Add a parameter 'myParameter' in your agent type of type double.
Give the agents different values for that parameter (cab be dine in the source or where ever you instantiate your agents)
In the delay block code section, use 'agent.myParameter' to access and apply that agent-specific duration.

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.

how to custom drop-off block according to agent type

Using previous pick-up blocks, i have an container agent with two different agent types inside (Myagent and Myagent1). I want to insert two different drop-off blocks,the first for Myagent and the second for Myagent1. the problem is which element type i should choose for the drop-off block. For example, if i chose Myagent, it would give me error because of Myagent1:
If i chose Agent then:
Both the agent have a parameter named cc.
(I read other answers on the forum like Drop-off specific custom agents using drop-off block in anylogic, but i still have this error).
thanks for the help.
The best option here is to create a parent agent type that has 'cc' property and have the two types of agents inherit from it as described here. Also as a side note, you should probably take care to name the agents and properties with something meaningful as it will help to understand the model and explain it should you need to ask for help in the future.

AnyLogic if condition selectOutput

I'm modelling a manufacturing line in anylogic. Two agents are being processed and transported via the same conveyor. Both Agents need to spend diffent delay times in a service station. Because of that i added two parallel services and now i want to sort the agents arriving on the conveyor to their corrosponding service stations.
flowchart
Agent1 needs to go to service and Agent2 to serviceT.
I assigned parameters to both Agents, Agent1 has the boolean parameter "S" set to true and Agent2 the same parameter set to false.
To sort the Agents in the selectOutput block i typed in the if condition agent.S == true as seen in the next screenshot.
selectOutput
Anylogic prompts following error: "Unresolved compilation problem: S cannot be resolved or is not a field"
What can i do about this?
Thank you!
I would like to answer this question in two parts:
Instead of using a selectOutput to model different delay times for the SAME station, it would be more reasonable to have only ONE service representing that ONE station. To model different times, set the delay time equal to agent.S where S is the delay time for each agent.
Regardless of whether you choose what I suggested or what you are already using, you will still get the same error. The reason for this error is most likely that you haven't specified the agent type going through the select output properly. In fact, if you look at the image of the select output properties you shared, under the "Advanced" tab, the agent type is set as the default type Agent. Make sure to replace that by the agent type that contains the parameter S.

How to use "wait" in anylogic?

I have a stock agent which is created in the end of my production line. My products are characterized by their model. I'm trying to create a logic to take out the products from this stock agent when they are to be delivered to the client. This delivery is controlled by an excel sheet and I'm taking the information through a SQL code. However, I was not able to find the right code to take out the products which are to be delivered. My agent population is called ProdutoStock and it's located in my main screen.
I have tried: Main.remove_ProdutoStock() but i couldn't figure out the arguments that i need for this function, since i have to take out of the agent a specific number of agents and also of a specific model.
So, I decided to create a wait block and use the free function to free the specific agents i wanted main.waiting_delivery.free() but i also can't figure out the necessary arguments for this function.
Would someone have any idea how I can take out of my agent/line the products that I need to deliver for my client (considering quality and also model)? This code is not being typed into my main screen.
the argument of the free method is the agent itself.
So you have to do main.waiting_delivery.free(yourAgent);
If you want to free the last agent that entered the wait block:
if(main.waiting_delivery.size()>0)
main.waiting_delivery.free(main.waiting_delivery.get(0));
If you want to free agents following a certain condition
List <YourAgent> theAgents=findAll(main.yourAgentPopulation,a->a.condition==true);
for(YourAgent a : theAgents){
main.waiting_delivery.free(a);
}