From 8985ad77cfd7ad83007897466d672a8bfea4ae82 Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 7 Aug 2015 14:16:45 +0200 Subject: [PATCH 1/6] added first debug output to track down bug Former-commit-id: ad333216c1bd16837a6c4de5c253637bbeb481c4 --- src/builder/DdPrismModelBuilder.cpp | 1 + .../builder/DdPrismModelBuilderTest.cpp | 88 +++++++++---------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index eae18d06e..07a5f1100 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -620,6 +620,7 @@ namespace storm { std::pair, ModuleDecisionDiagram> transitionMatrixModulePair = createSystemDecisionDiagram(generationInfo); storm::dd::Add transitionMatrix = transitionMatrixModulePair.first; + transitionMatrix.exportToDot("trans.dot"); ModuleDecisionDiagram const& globalModule = transitionMatrixModulePair.second; // Finally, we build the DDs for a reward structure, if requested. It is important to do this now, because diff --git a/test/functional/builder/DdPrismModelBuilderTest.cpp b/test/functional/builder/DdPrismModelBuilderTest.cpp index ea88d24f1..15f5b03ce 100644 --- a/test/functional/builder/DdPrismModelBuilderTest.cpp +++ b/test/functional/builder/DdPrismModelBuilderTest.cpp @@ -72,50 +72,50 @@ TEST(DdPrismModelBuilderTest, Mdp) { EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); std::shared_ptr> mdp = model->as>(); - - EXPECT_EQ(169, mdp->getNumberOfStates()); - EXPECT_EQ(436, mdp->getNumberOfTransitions()); - EXPECT_EQ(254, mdp->getNumberOfChoices()); - - program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader3.nm"); - model = storm::builder::DdPrismModelBuilder::translateProgram(program); - - EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); - mdp = model->as>(); - - EXPECT_EQ(364, mdp->getNumberOfStates()); - EXPECT_EQ(654, mdp->getNumberOfTransitions()); - EXPECT_EQ(573, mdp->getNumberOfChoices()); - - program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/coin2-2.nm"); - model = storm::builder::DdPrismModelBuilder::translateProgram(program); - - EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); - mdp = model->as>(); - - EXPECT_EQ(272, mdp->getNumberOfStates()); - EXPECT_EQ(492, mdp->getNumberOfTransitions()); - EXPECT_EQ(400, mdp->getNumberOfChoices()); - - program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/csma2-2.nm"); - model = storm::builder::DdPrismModelBuilder::translateProgram(program); - - EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); - mdp = model->as>(); - - EXPECT_EQ(1038, mdp->getNumberOfStates()); - EXPECT_EQ(1282, mdp->getNumberOfTransitions()); - EXPECT_EQ(1054, mdp->getNumberOfChoices()); - - program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/firewire3-0.5.nm"); - model = storm::builder::DdPrismModelBuilder::translateProgram(program); - - EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); - mdp = model->as>(); - - EXPECT_EQ(4093, mdp->getNumberOfStates()); - EXPECT_EQ(5585, mdp->getNumberOfTransitions()); - EXPECT_EQ(5519, mdp->getNumberOfChoices()); +// +// EXPECT_EQ(169, mdp->getNumberOfStates()); +// EXPECT_EQ(436, mdp->getNumberOfTransitions()); +// EXPECT_EQ(254, mdp->getNumberOfChoices()); +// +// program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader3.nm"); +// model = storm::builder::DdPrismModelBuilder::translateProgram(program); +// +// EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); +// mdp = model->as>(); +// +// EXPECT_EQ(364, mdp->getNumberOfStates()); +// EXPECT_EQ(654, mdp->getNumberOfTransitions()); +// EXPECT_EQ(573, mdp->getNumberOfChoices()); +// +// program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/coin2-2.nm"); +// model = storm::builder::DdPrismModelBuilder::translateProgram(program); +// +// EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); +// mdp = model->as>(); +// +// EXPECT_EQ(272, mdp->getNumberOfStates()); +// EXPECT_EQ(492, mdp->getNumberOfTransitions()); +// EXPECT_EQ(400, mdp->getNumberOfChoices()); +// +// program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/csma2-2.nm"); +// model = storm::builder::DdPrismModelBuilder::translateProgram(program); +// +// EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); +// mdp = model->as>(); +// +// EXPECT_EQ(1038, mdp->getNumberOfStates()); +// EXPECT_EQ(1282, mdp->getNumberOfTransitions()); +// EXPECT_EQ(1054, mdp->getNumberOfChoices()); +// +// program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/firewire3-0.5.nm"); +// model = storm::builder::DdPrismModelBuilder::translateProgram(program); +// +// EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp); +// mdp = model->as>(); +// +// EXPECT_EQ(4093, mdp->getNumberOfStates()); +// EXPECT_EQ(5585, mdp->getNumberOfTransitions()); +// EXPECT_EQ(5519, mdp->getNumberOfChoices()); program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/wlan0-2-2.nm"); model = storm::builder::DdPrismModelBuilder::translateProgram(program); From b2cec6395a21352b10269ebeef3bfeea293b613e Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 7 Aug 2015 14:34:17 +0200 Subject: [PATCH 2/6] more debug output Former-commit-id: ff8f9b5a81717d597e1b423f82d7f77b22af84eb --- src/builder/DdPrismModelBuilder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index 07a5f1100..69aea3119 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -621,6 +621,8 @@ namespace storm { std::pair, ModuleDecisionDiagram> transitionMatrixModulePair = createSystemDecisionDiagram(generationInfo); storm::dd::Add transitionMatrix = transitionMatrixModulePair.first; transitionMatrix.exportToDot("trans.dot"); + std::cout << "nnz: " << transitionMatrix.getNonZeroCount() << std::endl; + std::cout << "node: " << transitionMatrix.getNodeCount() << std::endl; ModuleDecisionDiagram const& globalModule = transitionMatrixModulePair.second; // Finally, we build the DDs for a reward structure, if requested. It is important to do this now, because @@ -651,6 +653,9 @@ namespace storm { transitionMatrixBdd = transitionMatrixBdd.existsAbstract(generationInfo.allNondeterminismVariables); } storm::dd::Bdd reachableStates = computeReachableStates(generationInfo, initialStates, transitionMatrixBdd); + reachableStates.exportToDot("reach.dot"); + std::cout << "reach nnz: " << reachableStates.getNonZeroCount() << std::endl; + std::cout << "reach node: " << reachableStates.getNodeCount() << std::endl; storm::dd::Add reachableStatesAdd = reachableStates.toAdd(); transitionMatrix *= reachableStatesAdd; if (stateAndTransitionRewards) { From 507331d8a92fbf3dc8e45bf16a8013347cbb9bbd Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 7 Aug 2015 14:47:56 +0200 Subject: [PATCH 3/6] more debug output Former-commit-id: acb7f9ea2f17ee903b05436aa3088640d92feb2a --- src/builder/DdPrismModelBuilder.cpp | 4 +--- src/storage/dd/CuddAdd.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index 69aea3119..2d94be7cc 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -623,6 +623,7 @@ namespace storm { transitionMatrix.exportToDot("trans.dot"); std::cout << "nnz: " << transitionMatrix.getNonZeroCount() << std::endl; std::cout << "node: " << transitionMatrix.getNodeCount() << std::endl; + std::cout << "trans: " << transitionMatrix << std::endl; ModuleDecisionDiagram const& globalModule = transitionMatrixModulePair.second; // Finally, we build the DDs for a reward structure, if requested. It is important to do this now, because @@ -653,9 +654,6 @@ namespace storm { transitionMatrixBdd = transitionMatrixBdd.existsAbstract(generationInfo.allNondeterminismVariables); } storm::dd::Bdd reachableStates = computeReachableStates(generationInfo, initialStates, transitionMatrixBdd); - reachableStates.exportToDot("reach.dot"); - std::cout << "reach nnz: " << reachableStates.getNonZeroCount() << std::endl; - std::cout << "reach node: " << reachableStates.getNodeCount() << std::endl; storm::dd::Add reachableStatesAdd = reachableStates.toAdd(); transitionMatrix *= reachableStatesAdd; if (stateAndTransitionRewards) { diff --git a/src/storage/dd/CuddAdd.cpp b/src/storage/dd/CuddAdd.cpp index 5eaded696..dbee2e94a 100644 --- a/src/storage/dd/CuddAdd.cpp +++ b/src/storage/dd/CuddAdd.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "src/storage/dd/CuddAdd.h" #include "src/storage/dd/CuddBdd.h" @@ -1055,7 +1056,12 @@ namespace storm { } std::ostream& operator<<(std::ostream& out, const Add& add) { - add.exportToDot(); + out << "ADD with " << add.getNonZeroCount() << " nnz, " << add.getNodeCount() << " nodes, " << add.getLeafCount() << " leaves" << std::endl; + std::vector variableNames; + for (auto const& variable : add.getContainedMetaVariables()) { + variableNames.push_back(variable.getName()); + } + out << "contained variables: " << boost::algorithm::join(variableNames, ", ") << std::endl; return out; } From 08747378d5b64e7e650eb9eacb434307f6e28de0 Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 7 Aug 2015 15:00:01 +0200 Subject: [PATCH 4/6] workplace switch Former-commit-id: eab2c2bc9e49aa4392294107528e9e398f074130 --- src/builder/DdPrismModelBuilder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index 2d94be7cc..13a6cb985 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -613,6 +613,7 @@ namespace storm { } preparedProgram = preparedProgram.substituteConstants(); + std::cout << "translating: " << preparedProgram << std::endl; // Start by initializing the structure used for storing all information needed during the model generation. // In particular, this creates the meta variables used to encode the model. @@ -621,8 +622,6 @@ namespace storm { std::pair, ModuleDecisionDiagram> transitionMatrixModulePair = createSystemDecisionDiagram(generationInfo); storm::dd::Add transitionMatrix = transitionMatrixModulePair.first; transitionMatrix.exportToDot("trans.dot"); - std::cout << "nnz: " << transitionMatrix.getNonZeroCount() << std::endl; - std::cout << "node: " << transitionMatrix.getNodeCount() << std::endl; std::cout << "trans: " << transitionMatrix << std::endl; ModuleDecisionDiagram const& globalModule = transitionMatrixModulePair.second; From c683934ea0f10088bc65343ef79ccbd2e224b6db Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 7 Aug 2015 19:53:58 +0200 Subject: [PATCH 5/6] removed debug output and fixed bug Former-commit-id: 0c33f61bbea9dfe743c213ff0eecdad1eb3008d1 --- src/builder/DdPrismModelBuilder.cpp | 3 - src/parser/PrismParser.cpp | 9 +- src/storage/prism/Program.cpp | 4 +- .../builder/DdPrismModelBuilderTest.cpp | 88 +++++++++---------- 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index 13a6cb985..eae18d06e 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -613,7 +613,6 @@ namespace storm { } preparedProgram = preparedProgram.substituteConstants(); - std::cout << "translating: " << preparedProgram << std::endl; // Start by initializing the structure used for storing all information needed during the model generation. // In particular, this creates the meta variables used to encode the model. @@ -621,8 +620,6 @@ namespace storm { std::pair, ModuleDecisionDiagram> transitionMatrixModulePair = createSystemDecisionDiagram(generationInfo); storm::dd::Add transitionMatrix = transitionMatrixModulePair.first; - transitionMatrix.exportToDot("trans.dot"); - std::cout << "trans: " << transitionMatrix << std::endl; ModuleDecisionDiagram const& globalModule = transitionMatrixModulePair.second; // Finally, we build the DDs for a reward structure, if requested. It is important to do this now, because diff --git a/src/parser/PrismParser.cpp b/src/parser/PrismParser.cpp index bff8c71b8..ddb348249 100644 --- a/src/parser/PrismParser.cpp +++ b/src/parser/PrismParser.cpp @@ -378,7 +378,8 @@ namespace storm { if (!actionName.empty()) { auto const& nameIndexPair = globalProgramInformation.actionIndices.find(actionName); if (nameIndexPair == globalProgramInformation.actionIndices.end()) { - globalProgramInformation.actionIndices[actionName] = globalProgramInformation.actionIndices.size(); + std::size_t nextIndex = globalProgramInformation.actionIndices.size(); + globalProgramInformation.actionIndices[actionName] = nextIndex; } } @@ -392,7 +393,8 @@ namespace storm { // Register the action name if it has not appeared earlier. auto const& nameIndexPair = globalProgramInformation.actionIndices.find(actionName); if (nameIndexPair == globalProgramInformation.actionIndices.end()) { - globalProgramInformation.actionIndices[actionName] = globalProgramInformation.actionIndices.size(); + std::size_t nextIndex = globalProgramInformation.actionIndices.size(); + globalProgramInformation.actionIndices[actionName] = nextIndex; } } @@ -518,7 +520,8 @@ namespace storm { if (!newActionName.empty()) { auto const& nameIndexPair = globalProgramInformation.actionIndices.find(newActionName); if (nameIndexPair == globalProgramInformation.actionIndices.end()) { - globalProgramInformation.actionIndices[newActionName] = globalProgramInformation.actionIndices.size(); + std::size_t nextIndex = globalProgramInformation.actionIndices.size(); + globalProgramInformation.actionIndices[newActionName] = nextIndex; } } diff --git a/src/storage/prism/Program.cpp b/src/storage/prism/Program.cpp index 0b61fd795..4655f1bcc 100644 --- a/src/storage/prism/Program.cpp +++ b/src/storage/prism/Program.cpp @@ -13,8 +13,10 @@ namespace storm { namespace prism { Program::Program(std::shared_ptr manager, ModelType modelType, std::vector const& constants, std::vector const& globalBooleanVariables, std::vector const& globalIntegerVariables, std::vector const& formulas, std::vector const& modules, std::map const& actionToIndexMap, std::vector const& rewardModels, bool fixInitialConstruct, storm::prism::InitialConstruct const& initialConstruct, std::vector