From 4c1958c2453278ace0a4406db7c95f097df9d456 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Tue, 22 Oct 2019 11:19:54 +0200 Subject: [PATCH] Fixed some compiler warnings --- src/storm-pars-cli/storm-pars.cpp | 3 +-- src/storm-pars/analysis/AssumptionChecker.cpp | 2 +- src/storm-pars/analysis/MonotonicityChecker.cpp | 6 +++--- src/storm-pars/analysis/Order.cpp | 12 ++++-------- src/storm-pars/analysis/OrderExtender.cpp | 10 +++------- .../analysis/AssumptionCheckerTest.cpp | 16 ++++++++-------- .../analysis/MonotonicityCheckerTest.cpp | 8 ++++---- .../storm-pars/analysis/OrderExtenderTest.cpp | 6 +++--- 8 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/storm-pars-cli/storm-pars.cpp b/src/storm-pars-cli/storm-pars.cpp index c2679770d..75dba4492 100644 --- a/src/storm-pars-cli/storm-pars.cpp +++ b/src/storm-pars-cli/storm-pars.cpp @@ -679,10 +679,9 @@ namespace storm { storm::storage::BitVector selectedStates(matrix.getRowCount()); storm::storage::BitVector selfLoopStates(matrix.getRowCount()); - for (auto i = 0; i < decomposition.size(); ++i) { + for (size_t i = 0; i < decomposition.size(); ++i) { auto scc = decomposition.getBlock(i); if (scc.size() > 1) { - auto nrInitial = 0; auto statesScc = scc.getStates(); std::vector entryStates; for (auto state : statesScc) { diff --git a/src/storm-pars/analysis/AssumptionChecker.cpp b/src/storm-pars/analysis/AssumptionChecker.cpp index e90b8e913..fce4596ab 100644 --- a/src/storm-pars/analysis/AssumptionChecker.cpp +++ b/src/storm-pars/analysis/AssumptionChecker.cpp @@ -30,7 +30,7 @@ namespace storm { auto matrix = model->getTransitionMatrix(); std::set::type> variables = models::sparse::getProbabilityParameters(*model); - for (auto i = 0; i < numberOfSamples; ++i) { + for (uint_fast64_t i = 0; i < numberOfSamples; ++i) { auto valuation = utility::parametric::Valuation(); for (auto var: variables) { auto lb = region.getLowerBoundary(var.name()); diff --git a/src/storm-pars/analysis/MonotonicityChecker.cpp b/src/storm-pars/analysis/MonotonicityChecker.cpp index 62bbc02e2..c53609220 100644 --- a/src/storm-pars/analysis/MonotonicityChecker.cpp +++ b/src/storm-pars/analysis/MonotonicityChecker.cpp @@ -104,7 +104,7 @@ namespace storm { } } else { - auto i = 0; + size_t i = 0; for (auto itr = map.begin(); i < map.size() && itr != map.end(); ++itr) { auto order = itr->first; @@ -553,7 +553,7 @@ namespace storm { // Check monotonicity in variable (*itr) by instantiating the model // all other variables fixed on lb, only increasing (*itr) - for (auto i = 0; (monDecr || monIncr) && i < numberOfSamples; ++i) { + for (uint_fast64_t i = 0; (monDecr || monIncr) && i < numberOfSamples; ++i) { // Create valuation auto valuation = storm::utility::parametric::Valuation(); for (auto itr2 = variables.begin(); itr2 != variables.end(); ++itr2) { @@ -629,7 +629,7 @@ namespace storm { bool monDecr = true; bool monIncr = true; - for (auto i = 0; i < numberOfSamples; ++i) { + for (uint_fast64_t i = 0; i < numberOfSamples; ++i) { auto valuation = storm::utility::parametric::Valuation(); for (auto itr2 = variables.begin(); itr2 != variables.end(); ++itr2) { // Only change value for current variable diff --git a/src/storm-pars/analysis/Order.cpp b/src/storm-pars/analysis/Order.cpp index 3c16f750f..350cffa29 100644 --- a/src/storm-pars/analysis/Order.cpp +++ b/src/storm-pars/analysis/Order.cpp @@ -231,14 +231,14 @@ namespace storm { } std::vector Order::sortStates(storm::storage::BitVector* states) { - auto numberOfSetBits = states->getNumberOfSetBits(); + uint_fast64_t numberOfSetBits = states->getNumberOfSetBits(); auto stateSize = states->size(); auto result = std::vector(numberOfSetBits, stateSize); for (auto state : *states) { if (result[0] == stateSize) { result[0] = state; } else { - auto i = 0; + uint_fast64_t i = 0; bool added = false; while (i < numberOfSetBits && !added) { if (result[i] == stateSize) { @@ -249,7 +249,7 @@ namespace storm { if (compareRes == ABOVE) { auto temp = result[i]; result[i] = state; - for (auto j = i + 1; j < numberOfSetBits && result[j + 1] != stateSize; j++) { + for (uint_fast64_t j = i + 1; j < numberOfSetBits && result[j + 1] != stateSize; j++) { auto temp2 = result[j]; result[j] = temp; temp = temp2; @@ -261,7 +261,7 @@ namespace storm { ++i; auto temp = result[i]; result[i] = state; - for (auto j = i + 1; j < numberOfSetBits && result[j + 1] != stateSize; j++) { + for (uint_fast64_t j = i + 1; j < numberOfSetBits && result[j + 1] != stateSize; j++) { auto temp2 = result[j]; result[j] = temp; temp = temp2; @@ -277,10 +277,6 @@ namespace storm { return result; } - void Order::toString(std::ostream &out) { - - } - bool Order::above(Node *node1, Node *node2) { bool found = false; for (auto const& state : node1->states) { diff --git a/src/storm-pars/analysis/OrderExtender.cpp b/src/storm-pars/analysis/OrderExtender.cpp index d9f109777..636dd8913 100644 --- a/src/storm-pars/analysis/OrderExtender.cpp +++ b/src/storm-pars/analysis/OrderExtender.cpp @@ -53,7 +53,7 @@ namespace storm { storm::storage::StronglyConnectedComponentDecompositionOptions const options; this->sccs = storm::storage::StronglyConnectedComponentDecomposition(matrix, options); acyclic = true; - for (auto i = 0; acyclic && i < sccs.size(); ++i) { + for (size_t i = 0; acyclic && i < sccs.size(); ++i) { acyclic &= sccs.getBlock(i).size() <= 1; } } @@ -91,13 +91,9 @@ namespace storm { auto matrix = this->model->getTransitionMatrix(); auto initialMiddleStates = storm::storage::BitVector(numberOfStates); - // Check if MC contains cycles - storm::storage::StronglyConnectedComponentDecompositionOptions const options; - - // Create the Order - + // Add possible cycle breaking states if (!acyclic) { - for (auto i = 0; i < sccs.size(); ++i) { + for (size_t i = 0; i < sccs.size(); ++i) { auto scc = sccs.getBlock(i); if (scc.size() > 1) { auto states = scc.getStates(); diff --git a/src/test/storm-pars/analysis/AssumptionCheckerTest.cpp b/src/test/storm-pars/analysis/AssumptionCheckerTest.cpp index e08e4287e..fd5e31a85 100644 --- a/src/test/storm-pars/analysis/AssumptionCheckerTest.cpp +++ b/src/test/storm-pars/analysis/AssumptionCheckerTest.cpp @@ -131,8 +131,8 @@ TEST(AssumptionCheckerTest, Simple1) { model = simplifier.getSimplifiedModel(); dtmc = model->as>(); - ASSERT_EQ(dtmc->getNumberOfStates(), 5); - ASSERT_EQ(dtmc->getNumberOfTransitions(), 8); + ASSERT_EQ(dtmc->getNumberOfStates(), 5ul); + ASSERT_EQ(dtmc->getNumberOfTransitions(), 8ul); // Create the region auto vars = storm::models::sparse::getProbabilityParameters(*dtmc); @@ -183,8 +183,8 @@ TEST(AssumptionCheckerTest, Simple2) { model = simplifier.getSimplifiedModel(); dtmc = model->as>(); - ASSERT_EQ(dtmc->getNumberOfStates(), 5); - ASSERT_EQ(dtmc->getNumberOfTransitions(), 8); + ASSERT_EQ(dtmc->getNumberOfStates(), 5ul); + ASSERT_EQ(dtmc->getNumberOfTransitions(), 8ul); // Create the region auto vars = storm::models::sparse::getProbabilityParameters(*dtmc); @@ -249,8 +249,8 @@ TEST(AssumptionCheckerTest, Simple3) { model = simplifier.getSimplifiedModel(); dtmc = model->as>(); - ASSERT_EQ(6, dtmc->getNumberOfStates()); - ASSERT_EQ(12, dtmc->getNumberOfTransitions()); + ASSERT_EQ(6ul, dtmc->getNumberOfStates()); + ASSERT_EQ(12ul, dtmc->getNumberOfTransitions()); // Create the region auto vars = storm::models::sparse::getProbabilityParameters(*dtmc); @@ -318,8 +318,8 @@ TEST(AssumptionCheckerTest, Simple4) { model = simplifier.getSimplifiedModel(); dtmc = model->as>(); - ASSERT_EQ(dtmc->getNumberOfStates(), 5); - ASSERT_EQ(dtmc->getNumberOfTransitions(), 8); + ASSERT_EQ(dtmc->getNumberOfStates(), 5ul); + ASSERT_EQ(dtmc->getNumberOfTransitions(), 8ul); // Create the region auto vars = storm::models::sparse::getProbabilityParameters(*dtmc); diff --git a/src/test/storm-pars/analysis/MonotonicityCheckerTest.cpp b/src/test/storm-pars/analysis/MonotonicityCheckerTest.cpp index 3f1afd50c..c83d436b4 100644 --- a/src/test/storm-pars/analysis/MonotonicityCheckerTest.cpp +++ b/src/test/storm-pars/analysis/MonotonicityCheckerTest.cpp @@ -150,8 +150,8 @@ std::vector> regions = storm::analysis::MonotonicityChecker monotonicityChecker = storm::analysis::MonotonicityChecker(dtmc, formulas, regions, true); auto result = monotonicityChecker.checkMonotonicity(); - EXPECT_EQ(1, result.size()); - EXPECT_EQ(2, result.begin()->second.size()); + EXPECT_EQ(1ul, result.size()); + EXPECT_EQ(2ul, result.begin()->second.size()); auto monotone = result.begin()->second.begin(); EXPECT_EQ(true, monotone->second.first); EXPECT_EQ(false, monotone->second.second); @@ -198,8 +198,8 @@ TEST(MonotonicityCheckerTest, Brp_with_bisimulation_samples) { auto monotonicityChecker = storm::analysis::MonotonicityChecker(dtmc, formulas, regions, true, 50); auto result = monotonicityChecker.checkMonotonicity(); - EXPECT_EQ(1, result.size()); - EXPECT_EQ(2, result.begin()->second.size()); + EXPECT_EQ(1ul, result.size()); + EXPECT_EQ(2ul, result.begin()->second.size()); auto monotone = result.begin()->second.begin(); EXPECT_EQ(true, monotone->second.first); EXPECT_EQ(false, monotone->second.second); diff --git a/src/test/storm-pars/analysis/OrderExtenderTest.cpp b/src/test/storm-pars/analysis/OrderExtenderTest.cpp index e9c0c2115..50b916b71 100644 --- a/src/test/storm-pars/analysis/OrderExtenderTest.cpp +++ b/src/test/storm-pars/analysis/OrderExtenderTest.cpp @@ -53,7 +53,7 @@ TEST(OrderExtenderTest, Brp_with_bisimulation) { EXPECT_EQ(dtmc->getNumberOfStates(), std::get<2>(criticalTuple)); auto order = std::get<0>(criticalTuple); - for (auto i = 0; i < dtmc->getNumberOfStates(); ++i) { + for (uint_fast64_t i = 0; i < dtmc->getNumberOfStates(); ++i) { EXPECT_TRUE((*order->getAddedStates())[i]); } @@ -86,8 +86,8 @@ TEST(OrderExtenderTest, Brp_without_bisimulation) { auto *extender = new storm::analysis::OrderExtender(dtmc); auto criticalTuple = extender->toOrder(formulas); - EXPECT_EQ(183, std::get<1>(criticalTuple)); - EXPECT_EQ(186, std::get<2>(criticalTuple)); + EXPECT_EQ(183ul, std::get<1>(criticalTuple)); + EXPECT_EQ(186ul, std::get<2>(criticalTuple)); }