You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.8 KiB

  1. #ifndef STORM_SOLVER_GAMESOLVER_H_
  2. #define STORM_SOLVER_GAMESOLVER_H_
  3. #include <vector>
  4. #include "src/solver/AbstractGameSolver.h"
  5. #include "src/solver/OptimizationDirection.h"
  6. #include "src/storage/sparse/StateType.h"
  7. namespace storm {
  8. namespace storage {
  9. template<typename ValueType>
  10. class SparseMatrix;
  11. }
  12. namespace solver {
  13. template<typename ValueType>
  14. class GameSolver : public AbstractGameSolver {
  15. public:
  16. /*
  17. * Constructs a game solver with the given player 1 and player 2 matrices.
  18. *
  19. * @param player1Matrix The matrix defining the choices of player 1.
  20. * @param player2Matrix The matrix defining the choices of player 2.
  21. */
  22. GameSolver(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, storm::storage::SparseMatrix<ValueType> const& player2Matrix);
  23. /*
  24. * Constructs a game solver with the given player 1 and player 2 matrices and options.
  25. *
  26. * @param player1Matrix The matrix defining the choices of player 1.
  27. * @param player2Matrix The matrix defining the choices of player 2.
  28. * @param precision The precision that is used to detect convergence.
  29. * @param maximalNumberOfIterations The maximal number of iterations.
  30. * @param relative Sets whether or not to detect convergence with a relative or absolute criterion.
  31. */
  32. GameSolver(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, storm::storage::SparseMatrix<ValueType> const& player2Matrix, double precision, uint_fast64_t maximalNumberOfIterations, bool relative);
  33. /*!
  34. * Solves the equation system defined by the game matrix. Note that the game matrix has to be given upon
  35. * construction time of the solver object.
  36. *
  37. * @param player1Goal Sets whether player 1 wants to minimize or maximize.
  38. * @param player2Goal Sets whether player 2 wants to minimize or maximize.
  39. * @param x The initial guess of the solution.
  40. * @param b The vector to add after matrix-vector multiplication.
  41. * @return The solution vector in the for of the vector x.
  42. */
  43. virtual void solveGame(OptimizationDirection player1Goal, OptimizationDirection player2Goal, std::vector<ValueType>& x, std::vector<ValueType> const& b) const;
  44. private:
  45. // The matrix defining the choices of player 1.
  46. storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix;
  47. // The matrix defining the choices of player 2.
  48. storm::storage::SparseMatrix<ValueType> const& player2Matrix;
  49. };
  50. }
  51. }
  52. #endif /* STORM_SOLVER_GAMESOLVER_H_ */