how to control 3D object of seized resource? - anylogic

I have a truck agent that seizes a trailer resource from "trailer" resourcepoolblock (thanks to seize block). I want that both the agent both the resource make a rotation in the 3D animation. I did for the agent, while for the resource i tried:
"agent.resourceUnitsOfPool(trailer).trailer1.setRotation(-PI);"
But it does not work. What is the right command in order to control the 3D object of the resource?
Thanks for the help.

resourceUnitsOfPool returns a list of all resource agents seized. Assuming you're only seizing a single trailer, you could do the following.
agent.resourceUnitsOfPool(trailer).get(0).setRotation(-PI);
The above would refer to the agent and set its rotation. If you want to rotate a Shape3D object within the agent, just refer to it after the get(0).
Or you could use resourceUnitOfPool (which I assume you were trying to use. Notice unit, singular), which returns the first occurrence of resource unit of a given pool among the seized resource units, and then proceed in a similar manner.

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.

Same resource from resource pool for subsequent process

There is a process, box enters station (i) and operator and machine are used for SETUP, then box moves to (ii) where only machine is used.
there is 1 - operator, but 2- machines.
there are 2 conveyer systems.
How to ensure that box uses same Machine resource in station (ii) as station (i)
**Or
Ensure the Machine is continually seized from station (i) to (ii)
To re-seize the same resource - When the box seizes a resource, set a variable equal to the resource that was seized. In the resource pool, you can see "on seize" and there is self, unit, agent. Agent is the one doing the seizing and unit is the one that got seized. For the second station, in the resources section, check "customize resource condition". Try something like agent.unitSeized == unit; where unitSeized is the variable you set up. See the help menu for this. You might have to play around a little on where this occurs, exact syntax.
To keep the resource seized, I would not use a station. There is no option to seize a resource with the built in station resource & release it later. I would use a position on conveyor and just handle everything manually. That is, convey to that POC, and then next block in your flowchart can be a seize. You can then delay for processing, add a convey for getting to the next POC on conveyor 2, delay for processing, release resource. This approach would work for your first case too. You can have much more control if you route to various positions, and then send to delays or other regular process blocks to get the behavior you want. If you take this approach, you could add decide blocks, so that it covers both of your cases via an input parameter.

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...

AnyLogic - Resource Pool Stored as Multiple Locations

I am using AnyLogic to model a process where an Agent needs to retrieve a resource that could be at 1 of several locations. I am having difficulty "storing" resources at multiple locations. I have "moved" the resource to one of two locations using moveTo(), but when the Agent goes to the other location - where the resource is NOT stored, it still seized the resource. Is there a way to limit the seize to only look for resources at that location?
Thanks!
In 8.3.1, your resource selection can be "Nearest the agent".
In previous versions, you can select "Customize resource choice" to select a specific agent. This might look something like agent.location == unit.location, where agent is the agent doing the seizing and unit represents a unit of the pool. If the resource agent and seizing agent both have a location variable that matches, the seize will seize that agent.

Anylogic: how to individually address to resources within a Resource Pool

I am using Anylogic where I have just one ResourcePool made by just one Resource Type unit (created through the command "Resource Agent" in the Process Library).
I define the capacity of the ResourcePool, let's say, to 20 and I would like to have each of the single element (or some of them) within the Pool with a different value for the same parameter (e.g 3 units have parameter=1 , other 4 units parameter=2 ...).
First of all how can I set individually each of this parameter? Do I need to use a population of agent? If yes how can I do that? And how can I call the resourcePoolPopulation in other location within the model?
Is there a clevere way to do that?
Hope it is clear, thanks!
That is a weak spot of resource pools, IMO. They are designed to hold a homogeneous "soup" of similar resources and it is hard to pull in a specific element.
However, not impossible, there are various ways. You can create your resource agents manually in an agent population first and add them to the pool manually after creation. Then, in the service object, tick "manual resource unit choice" (or similar) and use a criteria that matches your resource params.