Skip to content

Commit

Permalink
Fix the tally of important events from products
Browse files Browse the repository at this point in the history
The coding bug is in the loop terminator (occurrence != 0),
which should have been a continuator instead.

Closes #206
  • Loading branch information
rakhimov committed Jun 19, 2017
1 parent 995a56d commit 8f36038
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/importance_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ void ImportanceAnalysis::Analyze() noexcept {
this->basic_events();

std::vector<int> occurrences = this->occurrences();
for (int i = 0; i < basic_events.size() && occurrences[i]; ++i) {
for (int i = 0; i < basic_events.size(); ++i) {
if (occurrences[i] == 0)
continue;
const mef::BasicEvent& event = *basic_events[i];
double p_var = event.p();
ImportanceFactors imp{};
Expand Down
18 changes: 18 additions & 0 deletions tests/bench_baobab1_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ TEST_P(RiskAnalysisTest, Baobab1L8) {
EXPECT_EQ(distr, ProductDistribution());
}

TEST_P(RiskAnalysisTest, Baobab1L4Importance) {
std::vector<std::string> input_files = {
"./share/scram/input/Baobab/baobab1.xml",
"./share/scram/input/Baobab/baobab1-basic-events.xml"};
settings.limit_order(4).importance_analysis(true);
ASSERT_NO_THROW(ProcessInputFiles(input_files));
ASSERT_NO_THROW(analysis->Analyze());
EXPECT_EQ(72, products().size());
EXPECT_EQ(40, analysis->results()
.front()
.fault_tree_analysis->products()
.product_events()
.size());
EXPECT_EQ(
40,
analysis->results().front().importance_analysis->importance().size());
}

} // namespace test
} // namespace core
} // namespace scram

0 comments on commit 8f36038

Please sign in to comment.