Skip to content

Commit

Permalink
- fixed r19122
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19125 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Feb 15, 2014
1 parent 4fc8a16 commit d19da6d
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 95 deletions.
1 change: 1 addition & 0 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -199,6 +199,7 @@ uniontype VarKind "variable kind"
record EXTOBJ Absyn.Path fullClassName; end EXTOBJ;
record JAC_VAR end JAC_VAR;
record JAC_DIFF_VAR end JAC_DIFF_VAR;
record OPT_CONSTR end OPT_CONSTR;
end VarKind;

public
Expand Down
7 changes: 3 additions & 4 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -4779,7 +4779,7 @@ protected function addOptimizationVarsEqns1
algorithm
(outVars, outEqns) := match(constraintLst,inI,inVars,inEqns,b)
local
list<DAE.Exp> conLst,conLst2;
list<DAE.Exp> conLst;
DAE.Exp e;
DAE.ComponentRef leftcref;
BackendDAE.Var dummyVar;
Expand All @@ -4791,12 +4791,11 @@ algorithm
case(e::conLst,_,_,_,_) equation
//print("con"+& intString(inI) +& " "+& ExpressionDump.printExpStr(e) +& "\n");
leftcref = ComponentReference.makeCrefIdent("$TMP_con" +& intString(inI), DAE.T_REAL_DEFAULT, {});
dummyVar = BackendDAE.VAR(leftcref, BackendDAE.VARIABLE(), DAE.OUTPUT(), DAE.NON_PARALLEL(), DAE.T_REAL_DEFAULT, NONE(), NONE(), {}, DAE.emptyElementSource, NONE(), NONE(), DAE.NON_CONNECTOR());
dummyVar = Util.if_(b,BackendDAE.VAR(leftcref, BackendDAE.OPT_CONSTR(), DAE.OUTPUT(), DAE.NON_PARALLEL(), DAE.T_REAL_DEFAULT, NONE(), NONE(), {}, DAE.emptyElementSource, NONE(), NONE(), DAE.NON_CONNECTOR()),BackendDAE.VAR(leftcref, BackendDAE.VARIABLE(), DAE.OUTPUT(), DAE.NON_PARALLEL(), DAE.T_REAL_DEFAULT, NONE(), NONE(), {}, DAE.emptyElementSource, NONE(), NONE(), DAE.NON_CONNECTOR()));
conEqn = Util.if_(b,BackendEquation.generateResidualfromRealtion(leftcref, e, DAE.emptyElementSource),{});
v = BackendVariable.addNewVar(dummyVar, inVars);
eqns = listAppend(conEqn, inEqns);
conLst2 = Util.if_(b,listReverse(conLst),conLst);
(v,eqns)= addOptimizationVarsEqns1(listReverse(conLst), inI + 1, v,eqns,b);
(v,eqns)= addOptimizationVarsEqns1(conLst, inI + 1, v,eqns,b);
then (v,eqns);
else then (inVars,inEqns);
end match;
Expand Down
3 changes: 2 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -3320,7 +3320,8 @@ algorithm
inputvarsarr = BackendVariable.listVar1(inputvars);
paramvarsarr = BackendVariable.listVar1(paramvars);
outputvarsarr = BackendVariable.listVar1(outputvars);
//BackendDump.printVariables(outputvarsarr);

//BackendDump.printVariables(conVars);
object = checkObjectIsSet(outputvarsarr,"$TMP_mayerTerm");
object = BackendVariable.mergeVariables(object, checkObjectIsSet(outputvarsarr,"$TMP_lagrangeTerm"));
//BackendDump.printVariables(object);
Expand Down
15 changes: 15 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -1131,6 +1131,7 @@ algorithm
case (BackendDAE.VAR(varKind = BackendDAE.DUMMY_STATE())) then ();
case (BackendDAE.VAR(varKind = BackendDAE.DISCRETE())) then ();
case (BackendDAE.VAR(varKind = BackendDAE.STATE_DER())) then ();
case (BackendDAE.VAR(varKind = BackendDAE.OPT_CONSTR())) then ();
end match;
end failIfNonState;

Expand Down Expand Up @@ -1230,6 +1231,7 @@ algorithm
case ((BackendDAE.VAR(varKind=BackendDAE.STATE_DER()) :: _)) then true;
case ((BackendDAE.VAR(varKind=BackendDAE.DUMMY_DER()) :: _)) then true;
case ((BackendDAE.VAR(varKind=BackendDAE.DUMMY_STATE()) :: _)) then true;
case ((BackendDAE.VAR(varKind=BackendDAE.OPT_CONSTR()) :: _)) then true;
case ((v :: vs)) then hasContinousVar(vs);
case ({}) then false;
end match;
Expand Down Expand Up @@ -1291,6 +1293,8 @@ algorithm
end match;
end isVarStringAlg;



public function isVarIntAlg
input BackendDAE.Var var;
output Boolean result;
Expand Down Expand Up @@ -1628,6 +1632,17 @@ algorithm
end matchcontinue;
end isRealParam;

public function isRealOptimizeConstraintsVars
"Return true if variable is a constraint(slack variable)"
input BackendDAE.Var inVar;
output Boolean outBoolean;
algorithm
outBoolean := match (inVar)
case (BackendDAE.VAR(varKind = BackendDAE.OPT_CONSTR())) then true;
case (_) then false;
end match;
end isRealOptimizeConstraintsVars;

public function isNonRealParam
"Return true if variable is NOT a parameter of real-type"
input BackendDAE.Var inVar;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/ResidualCmp.mo
Expand Up @@ -182,8 +182,8 @@ algorithm
// generate all residual equations
(daevars,_,allEquations,allInitEquations) = generateEquationscollectVars(elementLst,{},1,{},{});
// generate variable definitions
simvars = SimCode.SIMVARS({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});
varinfo = SimCode.VARINFO(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
simvars = SimCode.SIMVARS({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});
varinfo = SimCode.VARINFO(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

modelInfo = SimCode.MODELINFO(inClassName,fileDir,varinfo,simvars,functions,{});
extObjInfo = SimCode.EXTOBJINFO({},{});
Expand Down
5 changes: 3 additions & 2 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -199,7 +199,7 @@ uniontype VarInfo "Number of variables of various types in a Modelica model."
Integer numNonLinearSystems;
Integer numMixedSystems;
Integer numStateSets;

Integer numOptimizeConstraints;
end VARINFO;
end VarInfo;

Expand Down Expand Up @@ -228,11 +228,12 @@ uniontype SimVars "Container for metadata about variables in a Modelica model."
list<SimVar> boolConstVars;
list<SimVar> stringConstVars;
list<SimVar> jacobianVars;
list<SimVar> realOptimizeConstraintsVars;
end SIMVARS;
end SimVars;

public constant SimVars emptySimVars = SIMVARS({}, {}, {}, {}, {}, {}, {}, {},
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {});
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},{});

uniontype SimVar "Information about a variable in a Modelica model."
record SIMVAR
Expand Down

0 comments on commit d19da6d

Please sign in to comment.