Wait block doesn't test if storage has space - anylogic

My wait block should test if my pallet rack has enough space to store my pallets. So when I have 20 pallets and my store has space for 15, 15 should be stored and the other 5 pallets should wait in my wait block until the pallet rack has space again.
The problem is that I get an error that there are no empty cells which means that the pallets which don't have space not wait in my block but go trough the wait block and that causes an error.
Where is the problem? Wait block and rack pick are attached.
waitblock_function
rackpick
error

I suggest you switch to using RestrictedAreaStart and RestrictedAreaEnd blocks: Simply queue agents before and set the capacity of the restricted area to your pallet capacity.
Much easier (and less error-prone) than your manual approach.

Related

There is no empty cell in storage pallet rack Error in AnyLogic

The first time, pallets get stored in rack and later on, they get picked by the resource.
Now 2nd time when pellets come to get store in the rack, I get rack full error but there is 0 pallets in rack at that time means rack is empty.
Attaching the model images below.
Error
Pallet Rack
Rack Store
How can i solve this problem?
I suspect you didn't use a rackpick to take the pallets out of the storage... you MUST use a rackpick
Or you need to use palletRack.remove(agent);
If that's not the problem, then you will have give more information

removing a specific number of pallets from a pallet rack

i would like to pick a certain amount of pallets from my racks but I have no idea how to actually do that. For example, I would like to deliver 5 pallets but i have 25 stored, if i use a wait or a queue that I release all agents get picked up.
to release 5 agents from the wait block so they can be delivered you have to do the following
List <MyAgent> deliverables=findAll(waitBlock,w->true).subList(0,5);
for(MyAgent x : deliverables){
waitBlock.free(x);
}

Frame collector & Out of memory errors (large memory allocations)

Task: Tasks spawn with fixed time intervals (source), each has remaining processing time which is given by uniform random [0 .. x]. Each task is processed by the module (delay). Each module has a fixed processing time. Module substracts it's processing time from the task's remaining processing time. If a task's remaining processing time depleted (less than 0), that task becomes completed reaches (sink). Otherwise it goes to the next module, and the same process repeats. There are N modules, that are linked one after eachother. If the task's remaining processing time has not depleted after processing at the N'th module, it goes to the 1st module with the highest priority and is being processed there until remaining processing time depletes.
Model Image
The issue: I've created the model, the max amount of spawned/sinked agents i could get is 17 for -Xmx8G and 15 for -Xmx4G. Then CPU/RAM usage rises to max and nothing happens.
Task Manager + Simulation Image
Task Manager Image
I've also checked troubleshooting "I got “Out Of Memory” error message. How can I fix it?" page.
Case
Result
Large number of agents, or agents with considerable memory footprints
My agents have 2 parameters that are unique to each agent. One is double (remaining_processing_time), another one is integer (queue_priority). Also all 17 spawned agents reached sink.
System Dynamics delay structures under small numeric time step settings
Not using that function anywhere, besides delay block.
Datasets auto-created for dynamic variables
This option is turned off
Maybe i missing something, but i can't really analyze with such small amount of agents. I'll leave a model here.
This model really had me stumped. Could not figure out where the memory was going and why as you run the model visually it stops yet the memory keeps on increasing exponentially... Until I did a Java profiling and found that you have 100s of Main in the memory...
]
You create a new Main() for every agent that comes from the source - so every agent is a new Main and every Main is a completely new "simulation" if you will..
Simply change it back to the default or in your case create your own agent type, since you want to save the remaining time and queue priority
You will also need to change the agent type in all your other blocks
Now if you run. your app it uses a fraction of memory

Pallet Rack Size does not update if using pick-up

I know that for an object to be removed from a pallet rack you need "Rack Pick". However, in one of my models, I have a different configuration where I am using pick up:
Step 1: 10 agents are in the rack
Step 2: Another agent picks them up
The way AnyLogic understands the above is that the rack still holds 10 agents, so I get the error eventually that the pallet rack is full. Is there a simple turnaround for this?
you have to remove the agents from cells with this line of code
palletRack.remove(agent);
put it to your pickup block, "on pickup" trigger.

Create a database with an arrival time and access to it in the process flow

I would like to create a database with different arrival times that my forklifts pick the pallets (rack pick) to the certain times. How could I do this? Which process blocks could I use to access to a database with arrival times?
For example at 10am on May 20 45 pallets should pick out of the pallet rack. I tested it with a delay block and it works but only with different hours where the pallets get picked and not an specific date. The important thing is the date which I get from a database.
process
Probably the easiest way is to have your in-rack agents (after your RackStore block) sit in a Wait block, and be freed from there (using the Wait block's free function) --- to then carry on to a RackPick block --- via AnyLogic dynamic events whose timings come from a database table.
(Your model as-is will just have your agents immediately exiting the rack and going to the Sink because the Queue does not stop them leaving.)
Your model startup would loop through the rows in the table and create dynamic event instances with the appropriate timeouts (delays from model start), and with a dynamic event parameter which specified the number of pallets to pick (and thus the number to free from the Wait block).