Skip to content

Commit

Permalink
- Added new implementation of uncertainty extraction algorithm
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12826 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Leonardo Laguna committed Sep 7, 2012
1 parent e7fce4c commit f10aa1e
Show file tree
Hide file tree
Showing 3 changed files with 1,352 additions and 1,685 deletions.
52 changes: 50 additions & 2 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected import System;
protected import Util;
protected import Values;
protected import ValuesUtil;
protected import Uncertainties;



Expand Down Expand Up @@ -4867,7 +4866,7 @@ algorithm
eqn_lst = BackendEquation.getEqns(residualeqns,eqns);
eq = listGet(eqn_lst,1);
var_lst = List.map1r(tvars, BackendVariable.getVarAt, vars);
subSyst = Uncertainties.getSubSystemDaeForVars(residual,tvars,dlow1_1);
subSyst = getSubSystemDaeForVars(residual,tvars,dlow1_1);
BackendDAE.DAE({sub_eqSyst2},sub_shared2) = subSyst;
(m_subSyst2,mT_subSyst2) = BackendDAEUtil.incidenceMatrix(sub_eqSyst2, sub_shared2, BackendDAE.NORMAL());
BackendDAE.EQSYSTEM(vars_subSyst,eqns_subSyst,_,_,_) = sub_eqSyst2;
Expand Down Expand Up @@ -4986,6 +4985,55 @@ algorithm
end matchcontinue;
end tearingSystem1;

public function getSubSystemDaeForVars "Returns a subsystem dae given a list of equations and a list of
variables as indices."
input list<Integer> eqnIndxLst;
input list<Integer> varIndxLst;
input BackendDAE.BackendDAE dae;
output BackendDAE.BackendDAE outDae;
algorithm
outDae:= match(eqnIndxLst,varIndxLst,dae)
local
list<BackendDAE.Equation> eqnLst;
list<BackendDAE.Var> varLst;
BackendDAE.EqSystem eqsys1;
list<Integer> fixedIndex;
case(eqnIndxLst,varIndxLst,dae) equation
BackendDAE.DAE(eqs=(eqsys1::_)) = dae;
fixedIndex = List.map1r(eqnIndxLst,intAdd,-1);
eqnLst = List.map1r(fixedIndex,BackendDAEUtil.equationNth,BackendEquation.daeEqns(eqsys1)); //daeArrayEqns equationNth
varLst = List.map1r(varIndxLst,BackendVariable.getVarAt,BackendVariable.daeVars(eqsys1));
then setDaeVarsAndEqs(dae,BackendDAEUtil.listEquation(eqnLst),BackendDAEUtil.listVar(varLst));
case(_,_,_) equation
//print("getSubSystemDaeForVars failed\n");
then fail();
end match;
end getSubSystemDaeForVars;

public function setDaeVarsAndEqs "
note: this function destroys matching
"
input BackendDAE.BackendDAE systIn;
input BackendDAE.EquationArray newEqnsIn;
input BackendDAE.Variables newVarsIn;
output BackendDAE.BackendDAE sysOut;
algorithm
sysOut:= match(systIn,newEqnsIn,newVarsIn)
local
Option<BackendDAE.IncidenceMatrix> m;
Option<BackendDAE.IncidenceMatrixT> mT;
BackendDAE.Matching matching;
BackendDAE.Shared shared;
BackendDAE.EquationArray newEqns;
BackendDAE.Variables newVars;
list<BackendDAE.EqSystem> eqlist;
case (BackendDAE.DAE(BackendDAE.EQSYSTEM(_,_,m,mT,matching)::eqlist,shared),newEqns,newVars)
then
BackendDAE.DAE(BackendDAE.EQSYSTEM(newVars,newEqns,m,mT,matching)::eqlist,shared);
end match;
end setDaeVarsAndEqs;


protected function printEquationArr
"prints an array of BackendDAE.Equations"
input array<Option<BackendDAE.Equation>> inArr;
Expand Down

0 comments on commit f10aa1e

Please sign in to comment.