16template<storm::dd::DdType Type,
typename ValueType>
19 storm::dd::Bdd<Type> const& illegalPlayer2Mask, std::set<storm::expressions::Variable>
const& rowMetaVariables,
20 std::set<storm::expressions::Variable>
const& columnMetaVariables,
21 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>>
const& rowColumnMetaVariablePairs,
22 std::set<storm::expressions::Variable>
const& player1Variables, std::set<storm::expressions::Variable>
const& player2Variables)
26 illegalPlayer1Mask.ite(A.getDdManager().getConstant(
storm::utility::infinity<ValueType>()), A.getDdManager().template getAddZero<ValueType>())),
28 illegalPlayer2Mask.ite(A.getDdManager().getConstant(
storm::utility::infinity<ValueType>()), A.getDdManager().template getAddZero<ValueType>())),
29 rowMetaVariables(rowMetaVariables),
30 columnMetaVariables(columnMetaVariables),
31 rowColumnMetaVariablePairs(rowColumnMetaVariablePairs),
32 player1Variables(player1Variables),
33 player2Variables(player2Variables),
34 generatePlayer1Strategy(false),
35 generatePlayer2Strategy(false) {
39template<storm::dd::DdType Type,
typename ValueType>
46 "Switching game method to Value iteration since the selected method is not supported by this solver.");
53 uint_fast64_t iterations = 0;
54 bool converged =
false;
57 if (generatePlayer1Strategy) {
58 if (basePlayer1Strategy) {
59 player1Strategy = basePlayer1Strategy.get();
64 boost::optional<storm::dd::Add<Type, ValueType>> previousPlayer2Values;
65 if (generatePlayer2Strategy) {
66 if (basePlayer2Strategy && player2Goal == storm::OptimizationDirection::Maximize) {
67 player2Strategy = basePlayer2Strategy.get();
71 previousPlayer2Values = (player2Strategy.get().template toAdd<ValueType>() *
72 (this->A.multiplyMatrix(x.
swapVariables(this->rowColumnMetaVariablePairs), this->columnMetaVariables) + b))
73 .sumAbstract(this->player2Variables);
75 player2Strategy = A.getDdManager().getBddZero();
76 previousPlayer2Values = A.getDdManager().template getAddZero<ValueType>();
87 if (player2Goal == storm::OptimizationDirection::Maximize) {
90 if (generatePlayer2Strategy) {
93 player2Strategy.get() = newValues.
greater(previousPlayer2Values.get()).ite(maxChoices, player2Strategy.get());
94 previousPlayer2Values = newValues;
99 tmp = (tmp + illegalPlayer2Mask);
102 if (generatePlayer2Strategy) {
109 if (player1Goal == storm::OptimizationDirection::Maximize) {
112 if (generatePlayer1Strategy) {
115 player1Strategy = newValues.
greater(xCopy).ite(maxChoices, player1Strategy.get());
120 tmp = (tmp + illegalPlayer1Mask);
123 if (generatePlayer1Strategy) {
139 }
while (!converged && iterations < maxIter);
140 STORM_LOG_INFO(
"Numerically solving the game took " << iterations <<
" iterations.");
145template<storm::dd::DdType Type,
typename ValueType>
147 generatePlayer1Strategy = value;
150template<storm::dd::DdType Type,
typename ValueType>
152 generatePlayer2Strategy = value;
155template<storm::dd::DdType Type,
typename ValueType>
157 setGeneratePlayer1Strategy(value);
158 setGeneratePlayer2Strategy(value);
161template<storm::dd::DdType Type,
typename ValueType>
163 STORM_LOG_THROW(player1Strategy, storm::exceptions::IllegalFunctionCallException,
"Cannot retrieve player 1 strategy because none was generated.");
164 return player1Strategy.get();
167template<storm::dd::DdType Type,
typename ValueType>
169 STORM_LOG_THROW(player2Strategy, storm::exceptions::IllegalFunctionCallException,
"Cannot retrieve player 2 strategy because none was generated.");
170 return player2Strategy.get();
173template<storm::dd::DdType Type,
typename ValueType>
176 storm::dd::Bdd<Type> const& illegalPlayer2Mask, std::set<storm::expressions::Variable>
const& rowMetaVariables,
177 std::set<storm::expressions::Variable>
const& columnMetaVariables,
178 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>>
const& rowColumnMetaVariablePairs,
179 std::set<storm::expressions::Variable>
const& player1Variables, std::set<storm::expressions::Variable>
const& player2Variables)
const {
180 return std::unique_ptr<storm::solver::SymbolicGameSolver<Type, ValueType>>(
182 rowColumnMetaVariablePairs, player1Variables, player2Variables));
SolverEnvironment & solver()
storm::RationalNumber const & getPrecision() const
uint64_t const & getMaximalNumberOfIterations() const
bool const & getRelativeTerminationCriterion() const
storm::solver::GameMethod const & getMethod() const
GameSolverEnvironment & game()
Add< LibraryType, ValueType > swapVariables(std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const &metaVariablePairs) const
Swaps the given pairs of meta variables in the ADD.
Bdd< LibraryType > greater(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are gre...
Add< LibraryType, ValueType > maxAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Max-abstracts from the given meta variables.
Bdd< LibraryType > minAbstractRepresentative(std::set< storm::expressions::Variable > const &metaVariables) const
Similar to minAbstract, but does not abstract from the variables but rather picks a valuation of each...
Add< LibraryType, ValueType > minAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Min-abstracts from the given meta variables.
Add< LibraryType, ValueType > multiplyMatrix(Add< LibraryType, ValueType > const &otherMatrix, std::set< storm::expressions::Variable > const &summationMetaVariables) const
Multiplies the current ADD (representing a matrix) with the given matrix by summing over the given me...
bool equalModuloPrecision(Add< LibraryType, ValueType > const &other, ValueType const &precision, bool relative=true) const
Checks whether the current and the given ADD represent the same function modulo some given precision.
Bdd< LibraryType > maxAbstractRepresentative(std::set< storm::expressions::Variable > const &metaVariables) const
Similar to maxAbstract, but does not abstract from the variables but rather picks a valuation of each...
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
virtual std::unique_ptr< storm::solver::SymbolicGameSolver< Type, ValueType > > create(storm::dd::Add< Type, ValueType > const &A, storm::dd::Bdd< Type > const &allRows, storm::dd::Bdd< Type > const &illegalPlayer1Mask, storm::dd::Bdd< Type > const &illegalPlayer2Mask, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables, 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) const
An interface that represents an abstract symbolic game solver.
storm::dd::Bdd< Type > const & getPlayer1Strategy() const
SymbolicGameSolver(storm::dd::Add< Type, ValueType > const &A, storm::dd::Bdd< Type > const &allRows, storm::dd::Bdd< Type > const &illegalPlayer1Mask, storm::dd::Bdd< Type > const &illegalPlayer2Mask, std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables, 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)
Constructs a symbolic game solver with the given meta variable sets and pairs.
virtual storm::dd::Add< Type, ValueType > solveGame(Environment const &env, OptimizationDirection player1Goal, OptimizationDirection player2Goal, storm::dd::Add< Type, ValueType > const &x, storm::dd::Add< Type, ValueType > const &b, boost::optional< storm::dd::Bdd< Type > > const &basePlayer1Strategy=boost::none, boost::optional< storm::dd::Bdd< Type > > const &basePlayer2Strategy=boost::none)
Solves the equation system defined by the game matrix.
void setGeneratePlayer1Strategy(bool value)
void setGeneratePlayersStrategies(bool value)
storm::dd::Bdd< Type > const & getPlayer2Strategy() const
void setGeneratePlayer2Strategy(bool value)
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN_COND(cond, message)
#define STORM_LOG_THROW(cond, exception, message)