OpenModelica错误:“撕裂启发式词无法避免离散的迭代变量……”
我正在开发一群无人机的模拟。我在无人机前的检查区域造成了一个函数,但是当我尝试使用它时,它会显示此错误:
"The tearing heuristic was not able to avoid discrete iteration variables because otherwise the system could not have been torn".
这是功能:
function seeNearObject "Restituisce una lista contenente tutti gli oggetti rilevati dal sistema video del drone"
InputReal x;
InputReal y;
InputReal z;
InputReal x2[K.N];
InputReal y2[K.N];
InputReal z2[K.N];
InputReal destX;
InputReal destY;
InputReal destZ;
InputReal intrX[K.nIntr];
InputReal intrY[K.nIntr];
InputReal intrZ[K.nIntr];
InputReal missX[K.nRocket];
InputReal missY[K.nRocket];
InputReal missZ[K.nRocket];
InputReal statX[K.nStatObs];
InputReal statY[K.nStatObs];
InputReal statZ[K.nStatObs];
OutputBool outneighbours[K.N];
OutputBool outnearIntr[K.nIntr];
OutputBool outnearMissile[K.nRocket];
OutputBool outnearStatObs[K.nStatObs];
protected
Real viewField[3];
algorithm
//Imposto i limiti del campo visivo. Data la direzione del drone, ogni asse avrà il suo limite.
// viewField := findViewField(x,y,z, destX,destY,destZ);
viewField := zeros(3);
for j in 1:K.N loop
outneighbours[j] := false;
if((x2[j] >= x and x2[j] <= viewField[1]) or (x2[j] <= x and x2[j] >= viewField[1])) then
if((y2[j] >= y and y2[j] <= viewField[2]) or (y2[j] <= y and y2[j] >= viewField[2])) then
if((z2[j] >= z and z2[j] <= viewField[3]) or (z2[j] <= z and z2[j] >= viewField[3])) then
outneighbours[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nIntr loop
outnearIntr[j] := false;
if((intrX[j] >= x and intrX[j] <= viewField[1]) or (intrX[j] <= x and intrX[j] >= viewField[1])) then
if((intrY[j] >= y and intrY[j] <= viewField[2]) or (intrY[j] <= y and intrY[j] >= viewField[2])) then
if((intrZ[j] >= z and intrZ[j] <= viewField[3]) or (intrZ[j] <= z and intrZ[j] >= viewField[3])) then
outnearIntr[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nRocket loop
outnearMissile[j] := false;
if((missX[j] >= x and missX[j] <= viewField[1]) or (missX[j] <= x and missX[j] >= viewField[1])) then
if((missY[j] >= y and missY[j] <= viewField[2]) or (missY[j] <= y and missY[j] >= viewField[2])) then
if((missZ[j] >= z and missZ[j] <= viewField[3]) or (missZ[j] <= z and missZ[j] >= viewField[3])) then
outnearMissile[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nStatObs loop
outnearStatObs[j] := false;
if((statX[j] >= x and statX[j] <= viewField[1]) or (statX[j] <= x and statX[j] >= viewField[1])) then
if((statY[j] >= y and statY[j] <= viewField[2]) or (statY[j] <= y and statY[j] >= viewField[2])) then
if((statZ[j] >= z and statZ[j] <= viewField[3]) or (statZ[j] <= z and statZ[j] >= viewField[3])) then
outnearStatObs[j] := true;
end if;
end if;
end if;
end for;
end seeNearObject;
所有输入是3D空间中的点,我有一个类似的功能(写得更好比这更明显。有错误吗?
I'm developing a simulation of a swarm of drones. I made a function for checking area in front of drones, but when i'm trying to use it it displays this error:
"The tearing heuristic was not able to avoid discrete iteration variables because otherwise the system could not have been torn".
This is the function:
function seeNearObject "Restituisce una lista contenente tutti gli oggetti rilevati dal sistema video del drone"
InputReal x;
InputReal y;
InputReal z;
InputReal x2[K.N];
InputReal y2[K.N];
InputReal z2[K.N];
InputReal destX;
InputReal destY;
InputReal destZ;
InputReal intrX[K.nIntr];
InputReal intrY[K.nIntr];
InputReal intrZ[K.nIntr];
InputReal missX[K.nRocket];
InputReal missY[K.nRocket];
InputReal missZ[K.nRocket];
InputReal statX[K.nStatObs];
InputReal statY[K.nStatObs];
InputReal statZ[K.nStatObs];
OutputBool outneighbours[K.N];
OutputBool outnearIntr[K.nIntr];
OutputBool outnearMissile[K.nRocket];
OutputBool outnearStatObs[K.nStatObs];
protected
Real viewField[3];
algorithm
//Imposto i limiti del campo visivo. Data la direzione del drone, ogni asse avrà il suo limite.
// viewField := findViewField(x,y,z, destX,destY,destZ);
viewField := zeros(3);
for j in 1:K.N loop
outneighbours[j] := false;
if((x2[j] >= x and x2[j] <= viewField[1]) or (x2[j] <= x and x2[j] >= viewField[1])) then
if((y2[j] >= y and y2[j] <= viewField[2]) or (y2[j] <= y and y2[j] >= viewField[2])) then
if((z2[j] >= z and z2[j] <= viewField[3]) or (z2[j] <= z and z2[j] >= viewField[3])) then
outneighbours[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nIntr loop
outnearIntr[j] := false;
if((intrX[j] >= x and intrX[j] <= viewField[1]) or (intrX[j] <= x and intrX[j] >= viewField[1])) then
if((intrY[j] >= y and intrY[j] <= viewField[2]) or (intrY[j] <= y and intrY[j] >= viewField[2])) then
if((intrZ[j] >= z and intrZ[j] <= viewField[3]) or (intrZ[j] <= z and intrZ[j] >= viewField[3])) then
outnearIntr[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nRocket loop
outnearMissile[j] := false;
if((missX[j] >= x and missX[j] <= viewField[1]) or (missX[j] <= x and missX[j] >= viewField[1])) then
if((missY[j] >= y and missY[j] <= viewField[2]) or (missY[j] <= y and missY[j] >= viewField[2])) then
if((missZ[j] >= z and missZ[j] <= viewField[3]) or (missZ[j] <= z and missZ[j] >= viewField[3])) then
outnearMissile[j] := true;
end if;
end if;
end if;
end for;
for j in 1:K.nStatObs loop
outnearStatObs[j] := false;
if((statX[j] >= x and statX[j] <= viewField[1]) or (statX[j] <= x and statX[j] >= viewField[1])) then
if((statY[j] >= y and statY[j] <= viewField[2]) or (statY[j] <= y and statY[j] >= viewField[2])) then
if((statZ[j] >= z and statZ[j] <= viewField[3]) or (statZ[j] <= z and statZ[j] >= viewField[3])) then
outnearStatObs[j] := true;
end if;
end if;
end if;
end for;
end seeNearObject;
All the inputs are point in a 3D space, and I have a similar function (written better than this) but it works clearly. Is there any error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能已经解决了这个问题,但是据我所知,代码可能会导致错误的两个问题。
(1)我在算法中看不到任何初始条件。在OpenModelica中,您应该始终具有
指定每个参数的启动值(输入中的参数)。
(2)读取与状态相关的变量
var
时,您应该始终使用pre(var)
调用,以读取var
的最后一个值,不是电流。那是因为OpenModelica使用代数公式来求解系统,如果您的模型具有循环(所有大型模型),则可能会导致代数公式不一致的问题。像这样,
应该总是
希望这会有所帮助。 :)
you probably solved this, but as far as I can see there are two issues with the code that may be causing the error.
(1) I don't see any initial condition in the algorithm. In OpenModelica you should always have a
in which you specify the starting values of each parameter (except for the ones in Input).
(2) When reading a status related variable
var
you should always use thepre(var)
call, to read the last value ofvar
, not the current. That is because OpenModelica uses algebraic formulas to solve the system and if your model has loops (all big models do) it may lead to this very issue in which the algebraic formula is inconsistent.Like so
It should always be something like
Hope this helps. :)