@@ -5754,7 +5754,7 @@ algorithm
57545754 local Integer diffcount;
57555755 case (BackendDAE . VAR (varKind= BackendDAE . STATE (index= diffcount),values = SOME (DAE . VAR_ATTR_REAL (stateSelectOption = SOME (DAE . ALWAYS ())))),_)
57565756 equation
5757- false = intEq(diffcount,level);
5757+ false = intEq(diffcount,level) or intEq(diffcount, 1 ) ;
57585758 then
57595759 ();
57605760 else then ();
@@ -7512,6 +7512,7 @@ algorithm
75127512 array< Boolean > eqnsflag;
75137513 BackendDAE . EqSystem syst;
75147514 DAE . FunctionTree funcs;
7515+ BackendDAE . StrongComponents comps;
75157516 case (BackendDAE . EQSYSTEM (matching= BackendDAE . NO_MATCHING ()),_,NONE (),_)
75167517 equation
75177518 vars = BackendVariable . daeVars(isyst);
@@ -7544,7 +7545,7 @@ algorithm
75447545 GraphML . dumpGraph(graph,filename);
75457546 then
75467547 ();
7547- case (BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (ass1= vec1,ass2= vec2)),_,NONE (),_)
7548+ case (BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (ass1= vec1,ass2= vec2,comps = {} )),_,NONE (),_)
75487549 equation
75497550 vars = BackendVariable . daeVars(isyst);
75507551 eqns = BackendEquation . daeEqns(isyst);
@@ -7565,7 +7566,7 @@ algorithm
75657566 GraphML . dumpGraph(graph,filename);
75667567 then
75677568 ();
7568- case (BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (ass1= vec1,ass2= vec2)),_,SOME (vec3),_)
7569+ case (BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (ass1= vec1,ass2= vec2,comps = {} )),_,SOME (vec3),_)
75697570 equation
75707571 vars = BackendVariable . daeVars(isyst);
75717572 eqns = BackendEquation . daeEqns(isyst);
@@ -7580,6 +7581,22 @@ algorithm
75807581 GraphML . dumpGraph(graph,filename);
75817582 then
75827583 ();
7584+ case (BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (ass1= vec1,ass2= vec2,comps= comps)),_,NONE (),_)
7585+ equation
7586+ vars = BackendVariable . daeVars(isyst);
7587+ eqns = BackendEquation . daeEqns(isyst);
7588+ funcs = BackendDAEUtil . getFunctions(ishared);
7589+ (_,m,mt) = BackendDAEUtil . getIncidenceMatrix(isyst, BackendDAE . NORMAL (), SOME (funcs));
7590+ graph = GraphML . getGraph("G" ,false );
7591+ // generate a node for each component and get the edges
7592+ vec3 = arrayCreate(arrayLength(mt),-1 );
7593+ graph = addCompsGraph(comps,vars,vec3,1 ,graph);
7594+ // generate edges
7595+ mapIncRowEqn = arrayCreate(arrayLength(mt),-1 );
7596+ graph = addCompsEdgesGraph(comps,m,vec3,1 ,1 ,mapIncRowEqn,1 ,graph);
7597+ GraphML . dumpGraph(graph,filename);
7598+ then
7599+ ();
75837600 end match;
75847601end dumpSystemGraphML;
75857602
@@ -8010,6 +8027,138 @@ algorithm
80108027 end matchcontinue;
80118028end addDirectedNumEdgeGraphEnhanced;
80128029
8030+ protected function addCompsGraph "function: addCompsGraph
8031+ author: Frenkel TUD 2013-02,
8032+ add for each component a node to the graph and strore
8033+ varcomp[var] = comp."
8034+ input BackendDAE . StrongComponents iComps;
8035+ input BackendDAE . Variables vars;
8036+ input array< Integer > varcomp;
8037+ input Integer iN;
8038+ input GraphML . Graph iGraph;
8039+ output GraphML . Graph oGraph;
8040+ algorithm
8041+ oGraph := match(iComps,vars,varcomp,iN,iGraph)
8042+ local
8043+ BackendDAE . StrongComponents rest;
8044+ BackendDAE . StrongComponent comp;
8045+ list< Integer > vlst;
8046+ GraphML . Graph graph;
8047+ array< Integer > varcomp1;
8048+ String text;
8049+ list< BackendDAE . Var > varlst;
8050+ case ({},_,_,_,_) then iGraph;
8051+ case (comp::rest,_,_,_,_)
8052+ equation
8053+ (_,vlst) = BackendDAETransform . getEquationAndSolvedVarIndxes(comp);
8054+ varcomp1 = List . fold1r(vlst,arrayUpdate,iN,varcomp);
8055+ varlst = List . map1r(vlst,BackendVariable . getVarAt,vars);
8056+ text = intString(iN) +& ":" +& stringDelimitList(List . map(List . map(varlst,BackendVariable . varCref),ComponentReference . printComponentRefStr)," \n " );
8057+ graph = GraphML . addNode("n" +& intString(iN),text,GraphML . COLOR_GREEN ,GraphML . RECTANGLE (),iGraph);
8058+ then
8059+ addCompsGraph(rest,vars,varcomp1,iN+ 1 ,graph);
8060+ end match;
8061+ end addCompsGraph;
8062+
8063+ protected function addCompsEdgesGraph "function: addCompsEdgesGraph
8064+ author: Frenkel TUD 2013-02,
8065+ add for each component the edges to the graph."
8066+ input BackendDAE . StrongComponents iComps;
8067+ input BackendDAE . IncidenceMatrix m;
8068+ input array< Integer > varcomp;
8069+ input Integer iN;
8070+ input Integer id;
8071+ input array< Integer > markarray;
8072+ input Integer mark;
8073+ input GraphML . Graph iGraph;
8074+ output GraphML . Graph oGraph;
8075+ algorithm
8076+ oGraph := match(iComps,m,varcomp,iN,id,markarray,mark,iGraph)
8077+ local
8078+ BackendDAE . StrongComponents rest;
8079+ BackendDAE . StrongComponent comp;
8080+ list< Integer > elst,vlst,usedvlst;
8081+ Integer n;
8082+ GraphML . Graph graph;
8083+ case ({},_,_,_,_,_,_,_) then iGraph;
8084+ case (comp::rest,_,_,_,_,_,_,_)
8085+ equation
8086+ // get eqns and vars of comps
8087+ (elst,vlst) = BackendDAETransform . getEquationAndSolvedVarIndxes(comp);
8088+ // get used vars of comp
8089+ _ = List . fold1r(vlst,arrayUpdate,mark,markarray) "set assigned visited" ;
8090+ vlst = getUsedVarsComp(elst,m,markarray,mark,{});
8091+ (n,graph) = addCompEdgesGraph(vlst,varcomp,markarray,mark+ 1 ,iN,id,iGraph);
8092+ then
8093+ addCompsEdgesGraph(rest,m,varcomp,iN+ 1 ,n,markarray,mark+ 2 ,graph);
8094+ end match;
8095+ end addCompsEdgesGraph;
8096+
8097+ protected function getUsedVarsComp "function: getUsedVarsComp
8098+ author: Frenkel TUD 2013-02,
8099+ get all used var of the comp."
8100+ input list< Integer > iEqns;
8101+ input BackendDAE . IncidenceMatrix m;
8102+ input array< Integer > markarray;
8103+ input Integer mark;
8104+ input list< Integer > iVars;
8105+ output list< Integer > oVars;
8106+ algorithm
8107+ oVars := match(iEqns,m,markarray,mark,iVars)
8108+ local
8109+ list< Integer > rest,vlst;
8110+ Integer e;
8111+ case ({},_,_,_,_) then iVars;
8112+ case (e::rest,_,_,_,_)
8113+ equation
8114+ vlst = List . select1(m[e], intGt, 0 );
8115+ vlst = List . select1r(vlst, isUnMarked, (markarray,mark));
8116+ _ = List . fold1r(vlst,arrayUpdate,mark,markarray) "set visited" ;
8117+ vlst = listAppend(vlst,iVars);
8118+ then
8119+ getUsedVarsComp(rest,m,markarray,mark,vlst);
8120+ end match;
8121+ end getUsedVarsComp;
8122+
8123+ protected function addCompEdgesGraph "function: addCompEdgesGraph
8124+ author: Frenkel TUD 2013-02,
8125+ add for eqach used var of the comp an edge."
8126+ input list< Integer > iVars;
8127+ input array< Integer > varcomp;
8128+ input array< Integer > markarray;
8129+ input Integer mark;
8130+ input Integer iN;
8131+ input Integer id;
8132+ input GraphML . Graph iGraph;
8133+ output Integer oN;
8134+ output GraphML . Graph oGraph;
8135+ algorithm
8136+ (oN,oGraph) := matchcontinue(iVars,varcomp,markarray,mark,iN,id,iGraph)
8137+ local
8138+ list< Integer > rest;
8139+ Integer v,n,c;
8140+ GraphML . Graph graph;
8141+ String text;
8142+ Option < GraphML . EdgeLabel > label ;
8143+ case ({},_,_,_,_,_,_) then (iN,iGraph);
8144+ case (v::rest,_,_,_,_,_,_)
8145+ equation
8146+ c = varcomp[v];
8147+ false = intEq(markarray[c],mark);
8148+ _ = arrayUpdate(markarray,c,mark);
8149+ graph = GraphML . addEgde("e" +& intString(id),"n" +& intString(c),"n" +& intString(iN),GraphML . COLOR_BLACK ,GraphML . LINE (),NONE (),(SOME (GraphML . ARROWSTANDART ()),NONE ()),iGraph);
8150+ (n,graph) = addCompEdgesGraph(rest,varcomp,markarray,mark,iN,id+ 1 ,graph);
8151+ then
8152+ (n,graph);
8153+ case (v::rest,_,_,_,_,_,_)
8154+ equation
8155+ (n,graph) = addCompEdgesGraph(rest,varcomp,markarray,mark,iN,id,iGraph);
8156+ then
8157+ (n,graph);
8158+ end matchcontinue;
8159+ end addCompEdgesGraph;
8160+
8161+
80138162protected function solvabilityWights "function: solvabilityWights
80148163 author: Frenkel TUD 2012-05,
80158164 return a integer for the solvability, this function is used
0 commit comments