Changeset 1a8d2923 in OpenModelica
- Timestamp:
- 2021-04-15T09:16:04+02:00 (3 years ago)
- Parents:
- 549d184
- git-author:
- Karim Abdelhak <karim.abdelhak@…> (04/14/21 14:49:18)
- git-committer:
- Karim Abdelhak <karim.abdelhak@…> (04/15/21 09:16:04)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/BackEnd/Matching.mo
r549d184 r1a8d2923 5637 5637 syst := isyst; 5638 5638 5639 /* check if index type is solvable and is unprocessed and if index reduction is activated */5640 if (not Flags.getConfigBool(Flags.NO_ASSC)) and BackendDAEUtil.hasIndexTypeSolvableAndUnprocessedScalar(syst) and BackendDAEUtil.doIndexReduction(inMatchingOptions) then5641 /* set the system to processed so that it gets analyzed only once */5642 syst := BackendDAEUtil.setAnalyticalToStructuralProcessed(syst, true);5643 5644 // ###### PHASE I:5645 // analyze the structural singular subset for additional5646 // analytical singularities and apply ASSC5647 unmatched_eqs := getUnassigned(ne, ass1_1, {});5648 meqns1 := getEqnsforIndexReduction(unmatched_eqs,ne,m,mt,ass1_1,ass2_1,inArg);5649 5650 for set in meqns1 loop5651 (ass1_1, ass2_1, syst, changed) := BackendDAEUtil.analyticalToStructuralSingularity(set, ass1_1, ass2_1, syst, changed, true);5652 end for;5653 5654 // ###### PHASE II:5655 // analyze the strong components for5656 // analytical singularities and apply ASSC5657 (_, m1, _, _, _) := BackendDAEUtil.getAdjacencyMatrixScalar(isyst, BackendDAE.NORMAL(), NONE(), BackendDAEUtil.isInitializationDAE(ishared));5658 comps := Sorting.Tarjan(m1, ass2_1);5659 5660 for comp in comps loop5661 (ass1_1, ass2_1, syst, changed) := BackendDAEUtil.analyticalToStructuralSingularity(comp, ass1_1, ass2_1, syst, changed, false);5662 end for;5663 5664 /* only do matching again if anything has changed */5665 if changed then5666 BackendDAEEXT.setAssignment(nv,ne,ass1_1,ass2_1);5667 BackendDAE.EQSYSTEM(m=SOME(m),mT=SOME(mt)) := syst;5668 matchingExternalsetAdjacencyMatrix(nv,ne,m);5669 /* Call with clearMatching = 0 to reuse old information */5670 BackendDAEEXT.matching(nv,ne,algIndx,cheapMatching,1.0,0);5671 BackendDAEEXT.getAssignment(ass1_1,ass2_1);5672 end if;5673 end if;5674 5639 5675 5640 /* get unmatched equations for index reduction */ 5676 5641 unmatched_eqs := getUnassigned(ne, ass1_1, {}); 5677 5678 if Flags.isSet(Flags.BLT_DUMP) and Flags.isSet(Flags.GRAPHML) then BackendDump.dumpBipartiteGraphEqSystem(isyst, ishared, "BeforMatching_"+intString(arrayLength(m))+"_unmatched "+intString(listLength(unmatched_eqs))); end if;5679 if Flags.isSet(Flags.BLT_DUMP) and listLength(unmatched_eqs) > 0 then print("unmatched equations: "+stringDelimitList(List.map(unmatched_eqs,intString),", ")+"\n\n"); end if;5680 5642 5681 5643 /* … … 5691 5653 5692 5654 meqns1 := getEqnsforIndexReduction(unmatched_eqs,ne,m1,m1t,ass1_1,ass2_1,inArg); 5655 5656 /* check if index type is solvable and is unprocessed and if index reduction is activated */ 5657 if (not Flags.getConfigBool(Flags.NO_ASSC)) and BackendDAEUtil.hasIndexTypeSolvableAndUnprocessedScalar(syst) and BackendDAEUtil.doIndexReduction(inMatchingOptions) then 5658 /* set the system to processed so that it gets analyzed only once */ 5659 syst := BackendDAEUtil.setAnalyticalToStructuralProcessed(syst, true); 5660 5661 // ###### PHASE I ASSC: 5662 // analyze the structural singular subset for additional 5663 // analytical singularities and apply ASSC 5664 for set in meqns1 loop 5665 (ass1_1, ass2_1, syst, changed) := BackendDAEUtil.analyticalToStructuralSingularity(set, ass1_1, ass2_1, syst, changed, true); 5666 end for; 5667 5668 // ###### PHASE II ASSC: 5669 // analyze the strong components for 5670 // analytical singularities and apply ASSC 5671 (_, m1, _, _, _) := BackendDAEUtil.getAdjacencyMatrixScalar(isyst, BackendDAE.NORMAL(), NONE(), BackendDAEUtil.isInitializationDAE(ishared)); 5672 comps := Sorting.Tarjan(m1, ass2_1); 5673 5674 for comp in comps loop 5675 (ass1_1, ass2_1, syst, changed) := BackendDAEUtil.analyticalToStructuralSingularity(comp, ass1_1, ass2_1, syst, changed, false); 5676 end for; 5677 5678 /* only do matching again if anything has changed */ 5679 if changed then 5680 BackendDAEEXT.setAssignment(nv,ne,ass1_1,ass2_1); 5681 BackendDAE.EQSYSTEM(m=SOME(m),mT=SOME(mt)) := syst; 5682 matchingExternalsetAdjacencyMatrix(nv,ne,m); 5683 /* Call with clearMatching = 0 to reuse old information */ 5684 BackendDAEEXT.matching(nv,ne,algIndx,cheapMatching,1.0,0); 5685 BackendDAEEXT.getAssignment(ass1_1,ass2_1); 5686 5687 // recompute MSSS 5688 unmatched_eqs := getUnassigned(ne, ass1_1, {}); 5689 m1 := arrayCopy(m); 5690 m1t := arrayCopy(mt); 5691 (m1,m1t) := removeEdgesForNoDerivativeFunctionInputs(m1,m1t,syst,ishared); 5692 (m1,m1t) := removeEdgesToDiscreteEquations(m1,m1t,syst,ishared); 5693 meqns1 := getEqnsforIndexReduction(unmatched_eqs,ne,m1,m1t,ass1_1,ass2_1,inArg); 5694 end if; 5695 end if; 5696 5697 if Flags.isSet(Flags.BLT_DUMP) and Flags.isSet(Flags.GRAPHML) then BackendDump.dumpBipartiteGraphEqSystem(isyst, ishared, "BeforMatching_"+intString(arrayLength(m))+"_unmatched "+intString(listLength(unmatched_eqs))); end if; 5698 if Flags.isSet(Flags.BLT_DUMP) and listLength(unmatched_eqs) > 0 then print("unmatched equations: "+stringDelimitList(List.map(unmatched_eqs,intString),", ")+"\n\n"); end if; 5699 5693 5700 /* 5694 5701 ----------------------------------------- … … 5707 5714 end if; 5708 5715 5709 //Debug information5710 //if listLength(List.flatten(meqns1)) >= 5 then meqs_short = List.firstN(List.flatten(meqns1),5); else meqs_short = List.flatten(meqns1); end if;5711 //BackendDump.dumpBipartiteGraphEqSystem(isyst,ishared,"MSSS_"+stringDelimitList(List.map(meqs_short,intString),"_"));5712 5716 (ass1_1,ass2_1,syst,shared,arg) := matchingExternal(meqns1,true,algIndx,-1,0,syst,ishared,nv,ne,ass1_1,ass2_1,inMatchingOptions,sssHandler,inArg); 5713 5717 then
Note: See TracChangeset
for help on using the changeset viewer.