Skip to content

Commit

Permalink
Generate smaller initialization tearing sets
Browse files Browse the repository at this point in the history
This fixes a bug which causes the initialization tearing set to
be much bigger than needed.

Deactivated for Cpp-runtime, because of failing Cpp models. This
should be fixed.
  • Loading branch information
ptaeuber committed Sep 27, 2016
1 parent 61f5e03 commit 99952ed
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -118,17 +118,27 @@ algorithm
execStat("inlineWhenForInitialization (initialization)");

(dae, initVars, outPrimaryParameters, outAllPrimaryParameters) := selectInitializationVariablesDAE(dae);
//if Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) then
// BackendDump.dumpVariables(initVars, "selected initialization variables");
//end if;
// if Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) then
// BackendDump.dumpVarList(outPrimaryParameters, "selected primary parameters");
// BackendDump.dumpVarList(outAllPrimaryParameters, "selected all primary parameters");
// end if;
execStat("selectInitializationVariablesDAE (initialization)");

hs := collectPreVariables(dae);
execStat("collectPreVariables (initialization)");

// collect vars and eqns for initial system
vars := BackendVariable.emptyVars();
fixvars := BackendVariable.emptyVars();

// If Cpp runtime is used set fixvars to emptyVars because otherwise Cpp testcases fail
// This is wrong and leads to bigger initialization tearing sets than necessary!!!
// To-Do: Fix the problems with the Cpp runtime
if stringEq(Config.simCodeTarget(), "Cpp") then
fixvars := BackendVariable.emptyVars();
else
fixvars := BackendVariable.listVar(outAllPrimaryParameters);
end if;

eqns := BackendEquation.emptyEqns();
reeqns := BackendEquation.emptyEqns();

Expand Down Expand Up @@ -226,6 +236,11 @@ algorithm
outInitDAE_lambda0 := NONE();
end if;

// Remove the globalKnownVars for the initialization set again
if not stringEq(Config.simCodeTarget(), "Cpp") then
initdae.shared := BackendDAEUtil.setSharedGlobalKnownVars(initdae.shared, BackendVariable.emptyVars());
end if;

// warn about selected default initial conditions
b1 := not listEmpty(dumpVars);
b2 := not listEmpty(removedEqns);
Expand Down

0 comments on commit 99952ed

Please sign in to comment.