@@ -3693,9 +3693,18 @@ algorithm
36933693 pa = incidenceRowExp1(varslst,p,pa,false );
36943694 then
36953695 ((e,false ,(vars,pa,ofunctionTree)));
3696+ /* higher derivative, is only present during index reduction */
3697+ case (((e as DAE . CALL (path = Absyn . IDENT (name = "der" ),expLst = {DAE . CREF (componentRef = cr),DAE . ICONST (_)}),(vars,pa,ofunctionTree))))
3698+ equation
3699+ (varslst,p) = BackendVariable . getVar(cr, vars);
3700+ pa = incidenceRowExp1(varslst,p,pa,false );
3701+ then
3702+ ((e,false ,(vars,pa,ofunctionTree)));
36963703
3704+ /* this case should not be here, because it points out that somewhere the dummy var replacement was not done */
36973705 case (((e as DAE . CALL (path = Absyn . IDENT (name = "der" ),expLst = {DAE . CREF (componentRef = cr)}),(vars,pa,ofunctionTree))))
36983706 equation
3707+ print("Use the devel case \n " );
36993708 cr = ComponentReference . crefPrefixDer(cr);
37003709 (varslst,p) = BackendVariable . getVar(cr, vars);
37013710 pa = incidenceRowExp1(varslst,p,pa,false );
@@ -3784,56 +3793,54 @@ end traversingincidenceRowExpFinder;
37843793protected function incidenceRowExp1
37853794 input list< Var > inVarLst;
37863795 input list< Integer > inIntegerLst;
3787- input list< Integer > inIntegerLst1 ;
3796+ input list< Integer > inVarIndxLst ;
37883797 input Boolean notinder;
3789- output list< Integer > outIntegerLst ;
3798+ output list< Integer > outVarIndxLst ;
37903799algorithm
3791- outIntegerLst := matchcontinue (inVarLst,inIntegerLst,inIntegerLst1 ,notinder)
3800+ outVarIndxLst := match (inVarLst,inIntegerLst,inVarIndxLst ,notinder)
37923801 local
37933802 list< Var > rest;
3794- list< Integer > irest,res, vars;
3803+ list< Integer > irest,vars;
37953804 Integer i,i1;
37963805 Boolean b;
37973806 case ({},{},vars,_) then vars;
37983807 /* If variable x is a state, der(x) is a variable in incidence matrix,
37993808 x is inserted as negative value, since it is needed by debugging and
38003809 index reduction using dummy derivatives */
3801- case (BackendDAE . VAR (varKind = BackendDAE . STATE (_)) :: rest,i::irest,vars,b)
3802- equation
3803- i1 = Util . if_(b,- i,i);
3804- failure(_ = List . getMemberOnTrue(i1, vars, intEq));
3805- res = incidenceRowExp1(rest,irest,i1::vars,b);
3806- then res;
3807- case (BackendDAE . VAR (varKind = BackendDAE . STATE_DER ()) :: rest,i::irest,vars,b)
3808- equation
3809- failure(_ = List . getMemberOnTrue(i, vars, intEq));
3810- res = incidenceRowExp1(rest,irest,i::vars,b);
3811- then res;
3812- case (BackendDAE . VAR (varKind = BackendDAE . VARIABLE ()) :: rest,i::irest,vars,b)
3813- equation
3814- failure(_ = List . getMemberOnTrue(i, vars, intEq));
3815- res = incidenceRowExp1(rest,irest,i::vars,b);
3816- then res;
3817- case (BackendDAE . VAR (varKind = BackendDAE . DISCRETE ()) :: rest,i::irest,vars,b)
3818- equation
3819- failure(_ = List . getMemberOnTrue(i, vars, intEq));
3820- res = incidenceRowExp1(rest,irest,i::vars,b);
3821- then res;
3822- case (BackendDAE . VAR (varKind = BackendDAE . DUMMY_DER ()) :: rest,i::irest,vars,b)
3823- equation
3824- failure(_ = List . getMemberOnTrue(i, vars, intEq));
3825- res = incidenceRowExp1(rest,irest,i::vars,b);
3826- then res;
3827- case (BackendDAE . VAR (varKind = BackendDAE . DUMMY_STATE ()) :: rest,i::irest,vars,b)
3828- equation
3829- failure(_ = List . getMemberOnTrue(i, vars, intEq));
3830- res = incidenceRowExp1(rest,irest,i::vars,b);
3831- then res;
3832- case (_ :: rest,_::irest,vars,b)
3833- equation
3834- res = incidenceRowExp1(rest,irest,vars,b);
3835- then res;
3836- end matchcontinue;
3810+ case (BackendDAE . VAR (varKind = BackendDAE . STATE (_)) :: rest,i::irest,_,_)
3811+ equation
3812+ i1 = Util . if_(notinder,- i,i);
3813+ b = List . isMemberOnTrue(i1, inVarIndxLst, intEq);
3814+ vars = List . consOnTrue(not b, i1, inVarIndxLst);
3815+ then incidenceRowExp1(rest,irest,vars,notinder);
3816+ case (BackendDAE . VAR (varKind = BackendDAE . STATE_DER ()) :: rest,i::irest,_,_)
3817+ equation
3818+ b = List . isMemberOnTrue(i, inVarIndxLst, intEq);
3819+ vars = List . consOnTrue(not b, i, inVarIndxLst);
3820+ then incidenceRowExp1(rest,irest,vars,notinder);
3821+ case (BackendDAE . VAR (varKind = BackendDAE . VARIABLE ()) :: rest,i::irest,_,_)
3822+ equation
3823+ b = List . isMemberOnTrue(i, inVarIndxLst, intEq);
3824+ vars = List . consOnTrue(not b, i, inVarIndxLst);
3825+ then incidenceRowExp1(rest,irest,vars,notinder);
3826+ case (BackendDAE . VAR (varKind = BackendDAE . DISCRETE ()) :: rest,i::irest,_,_)
3827+ equation
3828+ b = List . isMemberOnTrue(i, inVarIndxLst, intEq);
3829+ vars = List . consOnTrue(not b, i, inVarIndxLst);
3830+ then incidenceRowExp1(rest,irest,vars,notinder);
3831+ case (BackendDAE . VAR (varKind = BackendDAE . DUMMY_DER ()) :: rest,i::irest,_,_)
3832+ equation
3833+ b = List . isMemberOnTrue(i, inVarIndxLst, intEq);
3834+ vars = List . consOnTrue(not b, i, inVarIndxLst);
3835+ then incidenceRowExp1(rest,irest,vars,notinder);
3836+ case (BackendDAE . VAR (varKind = BackendDAE . DUMMY_STATE ()) :: rest,i::irest,_,_)
3837+ equation
3838+ b = List . isMemberOnTrue(i, inVarIndxLst, intEq);
3839+ vars = List . consOnTrue(not b, i, inVarIndxLst);
3840+ then incidenceRowExp1(rest,irest,vars,notinder);
3841+ case (_ :: rest,_::irest,_,_)
3842+ then incidenceRowExp1(rest,irest,inVarIndxLst,notinder);
3843+ end match;
38373844end incidenceRowExp1;
38383845
38393846public function traversingincidenceRowExpFinderwithInput "
@@ -8374,6 +8381,7 @@ protected
83748381 String strIndexReductionMethod;
83758382algorithm
83768383 allIndexReductionMethods := {(BackendDAETransform . reduceIndexDummyDer,"dummyDerivative" ,IndexReduction . noStateDeselection,"dummyDerivative" ),
8384+ (IndexReduction . pantelidesIndexReduction,"Pantelites" ,IndexReduction . noStateDeselection,"uode" ),
83778385 (IndexReduction . pantelidesIndexReduction,"Pantelites" ,IndexReduction . dynamicStateSelection,"dynamicStateSelection" )};
83788386 strIndexReductionMethod := getIndexReductionMethodString();
83798387 strIndexReductionMethod := Util . getOptionOrDefault(ostrIndexReductionMethod,strIndexReductionMethod);
0 commit comments