Search code examples
modelica

if-condition on array of booleans in Modelica


I'm sorry if this is a 'read the manual' question (I did but can't find an answer).

I have an array of Booleans and I want to test if any of them is true.

model TestArray

(...)
Boolean[:] booleanArray;
Real y;

equation
y = if [if any element in booleanArray is true] then ... else ...;

end TestArray;

How can I do this? Thanks, Roel


Solution

  • There are functions like the ones you are requesting in Modelica.Math.BooleanVectors.

    Here you'll find allTrue(Boolean b[:]), anyTrue(Boolean b[:]) and oneTrue(Boolean b[:]).