I have model, where I need to pickup agents using RackPick from PalletRack when the model time matches the agent parameter delivery date.
I have a parameter of type date, and I am generating random delivery dates (withing 30 days) using the following code addToDate(date(), DAY, random()*30);
I have a parameter called DeliveryDate, and on that date I want to RackPick agents from the pallete rack.
How can I do this?
Here are the images,
Note: in AnyLogic parameters should start with a lowercase letter to avoid confusion with classes and agent types. I used the lowercase version of your parameters in my code snippets.
I am going to assume you have generic Agent type agents in your pallet rack and on the date deliveryDate
of an order you want to pick as many as the orderQuantity
parameter describes.
Right now you are picking agents as soon as they were put into the pallet rack. To avoid this, put a Wait block between RackStore RackPick. Then create a Dynamic Event - I called it PickAgent. It will be responsible for freeing an agent from the wait block on delivery dates. PickAgent's action is wait.free(wait.get(0))
.
In your orders population delete the default value of deliveryDate
and go to your Order agent and write the following in the 'On startup:' action:
double deliveryDays = random()*30;
deliveryDate = addToDate(date(), DAY, deliveryDays);
for (int i = 0; i<orderQuantity; i++){
main.create_PickAgent(deliveryDays, DAY);
}
This will set the deliveryDate
parameter of your Order and also create a number of PickAgent events equal to orderQuantity
that will take action on deliveryDate
. This will lead to orderQuantity
number of agents to be picked from the pallet rack.
Note 2: If your Wait block is empty, this will throw an error. You need to define what should happen when there are not enough agents in storage to fulfill an order.