#ifndef STORM_SOLVER_SYMBOLICGAMESOLVER_H_ #define STORM_SOLVER_SYMBOLICGAMESOLVER_H_ #include #include #include "src/solver/AbstractGameSolver.h" #include "src/solver/OptimizationDirection.h" #include "src/storage/expressions/Variable.h" #include "src/storage/dd/Bdd.h" #include "src/storage/dd/Add.h" namespace storm { namespace solver { /*! * An interface that represents an abstract symbolic game solver. */ template class SymbolicGameSolver : public AbstractGameSolver { public: /*! * Constructs a symbolic game solver with the given meta variable sets and pairs. * * @param gameMatrix The matrix defining the coefficients of the game. * @param allRows A BDD characterizing all rows of the equation system. * @param illegalPlayer1Mask A BDD characterizing the illegal choices of player 1. * @param illegalPlayer2Mask A BDD characterizing the illegal choices of player 2. * @param rowMetaVariables The meta variables used to encode the rows of the matrix. * @param columnMetaVariables The meta variables used to encode the columns of the matrix. * @param rowColumnMetaVariablePairs The pairs of row meta variables and the corresponding column meta * variables. * @param player1Variables The meta variables used to encode the player 1 choices. * @param player2Variables The meta variables used to encode the player 2 choices. */ SymbolicGameSolver(storm::dd::Add const& gameMatrix, storm::dd::Bdd const& allRows, storm::dd::Bdd const& illegalPlayer1Mask, storm::dd::Bdd const& illegalPlayer2Mask, std::set const& rowMetaVariables, std::set const& columnMetaVariables, std::vector> const& rowColumnMetaVariablePairs, std::set const& player1Variables, std::set const& player2Variables); /*! * Constructs a symbolic game solver with the given meta variable sets and pairs. * * @param gameMatrix The matrix defining the coefficients of the game. * @param allRows A BDD characterizing all rows of the equation system. * @param illegalPlayer1Mask A BDD characterizing the illegal choices of player 1. * @param illegalPlayer2Mask A BDD characterizing the illegal choices of player 2. * @param rowMetaVariables The meta variables used to encode the rows of the matrix. * @param columnMetaVariables The meta variables used to encode the columns of the matrix. * @param rowColumnMetaVariablePairs The pairs of row meta variables and the corresponding column meta * variables. * @param player1Variables The meta variables used to encode the player 1 choices. * @param player2Variables The meta variables used to encode the player 2 choices. * @param precision The precision to achieve. * @param maximalNumberOfIterations The maximal number of iterations to perform when solving a linear * equation system iteratively. * @param relative Sets whether or not to use a relativ stopping criterion rather than an absolute one. */ SymbolicGameSolver(storm::dd::Add const& gameMatrix, storm::dd::Bdd const& allRows, storm::dd::Bdd const& illegalPlayer1Mask, storm::dd::Bdd const& illegalPlayer2Mask, std::set const& rowMetaVariables, std::set const& columnMetaVariables, std::vector> const& rowColumnMetaVariablePairs, std::set const& player1Variables, std::set const& player2Variables, double precision, uint_fast64_t maximalNumberOfIterations, bool relative); /*! * Solves the equation system defined by the game matrix. Note that the game matrix has to be given upon * construction time of the solver object. * * @param player1Goal Sets whether player 1 wants to minimize or maximize. * @param player2Goal Sets whether player 2 wants to minimize or maximize. * @param x The initial guess of the solution. * @param b The vector to add after matrix-vector multiplication. * @return The solution vector. */ virtual storm::dd::Add solveGame(OptimizationDirection player1Goal, OptimizationDirection player2Goal, storm::dd::Add const& x, storm::dd::Add const& b); // Setters that enable the generation of the players' strategies. void setGeneratePlayer1Strategy(bool value); void setGeneratePlayer2Strategy(bool value); void setGeneratePlayersStrategies(bool value); // Getters to retrieve the players' strategies. Only legal if they were generated. storm::dd::Bdd const& getPlayer1Strategy() const; storm::dd::Bdd const& getPlayer2Strategy() const; protected: // The matrix defining the coefficients of the linear equation system. storm::dd::Add A; // A BDD characterizing all rows of the equation system. storm::dd::Bdd allRows; // An ADD that can be used to compensate for the illegal choices of player 1. storm::dd::Add illegalPlayer1Mask; // An ADD that can be used to compensate for the illegal choices of player 2. storm::dd::Add illegalPlayer2Mask; // The row variables. std::set rowMetaVariables; // The column variables. std::set columnMetaVariables; // The pairs of meta variables used for renaming. std::vector> rowColumnMetaVariablePairs; // The player 1 variables. std::set player1Variables; // The player 2 variables. std::set player2Variables; // A flag indicating whether a player 1 is to be generated. bool generatePlayer1Strategy; // A player 1 strategy if one was generated. boost::optional> player1Strategy; // A flag indicating whether a player 2 is to be generated. bool generatePlayer2Strategy; // A player 1 strategy if one was generated. boost::optional> player2Strategy; }; } // namespace solver } // namespace storm #endif /* STORM_SOLVER_SYMBOLICGAMESOLVER_H_ */