3

以下の Modelica モデルは検証に合格します。

model TestController
  parameter Real off[4] = fill(20, 4) "Radiator turn off threshold";
  parameter Real on[4] = fill(19, 4) "Radiator turn on threshold";
  discrete Modelica.Blocks.Interfaces.RealInput x[4];
  output Modelica.Blocks.Interfaces.BooleanOutput h[4];
protected
  Boolean has_heater[4];
equation
  has_heater = {false, true, true, false};
algorithm
  for j in 1:4 loop
    h[j] := has_heater[j] and ((not h[j] and x[j] <= on[j]) or (h[j] and x[j] < off[j]));
  end for;
end TestController;

しかし、それをシミュレートしようとすると、コンパイルされたコードでエラーが発生します。

sme.12.0.0_1575385723_1403176131_main.cpp: In function ‘int function_zeroCrossing(f2c_integer*, double*, double*, f2c_integer*, double*, double*, f2c_integer*)’:
sme.12.0.0_1575385367_109695398_main.cpp:347:35: error: ‘$i1_j’ was not declared in this scope
  349 |   base_array_range_check1(&$tmp0, $i1_j - 1, "[:0:0-0:0]", "x[$i1_j]");
      |        

私が理解していない基本的なことがあるに違いありません。なぜこのループはシミュレートしないのですか? h の値の 2 番目の節を削除して単純にするとh[j] := has_heater[j]、シミュレーションが機能します。

4

2 に答える 2