10 changed files with 172 additions and 29 deletions
-
6src/models/symbolic/Model.h
-
2src/storage/expressions/Expression.cpp
-
16src/storage/expressions/Expression.h
-
8src/storage/prism/menu_games/AbstractProgram.cpp
-
9src/storage/prism/menu_games/AbstractProgram.h
-
1src/storage/prism/menu_games/AbstractionDdInformation.cpp
-
4src/storage/prism/menu_games/AbstractionDdInformation.h
-
53src/storage/prism/menu_games/MenuGame.cpp
-
78src/storage/prism/menu_games/MenuGame.h
-
24test/functional/abstraction/PrismMenuGameTest.cpp
@ -0,0 +1,53 @@ |
|||||
|
#include "src/storage/prism/menu_games/MenuGame.h"
|
||||
|
|
||||
|
#include "src/exceptions/InvalidOperationException.h"
|
||||
|
#include "src/exceptions/InvalidArgumentException.h"
|
||||
|
|
||||
|
#include "src/storage/dd/CuddBdd.h"
|
||||
|
#include "src/storage/dd/CuddAdd.h"
|
||||
|
|
||||
|
#include "src/models/symbolic/StandardRewardModel.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace prism { |
||||
|
namespace menu_games { |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
MenuGame<Type>::MenuGame(std::shared_ptr<storm::dd::DdManager<Type>> manager, |
||||
|
storm::dd::Bdd<Type> reachableStates, |
||||
|
storm::dd::Bdd<Type> initialStates, |
||||
|
storm::dd::Add<Type> transitionMatrix, |
||||
|
std::set<storm::expressions::Variable> const& rowVariables, |
||||
|
std::set<storm::expressions::Variable> const& columnVariables, |
||||
|
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, |
||||
|
std::set<storm::expressions::Variable> const& player1Variables, |
||||
|
std::set<storm::expressions::Variable> const& player2Variables, |
||||
|
std::set<storm::expressions::Variable> const& allNondeterminismVariables, |
||||
|
storm::expressions::Variable const& updateVariable, |
||||
|
std::map<storm::expressions::Expression, storm::dd::Bdd<Type>> const& expressionToBddMap) : storm::models::symbolic::StochasticTwoPlayerGame<Type>(manager, reachableStates, initialStates, transitionMatrix, rowVariables, nullptr, columnVariables, nullptr, rowColumnMetaVariablePairs, player1Variables, player2Variables, allNondeterminismVariables), updateVariable(updateVariable), expressionToBddMap(expressionToBddMap) { |
||||
|
// Intentionally left empty.
|
||||
|
} |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
storm::dd::Bdd<Type> MenuGame<Type>::getStates(std::string const& label) const { |
||||
|
STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Menu games do not provide labels."); |
||||
|
} |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
storm::dd::Bdd<Type> MenuGame<Type>::getStates(storm::expressions::Expression const& expression) const { |
||||
|
auto it = expressionToBddMap.find(expression); |
||||
|
STORM_LOG_THROW(it != expressionToBddMap.end(), storm::exceptions::InvalidArgumentException, "The given expression was not used in the abstraction process and can therefore not be retrieved."); |
||||
|
return it->second && this->getReachableStates(); |
||||
|
} |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
bool MenuGame<Type>::hasLabel(std::string const& label) const { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
template class MenuGame<storm::dd::DdType::CUDD>; |
||||
|
|
||||
|
} // namespace menu_games
|
||||
|
} // namespace prism
|
||||
|
} // namespace storm
|
||||
|
|
@ -0,0 +1,78 @@ |
|||||
|
#ifndef STORM_PRISM_MENU_GAMES_MENUGAME_H_ |
||||
|
#define STORM_PRISM_MENU_GAMES_MENUGAME_H_ |
||||
|
|
||||
|
#include <map> |
||||
|
|
||||
|
#include "src/models/symbolic/StochasticTwoPlayerGame.h" |
||||
|
|
||||
|
#include "src/utility/OsDetection.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace prism { |
||||
|
namespace menu_games { |
||||
|
|
||||
|
/*! |
||||
|
* This class represents a discrete-time stochastic two-player game. |
||||
|
*/ |
||||
|
template<storm::dd::DdType Type> |
||||
|
class MenuGame : public storm::models::symbolic::StochasticTwoPlayerGame<Type> { |
||||
|
public: |
||||
|
typedef typename storm::models::symbolic::StochasticTwoPlayerGame<Type>::RewardModelType RewardModelType; |
||||
|
|
||||
|
MenuGame(MenuGame<Type> const& other) = default; |
||||
|
MenuGame& operator=(MenuGame<Type> const& other) = default; |
||||
|
|
||||
|
#ifndef WINDOWS |
||||
|
MenuGame(MenuGame<Type>&& other) = default; |
||||
|
MenuGame& operator=(MenuGame<Type>&& other) = default; |
||||
|
#endif |
||||
|
|
||||
|
/*! |
||||
|
* Constructs a model from the given data. |
||||
|
* |
||||
|
* @param manager The manager responsible for the decision diagrams. |
||||
|
* @param reachableStates A DD representing the reachable states. |
||||
|
* @param initialStates A DD representing the initial states of the model. |
||||
|
* @param transitionMatrix The matrix representing the transitions in the model. |
||||
|
* @param rowVariables The set of row meta variables used in the DDs. |
||||
|
* @param columVariables The set of column meta variables used in the DDs. |
||||
|
* @param rowColumnMetaVariablePairs All pairs of row/column meta variables. |
||||
|
* @param player1Variables The meta variables used to encode the nondeterministic choices of player 1. |
||||
|
* @param player2Variables The meta variables used to encode the nondeterministic choices of player 2. |
||||
|
* @param allNondeterminismVariables The meta variables used to encode the nondeterminism in the model. |
||||
|
* @param updateVariable The variable used to encode the different updates of the probabilistic program. |
||||
|
* @param expressionToBddMap A mapping from expressions (used) in the abstraction to the BDDs encoding |
||||
|
* them. |
||||
|
*/ |
||||
|
MenuGame(std::shared_ptr<storm::dd::DdManager<Type>> manager, |
||||
|
storm::dd::Bdd<Type> reachableStates, |
||||
|
storm::dd::Bdd<Type> initialStates, |
||||
|
storm::dd::Add<Type> transitionMatrix, |
||||
|
std::set<storm::expressions::Variable> const& rowVariables, |
||||
|
std::set<storm::expressions::Variable> const& columnVariables, |
||||
|
std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& rowColumnMetaVariablePairs, |
||||
|
std::set<storm::expressions::Variable> const& player1Variables, |
||||
|
std::set<storm::expressions::Variable> const& player2Variables, |
||||
|
std::set<storm::expressions::Variable> const& allNondeterminismVariables, |
||||
|
storm::expressions::Variable const& updateVariable, |
||||
|
std::map<storm::expressions::Expression, storm::dd::Bdd<Type>> const& expressionToBddMap); |
||||
|
|
||||
|
virtual storm::dd::Bdd<Type> getStates(std::string const& label) const override; |
||||
|
|
||||
|
virtual storm::dd::Bdd<Type> getStates(storm::expressions::Expression const& expression) const override; |
||||
|
|
||||
|
virtual bool hasLabel(std::string const& label) const override; |
||||
|
|
||||
|
private: |
||||
|
// The meta variable used to encode the updates. |
||||
|
storm::expressions::Variable updateVariable; |
||||
|
|
||||
|
// A mapping from expressions that were used in the abstraction process to the the BDDs representing them. |
||||
|
std::map<storm::expressions::Expression, storm::dd::Bdd<Type>> expressionToBddMap; |
||||
|
}; |
||||
|
|
||||
|
} // namespace menu_games |
||||
|
} // namespace prism |
||||
|
} // namespace storm |
||||
|
|
||||
|
#endif /* STORM_PRISM_MENU_GAMES_MENUGAME_H_ */ |
Reference in new issue
xxxxxxxxxx