Different delay time for different agents in Anylogic - 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.

Related

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.

Considering differences in the same materials - Stations

I am trying to simulate a manufacturing assembly process, where material items are processed following an unique line. In the quality control stations, when a failure is detected, the object is sent to the repair area (by a truckpallet) and, when it is repaired, the same resource takes it and puts it at the start of the line. Until this point, I already programmed it.
The problem is the following: when it is a repaired object, is has to follow the same conveyor but with no stops in the stations. The object must enter a station and leave it, with no delays (as the works related with the stations have already been made).
I thought the best would be to consider the difference (repaired vs. not repaired) in the Agent, but then I can't work with it in the Main agent... I have also tried alternative solutions, for example defining variables in each station 1 and consider that in the stations delays and in the following station:
triangular( 109.1*delay_bec, delaytime_bec*delay_bec, 307.6*delay_bec)
Actions - in finished process:
if(delay_bec==0){
delay_headers=0;
delay_bec=1;}
But nothing worked... Any help?
I thought the best would be to consider the difference (repaired vs. not repaired) in the Agent, but then I can't work with it in the Main agent...
This is actually the correct approach. You need to create a custom agent type, give in a boolean variable isRepaired (or similar) and then in the delay you can dynamically adjust the duration using that characteristic:
agent.isRepaired ? 0. : 100
This will delay normal agents by 100 time units and repaired agents not at all.
Obviously, you must make sure that the agents flowing through the flow blocks are of your custom agent type (see the help how to do that)

How can I make this logic run through 3 types of agents?

1
2
As pic1 shows, in my logic, I've got 2 types of agents, so I set 3 sources. However, when I run the model, It couldn't through the queue and next steps, I think it's because of the setting of agent type. Do you know how can I set that agent type that can make 3 different agents go through this logic?
if a block in your process is handling several types of agents, it can definitely do it without issues, you don't need to touch the advanced settings, but if you did, change the agent type to Agent.
This Agent selection in the agent type is done automatically in AnyLogic, and that's why you should never touch the advanced section if you don't know what you are doing.
If it still doesn't work, it means that your error is different and not due to the different agent types, in which case you will need to specify the error you are experiencing

Anylogic ‘how to’ questions

I am using Anylogic for a simulation-modeling class, and I am not anylogic or coding smart. My last and only coding class was MatLab based about 16 yrs ago. I have a few questions about how to implement modeling concepts in a discrete model with anylogic.
How can I add/inject agents directly into a queue downstream from a source? I have tried adding an additional source to use the “Calls of inject() function,” but I am not sure how to implement it after selecting it ( example: what do I do after selecting the Calls of inject() function). I have the new source feeding directly into the queue where I want the inject.
How can I set the release of an agent to a defined schedule instead of a rate? Currently, I have my working model set to interarrival time. But I would like to set the agent release to a defined schedule. (example: agent-1 released at 120 seconds, agent-2 released at 150 seconds, agent-3 released at 270 seconds)
Any help would be greatly appreciated, especially if it can be written in a “explain to me like I am 5yrs old” format.
Question 1:
If you have a source connected directly to a queue, then when you call source.inject() an agent will be created at the source block and go to the queue. If you have 1 source with multiple possible destinations, then you will have to use select output blocks and some criteria to go from the source to the desired queue.
Since you mentioned not being a strong programmer, this probably wouldn't be for you, but I often find myself creating agents via add_population and then just adding them to an ArrayList until I am ready to pull them into the DES flow. Really, there are near infinite ways to control agent flow within AnyLogic.
Question 2:
Option a: Arrivals by "Arrival Table in Database" You can link an AnyLogic database table to Excel, and then the source block will just have an agent arrive based on that table.
Option b: Arrival Schedule - you could set this up manually within the development environment or load your schedule from a database. I prefer option a over option b given your brief description.
Option c: Read in data to variable and then write code to release based on next arrival time. 1,000s of ways to do this, but one example could be a list of doubles (your arrival times), set an event to delay until next arrival, call inject function, remove that arrival from the list. I think option a would be best for you, but given that AnyLogic allows you to add java code, there are no limits to how sophisticated you could make your arrival logic.
For 2) You could also use an event or a dynamic event. The action could be source.inject(1); and you can schedule them to your preferences with variables. Just be vigilant that you re-start the events if necessary.
There is a demo-model from AnyLogic for dynamic events.

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.