question

Tom avatar image
0 Likes"
Tom asked Tom commented

Set different label value to patients by percentage in proximity system.

Hi.


According to patient's label, I want to set different label value to patients by percentage.


Specifically, Floor spot1 give 'get' label's value - 0 or 1' to patient using set label function of proximity system.

Patients who have 'type a' label have 70% to acquire 'get' label's value - 0 and 30% to acquire value - 1 by Floor spot1.

Patients who have 'type b' label is the opposite.


I tried to solve this problem in patient flow but I couldn't find the way.

So I think I should to use code in set label page of proximity system.

Could you help me to solve this problem?


Thank you.

Q_set different label value by percentage.fsm

FlexSim 22.2.2
set labelby percentageproximity agent system
5 |100000

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

1 Answer

·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Tom commented

You could probably also solve this with a Decide activity in the patient flow, but using the proximity trigger is likely quicker.

Check which of the two "type" values are present on the patient, then use the "bernoulli" distribution to assign one of two values by percentage.

Object patient = agent.object;
if(patient.type == "a")
{
    patient.get = bernoulli(70, 0, 1, getstream(patient));
}
if(patient.type == "b")
{
    patient.get = bernoulli(70, 1, 0, getstream(patient));
}

1665729957907.png


1665729957907.png (5.7 KiB)
· 3
5 |100000

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

Tom avatar image Tom commented ·

Thank you for your replying!

I add code snippet in proximity trigger and it seems to be working properly.

Doesn't it matter to enter any value to 'tag value'?

q-code-snippet.png

Q_set different label value by percentage1.fsm

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Tom commented ·
I'm not sure what you mean by "tag value". The default code of the "Set Label" option uses different, older syntax when creating/setting the label.

patient.get = ... essentially does the same as patient.labels.assert("get").value = ...

The default code first assigns the object, label name and value to distinct variables in order to enable entering those in the option's GUI.

At this point you can actually delete the "Set Label" option from the trigger. The code snippet alone is enough to create and set the label.
0 Likes 0 ·
Tom avatar image Tom Felix Möhlmann commented ·

Ahhhh, Ok!

Thank you so much!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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