18 changed files with 226 additions and 44 deletions
-
4src/models/sparse/Ctmc.cpp
-
4src/models/sparse/Ctmc.h
-
4src/models/sparse/DeterministicModel.cpp
-
4src/models/sparse/DeterministicModel.h
-
12src/models/sparse/Dtmc.cpp
-
4src/models/sparse/Dtmc.h
-
4src/models/sparse/MarkovAutomaton.cpp
-
4src/models/sparse/MarkovAutomaton.h
-
12src/models/sparse/Mdp.cpp
-
6src/models/sparse/Mdp.h
-
8src/models/sparse/Model.cpp
-
11src/models/sparse/Model.h
-
4src/models/sparse/NondeterministicModel.cpp
-
4src/models/sparse/NondeterministicModel.h
-
41src/models/sparse/StochasticTwoPlayerGame.cpp
-
77src/models/sparse/StochasticTwoPlayerGame.h
-
42src/models/symbolic/StochasticTwoPlayerGame.cpp
-
25src/models/symbolic/StochasticTwoPlayerGame.h
@ -0,0 +1,41 @@ |
|||||
|
#include "src/models/sparse/StochasticTwoPlayerGame.h"
|
||||
|
|
||||
|
#include "src/adapters/CarlAdapter.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace models { |
||||
|
namespace sparse { |
||||
|
|
||||
|
template <typename ValueType> |
||||
|
StochasticTwoPlayerGame<ValueType>::StochasticTwoPlayerGame(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, |
||||
|
storm::storage::SparseMatrix<ValueType> const& player2Matrix, |
||||
|
storm::models::sparse::StateLabeling const& stateLabeling, |
||||
|
boost::optional<std::vector<ValueType>> const& optionalStateRewardVector, |
||||
|
boost::optional<std::vector<LabelSet>> const& optionalPlayer1ChoiceLabeling, |
||||
|
boost::optional<std::vector<LabelSet>> const& optionalPlayer2ChoiceLabeling) |
||||
|
: NondeterministicModel<ValueType>(storm::models::ModelType::S2pg, player2Matrix, stateLabeling, optionalStateRewardVector, boost::optional<storm::storage::SparseMatrix<ValueType>>(), optionalPlayer2ChoiceLabeling), player1Matrix(player1Matrix), player1Labels(optionalPlayer1ChoiceLabeling) { |
||||
|
// Intentionally left empty.
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
template <typename ValueType> |
||||
|
StochasticTwoPlayerGame<ValueType>::StochasticTwoPlayerGame(storm::storage::SparseMatrix<storm::storage::sparse::state_type>&& player1Matrix, |
||||
|
storm::storage::SparseMatrix<ValueType>&& player2Matrix, |
||||
|
storm::models::sparse::StateLabeling&& stateLabeling, |
||||
|
boost::optional<std::vector<ValueType>>&& optionalStateRewardVector, |
||||
|
boost::optional<std::vector<LabelSet>>&& optionalPlayer1ChoiceLabeling, |
||||
|
boost::optional<std::vector<LabelSet>>&& optionalPlayer2ChoiceLabeling) |
||||
|
: NondeterministicModel<ValueType>(storm::models::ModelType::S2pg, std::move(player2Matrix), std::move(stateLabeling), std::move(optionalStateRewardVector), boost::optional<storm::storage::SparseMatrix<ValueType>>(), std::move(optionalPlayer2ChoiceLabeling)), player1Matrix(std::move(player1Matrix)), player1Labels(std::move(optionalPlayer1ChoiceLabeling)) { |
||||
|
// Intentionally left empty.
|
||||
|
} |
||||
|
|
||||
|
template class StochasticTwoPlayerGame<double>; |
||||
|
template class StochasticTwoPlayerGame<float>; |
||||
|
|
||||
|
#ifdef STORM_HAVE_CARL
|
||||
|
template class StochasticTwoPlayerGame<storm::RationalFunction>; |
||||
|
#endif
|
||||
|
|
||||
|
} // namespace sparse
|
||||
|
} // namespace models
|
||||
|
} // namespace storm
|
@ -0,0 +1,77 @@ |
|||||
|
#ifndef STORM_MODELS_SPARSE_STOCHASTICTWOPLAYERGAME_H_ |
||||
|
#define STORM_MODELS_SPARSE_STOCHASTICTWOPLAYERGAME_H_ |
||||
|
|
||||
|
#include "src/models/sparse/NondeterministicModel.h" |
||||
|
#include "src/utility/OsDetection.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace models { |
||||
|
namespace sparse { |
||||
|
|
||||
|
/*! |
||||
|
* This class represents a (discrete-time) stochastic two-player game. |
||||
|
*/ |
||||
|
template <typename ValueType> |
||||
|
class StochasticTwoPlayerGame : public NondeterministicModel<ValueType> { |
||||
|
public: |
||||
|
/*! |
||||
|
* Constructs a model from the given data. |
||||
|
* |
||||
|
* @param player1Matrix The matrix representing the choices of player 1. |
||||
|
* @param player2Matrix The matrix representing the choices of player 2. |
||||
|
* @param stateLabeling The labeling of the states. |
||||
|
* @param optionalStateRewardVector The reward values associated with the states. |
||||
|
* @param optionalPlayer1ChoiceLabeling A vector that represents the labels associated with the choices of each player 1 state. |
||||
|
* @param optionalPlayer2ChoiceLabeling A vector that represents the labels associated with the choices of each player 2 state. |
||||
|
*/ |
||||
|
StochasticTwoPlayerGame(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, |
||||
|
storm::storage::SparseMatrix<ValueType> const& player2Matrix, |
||||
|
storm::models::sparse::StateLabeling const& stateLabeling, |
||||
|
boost::optional<std::vector<ValueType>> const& optionalStateRewardVector = boost::optional<std::vector<ValueType>>(), |
||||
|
boost::optional<std::vector<LabelSet>> const& optionalPlayer1ChoiceLabeling = boost::optional<std::vector<LabelSet>>(), |
||||
|
boost::optional<std::vector<LabelSet>> const& optionalPlayer2ChoiceLabeling = boost::optional<std::vector<LabelSet>>()); |
||||
|
|
||||
|
/*! |
||||
|
* Constructs a model by moving the given data. |
||||
|
* |
||||
|
* @param player1Matrix The matrix representing the choices of player 1. |
||||
|
* @param player2Matrix The matrix representing the choices of player 2. |
||||
|
* @param stateLabeling The labeling of the states. |
||||
|
* @param optionalStateRewardVector The reward values associated with the states. |
||||
|
* @param optionalPlayer1ChoiceLabeling A vector that represents the labels associated with the choices of each player 1 state. |
||||
|
* @param optionalPlayer2ChoiceLabeling A vector that represents the labels associated with the choices of each player 2 state. |
||||
|
*/ |
||||
|
StochasticTwoPlayerGame(storm::storage::SparseMatrix<storm::storage::sparse::state_type>&& player1Matrix, |
||||
|
storm::storage::SparseMatrix<ValueType>&& player2Matrix, |
||||
|
storm::models::sparse::StateLabeling&& stateLabeling, |
||||
|
boost::optional<std::vector<ValueType>>&& optionalStateRewardVector = boost::optional<std::vector<ValueType>>(), |
||||
|
boost::optional<std::vector<LabelSet>>&& optionalPlayer1ChoiceLabeling = boost::optional<std::vector<LabelSet>>(), |
||||
|
boost::optional<std::vector<LabelSet>>&& optionalPlayer2ChoiceLabeling = boost::optional<std::vector<LabelSet>>()); |
||||
|
|
||||
|
StochasticTwoPlayerGame(StochasticTwoPlayerGame const& other) = default; |
||||
|
StochasticTwoPlayerGame& operator=(StochasticTwoPlayerGame const& other) = default; |
||||
|
|
||||
|
#ifndef WINDOWS |
||||
|
StochasticTwoPlayerGame(StochasticTwoPlayerGame&& other) = default; |
||||
|
StochasticTwoPlayerGame& operator=(StochasticTwoPlayerGame&& other) = default; |
||||
|
#endif |
||||
|
|
||||
|
private: |
||||
|
// A matrix that stores the player 1 choices. This matrix contains a row group for each player 1 node. Every |
||||
|
// row group contains a row for each choice in that player 1 node. Each such row contains exactly one |
||||
|
// (non-zero) entry at a column that indicates the player 2 node this choice leads to (which is essentially |
||||
|
// the index of a row group in the matrix for player 2). |
||||
|
storm::storage::SparseMatrix<storm::storage::sparse::state_type> player1Matrix; |
||||
|
|
||||
|
// An (optional) vector of labels attached to the choices of player 1. Each row of the matrix can be equipped |
||||
|
// with a set of labels to tag certain choices. |
||||
|
boost::optional<std::vector<LabelSet>> player1Labels; |
||||
|
|
||||
|
// The matrix and labels for player 2 are stored in the superclass. |
||||
|
}; |
||||
|
|
||||
|
} // namespace sparse |
||||
|
} // namespace models |
||||
|
} // namespace storm |
||||
|
|
||||
|
#endif /* STORM_MODELS_SPARSE_STOCHASTICTWOPLAYERGAME_H_ */ |
@ -0,0 +1,42 @@ |
|||||
|
#include "src/models/symbolic/StochasticTwoPlayerGame.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace models { |
||||
|
namespace symbolic { |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
StochasticTwoPlayerGame<Type>::StochasticTwoPlayerGame(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::shared_ptr<storm::adapters::AddExpressionAdapter<Type>> rowExpressionAdapter, |
||||
|
std::set<storm::expressions::Variable> const& columnVariables, |
||||
|
std::shared_ptr<storm::adapters::AddExpressionAdapter<Type>> columnExpressionAdapter, |
||||
|
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& nondeterminismVariables, |
||||
|
std::map<std::string, storm::expressions::Expression> labelToExpressionMap, |
||||
|
boost::optional<storm::dd::Add<Type>> const& optionalStateRewardVector, |
||||
|
boost::optional<storm::dd::Add<Type>> const& optionalTransitionRewardMatrix) |
||||
|
: NondeterministicModel<Type>(storm::models::ModelType::S2pg, manager, reachableStates, initialStates, transitionMatrix, rowVariables, rowExpressionAdapter, columnVariables, columnExpressionAdapter, rowColumnMetaVariablePairs, nondeterminismVariables, labelToExpressionMap, optionalStateRewardVector, optionalTransitionRewardMatrix), player1Variables(player1Variables), player2Variables(player2Variables) { |
||||
|
// Intentionally left empty.
|
||||
|
} |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
std::set<storm::expressions::Variable> const& StochasticTwoPlayerGame<Type>::getPlayer1Variables() const { |
||||
|
return player1Variables; |
||||
|
} |
||||
|
|
||||
|
template<storm::dd::DdType Type> |
||||
|
std::set<storm::expressions::Variable> const& StochasticTwoPlayerGame<Type>::getPlayer2Variables() const { |
||||
|
return player2Variables; |
||||
|
} |
||||
|
|
||||
|
// Explicitly instantiate the template class.
|
||||
|
template class StochasticTwoPlayerGame<storm::dd::DdType::CUDD>; |
||||
|
|
||||
|
} // namespace symbolic
|
||||
|
} // namespace models
|
||||
|
} // namespace storm
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue