1#include "storm-config.h"
19storm::jani::Model getJaniModelFromPrism(std::string
const& pathInTestResourcesDir,
bool prismCompatability =
false) {
24 EXPECT_TRUE(unsupportedFeatures.empty()) <<
"Model '" << pathInTestResourcesDir <<
"' uses unsupported feature(s) " << unsupportedFeatures.
toString();
28class ExplicitJaniModelBuilderTest :
public ::testing::Test {
30 void SetUp()
override {
31#ifndef STORM_HAVE_SMT_SOLVER
32 GTEST_SKIP() <<
"No SMT solver available.";
38 auto janiModel = getJaniModelFromPrism(
"/dtmc/die.pm");
41 EXPECT_EQ(13ul, model->getNumberOfStates());
42 EXPECT_EQ(20ul, model->getNumberOfTransitions());
46 EXPECT_EQ(13ul, model->getNumberOfStates());
47 EXPECT_EQ(20ul, model->getNumberOfTransitions());
51 EXPECT_EQ(13ul, model->getNumberOfStates());
52 EXPECT_EQ(20ul, model->getNumberOfTransitions());
54 janiModel = getJaniModelFromPrism(
"/dtmc/brp-16-2.pm");
56 EXPECT_EQ(677ul, model->getNumberOfStates());
57 EXPECT_EQ(867ul, model->getNumberOfTransitions());
59 janiModel = getJaniModelFromPrism(
"/dtmc/crowds-5-5.pm");
61 EXPECT_EQ(8607ul, model->getNumberOfStates());
62 EXPECT_EQ(15113ul, model->getNumberOfTransitions());
64 janiModel = getJaniModelFromPrism(
"/dtmc/leader-3-5.pm");
66 EXPECT_EQ(273ul, model->getNumberOfStates());
67 EXPECT_EQ(397ul, model->getNumberOfTransitions());
69 janiModel = getJaniModelFromPrism(
"/dtmc/nand-5-2.pm");
71 EXPECT_EQ(1728ul, model->getNumberOfStates());
72 EXPECT_EQ(2505ul, model->getNumberOfTransitions());
76 janiModel = janiModel.defineUndefinedConstants(constants);
78 EXPECT_EQ(5ul, model->getNumberOfStates());
79 EXPECT_EQ(5ul, model->getNumberOfTransitions());
82TEST_F(ExplicitJaniModelBuilderTest, pdtmc) {
83 auto janiModel = getJaniModelFromPrism(
"/pdtmc/parametric_die.pm");
84 std::shared_ptr<storm::models::sparse::Model<storm::RationalFunction>> model =
86 EXPECT_EQ(13ul, model->getNumberOfStates());
87 EXPECT_EQ(20ul, model->getNumberOfTransitions());
90 janiModel.substituteConstantsFunctionsTranscendentals();
92 EXPECT_EQ(13ul, model->getNumberOfStates());
93 EXPECT_EQ(20ul, model->getNumberOfTransitions());
95 janiModel = getJaniModelFromPrism(
"/pdtmc/brp16_2.pm");
97 EXPECT_EQ(677ul, model->getNumberOfStates());
98 EXPECT_EQ(867ul, model->getNumberOfTransitions());
101TEST_F(ExplicitJaniModelBuilderTest, Ctmc) {
102 auto janiModel = getJaniModelFromPrism(
"/ctmc/cluster2.sm",
true);
105 EXPECT_EQ(276ul, model->getNumberOfStates());
106 EXPECT_EQ(1120ul, model->getNumberOfTransitions());
108 janiModel = getJaniModelFromPrism(
"/ctmc/embedded2.sm",
true);
110 EXPECT_EQ(3478ul, model->getNumberOfStates());
111 EXPECT_EQ(14639ul, model->getNumberOfTransitions());
113 janiModel = getJaniModelFromPrism(
"/ctmc/polling2.sm",
true);
115 EXPECT_EQ(12ul, model->getNumberOfStates());
116 EXPECT_EQ(22ul, model->getNumberOfTransitions());
118 janiModel = getJaniModelFromPrism(
"/ctmc/fms2.sm",
true);
120 EXPECT_EQ(810ul, model->getNumberOfStates());
121 EXPECT_EQ(3699ul, model->getNumberOfTransitions());
123 janiModel = getJaniModelFromPrism(
"/ctmc/tandem5.sm",
true);
125 EXPECT_EQ(66ul, model->getNumberOfStates());
126 EXPECT_EQ(189ul, model->getNumberOfTransitions());
129TEST_F(ExplicitJaniModelBuilderTest,
Mdp) {
130 auto janiModel = getJaniModelFromPrism(
"/mdp/two_dice.nm");
133 EXPECT_EQ(169ul, model->getNumberOfStates());
134 EXPECT_EQ(436ul, model->getNumberOfTransitions());
136 janiModel = getJaniModelFromPrism(
"/mdp/leader3.nm");
138 EXPECT_EQ(364ul, model->getNumberOfStates());
139 EXPECT_EQ(654ul, model->getNumberOfTransitions());
141 janiModel = getJaniModelFromPrism(
"/mdp/coin2-2.nm");
143 EXPECT_EQ(272ul, model->getNumberOfStates());
144 EXPECT_EQ(492ul, model->getNumberOfTransitions());
146 janiModel = getJaniModelFromPrism(
"/mdp/csma2-2.nm");
148 EXPECT_EQ(1038ul, model->getNumberOfStates());
149 EXPECT_EQ(1282ul, model->getNumberOfTransitions());
151 janiModel = getJaniModelFromPrism(
"/mdp/firewire3-0.5.nm");
153 EXPECT_EQ(4093ul, model->getNumberOfStates());
154 EXPECT_EQ(5585ul, model->getNumberOfTransitions());
156 janiModel = getJaniModelFromPrism(
"/mdp/wlan0-2-2.nm");
158 EXPECT_EQ(37ul, model->getNumberOfStates());
159 EXPECT_EQ(59ul, model->getNumberOfTransitions());
161 janiModel = getJaniModelFromPrism(
"/mdp/sync.nm");
163 EXPECT_EQ(5ul, model->getNumberOfStates());
164 EXPECT_EQ(24ul, model->getNumberOfTransitions());
165 EXPECT_EQ(12ul, model->getNumberOfChoices());
171 EXPECT_EQ(2ul, model->getChoiceLabeling().getNumberOfLabels());
176 EXPECT_EQ(2ul, model->getChoiceLabeling().getNumberOfLabels());
179TEST_F(ExplicitJaniModelBuilderTest, Ma) {
180 auto janiModel = getJaniModelFromPrism(
"/ma/simple.ma");
183 EXPECT_EQ(5ul, model->getNumberOfStates());
184 EXPECT_EQ(8ul, model->getNumberOfTransitions());
188 janiModel = getJaniModelFromPrism(
"/ma/hybrid_states.ma");
190 EXPECT_EQ(5ul, model->getNumberOfStates());
191 EXPECT_EQ(13ul, model->getNumberOfTransitions());
195 janiModel = getJaniModelFromPrism(
"/ma/stream2.ma");
197 EXPECT_EQ(12ul, model->getNumberOfStates());
198 EXPECT_EQ(14ul, model->getNumberOfTransitions());
204 janiModel = janiModel.defineUndefinedConstants(constants);
206 EXPECT_EQ(1536ul, model->getNumberOfStates());
207 EXPECT_EQ(6448ul, model->getNumberOfTransitions());
212TEST_F(ExplicitJaniModelBuilderTest, FailComposition) {
213 auto janiModel = getJaniModelFromPrism(
"/mdp/system_composition.nm");
218TEST_F(ExplicitJaniModelBuilderTest, unassignedVariables) {
221 EXPECT_EQ(25ul, model->getNumberOfStates());
222 EXPECT_EQ(81ul, model->getNumberOfTransitions());
225TEST_F(ExplicitJaniModelBuilderTest, enumerateInitial) {
228 EXPECT_EQ(94ul, model->getNumberOfStates());
229 EXPECT_EQ(145ul, model->getNumberOfTransitions());
230 EXPECT_EQ(72ul, model->getInitialStates().getNumberOfSetBits());
233TEST_F(ExplicitJaniModelBuilderTest, SynchronizationVectorOutputActionIndex) {
234 auto janiModel =
storm::api::parseJaniModel(STORM_TEST_RESOURCES_DIR
"/mdp/synchronization_vector_output_action_index.jani").first;
237 std::deque<storm::generator::CompressedState> states;
239 for (uint32_t index = 0; index < states.size(); ++index) {
240 if (states[index] == state) {
244 states.push_back(state);
245 return static_cast<uint32_t
>(states.size() - 1);
248 auto initialStates = generator.getInitialStates(stateToIdCallback);
249 ASSERT_EQ(1ul, initialStates.size());
250 generator.load(states[initialStates.front()]);
252 auto behavior = generator.expand(stateToIdCallback);
253 ASSERT_EQ(3ul, behavior.getNumberOfChoices());
255 std::set<std::string> actionNames;
256 for (
auto const& choice : behavior.getChoices()) {
259 EXPECT_EQ(std::set<std::string>({
"d",
"e",
"f"}), actionNames);
262TEST_F(ExplicitJaniModelBuilderTest, AssignmentLevels) {
265 std::map<std::string, std::map<std::string, double>> expected = {{
"levels_det_transient", {{
"xb=2", 1.0}}},
266 {
"levels_random_transient", {{
"agree1", 0.5}, {
"mismatch", 0.0}, {
"agree2", 0.5}}},
267 {
"levels_next_state_read", {{
"agree1", 0.5}, {
"mismatch", 0.0}}},
268 {
"levels_receiver_flips", {{
"a1b2", 0.125}, {
"a2b3", 0.375}, {
"a1b3", 0.0}}},
269 {
"levels_three_levels", {{
"xc=3", 1.0}}},
270 {
"levels_edge_assignment", {{
"agree1", 0.5}, {
"mismatch", 0.0}}}};
271 for (
auto const& [file, expectedValues] : expected) {
275 ASSERT_EQ(expectedValues.size(), formulas.size()) << file;
276 for (uint64_t i = 0;
i < formulas.size(); ++
i) {
279 EXPECT_NEAR(expectedValues.at(modelAndProperties.second[i].getName()), result->asQuantitativeCheckResult<
double>().getMax(), 1e-6)
280 << file <<
" " << modelAndProperties.second[
i].getName();
TEST_F(ConstraintCollectorTest, PolynomialDenominators)
storm::models::sparse::Dtmc< double > Dtmc
storm::models::sparse::Mdp< double > Mdp
BuilderOptions & setBuildChoiceLabels(bool newValue=true)
Should the choice labels be built?
std::shared_ptr< storm::models::sparse::Model< ValueType, RewardModelType > > build()
Convert the program given at construction time to an abstract model.
static storm::jani::ModelFeatures getSupportedJaniFeatures()
Returns the jani features with which this builder can deal natively.
std::string const & getName() const
Returns the name of the location.
std::string toString() const
Action const & getAction(uint64_t index) const
Retrieves the action with the given index.
ModelFeatures restrictToFeatures(ModelFeatures const &modelFeatures)
Attempts to eliminate all features of this model that are not in the given set of features.
storm::jani::Model const & asJaniModel() const
SymbolicModelDescription preprocess(std::string const &constantDefinitionString="") const
SymbolicModelDescription toJani(bool makeVariablesGlobal=true) const
A qualitative check result over the states of a sparse model.
This class represents a Markov automaton.
storm::storage::BitVector const & getMarkovianStates() const
Retrieves the set of Markovian states of the model.
static storm::prism::Program parse(std::string const &filename, bool prismCompatability=false)
Parses the given file into the PRISM storage classes assuming it complies with the PRISM syntax.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > createTask(std::shared_ptr< const storm::logic::Formula > const &formula, bool onlyInitialStatesRelevant=false)
std::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > parseJaniModel(std::string const &filename, boost::optional< std::vector< std::string > > const &propertyFilter)
std::unique_ptr< storm::modelchecker::CheckResult > verifyWithSparseEngine(storm::Environment const &env, std::shared_ptr< storm::models::sparse::Dtmc< ValueType > > const &dtmc, storm::modelchecker::CheckTask< storm::logic::Formula, ValueType > const &task, bool preferEliminationChecker=false)
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::languages::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, typename storm::builder::ExplicitModelBuilder< ValueType >::Options const &explorationOptions=typename storm::builder::ExplicitModelBuilder< ValueType >::Options())
storm::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
std::map< storm::expressions::Variable, storm::expressions::Expression > parseConstantDefinitionString(storm::expressions::ExpressionManager const &manager, std::string const &constantDefinitionString)
Parses a comma-separated string of constant definitions (e.g.
#define STORM_SILENT_ASSERT_THROW(statement, expected_exception)