Skip to content

Commit

Permalink
optimize some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Dec 17, 2015
1 parent 8000c93 commit 5088b2d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -1332,7 +1332,7 @@ algorithm
({stmt},_) = BackendVarTransform.replaceStatementLst({stmtIn},repl,NONE(),{},false);
DAE.STMT_ASSIGN(exp1=e1,exp=e2) = stmt;
b1 = Expression.isConst(e1);
b2 = Expression.isConst(e2) and b1;
b2 = Expression.isConst(e2);
//stmt = if_(b1,stmtIn,stmt);
stmt = stmtIn;
then
Expand Down
23 changes: 10 additions & 13 deletions Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -2288,20 +2288,17 @@ protected function replaceStateIndex
input Integer iR;
input array<Integer> stateindexs;
output Integer oR;
protected
Integer s,r;
algorithm
oR := matchcontinue(iR,stateindexs)
local
Integer s,r;
case (_,_)
equation
false = intGt(iR,0);
r = intAbs(iR);
s = stateindexs[r];
true = intGt(s,0);
then
s;
case (_,_) then iR;
end matchcontinue;
oR := iR;
if not intGt(iR,0) then
r := intAbs(iR);
s := stateindexs[r];
if intGt(s,0) then
oR := s;
end if;
end if;
end replaceStateIndex;

protected function getIncidenceMatrixLevelEquations
Expand Down
22 changes: 7 additions & 15 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -1480,7 +1480,7 @@ algorithm
case BackendDAE.SOLVABILITY_CONSTONE() then true;
case BackendDAE.SOLVABILITY_CONST() then true;
case BackendDAE.SOLVABILITY_PARAMETER(b=b) then b;
case BackendDAE.SOLVABILITY_LINEAR(b=b) then false;
case BackendDAE.SOLVABILITY_LINEAR() then false;
case BackendDAE.SOLVABILITY_NONLINEAR() then false;
case BackendDAE.SOLVABILITY_UNSOLVABLE() then false;
case BackendDAE.SOLVABILITY_SOLVABLE() then true;
Expand Down Expand Up @@ -3070,20 +3070,12 @@ algorithm
size := List.fold2(interEqs,sizeOfAssignable,me,ass1In,0);
arrayUpdate(ass1In,Var,-1);

OutValue := matchcontinue(size,num)
case(_,_)
equation
true = size < num;
then ((me,ass1In,selEqs,selVars,cVars,num,indx+1,size::counts));
case(_,_)
equation
true = size == num;
then ((me,ass1In,selEqs,selVars,indx::cVars,num,indx+1,size::counts));
case(_,_)
equation
true = size > num;
then ((me,ass1In,selEqs,selVars,{indx},size,indx+1,size::counts));
end matchcontinue;
OutValue := if size < num then
((me,ass1In,selEqs,selVars,cVars,num,indx+1,size::counts))
else if size == num then
((me,ass1In,selEqs,selVars,indx::cVars,num,indx+1,size::counts))
else
((me,ass1In,selEqs,selVars,{indx},size,indx+1,size::counts));

if Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("Var " + intString(listGet(selVars,indx)) + " would causalize " + intString(size) + " Eqns\n");
Expand Down

0 comments on commit 5088b2d

Please sign in to comment.