Keep resource seized after Rack Pick in AnyLogic - anylogic

I can't seem to find a way to keep a resource seized after "rackPick". In the "rackPick" block I am choosing "Use resources to move". So I want a resource to move the agent from the pallet rack to a certain node. When reaching the node, I want the same resource to stay there to work on other activities (e.g. pick-up block). However, there is no option not to release the resource after picking. I also don't want to use a seize block before rack pick because I want the agent to move at the speed of the resource during picking. Any suggestions?
Thanks.
Additional details:
The exact process is as follows:
Rack Pick --> Pick-up --> Rack Store
I need the same resource to do the three steps.

what you have to do is reserve the resource. You can have a link to agents in the resource called agentLink... it will be connected if reserved and disconnected if not reserved.
in the resourcePool on seize unit action you can connect agent and resource through the agentLink (unit.agentLink.connectTo(agent))
You do also in the rackpick block custom choosing of a resource based on the condition !unit.agentLink.isConnected()
then in the rackstore you use the condition of the resource as unit.agent.equals(agent.resourceLink.getConnectedAgent())
And that's it :)

Related

AnyLogic - Is there a function like "Move by Transporter to seized resource"?

In this model I want to transport MaterialBoxes (Agent) to the next available workstation by an AGV. I wanted to keep the model as simple as possible, but I did not find a solution to transport the MaterialBoxes to a seized resource (Workstation 1 or Workstation 2) by using the "Move by Transporter" or "Seize Transporter" blocks. Therefore I adapted the solution of the "job shop model" (https://anylogic.help/tutorials/job-shop/index.html) by using the "rack pick" block to transport the Materialboxes from the rack to the seized workstation. How can I adapt the model and avoid the process step going through the rack system with "rackStore" and "rackPick"? And I still have the problem to allocate an AGV to transport the MaterialBoxes from Workstation 1 and Workstation 2 to the Exit. Currently I'm just using the "moveTo" block to transport the boxes without a transport resource to the Exit. I am grateful for any advice. Thank you very much.
current Model
You need to add a custom variable to your agents where you can store the workstation that they seized and then in the move to block you can have them move to the station that they seized.
When the agent then seizes a workstation you save the work station it seized to the variable.
When it is time to move the agent you can move it to the location of the seized workstation.
You can also check out the solution in the example model Trauma Center https://cloud.anylogic.com/model/0c41592c-96d8-4824-b816-c89eccfd79db?mode=SETTINGS
Here agents move to the resource unit home, location of the unit that they seized

In AnyLogic make a resource (like an operator) "drive" an agent from a TransporterFleet

I would like to know if in anylogic there is a way to show that a resource (in my case an operator) moves together with a transporter taken from a TransporterFleet.
I attach an image of the blocks involved. Basically you have a seize of a resource from the Operator1 resource pool which is sent to the node where the transporter is located (forkliftsHome1). Once arrived, the transporter starts its unloading operation from a Storage (so far so good).
However, when the transporter arrives at its destination and has finished unloading (I have chosen the option that the transporter does not return to its home), the Operator1 resource from the resource pool is freed as it is still on forkliftsHome1. In practice, Operator1 is occupied as I wanted, but in fact the transport is carried out only by the transporter. Is there any way to move them together so that when Operator1 is released it is on the transporter's location (or on a nearby node)?
this is the image of the blocks I'm talking about: tree blocks I'm interested are seizeOperator1ForRetrieve , retrievePallet , releaseOperator1
This is cheating a bit, but if you do not actually need the operator to travel with the forklift, my solution in a similar situation was making the operator invisible while the forklift transports the item, then as a custom wrap-up task I made the operator jump beside the forklift with a moveTo block then made it visible again
(see the process flow pictured here). This was possible by connecting the operator and forklift with the 'Link to agents' element, so for the destination of the operator I could obtain the x,y,z coordinates of the forklift.

Assign priorities for multiple Seize Blocks for the same resource in AnyLogic

I have a not so typical scenario for which I am not sure how to proceed:
There are two stations located at two different locations.
Both stations require the same resource.
The resource moves from station to station once released. So it keeps going from station 1 to station 2 to station 1, etc. until it is seized again. This is modeled by adding a link from the resource process port of the release block. So it is not completely released unless a condition applies. The condition is that there are agents waiting in the queue of the seize block of that same resource. So it should keep moving until it is needed again. The tricky part is that there are two seize blocks for that resource, one for each station. It is possible that agents are ready and waiting in the resource's seize element at both stations. I am adding an image of the resource's process at release. So at "selectOuput4" it checks whether station 1's seize element has agents waiting, if so, the resource is released and can be seized. Otherwise, it moves to station 2 and checks the same but for station 2.
My concern is that there might be a situation where both stations have agents waiting in their respective seize blocks. How can I make sure the resource will be seized by station 1's seize element and not station 2's, and vice versa. Is there a way to control where the resource is going in a case where two seize elements are waiting for it? Or is it always random?
I apologize for the long post, and I hope I managed to deliver my idea properly.
First, I think your design is a bit weird because you keep the resource always seized.
What I would do is first have a statechart in the resource that controls the resource movement from one place to the next so you have more control over it. The statechart would be used to move your resource ONLY when it's not seized. This will allow a case in which your resource is moving from station 1 to station 2 but something comes to station 1 queue and the resource can immediately react and come back to station 1 before it reaches station 2 (if you think it would be a good idea to do that)
The second is that the seize block defines the priority for a task when the agent arrives to the seize block, and your situation requires changing that priority dynamically, which can't be done as far as I know, so the wait block before the seize block is unfortunately a good option.

to use a resource pool of forklifts for different process flows and different tasks to the same time

Is it possible to use a resource pool with forklifts for different process flows? I would like to have a resource pool of 100 forklifts which I use for different tasks to the same time. So for example forklift 1 should transport pallets at 6 am to pallet rack 1 and forklift nr2 should transport pallets at 6 am to pallet rack 2. So currently I have a lot of resource pools for different tasks and I would like to know if it is also possible with only one resource pool.
It's possible... on the seize or service block, on the advanced section of the properties you can check the box "customize resource choice" and you will be able to select the resource you want to use for each one of the tasks.
Your resources will need at least an id, so you can do ((YourResourceType)unit).id==2 for example as the resource condition for your resource to be used for what you want. This condition you will see it as soon as you check the "customize resource choice" box.

AnyLogic "End of Shift" logic

I have a resource pool that adds units into the population "forklifts". The agents of type Forklift are chosen by other agents and later seized for specific tasks. There is also a schedule for the resource pool.
The problem is that whenever capacity decreases, forklifts units that are moving in the model (but not seized yet) are halted because they are no longer active. Is there a way to customize the choice of resources for the "end of shift". I cannot find anything in Help or online.
Thanks!
I have tried iterating through the resource pool but there is no function I could find to determine whether a unit is active or not. There are boolean functions for idle and busy.
agent.unload_forklift = findFirst(forklifts, f->f.in_use == false);
There are agents that choose resource agents based on internal variables. Maybe I could iterate through the resource pool instead of the population...
I expect forklifts' capacity to decrease based on a customize signal not randomly.