question

Quoc Nhat Han T avatar image
0 Likes"
Quoc Nhat Han T asked Quoc Nhat Han T commented

Dynamically acquire location

My people-based model has multiple MultiLocation to be used by different types of patients. From a given point on the flow, the patient will acquire the location based on the label type of her/his token matching location's label type.

My piece of code below found the correct reference but seems to unable return the right reference.

/**Custom Code*/
Object current = param(1); 
Object person = current;
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

Array groupe_salle_d_attente = Group("Groupe_salle_d_attente").toFlatArray();//All the waiting rooms
print("Token.id=", token.id);
print("Token.type=", token.type);
for (int i = 1; i <= groupe_salle_d_attente.length; i++) {
    if (groupe_salle_d_attente[i].as(Object).type == token.type) {
        print("Salle d'attente=",groupe_salle_d_attente[i]);
        return groupe_salle_d_attente[i];
    }
}
print("Salle d'attente not found");
return 0.0;
time: 94.012196 exception: Error: Invalid list reference at push to list activity "Chercher_salle_d_attente" in "Circuit_Consultation"
FlexSim 20.0.5
process flowhealthcareacquire location
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Quoc Nhat Han T avatar image Quoc Nhat Han T commented ·

Here is a simpler example 1.1 Build a waiting area_1.fsm

0 Likes 0 ·

1 Answer

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Quoc Nhat Han T commented

You put that code in the wrong place. The Location Resource field of the Acquire Location activity needs to return a Location Resource not a Location. The Location field of the Location Resource activity is the correct place to put it. Here's your updated model:

LocationByType.fsm

Also, it doesn't look like you're using activity sets, they'll make your life a lot easier when building people models. If you haven't already you should go through this tutorial, it will teach you the best practices for building people models:

https://docs.flexsim.com/en/20.0/Tutorials/FlexSimHC/OverviewFlexSimHC/


locationbytype.fsm (250.8 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Quoc Nhat Han T avatar image Quoc Nhat Han T commented ·

Thanks to your indication, I finally managed to overcome. The predefined activity sets are indeed powerful and well prepared. I'll take a closer look and put into my model.

0 Likes 0 ·