【发布时间】:2019-03-08 12:49:46
【问题描述】:
以下 Modelica 模型进行检查和模拟。
model boolCheck_OK1
Real a = sin(time);
Real b = cos(time);
Real c;
//protected
// Boolean isInReg = inRegionCheck(a, b);
equation
c = if inRegionCheck(a, b) then 1.3*a^b else 0.7*b^a;
end boolCheck_OK1;
函数 inRegionCheck() 返回一个布尔值,这里是一个简化版:
function inRegionCheck
input Real a;
input Real b;
output Boolean c;
algorithm
c := a>b;
end inRegionCheck;
在实际代码中,该函数有更多的输入和更长的名称,并且有几行长,并且多次使用相同的检查,所以为了便于阅读,我想引入一个中间变量,如注释保护部分所示,但这会导致错误“连续时间中的非实数方程不合法”。
对优雅的解决方法有什么建议吗?
【问题讨论】:
标签: time boolean modelica continuous