question

Ranjith Tellis avatar image
1 Like"
Ranjith Tellis asked Ranjith Tellis commented

OptQuest + FlexSim HC: add logical constraints?

Hi All,

We are using OptQuest with Flexsim HC v5.3.4. How can we add logical constraints to OptQuest?

For example:

Var1 == 1 and Var2 == 1 and Var3 == 0 and Var4 == 0

(Var1 == 1 and Var2 == 1) OR (Var3 == 1 and Var4 == 1)

thanks.

FlexSim HC 5.3.4
flexsim hcoptquestconstraints
5 |100000

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

Cliff King avatar image
1 Like"
Cliff King answered Jordan Johnson commented

In general, you should limit the number and complexity of the constraints you define in OptQuest. You're better off defining the constraints (especially if they are constraints on the input variables) within the model itself, using script; rather than have OptQuest waste its time running invalid runs (i.e. runs that don't satisfy the constraints). If the the contraints are a function of the input variables, are you sure you can't better handle them with the lower and upper bounds of the variables themselves? Typically contraints are a function of the PFM's such as LOS < 1440.

I haven't been able to find anyone here who has defined complex contraint logic using AND and OR, but capital AND and OR should work. My suggestion is to test it and see. It's also possible == doesn't work, or at least it doesn't make sense to have constraints that match a specific value (once again, you ought to be able to handle this with the upper/lower limit bounds and/or model script). Try using <=, >=, <, and > only.

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

Ranjith Tellis avatar image Ranjith Tellis commented ·

Thanks for your response @Cliff King.

I agree that the first place to handle the valid values would be in the upper & lower bounds of the variables. But these are constraints in combination with multiple variables.

For the logical keywords in the constraint equation, we already tried these possibilities (AND, and, &, &&, OR, or, |, ||) which did not work; the error message was - error in constraint equation.

Yes, for == the correct form is =.

The question still is why OptQuest in FlexSim HC does not allow the AND, OR keywords in the constraint equation? The OptQuest documentation and OptQuest with other simulation engines shows examples of using these keywords.

0 Likes 0 ·
Cliff King avatar image Cliff King Ranjith Tellis commented ·

@jordan.johnson will you please look into Ranjith's claim that the AND, OR keywords work in OptQuest and other simulation engines, but not in FlexSim HC. Thanks!

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ commented ·

OptQuest doesn't accept plain < or >, only >= or <=. Be sure to use those variations.

0 Likes 0 ·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Ranjith Tellis commented

OptQuest does support using the AND and OR keywords. There could be a bug in our interface with OptQuest, but I am unable to replicate it. If you could post a model, we will be able to investigate the issue. If you want, you can mark the question as private, so that only we here at FlexSim can see the model.

As a workaround for now, you can proceed by creating performance measure called Failed that is just the value of a node in tree. You can set that node to 0 on reset, and then, at time 0 in the model, have a user event that analyzes the variable values. If they meet your requirements, leave the flag alone, and proceed. If they fail, then set the Failed node value to 1, and call the endreplication() command. Be sure to add a simple constraint: Failed <= 0. That way, you don't have to execute a model run just to find out if the variables were invalid. This approach allows you to use FlexScript to define your constraints, which can be more flexible.

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

Ranjith Tellis avatar image Ranjith Tellis commented ·

Thanks for your response Jordan.

We investigated the use of OR & AND further and found that it does work when the decision variable is associated with enabling/disabling the Patient Arrival Object. This does not work even when the decision variable to represented as integer instead of binary. The OR works fine when the decision variable is for example the number of resources in a group.

We did not try your work around. As an alternative, we are creating individual model files with different settings to enable our analysis.

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.