Browse Source

fixes for JANI flattening tests

tempestpy_adaptions
dehnert 8 years ago
parent
commit
2c17bdded7
  1. 4
      src/storm/storage/jani/Model.cpp
  2. 5
      src/storm/storage/jani/Model.h
  3. 98
      src/test/storage/JaniModelTest.cpp

4
src/storm/storage/jani/Model.cpp

@ -684,6 +684,10 @@ namespace storm {
return automata[it->second];
}
Automaton& Model::getAutomaton(uint64_t index) {
return automata[index];
}
Automaton const& Model::getAutomaton(std::string const& name) const {
auto it = automatonToIndex.find(name);
STORM_LOG_THROW(it != automatonToIndex.end(), storm::exceptions::InvalidOperationException, "Unable to retrieve unknown automaton '" << name << "'.");

5
src/storm/storage/jani/Model.h

@ -234,6 +234,11 @@ namespace storm {
*/
Automaton& getAutomaton(std::string const& name);
/*!
* Retrieves the automaton with the given index.
*/
Automaton& getAutomaton(uint64_t index);
/*!
* Retrieves the automaton with the given name.
*/

98
src/test/storage/JaniModelTest.cpp

@ -4,79 +4,79 @@
#include "storm/utility/solver.h"
#include "storm/storage/jani/Model.h"
#include "storm/storage/jani/janiModel.h"
#ifdef STORM_HAVE_MSAT
TEST(JaniModelTest, FlattenModules) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/leader3.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(74, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(74, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Wlan_Mathsat) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/wlan0_collide.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(179, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(179, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Csma_Mathsat) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/csma2_2.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(70, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(70, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Firewire_Mathsat) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/firewire.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(5024, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(5024, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Coin_Mathsat) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/coin2.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(13, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(13, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Dice_Mathsat) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/two_dice.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::MathsatSmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(16, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(16, janiModel.getAutomaton(0).getNumberOfEdges());
}
#endif
@ -84,72 +84,72 @@ TEST(JaniModelTest, FlattenModules_Dice_Mathsat) {
TEST(JaniModelTest, FlattenModules_Leader_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/leader3.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(74, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(74, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Wlan_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/wlan0_collide.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(179, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(179, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Csma_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/csma2_2.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(70, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(70, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Firewire_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/firewire.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(5024, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(5024, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Coin_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/coin2.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(13, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(13, janiModel.getAutomaton(0).getNumberOfEdges());
}
TEST(JaniModelTest, FlattenModules_Dice_Z3) {
storm::prism::Program program;
ASSERT_NO_THROW(program = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/two_dice.nm"));
storm::jani::Model janiModel = program.toJani();
storm::jani::Model janiModel = model.toJani();
std::shared_ptr<storm::utility::solver::SmtSolverFactory> smtSolverFactory = std::make_shared<storm::utility::solver::Z3SmtSolverFactory>();
ASSERT_NO_THROW(model = model.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, program.getNumberOfModules());
EXPECT_EQ(16, program.getModule(0).getNumberOfCommands());
ASSERT_NO_THROW(model = janiModel.flattenComposition(smtSolverFactory));
EXPECT_EQ(1, janiModel.getNumberOfAutomata());
EXPECT_EQ(16, janiModel.getAutomaton(0).getNumberOfEdges());
}
#endif
Loading…
Cancel
Save