Browse Source
more work on JANI next state generator and the corresponding tests
more work on JANI next state generator and the corresponding tests
Former-commit-id: e170c9989c
tempestpy_adaptions
dehnert
9 years ago
11 changed files with 518 additions and 29 deletions
-
6src/builder/ExplicitModelBuilder.cpp
-
9src/builder/ExplicitModelBuilder.h
-
211src/generator/JaniNextStateGenerator.cpp
-
28src/generator/JaniNextStateGenerator.h
-
2src/generator/PrismNextStateGenerator.cpp
-
109src/storage/jani/Automaton.cpp
-
21src/storage/jani/Automaton.h
-
7src/storage/jani/Model.cpp
-
8src/storage/jani/Model.h
-
124test/functional/builder/ExplicitJaniModelBuilderTest.cpp
-
8test/functional/builder/ExplicitPrismModelBuilderTest.cpp
@ -0,0 +1,124 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
#include "src/models/sparse/StandardRewardModel.h"
|
|||
#include "src/settings/SettingMemento.h"
|
|||
#include "src/parser/PrismParser.h"
|
|||
#include "src/builder/ExplicitModelBuilder.h"
|
|||
#include "src/storage/jani/Model.h"
|
|||
|
|||
#include "src/settings/modules/IOSettings.h"
|
|||
|
|||
TEST(ExplicitJaniModelBuilderTest, Dtmc) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm"); |
|||
storm::jani::Model janiModel = program.toJani(); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(13ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(20ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(677ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(867ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(8607ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(15113ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(273ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(397ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/nand-5-2.pm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(1728ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(2505ul, model->getNumberOfTransitions()); |
|||
} |
|||
|
|||
TEST(ExplicitJaniModelBuilderTest, Ctmc) { |
|||
// Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
|
|||
std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true); |
|||
|
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/cluster2.sm"); |
|||
storm::jani::Model janiModel = program.toJani(); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitModelBuilder<double>(program).build(); |
|||
EXPECT_EQ(276ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(1120ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/embedded2.sm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(3478ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(14639ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/polling2.sm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(12ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(22ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/fms2.sm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(810ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(3699ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/tandem5.sm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(66ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(189ul, model->getNumberOfTransitions()); |
|||
} |
|||
|
|||
TEST(ExplicitJaniModelBuilderTest, Mdp) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm"); |
|||
storm::jani::Model janiModel = program.toJani(); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitModelBuilder<double>(program).build(); |
|||
EXPECT_EQ(169ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(436ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader3.nm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(364ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(654ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/coin2-2.nm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(272ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(492ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/csma2-2.nm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(1038ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(1282ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/firewire3-0.5.nm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(4093ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(5585ul, model->getNumberOfTransitions()); |
|||
|
|||
program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/wlan0-2-2.nm"); |
|||
janiModel = program.toJani(); |
|||
model = storm::builder::ExplicitModelBuilder<double>(janiModel).build(); |
|||
EXPECT_EQ(37ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(59ul, model->getNumberOfTransitions()); |
|||
} |
|||
|
|||
TEST(ExplicitJaniModelBuilderTest, Fail) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/system_composition.nm"); |
|||
storm::jani::Model janiModel = program.toJani(); |
|||
|
|||
ASSERT_THROW(storm::builder::ExplicitModelBuilder<double>(janiModel).build(), storm::exceptions::WrongFormatException); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue