Lift assigned to specific agent type Anylogic - anylogic

I've a question, in my model I've multiple lift areas with 2 lifts, but only 1 lift is assigned for good transport (so agent type=AGV ) may use this lifts and the other lift is assigned for persons (agent type= person).
Is there a way to make the agents know which lift they should take and not take the lift which is not assigned for this specific goods transport.
Thanks

you can use this:
agent instanceof AGV
or
agent instanceof Person
You can put an selectOutput block to check this and send the agent to an intermediate point near the lift so it takes it, but if the AGV is a transporter that is acting as a resource, then you need to have the transporter as a variable in your agent so you can use as your condition
agent.transporter instanceof AGV

Related

Can a transporter follow an 'material' agent into another agent?

I have an material agent that is moved from the Main agent to inside another agent (simulating a room). I can send the material agent using the Exit and Enter blocks. The 'room' agent contains a network that the material agent is being sent to.
The material agent is initially being moved in Main using a Transporter. However I'm not able to get this Transporter to follow the material agent into the room agent. The main questions is - is it possible to send a Transporter into another agent? Or does it need to remain in the agent that the Transporter Fleet is located?
Thank you.
I will correct benjamin by saying that with setEnvironment you can't do it since that's a function that is called on the agent initialization.
Instead of setEnvironment,something you do normally is to send the agent to a new population (which is the way you dynamically change environment), but it doesn't work with transporters
My answer would be that you can't do it since transporters who follow paths are defined as strict AGVs and can only move on their initial network and you can't change the network, unlike other agents.
But i'm always a bit suspicious of myself when i say something is not possible...
This should be possible with some setEnvironment() calls.
However, it is not a good setup. Think of reality: your rooms are spatially all part of the same environment: your flat (or factory or whatever). Moving from 1 room to the next does not mean you change your flat. You stay in the same environment.
You should setup your room agents like that as well: their spatial representation should reside in Main (or whatever agent they are embedded in).
Use a parameter of type ShapeRectangle or similar in your Room agent to define which rectangle (or else) represents the spatial aspect of the room.
Then, the flow chart blocks in the Room agent simply refer to that parameter for their spatial needs.

How to use my agent to enter a process flow of a specific agent (ex: Depot[0]) from a population of agent (ex: Depots)?

So, I have a case in anylogic where a drone needs to be transported via a bike from a certain place (namely, Depot) to a certain place (namely, Stopover Point). After that, the drone will be released from the bike and will do some mapping to a set of designated locations of Mapping Points. For this case, I used a process flow to make the bike (that I treat as a resource unit) to seize the agent (drone) at the Depot before the bike move to the Stopover Point and releasing the drone there.
At first, I used to make some kind of sandbox model where I only use one Depot and one Stopover Point
so that it is easier when I want to use my agent (drone) in a process flow via enter block (ex: I only have to write main.depot.enter.take(this); at my agent (drone) statechart to enter it to the process flow at Depot bacause the Depot is a single agent).
The problem occurs when I tried to use more than one Depot and make it as a population of agent. This makes me unable to use main.depot.enter.take(this); because of the property of the Depot for it is now a population of agent and not a single agent anymore.
The question is how should I do if I want my agent (drone) to enter the process flow of a certain/specific Depot (ex: only Depot[0])? I have used a paramater such as "name" with the value consists of texts like "Depot 1, Depot 2, and so on" and modify the commmand to filter(main.depots, a -> a.name == "Depot 1").enter.take(this); or main.depot[0].enter.take(this); but I think that's not the right way to code it because it didn't works. So, how is exactly the correct way to code or to do it if I want my agent to enter a process flow of a specific agent (ex: Depot[0]) from a population of agent (ex: Depots)? Thank you.
You should use () instead of [] to select one depot from the population.
So to select the one with index 0, you write: main.depot(0).enter.take(this).
To select a depot based on the name parameter, I would use the findFirst function which selects one of the depots. In your exitblock, you could write:
main.depot(findFirst(main.depot, a->a.name.equals("Depot1")).getIndex()).enter.take(this)
The getIndex()method returns the index of the selected agent.

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 sort a queue with different agent types by agent comparison in Anylogic?

Let's have a model in which two type of agents arrive to the system: dogs and cats. This agents have a parameter age of type double. The agents go into a unique queue that should be ordered by age and then be served by a single server and get out of the system as seen in the following example Proposed model.
My first question is: How to order the queue by agent comparison using the age attribute?
The main issue I face is that the queue block (as almost all blocks) require to define a single agent type in the advanced properties. First I tried to do it directly in the queue using the agent type "Agent", as the attribute name is the same for both entity types (queue example1), but then I get the error "age cannot be resolved or is not a field" as the general agent type "Agent" doesn't have such an attribute. Then, I tried casting the agent1 and agent2 to dog and cat as seen in (queue example2), but of course during the runtime I get the error dog can't be casted to cat or viceversa as we can't know if agent1 is going to be of type cat or dog at a given time.
Thinking of the version in which I route the agents through exit/enter blocks, I get into the same issue, the only agent type that I could use in the enter block to merge different agent types is "Agent", but then the attribute age of the different agent types can't be used to sort the queue.
My second question is: how to route n agent types to x different locations so that the individual parameters or variables can be used afterwards without casting the agent type (as we don't know which is going to get into the block)?
you need to create another agent type called for example Animal where you will store the age variable... then cat and dog will extends from that agent... you can do that in the advanced properties of the agent:
.
With that, the agent that will be used in your process will be of type animal... so your second question is not needed anymore.