Skip to content

Commit

Permalink
- Bugfix removeSimpleEquationsX
Browse files Browse the repository at this point in the history
- Bugfix initialisation c_runtime windows
- Util: bugfix arrayMapNoCopy_1
- add testcase testsimulate

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8487 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Apr 4, 2011
1 parent 011d188 commit 0aa00ea
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -1689,7 +1689,7 @@ algorithm
(es,{}) = ExpressionSolve.solve(e1,e2,cre);
// constant or alias
(dae1,newvars,newvars1) = constOrAlias(var,cr,es,dae,mvars,mavars);
then (cr,i,es,dae1,newvars,mavars);
then (cr,i,es,dae1,newvars,newvars1);
// a = b
case({i,j},length,pos,dae,mvars,mavars) equation
pos_1 = pos-1;
Expand Down
37 changes: 32 additions & 5 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -1065,46 +1065,52 @@ algorithm
local
Option<DAE.Exp> min,max,start,fixed,nominal;
String snominal;
Option<Boolean> isProtected;
case NONE() then ();
case SOME(DAE.VAR_ATTR_REAL(min=(min,max),initial_=start,fixed=fixed,nominal=nominal))
case SOME(DAE.VAR_ATTR_REAL(min=(min,max),initial_=start,fixed=fixed,nominal=nominal,isProtected=isProtected))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptExpression(nominal,"nominal");
dumpOptBoolean(isProtected,"protected");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_INT(min=(min,max),initial_=start,fixed=fixed))
case SOME(DAE.VAR_ATTR_INT(min=(min,max),initial_=start,fixed=fixed,isProtected=isProtected))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_BOOL(initial_=start,fixed=fixed))
case SOME(DAE.VAR_ATTR_BOOL(initial_=start,fixed=fixed,isProtected=isProtected))
equation
print("(");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_STRING(initial_=start))
case SOME(DAE.VAR_ATTR_STRING(initial_=start,isProtected=isProtected))
equation
print("(");
dumpOptExpression(start,"start");
dumpOptBoolean(isProtected,"protected");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_ENUMERATION(min=(min,max),start=start,fixed=fixed))
case SOME(DAE.VAR_ATTR_ENUMERATION(min=(min,max),start=start,fixed=fixed,isProtected=isProtected))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
print(") ");
then ();
else ();
Expand Down Expand Up @@ -1132,6 +1138,27 @@ algorithm
end match;
end dumpOptExpression;

protected function dumpOptBoolean
"function: dumpOptBoolean
Helper function to dump."
input Option<Boolean> inExp;
input String inString;
algorithm
_:=
match (inExp,inString)
local
Boolean e;
String s,se,str;
case (SOME(e),s)
equation
se = boolString(e);
str = stringAppendList({s," = ",se," "});
print(str);
then ();
else ();
end match;
end dumpOptBoolean;

public function dumpIncidenceMatrix
"function: dumpIncidenceMatrix
author: PA
Expand Down
6 changes: 5 additions & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -91,11 +91,15 @@ algorithm

case (((BackendDAE.ALGORITHM(index=indx,in_=expl,out=expl1,source = source)) :: es),repl)
equation
expl = Util.listMap2(expl,VarTransform.replaceExp,repl,NONE());
expl = Util.listMap(expl,ExpressionSimplify.simplify);
expl2 = Util.listMap2(expl1,VarTransform.replaceExp,repl,NONE());
expl2 = Util.listMap(expl2,ExpressionSimplify.simplify);
// original algorithm is done by replaceAlgorithms
// inputs and ouputs are updated from DEALow.updateAlgorithmInputsOutputs
es_1 = replaceEquations(es, repl);
then
(BackendDAE.ALGORITHM(indx,expl,expl1,source) :: es_1);
(BackendDAE.ALGORITHM(indx,expl,expl2,source) :: es_1);

case ((BackendDAE.SOLVED_EQUATION(componentRef = cr,exp = e,source = source) :: es),repl)
equation
Expand Down
6 changes: 2 additions & 4 deletions Compiler/Util/Util.mo
Expand Up @@ -1119,9 +1119,7 @@ See also listMap, arrayMap
output tuple<Type_a,Type_b> outTpl;
end FuncType;
algorithm
outArray := array;
outArg := inArg;
// (outArray,outArg) := arrayMapNoCopyHelp1_1(array,func,1,arrayLength(array),inArg);
(outArray,outArg) := arrayMapNoCopyHelp1_1(array,func,1,arrayLength(array),inArg);
end arrayMapNoCopy_1;

protected function arrayMapNoCopyHelp1_1 "help function to arrayMap"
Expand Down Expand Up @@ -1153,7 +1151,7 @@ algorithm
((newElt,extarg)) = func((inArray[pos],inArg));
a = arrayUpdate(inArray,pos,newElt);
(a1,extarg1) = arrayMapNoCopyHelp1_1(a,func,pos+1,len,extarg);
then (a1,extarg);
then (a1,extarg1);
end matchcontinue;
end arrayMapNoCopyHelp1_1;

Expand Down
3 changes: 3 additions & 0 deletions Makefile.common
Expand Up @@ -57,6 +57,9 @@ testlog:
testmos:
(cd testsuite/mosfiles; time $(MAKE) -f Makefile)

testsimulation:
(cd testsuite; time $(MAKE) -f Makefile simulation)

testmo:
(cd testsuite/mofiles; time $(MAKE) -f Makefile test)

Expand Down
7 changes: 5 additions & 2 deletions c_runtime/simulation_init.cpp
Expand Up @@ -186,8 +186,11 @@ int simplex_initialization(long& nz,double *z)
}

if (IFAULT == 1) {
printf("Error in initialization. Solver iterated %d times without finding a solution\n",(int)MAXF);
return -1;
leastSquare(&nz,z,&funcValue);
if (funcValue > SIMP) {
printf("Error in initialization. Solver iterated %d times without finding a solution\n",(int)MAXF);
return -1;
}
} else if(IFAULT == 2 ) {
printf("Error in initialization. Inconsistent initial conditions.\n");
return -1;
Expand Down

0 comments on commit 0aa00ea

Please sign in to comment.