question

Jim Montgomery avatar image
1 Like"
Jim Montgomery asked Matthew Gillespie action

How does one create companions based on probability

So you've taught me how to create companions for every patient. What if a companion only shows up 75% of the time for a particular patient type? How do I create companions based on probability?

FlexSim HC 5.0.12
flexsim hccompanionsby percentage
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

Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Maryam H2 commented

You can use a Decision Point activity that 75% of the time starts the activity that makes companions while the other 25% of the time it starts either a different activity or the activity after the companion creation activity. Basically you want to use the decision point activity to branch your logic.

In the Next Activity field of the Decision Point activity you'll find a Based on Percentages pickoption that you'll find useful.

Alternatively you could put some code right into the trigger where the companions are created.

In HC there's a simplified command, P(), for doing things by percentage. For example, the code in this if statement would fire 75% of the time:

if( P(75, 1, 25, 0) )
{
	//Do Something
}

So you could open up the code editor for the trigger that's creating companions and wrap the trigger in an if statement like the one above.

· 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.

Jim Montgomery avatar image Jim Montgomery commented ·

Excellent. Thank you very much.

0 Likes 0 ·
Maryam H2 avatar image Maryam H2 commented ·

Can I edit the code editor the same way you mentioned in FlexSim 21.1.1?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Maryam H2 commented ·

Not by default with that syntax - you can use the bernoulli() function though.

0 Likes 0 ·