Skip to content

Commit

Permalink
[BE] implement max size for assc
Browse files Browse the repository at this point in the history
 - implement user flag --maxSizeASSC=
 - ticket #5952
  • Loading branch information
kabdelhak authored and adrpo committed May 12, 2020
1 parent 08f00f9 commit 8f7933f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
44 changes: 23 additions & 21 deletions OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -8103,30 +8103,32 @@ algorithm
loopVars := (BackendVariable.getVarAt(syst.orderedVars, ass1[eqnIndex]), ass1[eqnIndex]) :: loopVars;
end for;

try
/* generate linear integer sub jacobian from system */
linIntJac := SymbolicJacobian.generateLinearIntegerJacobian(loopEqs, loopVars, ass1);

if not SymbolicJacobian.emptyOrSingleLinearIntegerJacobian(linIntJac) then
if Flags.isSet(Flags.DUMP_ASSC) then
BackendDump.dumpLinearIntegerJacobianSparse(linIntJac, "Original");
end if;
if listLength(loopEqs) <= Flags.getConfigInt(Flags.MAX_SIZE_ASSC) then
try
/* generate linear integer sub jacobian from system */
linIntJac := SymbolicJacobian.generateLinearIntegerJacobian(loopEqs, loopVars, ass1);

if not SymbolicJacobian.emptyOrSingleLinearIntegerJacobian(linIntJac) then
if Flags.isSet(Flags.DUMP_ASSC) then
BackendDump.dumpLinearIntegerJacobianSparse(linIntJac, "Original");
end if;

/* solve jacobian with gaussian elimination */
linIntJac := SymbolicJacobian.solveLinearIntegerJacobian(linIntJac);
if Flags.isSet(Flags.DUMP_ASSC) then
BackendDump.dumpLinearIntegerJacobianSparse(linIntJac, "Solved");
end if;
/* solve jacobian with gaussian elimination */
linIntJac := SymbolicJacobian.solveLinearIntegerJacobian(linIntJac);
if Flags.isSet(Flags.DUMP_ASSC) then
BackendDump.dumpLinearIntegerJacobianSparse(linIntJac, "Solved");
end if;

/* set changed to true if it was true before, or any row changed in the jacobian */
changed := changed or SymbolicJacobian.anyRowChanged(linIntJac);
/* set changed to true if it was true before, or any row changed in the jacobian */
changed := changed or SymbolicJacobian.anyRowChanged(linIntJac);

/* resolve zero rows to new equations and update assignments / adjacency matrix */
(ass1, ass2, syst) := SymbolicJacobian.resolveAnalyticalSingularities(linIntJac, ass1, ass2, syst);
end if;
else
/* possibly fails if jacobian is empty --- nothing to do */
end try;
/* resolve zero rows to new equations and update assignments / adjacency matrix */
(ass1, ass2, syst) := SymbolicJacobian.resolveAnalyticalSingularities(linIntJac, ass1, ass2, syst);
end if;
else
/* possibly fails if jacobian is empty --- nothing to do */
end try;
end if;
end if;
end analyticalToStructuralSingularity;

Expand Down
21 changes: 12 additions & 9 deletions OMCompiler/Compiler/Util/Flags.mo
Expand Up @@ -1313,36 +1313,39 @@ constant ConfigFlag NO_ASSC = CONFIG_FLAG(131, "noASSC",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Gettext.gettext("Disables analytical to structural singularity conversion."));


constant ConfigFlag FULL_ASSC = CONFIG_FLAG(132, "fullASSC",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Gettext.gettext("Enables full equation replacement for BLT transformation from the ASSC algorithm."));

constant ConfigFlag USE_ZEROMQ_IN_SIM = CONFIG_FLAG(133, "useZeroMQInSim",
constant ConfigFlag MAX_SIZE_ASSC = CONFIG_FLAG(133, "maxSizeASSC",
NONE(), EXTERNAL(), INT_FLAG(200), NONE(),
Gettext.gettext("Sets the maximum system size for the analytical to structural conversion algorithm (default 200)."));

constant ConfigFlag USE_ZEROMQ_IN_SIM = CONFIG_FLAG(134, "useZeroMQInSim",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Gettext.gettext("Configures to use zeroMQ in simulation runtime to exchange information via ZeroMQ with other applications"));

constant ConfigFlag ZEROMQ_PUB_PORT = CONFIG_FLAG(134, "zeroMQPubPort",
constant ConfigFlag ZEROMQ_PUB_PORT = CONFIG_FLAG(135, "zeroMQPubPort",
NONE(), EXTERNAL(), INT_FLAG(3203), NONE(),
Gettext.gettext("Configures port number for simulation runtime to send information via ZeroMQ"));

constant ConfigFlag ZEROMQ_SUB_PORT = CONFIG_FLAG(135, "zeroMQSubPort",
constant ConfigFlag ZEROMQ_SUB_PORT = CONFIG_FLAG(136, "zeroMQSubPort",
NONE(), EXTERNAL(), INT_FLAG(3204), NONE(),
Gettext.gettext("Configures port number for simulation runtime to receive information via ZeroMQ"));

constant ConfigFlag ZEROMQ_JOB_ID = CONFIG_FLAG(136, "zeroMQJOBID",
constant ConfigFlag ZEROMQ_JOB_ID = CONFIG_FLAG(137, "zeroMQJOBID",
NONE(), EXTERNAL(), STRING_FLAG("empty"), NONE(),
Gettext.gettext("Configures the ID with which the omc api call is labelled for zeroMQ communication."));
constant ConfigFlag ZEROMQ_SERVER_ID = CONFIG_FLAG(137, "zeroMQServerID",
constant ConfigFlag ZEROMQ_SERVER_ID = CONFIG_FLAG(138, "zeroMQServerID",
NONE(), EXTERNAL(), STRING_FLAG("empty"), NONE(),
Gettext.gettext("Configures the ID with which server application is labelled for zeroMQ communication."));
constant ConfigFlag ZEROMQ_CLIENT_ID = CONFIG_FLAG(138, "zeroMQClientID",
constant ConfigFlag ZEROMQ_CLIENT_ID = CONFIG_FLAG(139, "zeroMQClientID",
NONE(), EXTERNAL(), STRING_FLAG("empty"), NONE(),
Gettext.gettext("Configures the ID with which the client application is labelled for zeroMQ communication."));
constant ConfigFlag FMI_VERSION = CONFIG_FLAG(139,
constant ConfigFlag FMI_VERSION = CONFIG_FLAG(140,
"", NONE(), INTERNAL(), STRING_FLAG(""), NONE(),
Gettext.gettext("returns the FMI Version either 1.0 or 2.0."));
constant ConfigFlag FLAT_MODELICA = CONFIG_FLAG(140, "flatModelica",
constant ConfigFlag FLAT_MODELICA = CONFIG_FLAG(141, "flatModelica",
SOME("f"), EXTERNAL(), BOOL_FLAG(false), NONE(),
Gettext.gettext("Outputs experimental flat Modelica."));

Expand Down
1 change: 1 addition & 0 deletions OMCompiler/Compiler/Util/FlagsUtil.mo
Expand Up @@ -390,6 +390,7 @@ constant list<Flags.ConfigFlag> allConfigFlags = {
Flags.LINEARIZATION_DUMP_LANGUAGE,
Flags.NO_ASSC,
Flags.FULL_ASSC,
Flags.MAX_SIZE_ASSC,
Flags.USE_ZEROMQ_IN_SIM,
Flags.ZEROMQ_PUB_PORT,
Flags.ZEROMQ_SUB_PORT,
Expand Down

0 comments on commit 8f7933f

Please sign in to comment.