Browse Source
Fixed SCC decomposition. Added functional tests for SCC decomposition.
Fixed SCC decomposition. Added functional tests for SCC decomposition.
Former-commit-id: 25a7805fcb
tempestpy_adaptions
dehnert
11 years ago
6 changed files with 142 additions and 99 deletions
-
4src/storage/MaximalEndComponentDecomposition.cpp
-
28src/storage/StronglyConnectedComponentDecomposition.cpp
-
33test/functional/storage/MaximalEndComponentDecompositionTest.cpp
-
46test/functional/storage/StronglyConnectedComponentDecompositionTest.cpp
-
70test/performance/graph/GraphTest.cpp
-
48test/performance/storage/StronglyConnectedComponentDecompositionTest.cpp
@ -0,0 +1,46 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
#include "src/parser/AutoParser.h"
|
|||
#include "src/storage/StronglyConnectedComponentDecomposition.h"
|
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, FullSystem1) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.lab", "", ""); |
|||
std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = parser.getModel<storm::models::MarkovAutomaton<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
|
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton)); |
|||
ASSERT_EQ(5, sccDecomposition.size()); |
|||
|
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true)); |
|||
ASSERT_EQ(2, sccDecomposition.size()); |
|||
|
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true)); |
|||
ASSERT_EQ(2, sccDecomposition.size()); |
|||
|
|||
markovAutomaton = nullptr; |
|||
} |
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, FullSystem2) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.lab", "", ""); |
|||
std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = parser.getModel<storm::models::MarkovAutomaton<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, false)); |
|||
|
|||
ASSERT_EQ(sccDecomposition.size(), 2); |
|||
|
|||
// Now, because there is no ordering we have to check the contents of the MECs in a symmetrical way.
|
|||
storm::storage::StateBlock const& scc1 = sccDecomposition[0]; |
|||
storm::storage::StateBlock const& scc2 = sccDecomposition[1]; |
|||
|
|||
std::vector<uint_fast64_t> correctScc1 = {1, 3, 8, 9, 10}; |
|||
std::vector<uint_fast64_t> correctScc2 = {4, 5, 6, 7}; |
|||
ASSERT_TRUE(scc1 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc1 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end())); |
|||
ASSERT_TRUE(scc2 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc2 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end())); |
|||
|
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true)); |
|||
ASSERT_EQ(1, sccDecomposition.size()); |
|||
|
|||
markovAutomaton = nullptr; |
|||
} |
@ -0,0 +1,48 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
#include "src/parser/AutoParser.h"
|
|||
#include "src/storage/StronglyConnectedComponentDecomposition.h"
|
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, Crowds) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", ""); |
|||
std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc)); |
|||
|
|||
ASSERT_EQ(sccDecomposition.size(), 1290297ull); |
|||
dtmc = nullptr; |
|||
} |
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, SynchronousLeader) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.lab", "", ""); |
|||
std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc)); |
|||
|
|||
ASSERT_EQ(sccDecomposition.size(), 1279673ull); |
|||
dtmc = nullptr; |
|||
} |
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, AsynchronousLeader) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader6.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader6.lab", "", ""); |
|||
std::shared_ptr<storm::models::Mdp<double>> mdp = parser.getModel<storm::models::Mdp<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp)); |
|||
|
|||
ASSERT_EQ(sccDecomposition.size(), 146844ull); |
|||
mdp = nullptr; |
|||
} |
|||
|
|||
TEST(StronglyConnectedComponentDecomposition, Consensus) { |
|||
storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.tra", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.lab", "", ""); |
|||
std::shared_ptr<storm::models::Mdp<double>> mdp = parser.getModel<storm::models::Mdp<double>>(); |
|||
|
|||
storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition; |
|||
ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp)); |
|||
|
|||
ASSERT_EQ(sccDecomposition.size(), 2611ull); |
|||
mdp = nullptr; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue