Search code examples
simulationreinforcement-learninganylogicagent-based-modelingdiscrete

Change priority rule of a Queue block at runtime in Anylogic


I am trying to implement reinforcement learning in Anylogic using pathmind library, the RL agent can take either of two actions which is changing the priority rule of a Queue block.

I have a Queue block where I'm using priority-based queueing. I have two priority rules: using agent's departure date & agent's wait time. I want to either of these rules during runtime using another function called doAction(action). A value 0 or 1 will be passed to this function. The function body would be like this:

doAction(action){

if(action==0){
//set departure_date as priority rule of Queueblock}

else{
//set wait_time as priority rule of Queueblock}

}

The expression of my queue block is given here. QueueBlock.

RL parameters are mentioned here. RL Params

What should be the code to set priority rule dynamically from the doAction(action) function?


Solution

  • I would suggest to rather make the priority rule dynamic inside the queue.

    I assume you have some agent with a field for departureTime as well as for waitingTime.

    Then you can do something like the following: You simply have a different priority level for each agent if the priority option changes. Here I am using boolean useDaprtureTime, but you can make it as complex as you need and even have a function in the "Agent Priority" field that returns the priority level.

    Just remember that you need to call queue.sortAgents() if you change the rule since only the new agents that arrive are sorted, not the entire list of agents waiting in the queue since this will be too resource-intensive.

    enter image description here