Skip to content

Commit

Permalink
[iss-258]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit f981c15
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Aug 27 14:53:20 2024 -0300

    Added mmoc system test.

commit e6aea70
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Aug 27 14:52:55 2024 -0300

    Update vs code settings file.

commit 1d75351
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Aug 27 14:52:41 2024 -0300

    Added engine system test.

commit a9cc65d
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Aug 27 09:42:54 2024 -0300

    Fixed dq approximation error on recompute next time for QSS method.

commit a2c4967
Author: joaquin.f.fernandez <[email protected]>
Date:   Tue Aug 27 09:42:16 2024 -0300

    Added macro definition for dq approximation value.
  • Loading branch information
joaquinffernandez committed Aug 27, 2024
1 parent 1777b45 commit eb9521c
Show file tree
Hide file tree
Showing 23 changed files with 10,776 additions and 50 deletions.
3 changes: 2 additions & 1 deletion src/engine/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"files.associations": {
"random": "cpp"
"random": "cpp",
"qss_bdf.h": "c"
},
"C_Cpp.dimInactiveRegions": true
}
5 changes: 5 additions & 0 deletions src/engine/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
typedef struct type##_ *type; \
typedef const struct type##_ *const_##type;

/// Define a minimum approximation of DQ used in QSS methods when
/// recomputing state variables next times, to avoid numerical
/// errors. @see https://github.com/CIFASIS/qss-solver/issues/258
#define DQ_APPROX 0.999999999

#ifdef QSS_PARALLEL

#define QSS_FUNC_DECL(module, name) module##_##PAR_##name
Expand Down
18 changes: 11 additions & 7 deletions src/engine/qss/methods/qss.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ void QSS_FUNC_DECL(QSS, recomputeNextTime)(QA_quantizer quantizer, int var, doub
{
int cf0 = var * 2, cf1 = cf0 + 1;
double coeff[2];
coeff[0] = q[cf0] - x[cf0] - lqu[var];
coeff[1] = -x[cf1];
nTime[var] = t + minPosRoot(coeff, 1);
coeff[0] = q[cf0] - x[cf0] + lqu[var];
double timeaux = t + minPosRoot(coeff, 1);
if (timeaux < nTime[var]) {
nTime[var] = timeaux;
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * DQ_APPROX) {
nTime[var] = t;
} else {
coeff[0] = q[cf0] - x[cf0] - lqu[var];
coeff[1] = -x[cf1];
nTime[var] = t + minPosRoot(coeff, 1);
coeff[0] = q[cf0] - x[cf0] + lqu[var];
double timeaux = t + minPosRoot(coeff, 1);
if (timeaux < nTime[var]) {
nTime[var] = timeaux;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/qss/methods/qss2.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void QSS_FUNC_DECL(QSS2, recomputeNextTime)(QA_quantizer quantizer, int var, dou
{
int cf0 = var * 3, cf1 = cf0 + 1, cf2 = cf1 + 1;
double coeff[3];
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * 0.999999999) {
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * DQ_APPROX) {
nTime[var] = t;
} else {
coeff[0] = q[cf0] + lqu[var] - x[cf0];
Expand Down
2 changes: 1 addition & 1 deletion src/engine/qss/methods/qss3.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void QSS_FUNC_DECL(QSS3, recomputeNextTime)(QA_quantizer quantizer, int var, dou
{
int cf0 = var * 4, cf1 = cf0 + 1, cf2 = cf1 + 1, cf3 = cf2 + 1;
double coeff[4];
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * 0.999999999) {
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * DQ_APPROX) {
nTime[var] = t;
} else {
coeff[0] = q[cf0] + lqu[var] - x[cf0];
Expand Down
2 changes: 1 addition & 1 deletion src/engine/qss/methods/qss4.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void QSS_FUNC_DECL(QSS4, recomputeNextTime)(QA_quantizer quantizer, int var, dou
{
int cf0 = var * 5, cf1 = cf0 + 1, cf2 = cf1 + 1, cf3 = cf2 + 1, cf4 = cf3 + 1;
double coeff[5];
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * 0.999999999) {
if (fabs(q[cf0] - x[cf0]) >= lqu[var] * DQ_APPROX) {
nTime[var] = t;
} else {
coeff[0] = q[cf0] + lqu[var] - x[cf0];
Expand Down
Loading

0 comments on commit eb9521c

Please sign in to comment.