@@ -1075,12 +1075,13 @@ protected function getConsistentEquations "author: mwenzler"
1075
1075
input array< Integer > vecVarToEqs;
1076
1076
input BackendDAE . Variables vars;
1077
1077
input BackendDAE . Shared shared ;
1078
+ input Integer counter;
1078
1079
output list< Integer > outUnassignedEqns;
1079
1080
output Boolean outConsistent;
1080
1081
algorithm
1081
- (outUnassignedEqns, outConsistent) := matchcontinue(inUnassignedEqns, inEqns, inEqnsOrig, inM,vecVarToEqs, vars, shared )
1082
+ (outUnassignedEqns, outConsistent) := matchcontinue(inUnassignedEqns, inEqns, inEqnsOrig, inM,vecVarToEqs, vars, shared , counter )
1082
1083
local
1083
- Integer currEqID, currVarID, currID;
1084
+ Integer currEqID, currVarID, currID, nVars, nEqns ;
1084
1085
list< Integer > unassignedEqns, unassignedEqns2, listVar;
1085
1086
list< BackendDAE . Equation > eqns_list;
1086
1087
list< BackendDAE . Equation > eqns_list_new;
@@ -1099,10 +1100,13 @@ algorithm
1099
1100
DAE . FunctionTree funcs;
1100
1101
list< BackendDAE . Equation > list_inEqns;
1101
1102
1102
- case ({}, _, _, _, _, _, _)
1103
+ case ({}, _, _, _, _, _, _, _ )
1103
1104
then ({}, true );
1104
1105
1105
- case (currID::unassignedEqns, _, _, _, _, _, _) equation
1106
+ case (currID::unassignedEqns, _, _, _, _, _, _, _) equation
1107
+ nVars = BackendVariable . varsSize(vars);
1108
+ nEqns = BackendDAEUtil . equationSize(inEqnsOrig);
1109
+ true = intLe(counter, nEqns- nVars);
1106
1110
eqn = BackendEquation . equationNth1(inEqns, currID);
1107
1111
BackendDAE . EQUATION (exp= lhs, scalar= rhs) = eqn;
1108
1112
exp = DAE . BINARY (lhs, DAE . SUB (DAE . T_REAL_DEFAULT ), rhs);
@@ -1114,10 +1118,10 @@ algorithm
1114
1118
eqn = BackendEquation . equationNth1(inEqnsOrig, currID);
1115
1119
Error . addCompilerNotification("The following equation is consistent and got removed from the initialization problem: " +& BackendDump . equationString(eqn));
1116
1120
1117
- (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared );
1121
+ (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared , counter + 1 );
1118
1122
then (currID::unassignedEqns2, consistent);
1119
1123
1120
- case (currID::unassignedEqns, _, _, _, _, _, _) equation
1124
+ case (currID::unassignedEqns, _, _, _, _, _, _, _ ) equation
1121
1125
true = emptyListOfIncidenceMatrix({currID},inM,vecVarToEqs, false );
1122
1126
eqn = BackendEquation . equationNth1(inEqns, currID);
1123
1127
BackendDAE . EQUATION (exp= lhs, scalar= rhs) = eqn;
@@ -1131,10 +1135,10 @@ algorithm
1131
1135
eqn2 = BackendEquation . equationNth1(inEqnsOrig, currID);
1132
1136
Error . addCompilerError("The initialization problem is inconsistent due to the following equation: " +& BackendDump . equationString(eqn2) +& " (" +& BackendDump . equationString(eqn) +& ")" );
1133
1137
1134
- (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared );
1138
+ (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared , counter );
1135
1139
then ({}, false );
1136
1140
1137
- case (currID::unassignedEqns, _, _, _, _, _, _) equation
1141
+ case (currID::unassignedEqns, _, _, _, _, _, _, _ ) equation
1138
1142
true = emptyListOfIncidenceMatrix({currID},inM,vecVarToEqs, false );
1139
1143
eqn = BackendEquation . equationNth1(inEqns, currID);
1140
1144
BackendDAE . EQUATION (exp= lhs, scalar= rhs) = eqn;
@@ -1157,10 +1161,10 @@ algorithm
1157
1161
eqn2 = BackendEquation . equationNth1(inEqnsOrig, currID);
1158
1162
Error . addCompilerNotification("It was not possible to analyze the given system symbolically, because the relevant equations are part of an algebraic loop. This is not supported yet." );
1159
1163
1160
- (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared );
1164
+ (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs, vars, shared , counter );
1161
1165
then ({}, false );
1162
1166
1163
- case (currID::unassignedEqns, _, _, _, _, _, _) equation
1167
+ case (currID::unassignedEqns, _, _, _, _, _, _, _ ) equation
1164
1168
// true = intEq(listLength(inM[currID]), 0);
1165
1169
true = emptyListOfIncidenceMatrix({currID},inM,vecVarToEqs, false );
1166
1170
eqn = BackendEquation . equationNth1(inEqns, currID);
@@ -1177,9 +1181,9 @@ algorithm
1177
1181
1178
1182
then ({}, false );
1179
1183
1180
- case (currID::unassignedEqns, _, _, _, _ , _, _) equation
1184
+ case (currID::unassignedEqns, _, _, _, _ , _, _, _ ) equation
1181
1185
false = emptyListOfIncidenceMatrix({currID},inM,vecVarToEqs, true );
1182
- (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs,vars, shared );
1186
+ (unassignedEqns2, consistent) = getConsistentEquations(unassignedEqns, inEqns, inEqnsOrig, inM, vecVarToEqs,vars, shared , counter );
1183
1187
then (unassignedEqns2, consistent);
1184
1188
end matchcontinue;
1185
1189
end getConsistentEquations;
@@ -1692,7 +1696,7 @@ algorithm
1692
1696
unassignedEqns= adaptUnassignedEqns(unassignedEqns, {}, mapIncRowEqn);
1693
1697
eqns_1= removeEqswork(unassignedEqns,eqns_list,vars,outRepl);
1694
1698
substEqns = BackendEquation . listEquation(eqns_1);
1695
- (outUnassignedEqns, true ) = getConsistentEquations(unassignedEqns, substEqns, eqns, m2, vec1,vars, shared );
1699
+ (outUnassignedEqns, true ) = getConsistentEquations(unassignedEqns, substEqns, eqns, m2, vec1,vars, shared , 1 );
1696
1700
1697
1701
// remove all unassigned equations
1698
1702
substEqns = BackendEquation . equationDelete(substEqns, outUnassignedEqns);
0 commit comments