anylogic

Releasing Agent Based on Process of Different Agent


I am trying to figure out how to release an agent of type BoosterTrailer upon an agent of type Pallet leaving a service block (aptly named service). I have attempted to achieve this by putting the BoosterTrailer population in a waiting block named waitForBooster and then adding the following code to the On exit field of the service block processing pallets:

if(waitForBooster.size()>0){
    BoosterTrailer trailer=waitForBooster.get(0);
    waitForBooster.free(trailer);
}

I thought maybe the issue was having the code being executed by the agent in the service block, so I moved the formula to a function named goTrailer. However, the same issue persists.

When I do this, I get the following errors:

Type mismatch: cannot convert from Wait<BoosterTrailer> to BoosterTrailer. Location: AgentTransportation/Main/goTrailer - Function

The method free(BoosterTrailer) is undefined for the type Main._waitForBooster_Population. Location: AgentTransportation/Main/goTrailer - Function`

What is the best way to release an agent from a queue, based on an agent of a different type leaving a service block? I want to do this to simulate a trailer starting a journey based on the start of the journey of the object it's carrying.

Images can be found below:

waitForBooster Properties Function and Process Flow

Any and all help is greatly appreciated, I've stared at this for quite a bit of time and don't understand why this isn't working.


Solution

  • I assume you wanted to fill up waitForBooster with 100 agents at the beginning, but actually by setting it to Population of agents in the Advanced section, you have a block now that represents 100 different Wait blocks (which will remain empty).

    As far as I know, currently it is not possible to insert agents into process flow without either using a Source or an Enter block.

    Set waitForBoosters back to Single agent and try something like this: Added Source block to flow Properties of new source block