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

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

Related

How to send agents to sink block if aging higher than threshold

I am building a model where at any point in time if any agent is in system beyond threshold it has to go to Sink block. Is it possible to do it based on Agent time in system ?
If agents spent 180 days and beyond I want to send it to write-off block
what you need to do first is to create an enter block that connects to your sink block
With that done, most of the blocks have a remove method associated, so you can do this, with any agent a:
a.currentBlock().remove(a);
enter.take(a);
Nevertheless, this is not good practice in my opinion, removing an agent from any block at any time will almost certainly mess up your flow logic in some way...

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

Make pedestrians divert to another queue if QueueTime Exceeds a preselected Value

Edited Version:
I'm actually modelling an airport check-in terminal. It works fine so far, but additional I'm still trying to implement a function, that allows my pedestrians not to enter the service-queue if the queue time exceeds a preselected value (e.g. already 15 Passengers in the queue) and therefore walks to some kind of backup Service that opens during this busy times.
Here is my approach:
Variable QueueSize returns permanently the actual Number of Passengers in the Queue.
Every time a ped enters the pedservice block CheckInEco, the function waitingTime() starts:
QueueSize = CheckInEco.size();
if (QueueSize > 15) CheckInEco.cancel(ped)
So, as soon as there are more than 15 Agents in the queue, number 16 should bypass and move to an alternate ServiceBlock, which I would connect to the ccl Port of the CheckInEco Service. But when building the model, I get this message: ped cannot be resolved to a variable?
According to Anylogic Help, it should be possible to use this cancel - call, but I'm not really experienced with it.. Maybe, someone can help me out?
You can simply use a select output block to prevent pedestrians from going into the service block if there are more than 16 pedestrians already in.
Your original question had to do with waiting time, you should follow the exact same approach. But with waiting time it gets more complicated since you don't want to take the average waiting time from the start of the simulation.... so you need to decide if you want to take the last 10 minutes, 1 hour etc and do you want to include the current waiting time of agents in the queue. Since this is the the questions anymore I am not going to add it here, perhaps ask a new question if this is still the case.

Limit the number of resources (forklifts) used in tasks

I have pallets shipments arrive at a warehouse. Once the arrive, forklifts are used to unload then and move the shipments to storage units. The current capacity of the forklift pool is 50. What happens now that when pallets arrive with a number of shipments to be unloaded and stored, let's say 10 shipments, then ten forklifts go to the pallets and unload the 10 shipments at once. Since the flowchart a pallet arrives and a forklift is seized consequently. I want to have one of two forklifts to be associated with a pallet at until all shipments are unloaded. I tried to use restricted Area Start and End between the forklift seize block and the shipment moveTo block but that limited the number of forklifts assigned to all pallets not only the one at the time.
Thank you
This is a lot, so i will just give you the hints necessary to do what you want
step 1. You need for each pallet to have a variable associated with that shipment. This varaiable can be an id integer, or maybe a variable of type Shipment.
step 2. Then on the on seize block, you have to specify a custom resource selection that defines the forklift you can use for that pallet. It would be either a forklift that is already assigned to that shipment, or a forklift that is free and no other forklift is connected to that shipment... here the logic depends on your own case and on how many forklifts should be used per shipment
step 3. When the resource is chosen, You connect that resource to your shipment through a variable or through a link to agents, if that resource was not previously connected to it.
step 4. When there are no more pallets available, you disconnect the forklift from the shipment so you have a new forklift free for any new shipment coming through

How to store agents in a block untill a tronsporter can move them?

I'm a new AnyLogic user so hopefully this is a simple problem. I would like to use a block as to represent a storage area for items to be used in an assembly, I am using the delay block with delay time of 0, but maybe the queue block would be more appropriate? I have set up a model in which every X number of seconds a "truck" arrives and if the delay block contains less than a specified capacity of elements, the inject function is called to refill the block. This sort of works, but is seems that the agents are flowing through the delay block's out port and thus do not count toward its capacity (that makes sense to me...) resulting in my source blocks continuing to create agents when the system isn't ready for them. My delay block is followed by a "move by transporter" block which seems to be getting all of the delay blocks outputs immediately. There are only two transporters in my model and I am not sure why more than two agents can be accepted by the transporter block at a time. I set my transporter fleet to have a capacity of 2 but that did not solve the problem.
Any advice would be helpful! Perhaps a different approach is needed. My goal is to have an essentially unlimited pool of parts at the inlet of the factory, but only create agents when the downstream processes are able to pull them in. Thanks in advance!
Welcome to SOF :)
Best use a "Wait" block here:
Let your trucks dump stuff into "Wait" whenever they arrive. Your downstream block can now pull them when they are ready using myWaitBlock.free(someAgent for as many agents as they want to pull from it.
Similarly, you can use a Delay with infinite capacity and set its type to "Until stopDelay() is called". Then similarly as the "Wait" block, you call myDelayBlock.stopDelay(someAgent) when you want.
Another option: Use a hold-block in front of a normal (infinite) queue and unblock it when ready: myHoldBlock.unBlock(numToLetThrough) --> probably the easiest
PS: Please also check how to ask good questions here on SOF, yours is very long, much easier to understand with some screenshots :) --> https://stackoverflow.com/help/how-to-ask