Skip to content

Commit

Permalink
Improve notification for alg loops (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Feb 23, 2022
1 parent 4a5d026 commit cbeadae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
25 changes: 19 additions & 6 deletions src/OMSimulatorLib/DirectedGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
#include "Util.h"
#include "Variable.h"

#include <iostream>
#include <string>
#include <algorithm>
#include <deque>
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <stdlib.h>
#include <stack>
#include <algorithm>
#include <deque>
#include <stdlib.h>
#include <string>

oms::DirectedGraph::DirectedGraph()
{
Expand Down Expand Up @@ -255,24 +256,36 @@ void oms::DirectedGraph::calculateSortedConnections()
std::deque< std::vector<int> > components = getSCCs();
oms_ssc_t SCC;
sortedConnections.clear();
std::set<std::string> component_names;

for (int i = 0; i < components.size(); ++i)
{
SCC.clear();
component_names.clear();
for (int j = 0; j < components[i].size(); ++j)
{
Connector conA = nodes[edges[components[i][j]].first];
Connector conB = nodes[edges[components[i][j]].second];

if (oms::Connection::isValid(conA.getName(), conB.getName(), conA, conB))
{
SCC.push_back(std::pair<int, int>(edges[components[i][j]]));
component_names.insert(conA.getOwner());
component_names.insert(conB.getOwner());
}
}

if (SCC.size() > 0)
sortedConnections.push_back(SCC);

if (SCC.size() > 1)
logWarning("Alg. loop (size " + std::to_string(SCC.size()) + ")");
{
std::stringstream ss;
ss << "Alg. loop (size " << SCC.size() << ")" << std::endl;
for (const auto& name: component_names)
ss << " " << name << std::endl;
logInfo(ss.str());
}
}

sortedConnectionsAreValid = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,17 @@ end
-- warning: [eCS_Generic_Export: resources/0006_eCS_Generic_Export.fmu] The dependencies of the initial unknowns defined in the FMU are ignored because the flag --ignoreInitialUnknowns is active. Instead, all the initial unknowns will depend on all inputs.
-- warning: [eCS_SW: resources/0007_eCS_SW.fmu] The dependencies of the initial unknowns defined in the FMU are ignored because the flag --ignoreInitialUnknowns is active. Instead, all the initial unknowns will depend on all inputs.
-- warning: [engine: resources/0008_engine.fmu] The dependencies of the initial unknowns defined in the FMU are ignored because the flag --ignoreInitialUnknowns is active. Instead, all the initial unknowns will depend on all inputs.
-- warning: Alg. loop (size 80)
-- info: Alg. loop (size 80)
-- AircraftVehicleDemonstrator.root.cockpit
-- AircraftVehicleDemonstrator.root.consumer_A
-- AircraftVehicleDemonstrator.root.consumer_B
-- AircraftVehicleDemonstrator.root.eCS_Generic_Export
-- AircraftVehicleDemonstrator.root.eCS_SW
-- AircraftVehicleDemonstrator.root.engine
-- info: Result file: AircraftVehicleDemonstrator_res.mat (bufferSize=10)
-- info: AircraftVehicleDemonstrator.root.engine.pB.p is equal
-- info: AircraftVehicleDemonstrator.root.eCS_Generic_Export.Meas_PACK_TEMP is equal
-- info: AircraftVehicleDemonstrator.root.eCS_Generic_Export.Meas_PACK_PRESS is equal
-- info: 7 warnings
-- info: 6 warnings
-- info: 0 errors
-- endResult
6 changes: 3 additions & 3 deletions testsuite/simulation/equationPair.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
model.delete()

## Result:
## warning: Alg. loop (size 2)
## info: Alg. loop (size 2)
## equationPair.root.equation1
## equationPair.root.equation2
## info: iteration 1
## inputs:
## equation2.x2: 8.4
Expand Down Expand Up @@ -128,6 +130,4 @@
## info: No result file will be created
## x1: 4.5572 (res: 7.54e-13)
## x1: 0.0928 (res: -4.45e-05)
## info: 1 warnings
## info: 0 errors
## endResult

0 comments on commit cbeadae

Please sign in to comment.