You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a typical use case, but in a recent version of the C-ROADS, the following equation was used and SDE emitted incorrect code, so I'm logging this issue while I remember the details.
Model equations that trigger the issue (this can be added to the existing sum.mdl test to reproduce):
DimT: T1, T2 ~~|
DimT': DimT ~~|
DimU: U1, U2, U3, U4 ~~|
t[DimT] = 1, 2 ~~|
u[DimU] = 10, 20, 30, 40 ~~|
t two dim[DimT,DimT'] = (10 * t[DimT]) + t[DimT'] ~~|
t two dim with u[DimT, DimT', DimU] = (10 * u[DimU]) + (10 * t[DimT]) + t[DimT'] ~~|
v[DimT] = SUM(t two dim[DimT, DimT!]) ~~|
w[DimT, DimU] = u[DimU] * SUM(t two dim[DimT, DimT!]) ~~|
x[DimT, DimU] = SUM(t two dim with u[DimT, DimT!, DimU]) ~~|
In short, we have some equations in C-ROADS that use a 2D array for expressing relationships between two dimensions, and in some places we have a SUM that involves both dimensions (for example, see v[DimT] above). SDE generates the following code for that one, which has the wrong indexes (it has _t_two_dim[v][v], which is incorrect; it should be _t_two_dim[i][v]:
// v[DimT] = SUM(t two dim[DimT, DimT!])
for (size_t i = 0; i < 2; i++) {
double __t12 = 0.0;
for (size_t v = 0; v < 2; v++) {
__t12 += _t_two_dim[v][v];
}
_v[i] = __t12;
}
As a workaround, we can use [DimT, DimT'!] ("DimT prime") instead of [DimT, DimT!] so that SDE treats them as two separate/distinct dimensions. The workaround is fine for now, but it would be safer if we could fix this issue in SDE.
The text was updated successfully, but these errors were encountered:
It appears that this issue is resolved by the fixes for #179. I will include the above sample model in that branch (and will update the unit tests to cover these cases) and will mark this issue as being "fixed" by the forthcoming PR.
I'm not sure if this is a typical use case, but in a recent version of the C-ROADS, the following equation was used and SDE emitted incorrect code, so I'm logging this issue while I remember the details.
Model equations that trigger the issue (this can be added to the existing
sum.mdl
test to reproduce):In short, we have some equations in C-ROADS that use a 2D array for expressing relationships between two dimensions, and in some places we have a
SUM
that involves both dimensions (for example, seev[DimT]
above). SDE generates the following code for that one, which has the wrong indexes (it has_t_two_dim[v][v]
, which is incorrect; it should be_t_two_dim[i][v]
:As a workaround, we can use
[DimT, DimT'!]
("DimT prime") instead of[DimT, DimT!]
so that SDE treats them as two separate/distinct dimensions. The workaround is fine for now, but it would be safer if we could fix this issue in SDE.The text was updated successfully, but these errors were encountered: