How to find all resourcepools in Anylogic

Viewed 24

Is there a way to find all resourcepools in the main agent? E.g. I have created different resourcepools like operator, equipment, storage, etc. And i want to store all of them in a collection. But instead of manually adding them to the collection, can i search through the entire main agent for all the resourcepools and directly add them to the collection using Java?

1 Answers

Sure. Loop through objects and check if they are resource pools. If you are on Main, you can call this code, it checks all objects on Main (or where ever you call it from):

for (Object currentObject : getObjects(){
    if (currentObject instanceof ResourcePool) {
        // add here
    }
}
Related