Skip to content

Commit

Permalink
improved scaling of goal function in dyn. optimization
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22195 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Sep 9, 2014
1 parent 4d1024b commit 4ba144b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -2048,6 +2048,17 @@ algorithm
end match;
end getVarDirection;

public function getVarNominalValue "
Returns the DAE.NominalValue or default value of a variable."
input BackendDAE.Var InVar;
output DAE.Exp nom;
algorithm
nom := match(InVar)
local Option<DAE.VariableAttributes> attr;
case(BackendDAE.VAR(values = attr)) then DAEUtil.getNominalAttr(attr);
end match;
end varNominalValueFail;


public function isVarOnTopLevelAndOutput "and has the DAE.VarDirection = OUTPUT
The check for top-model is done by spliting the name at \'.\' and
Expand Down
6 changes: 5 additions & 1 deletion Compiler/BackEnd/DynamicOptimization.mo
Expand Up @@ -252,19 +252,23 @@ output Option<DAE.Exp> mayer;
algorithm
mayer := match(InVarlst, Inmayer)
local list<BackendDAE.Var> varlst; BackendDAE.Var v;
DAE.Exp e, e2, e3; Option<DAE.Exp> opte; DAE.ComponentRef cr;
DAE.Exp e, e2, e3, nom; Option<DAE.Exp> opte; DAE.ComponentRef cr;

case({},NONE()) then NONE();
case({},opte as SOME(e)) then opte;
case(v::varlst, SOME(e)) equation
nom = BackendVariable.getVarNominalValue(v);
cr = BackendVariable.varCref(v);
e2 = DAE.CREF(cr, DAE.T_REAL_DEFAULT);
e2 = Expression.expDiv(e2, nom);
e3 = Expression.expAdd(e,e2);
opte = SOME(e3);
then findMayerTerm2(varlst, opte);
case(v::varlst, NONE()) equation
nom = BackendVariable.getVarNominalValue(v);
cr = BackendVariable.varCref(v);
e2 = DAE.CREF(cr, DAE.T_REAL_DEFAULT);
e2 = Expression.expDiv(e2, nom);
opte = SOME(e2);
then findMayerTerm2(varlst, opte);
else then NONE();
Expand Down

0 comments on commit 4ba144b

Please sign in to comment.