@@ -7271,130 +7271,6 @@ algorithm
72717271 // fcall2(Flags.DUMP_EQNINORDER, BackendDump.dumpEqnsSolved, outDAE, "system for jacobians");
72727272end getSolvedSystemforJacobians;
72737273
7274- public function getOptimizesDAEModeSystem
7275- "Run the equation system pipeline."
7276- input BackendDAE . BackendDAE inDAE;
7277- input String fileNamePrefix;
7278- input Option < list< String >> strPreOptModules = NONE ();
7279- input Option < String > strmatchingAlgorithm = NONE ();
7280- input Option < String > strdaeHandler = NONE ();
7281- input Option < list< String >> strPostOptModules = NONE ();
7282- output BackendDAE . BackendDAE outSimDAE;
7283- output BackendDAE . BackendDAE outInitDAE;
7284- output Option < BackendDAE . InlineData > outInlineData;
7285- output list< BackendDAE . Equation > outRemovedInitialEquationLst;
7286- protected
7287- BackendDAE . BackendDAE dae, simDAE;
7288- list< tuple< BackendDAEFunc . optimizationModule, String >> preOptModules;
7289- list< tuple< BackendDAEFunc . optimizationModule, String >> postOptModules;
7290- tuple< BackendDAEFunc . StructurallySingularSystemHandlerFunc , String , BackendDAEFunc . stateDeselectionFunc, String > daeHandler;
7291- tuple< BackendDAEFunc . matchingAlgorithmFunc, String > matchingAlgorithm;
7292- BackendDAE . InlineData inlineData;
7293- BackendDAE . Variables globalKnownVars;
7294- Integer numCheckpoints;
7295- DAE . FunctionTree funcTree;
7296- algorithm
7297- numCheckpoints:= ErrorExt . getNumCheckpoints();
7298- try
7299- StackOverflow . clearStacktraceMessages();
7300- preOptModules := getPreOptModules(strPreOptModules);
7301- postOptModules := getPostOptModules(strPostOptModules);
7302- matchingAlgorithm := getMatchingAlgorithm(strmatchingAlgorithm);
7303- daeHandler := getIndexReductionMethod(strdaeHandler);
7304-
7305- if Flags . isSet(Flags . DUMP_DAE_LOW ) then
7306- BackendDump . dumpBackendDAE(inDAE, "dumpdaelow" );
7307- if Flags . isSet(Flags . ADDITIONAL_GRAPHVIZ_DUMP ) then
7308- BackendDump . graphvizIncidenceMatrix(inDAE, "dumpdaelow" );
7309- end if ;
7310- end if ;
7311-
7312- // pre-optimization phase
7313- dae := preOptimizeDAE(inDAE, preOptModules);
7314-
7315- execStat("pre-optimization done (n=" + String (daeSize(dae))+ ")" );
7316- // transformation phase (matching and sorting using index reduction method)
7317- dae := causalizeDAE(dae, NONE (), matchingAlgorithm, daeHandler, true );
7318- execStat("matching and sorting (n=" + String (daeSize(dae))+ ")" );
7319-
7320- // synchronous features post-phase
7321- dae := SynchronousFeatures . synchronousFeatures(dae);
7322- if Flags . isSet(Flags . OPT_DAE_DUMP ) then
7323- BackendDump . dumpBackendDAE(dae, "synchronousFeatures" );
7324- end if ;
7325-
7326- if Flags . isSet(Flags . GRAPHML ) then
7327- BackendDump . dumpBipartiteGraphDAE(dae, fileNamePrefix);
7328- end if ;
7329-
7330- if Flags . isSet(Flags . BLT_DUMP ) then
7331- BackendDump . bltdump("bltdump" , dae);
7332- end if ;
7333-
7334- if Flags . isSet(Flags . EVAL_OUTPUT_ONLY ) then
7335- // prepare the equations
7336- dae := BackendDAEOptimize . evaluateOutputsOnly(dae);
7337- end if ;
7338-
7339- // generate system for initialization
7340- (outInitDAE, _, outRemovedInitialEquationLst, globalKnownVars) := Initialization . solveInitialSystem(dae);
7341-
7342- // use function tree from initDAE further for simDAE
7343- simDAE := BackendDAEUtil . setFunctionTree(dae, BackendDAEUtil . getFunctions(outInitDAE. shared ));
7344-
7345- // Set updated globalKnownVars
7346- simDAE := setDAEGlobalKnownVars(simDAE, globalKnownVars);
7347-
7348- simDAE := BackendDAEOptimize . addInitialStmtsToAlgorithms(simDAE, false );
7349- simDAE := Initialization . removeInitializationStuff(simDAE);
7350-
7351- // generate inline solver
7352- outInlineData := SymbolicImplicitSolver . symSolver(simDAE);
7353-
7354- // post-optimization phase
7355- simDAE := postOptimizeDAE(simDAE, postOptModules, matchingAlgorithm, daeHandler);
7356-
7357- // sort the globalKnownVars
7358- simDAE := sortGlobalKnownVarsInDAE(simDAE);
7359- execStat("sort global known variables" );
7360-
7361- // remove unused functions
7362- funcTree := BackendDAEOptimize . copyRecordConstructorAndExternalObjConstructorDestructor(BackendDAEUtil . getFunctions(simDAE. shared ));
7363- funcTree := BackendDAEOptimize . removeUnusedFunctions(outInitDAE. eqs, outInitDAE. shared , outRemovedInitialEquationLst, BackendDAEUtil . getFunctions(simDAE. shared ), funcTree);
7364- funcTree := BackendDAEOptimize . removeUnusedFunctions(simDAE. eqs, simDAE. shared , {}, BackendDAEUtil . getFunctions(simDAE. shared ), funcTree);
7365- outSimDAE := BackendDAEUtil . setFunctionTree(simDAE, funcTree);
7366- execStat("remove unused functions" );
7367-
7368- if Flags . isSet(Flags . DUMP_INDX_DAE ) then
7369- BackendDump . dumpBackendDAE(outSimDAE, "dumpindxdae" );
7370- if Flags . isSet(Flags . ADDITIONAL_GRAPHVIZ_DUMP ) then
7371- BackendDump . graphvizBackendDAE(outSimDAE, "dumpindxdae" );
7372- end if ;
7373- end if ;
7374- if Flags . isSet(Flags . DUMP_TRANSFORMED_MODELICA_MODEL ) then
7375- BackendDump . dumpBackendDAEToModelica(outSimDAE, "dumpindxdae" );
7376- end if ;
7377- if Flags . isSet(Flags . DUMP_BACKENDDAE_INFO ) or Flags . isSet(Flags . DUMP_STATESELECTION_INFO ) or Flags . isSet(Flags . DUMP_DISCRETEVARS_INFO ) then
7378- BackendDump . dumpCompShort(outSimDAE);
7379- end if ;
7380- if Flags . isSet(Flags . DUMP_EQNINORDER ) then
7381- BackendDump . dumpEqnsSolved(outSimDAE, "indxdae: eqns in order" );
7382- end if ;
7383- if Flags . isSet(Flags . DUMP_LOOPS ) then
7384- BackendDump . dumpLoops(outSimDAE);
7385- end if ;
7386- checkBackendDAEWithErrorMsg(outSimDAE);
7387- return ;
7388- else
7389- setGlobalRoot(Global . stackoverFlowIndex, NONE ());
7390- ErrorExt . rollbackNumCheckpoints(ErrorExt . getNumCheckpoints()- numCheckpoints);
7391- Error . addInternalError("Stack overflow in " + getInstanceName()+ "... \n " + stringDelimitList(StackOverflow . readableStacktraceMessages(), " \n " ), sourceInfo());
7392- /* Do not fail or we can loop too much */
7393- StackOverflow . clearStacktraceMessages();
7394- end try annotation(__OpenModelica_stackOverflowCheckpoint= true );
7395- fail();
7396- end getOptimizesDAEModeSystem;
7397-
73987274public function sortGlobalKnownVarsInDAE "
73997275author: ptaeuber
74007276This function sorts the globalKnownVars"
0 commit comments