Browse Source

Added template instanziation for storm::RationalFunction.

Added a test for Prism AbstractPrograms with storm::RationalFunction.


Former-commit-id: 5a696149cb
tempestpy_adaptions
PBerger 9 years ago
parent
commit
4fff7b39ef
  1. 2
      resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp
  2. 5
      resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp
  3. 5
      resources/3rdparty/sylvan/src/sylvan_storm_rational_function.h
  4. 9
      src/abstraction/MenuGame.cpp
  5. 2
      src/abstraction/MenuGameAbstractor.cpp
  6. 6
      src/abstraction/StateSetAbstractor.cpp
  7. 10
      src/abstraction/prism/AbstractCommand.cpp
  8. 8
      src/abstraction/prism/AbstractModule.cpp
  9. 11
      src/abstraction/prism/AbstractProgram.cpp
  10. 7
      src/adapters/AddExpressionAdapter.cpp
  11. 2
      src/modelchecker/DFTAnalyser.h
  12. 7
      src/models/symbolic/Model.cpp
  13. 7
      src/models/symbolic/NondeterministicModel.cpp
  14. 12
      src/models/symbolic/StochasticTwoPlayerGame.cpp
  15. 2
      src/storage/dd/sylvan/InternalSylvanAdd.cpp
  16. 5
      src/storage/dd/sylvan/InternalSylvanAdd.h
  17. 7
      src/storage/dd/sylvan/InternalSylvanBdd.cpp
  18. 4
      src/storage/dd/sylvan/InternalSylvanDdManager.cpp
  19. 7
      src/storage/dd/sylvan/InternalSylvanDdManager.h
  20. 5
      src/storage/dd/sylvan/SylvanAddIterator.cpp
  21. 21
      test/functional/abstraction/PrismMenuGameTest.cpp

2
resources/3rdparty/sylvan/src/sylvan_obj_mtbdd_storm.hpp

@ -28,6 +28,8 @@
* @brief Computes f / g for Rational Functions
*/
Mtbdd DivideRF(const Mtbdd &other) const;
Mtbdd AbstractPlusRF(const BddSet &variables) const;
#endif
Bdd NotZero() const;

5
resources/3rdparty/sylvan/src/sylvan_obj_storm.cpp

@ -46,6 +46,11 @@ Mtbdd::DivideRF(const Mtbdd &other) const
return sylvan_storm_rational_function_divide(mtbdd, other.mtbdd);
}
Mtbdd Mtbdd::AbstractPlusRF(const BddSet &variables) const {
LACE_ME;
return sylvan_storm_rational_function_abstract_plus(mtbdd, variables.set.bdd);
}
#endif
Mtbdd

5
resources/3rdparty/sylvan/src/sylvan_storm_rational_function.h

@ -99,6 +99,11 @@ TASK_DECL_2(MTBDD, sylvan_storm_rational_function_op_neg, MTBDD, size_t)
TASK_DECL_3(MTBDD, sylvan_storm_rational_function_and_exists, MTBDD, MTBDD, MTBDD);
#define sylvan_storm_rational_function_and_exists(a, b, vars) CALL(sylvan_storm_rational_function_and_exists, a, b, vars)
/**
* Abstract the variables in <v> from <a> by taking the sum of all values
*/
#define sylvan_storm_rational_function_abstract_plus(dd, v) mtbdd_abstract(dd, v, TASK(sylvan_storm_rational_function_abstract_op_plus))
#ifdef __cplusplus
}
#endif /* __cplusplus */

9
src/abstraction/MenuGame.cpp

@ -8,6 +8,9 @@
#include "src/models/symbolic/StandardRewardModel.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace abstraction {
@ -25,7 +28,7 @@ namespace storm {
std::set<storm::expressions::Variable> const& player2Variables,
std::set<storm::expressions::Variable> const& allNondeterminismVariables,
std::set<storm::expressions::Variable> const& probabilisticBranchingVariables,
std::map<storm::expressions::Expression, storm::dd::Bdd<Type>> const& expressionToBddMap) : storm::models::symbolic::StochasticTwoPlayerGame<Type>(manager, reachableStates, initialStates, deadlockStates, transitionMatrix.sumAbstract(probabilisticBranchingVariables), rowVariables, nullptr, columnVariables, nullptr, rowColumnMetaVariablePairs, player1Variables, player2Variables, allNondeterminismVariables), probabilisticBranchingVariables(probabilisticBranchingVariables), expressionToBddMap(expressionToBddMap), bottomStates(bottomStates) {
std::map<storm::expressions::Expression, storm::dd::Bdd<Type>> const& expressionToBddMap) : storm::models::symbolic::StochasticTwoPlayerGame<Type, ValueType>(manager, reachableStates, initialStates, deadlockStates, transitionMatrix.sumAbstract(probabilisticBranchingVariables), rowVariables, nullptr, columnVariables, nullptr, rowColumnMetaVariablePairs, player1Variables, player2Variables, allNondeterminismVariables), probabilisticBranchingVariables(probabilisticBranchingVariables), expressionToBddMap(expressionToBddMap), bottomStates(bottomStates) {
// Intentionally left empty.
}
@ -62,7 +65,9 @@ namespace storm {
template class MenuGame<storm::dd::DdType::CUDD, double>;
template class MenuGame<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class MenuGame<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
}
}

2
src/abstraction/MenuGameAbstractor.cpp

@ -1 +1 @@
#include "src/abstraction/MenuGameAbstractor.h"
#include "src/abstraction/MenuGameAbstractor.h"

6
src/abstraction/StateSetAbstractor.cpp

@ -7,6 +7,9 @@
#include "src/utility/macros.h"
#include "src/utility/solver.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace abstraction {
@ -159,5 +162,8 @@ namespace storm {
template class StateSetAbstractor<storm::dd::DdType::CUDD, double>;
template class StateSetAbstractor<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class StateSetAbstractor<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
}
}

10
src/abstraction/prism/AbstractCommand.cpp

@ -13,6 +13,9 @@
#include "src/utility/solver.h"
#include "src/utility/macros.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace abstraction {
namespace prism {
@ -32,7 +35,7 @@ namespace storm {
// Refine the command based on all initial predicates.
std::vector<uint_fast64_t> allPredicateIndices(abstractionInformation.getNumberOfPredicates());
for (auto index = 0; index < abstractionInformation.getNumberOfPredicates(); ++index) {
for (decltype(abstractionInformation.getNumberOfPredicates()) index = 0; index < abstractionInformation.getNumberOfPredicates(); ++index) {
allPredicateIndices[index] = index;
}
this->refine(allPredicateIndices);
@ -313,6 +316,9 @@ namespace storm {
template class AbstractCommand<storm::dd::DdType::CUDD, double>;
template class AbstractCommand<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class AbstractCommand<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
}
}
}
}

8
src/abstraction/prism/AbstractModule.cpp

@ -7,6 +7,9 @@
#include "src/storage/prism/Module.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace abstraction {
namespace prism {
@ -62,6 +65,9 @@ namespace storm {
template class AbstractModule<storm::dd::DdType::CUDD, double>;
template class AbstractModule<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class AbstractModule<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
}
}
}
}

11
src/abstraction/prism/AbstractProgram.cpp

@ -12,6 +12,9 @@
#include "src/exceptions/WrongFormatException.h"
#include "src/exceptions/InvalidArgumentException.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace abstraction {
namespace prism {
@ -160,7 +163,7 @@ namespace storm {
}
// Construct the transition matrix by cutting away the transitions of unreachable states.
storm::dd::Add<DdType> transitionMatrix = (gameBdd.first && reachableStates).template toAdd<ValueType>() * commandUpdateProbabilitiesAdd + deadlockTransitions;
storm::dd::Add<DdType, ValueType> transitionMatrix = (gameBdd.first && reachableStates).template toAdd<ValueType>() * commandUpdateProbabilitiesAdd + deadlockTransitions;
std::set<storm::expressions::Variable> usedPlayer2Variables(abstractionInformation.getPlayer2Variables().begin(), abstractionInformation.getPlayer2Variables().begin() + gameBdd.second);
@ -191,7 +194,9 @@ namespace storm {
// Explicitly instantiate the class.
template class AbstractProgram<storm::dd::DdType::CUDD, double>;
template class AbstractProgram<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class AbstractProgram<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
}
}
}
}

7
src/adapters/AddExpressionAdapter.cpp

@ -8,6 +8,9 @@
#include "src/storage/dd/Add.h"
#include "src/storage/dd/Bdd.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace adapters {
@ -201,6 +204,8 @@ namespace storm {
// Explicitly instantiate the symbolic expression adapter
template class AddExpressionAdapter<storm::dd::DdType::CUDD, double>;
template class AddExpressionAdapter<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class AddExpressionAdapter<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
} // namespace adapters
} // namespace storm

2
src/modelchecker/DFTAnalyser.h

@ -122,7 +122,7 @@ private:
STORM_LOG_TRACE("Result for permutation:"<<permResult);
permutation = nextBitPermutation(permutation);
result += permResult;
} while(permutation < (1 << nrM) && permutation != 0);
} while(permutation < (static_cast<size_t>(1) << nrM) && permutation != 0);
}
if(invResults) {
return storm::utility::one<ValueType>() - result;

7
src/models/symbolic/Model.cpp

@ -13,6 +13,9 @@
#include "src/models/symbolic/StandardRewardModel.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace models {
namespace symbolic {
@ -243,7 +246,9 @@ namespace storm {
// Explicitly instantiate the template class.
template class Model<storm::dd::DdType::CUDD, double>;
template class Model<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class Model<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
} // namespace symbolic
} // namespace models
} // namespace storm

7
src/models/symbolic/NondeterministicModel.cpp

@ -6,6 +6,9 @@
#include "src/models/symbolic/StandardRewardModel.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace models {
namespace symbolic {
@ -76,7 +79,9 @@ namespace storm {
// Explicitly instantiate the template class.
template class NondeterministicModel<storm::dd::DdType::CUDD, double>;
template class NondeterministicModel<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class NondeterministicModel<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
} // namespace symbolic
} // namespace models
} // namespace storm

12
src/models/symbolic/StochasticTwoPlayerGame.cpp

@ -6,6 +6,9 @@
#include "src/models/symbolic/StandardRewardModel.h"
#include "storm-config.h"
#include "src/adapters/CarlAdapter.h"
namespace storm {
namespace models {
namespace symbolic {
@ -60,9 +63,12 @@ namespace storm {
}
// Explicitly instantiate the template class.
template class StochasticTwoPlayerGame<storm::dd::DdType::CUDD, double>;
template class StochasticTwoPlayerGame<storm::dd::DdType::Sylvan, double>;
template class StochasticTwoPlayerGame<storm::dd::DdType::CUDD, double>;
template class StochasticTwoPlayerGame<storm::dd::DdType::Sylvan, double>;
#ifdef STORM_HAVE_CARL
template class StochasticTwoPlayerGame<storm::dd::DdType::Sylvan, storm::RationalFunction>;
#endif
} // namespace symbolic
} // namespace models
} // namespace storm
} // namespace storm

2
src/storage/dd/sylvan/InternalSylvanAdd.cpp

@ -297,7 +297,7 @@ namespace storm {
#ifdef STORM_HAVE_CARL
template<>
InternalAdd<DdType::Sylvan, storm::RationalFunction> InternalAdd<DdType::Sylvan, storm::RationalFunction>::sumAbstract(InternalBdd<DdType::Sylvan> const& cube) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented: sumAbstract");
return InternalAdd<DdType::Sylvan, storm::RationalFunction>(ddManager, this->sylvanMtbdd.AbstractPlusRF(cube.sylvanBdd));
}
#endif

5
src/storage/dd/sylvan/InternalSylvanAdd.h

@ -14,12 +14,7 @@
#include "src/storage/expressions/Variable.h"
#include "src/adapters/CarlAdapter.h"
#include "storm-config.h"
// TODO: Remove this later on.
#ifndef STORM_HAVE_CARL
#define STORM_HAVE_CARL 1
#endif
namespace storm {
namespace storage {

7
src/storage/dd/sylvan/InternalSylvanBdd.cpp

@ -14,12 +14,7 @@
#include "src/exceptions/NotSupportedException.h"
#include "src/adapters/CarlAdapter.h"
#include "storm-config.h"
// TODO: Remove this later on.
#ifndef STORM_HAVE_CARL
#define STORM_HAVE_CARL 1
#endif
namespace storm {
namespace dd {
@ -503,4 +498,4 @@ namespace storm {
template InternalAdd<DdType::Sylvan, uint_fast64_t> InternalBdd<DdType::Sylvan>::ite(InternalAdd<DdType::Sylvan, uint_fast64_t> const& thenAdd, InternalAdd<DdType::Sylvan, uint_fast64_t> const& elseAdd) const;
template InternalAdd<DdType::Sylvan, storm::RationalFunction> InternalBdd<DdType::Sylvan>::ite(InternalAdd<DdType::Sylvan, storm::RationalFunction> const& thenAdd, InternalAdd<DdType::Sylvan, storm::RationalFunction> const& elseAdd) const;
}
}
}

4
src/storage/dd/sylvan/InternalSylvanDdManager.cpp

@ -13,10 +13,6 @@
#include "src/utility/sylvan.h"
#include "storm-config.h"
// TODO: Remove this later on.
#ifndef STORM_HAVE_CARL
#define STORM_HAVE_CARL 1
#endif
namespace storm {
namespace dd {

7
src/storage/dd/sylvan/InternalSylvanDdManager.h

@ -10,12 +10,7 @@
#include "src/storage/dd/sylvan/InternalSylvanAdd.h"
#include "src/adapters/CarlAdapter.h"
#include "storm-config.h"
// TODO: Remove this later on.
#ifndef STORM_HAVE_CARL
#define STORM_HAVE_CARL 1
#endif
namespace storm {
namespace dd {
@ -170,4 +165,4 @@ namespace storm {
}
}
#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANDDMANAGER_H_ */
#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANDDMANAGER_H_ */

5
src/storage/dd/sylvan/SylvanAddIterator.cpp

@ -11,12 +11,7 @@
#include <cmath>
#include "src/adapters/CarlAdapter.h"
#include "storm-config.h"
// TODO: Remove this later on.
#ifndef STORM_HAVE_CARL
#define STORM_HAVE_CARL 1
#endif
namespace storm {
namespace dd {

21
test/functional/abstraction/PrismMenuGameTest.cpp

@ -16,6 +16,8 @@
#include "src/utility/solver.h"
#include "src/adapters/CarlAdapter.h"
TEST(PrismMenuGame, DieAbstractionTest_Cudd) {
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
@ -50,6 +52,25 @@ TEST(PrismMenuGame, DieAbstractionTest_Sylvan) {
EXPECT_EQ(0, game.getBottomStates().getNonZeroCount());
}
#ifdef STORM_HAVE_CARL
TEST(PrismMenuGame, DieAbstractionTest_SylvanWithRationalFunction) {
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
std::vector<storm::expressions::Expression> initialPredicates;
storm::expressions::ExpressionManager& manager = program.getManager();
initialPredicates.push_back(manager.getVariableExpression("s") < manager.integer(3));
storm::abstraction::prism::AbstractProgram<storm::dd::DdType::Sylvan, storm::RationalFunction> abstractProgram(program.getManager(), program, initialPredicates, std::make_unique<storm::utility::solver::MathsatSmtSolverFactory>(), false);
storm::abstraction::MenuGame<storm::dd::DdType::Sylvan, storm::RationalFunction> game = abstractProgram.getAbstractGame();
EXPECT_EQ(10, game.getNumberOfTransitions());
EXPECT_EQ(2, game.getNumberOfStates());
EXPECT_EQ(0, game.getBottomStates().getNonZeroCount());
}
#endif
TEST(PrismMenuGame, DieAbstractionAndRefinementTest_Cudd) {
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
Loading…
Cancel
Save