Moving one agent within another agent in Anylogic

2019-09-10 19:39发布

问题:

I am making simple distribution center in Anylogic.I did make truck agent and i am able to move it from one gis point to another gis point.

But I want to load some other agents(Let's say banana agent) into my truck agent and then trucks start their journey(if truck is full of banana).How can i do this?

回答1:

I hope you have already solved your problem from almost a year ago. However, since there is no specific answer, I'll leave it here for anyone who might get stuck with the same problem.

Anylogic's Process Modelling Library (PML) has an element called Pickup and its opposite, Dropoff. This is used to do exactly what you asked: to load some element into a transporter (either a truck, a forklift, or even a person).

To use the block as you asked you would need a topology like in the picture:

The Queue elements are necessary to hold elements until the pickup occurs. The Pickup element might pick elements in three modes:

  • While a given condition is True;
  • An exact amount (if available);
  • All available agents.

I'm assuming all trucks must be completely filled up to its maximum capacity. Hence, the chosen mode will be the second one where the exact amount will be TruckCapacity, a parameter of agent Truck. The selected mode picks up agents (in this case Bananas) up to the desired amount. However, if nothing is available or the present amount is inferior to the desired, the native behavior of the Pickup block is to allow the container element to simply go through it and pick only what's available.

To prevent such behavior, I've created a restricted area where only 1 Truck can be at a time. Additionally, the Hold block WaitFullyLoaded (set to initially blocked) forces the container agent Truck to be fully loaded. Whenever a Banana enters the Queue waitTruck, a verification is performed to check if 1 Truck can be filled. If so, allows passage for that one truck:

if(self.size()/TruckCapacity>=1){
    WaitFullyLoaded.unblock();
}

To block WaitFullyLoaded again, when the truck passes through the restrictedAreaEnd block, it performs WaitFullyLoaded.block();

The main idea is this. However, many features can be added and changed.

Hope this helps,

Luís



标签: anylogic