Search code examples
anylogic

How to change the color of rectangular node based on number of agents in the node in Anylogic?


Is there a way to change the color of my rectangular nodes (represented as resource pool) based on number of resources idle/busy. For example, if I have 10 resource pool available, then the home node will be green, if I have 5 available resource out of 10 then the home node will be yellow, and if it is less than 3 then the home node will be red.


Solution

  • you can use an event that is triggered every second, or every 10 seconds, or every time a resource is seized or released (check the actions on seize and release on the resourcepool block)

    if(resurcePool.idle()<3){
       node.setFillColor(red);
    }else{
       node.setFillColor(green);
    }