How i can deal with transporter and do logic in flow chart as like resources? - anylogic

[model] https://i.stack.imgur.com/7A51i.jpg
I tried to put my transporters in queue and delay in its path (during unloading), after the transporter unload the cargo and goes back to the resource (which load the transporter). i tried to model it as a resource as shown but, i got an error (type : cast) as my agent consider to be a material item type ( can't cast the delay to transporter's agent type). what is the problem, and what i can do to achieve that with transporters instead of considering it a resource type.

Related

Choosing an transporter with enough battery ANYLOGIC

In my model I've created an automobile robots(AMR) which transports orders. The Automobile robots is a transporter fleet, which is agent type AMR. This agent type has a parameter which is a boolean for needCharging (see figure 1), during my simulation at a certain point a robot needs to charge and the needCharging parameters changes to true.
In my model I want when I seize a transporter that he only chooses a transporter in the fleet where NeedCharging==false. So I coded it in the transporter choice condition as !unit.NeedCharging. (see figure 2 and 3 which showing the fleet and seize), but somehow he does not link the unit to a transporter in the seize block, how can I fix this that he only seizes transporters which does not have the parameter needcharging states as true.
Try the following instead:
!((AMR)unit).NeedCharging

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.

Moving two agents together

I am creating a model that includes both Material Handling and ABM components. I have an Agent Type that is called "Box" and there are 5 boxes that are placed on a conveyor in main. I have another Agent Type called "Product". The boxes are expected to carry the product. As a result, the box and product are expected to move on the conveyor as one. So, I was looking for something similar to move to agent, but that only works if the agent is not moving (i.e. it won't follow the agent everywhere it would just move to its position at the time the function is called). I can think of many solutions, none being ideal. Some include:
Not really moving the product agent, instead adding an animation shape of the product in the Box agent type and turn it on and off depending on the Product's state.
Using DES blocks (pickup/dropoff), but the problem with these is they convert the two agents to one... I am looking to keep both agents, but have them move together
Using something similar to Attach Resource, but then I'll have to define my Box or Product agent as a resource type
These are some of the solutions that came to mind, but I feel there must be a smoother solution. Any suggestions? Is there an ABM function that can resolve this?
Thanks!

Avoiding collisions with other objects while moving an Agent to a specific destination

I have in my model some free-moving agents, which travel to specific nodes. I use the function...
moveTo(node)
...to specify the node an agent should visit. Using this function, the agent travels the shortest path to the node. However, the model layout contains areas (i.e. image files), which the agent should not pass. Right now, the agents may travel through these areas to reach their destination. Now I'm wondering, whether there is an easy way to permit an agent to enter specific areas in the model, when traveling to a node.
I already took a look at the example model "Wandering Elephants" where the elephants are permitted to walk through areas with water. The solution there is, that if an elephant meets water in the direction it's currently heading, it randomly searches for another direction, until it finds one without water. However, this approach doesn't really fit to my problem, as the elephants in the model wander around without any specific destination. I'm searching for a method, which works for an agent that travels to a specific point. In the best case, the agent would search the shortest path around the obstacle to reach its destination.
Edit 1: The following figure shows my problem in a nutshell. On the left side is my model structure, while on the right side the state chart of my custom agent. What is happening in the model: The 3 sources are producing agents, which will be delayed for an uncertain time (delay stops with stopDelay()). Everytime an agent enters a delay, the delay is added to the collection request. My customagent check requests in a loop until the collection contains at least one request. Then, the customagent randomly selects a request (i.e. delay object) to serve. Each delay is associated with a node (the collection processNodes maps delays to nodes). Now, I want to cast my customagent to a Transporter and move it to the corresponding node. The agent should avoid collisions with the stripped walls in the model. I want to avoid any seizing and releasing of resources. I just want to adapt the behaviour of the Transport agent from the material handling library to my agent.
Edit 2:
In my current testbed, my custom agent does not consider node 1 or node 2. For testing, the agent should only try to reach node without any collisions.
I found a sufficient work-around. Not exactly what I wanted, but it works. Against my initial intention, I use now seize and release for transports. However, I added a hold-block in front of each seized-block and only a resource, which decides to serve the process, is able to unblock the corresponding hold. The on-enter control of the unblocked hold ensures that the hold is directly blocked again as soon as a single agent flows through. For the case that other users are also interested in the solution, I attached the flow-chart of the process and the state-chart of the Transporter-Agent. The system structure is quite the same as in my initial question.
There is no build-in way unless you use transporters from the Material handling library (or pedestrians). These can do what you need.
So easiest might be to convert you agents to transporters temporarily.
Otherwise, you will have to code something yourself...

How do I seize a subset of seized resources?

I have a pool of 25 agents (Operators). When an Order is generated, I seize a few Operators and move them to one of many different ProductionSuites as determined by a parameter in the Order.
Within the ProductionSuite, I have a variable of type ResourcePool that I would like to use to have these Operators perform tasks.
In the main window, I put this code in the "On seize unit:" code box:
agent.assignedSuite.suiteOperatorPool.addAgentToContents(unit);
but this triggers a NullPointerException error. Am I using the addAgentToContents method incorrectly?
You have not initialized your suiteOperatorPool variable, it's "initial value" field is empty. Hence, this is just an empty shell of type ResourcePool that cannot do anything, including adding agents to it.
You would need to initialize it properly using the ResourcePool API, but I don't think that is possible.
Also, you cannot have resources be part of 2 resource pools, as you are trying to do. You should think of a different way to solve your problem. Maybe rephrase the issue so we can think of alternatives. You might not need a RP at all but just use pure agent functionality...?