dehnert
9 years ago
7 changed files with 159 additions and 42 deletions
-
22src/solver/AbstractGameSolver.cpp
-
40src/solver/AbstractGameSolver.h
-
17src/solver/GameSolver.cpp
-
52src/solver/GameSolver.h
-
28src/solver/SymbolicGameSolver.cpp
-
34src/solver/SymbolicGameSolver.h
-
8test/functional/solver/FullySymbolicGameSolverTest.cpp
@ -0,0 +1,22 @@ |
|||
#include "src/solver/AbstractGameSolver.h"
|
|||
|
|||
#include "src/settings/SettingsManager.h"
|
|||
#include "src/settings/modules/NativeEquationSolverSettings.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
AbstractGameSolver::AbstractGameSolver() { |
|||
// Get the settings object to customize solving.
|
|||
storm::settings::modules::NativeEquationSolverSettings const& settings = storm::settings::nativeEquationSolverSettings(); |
|||
|
|||
// Get appropriate settings.
|
|||
maximalNumberOfIterations = settings.getMaximalIterationCount(); |
|||
precision = settings.getPrecision(); |
|||
relative = settings.getConvergenceCriterion() == storm::settings::modules::NativeEquationSolverSettings::ConvergenceCriterion::Relative; |
|||
} |
|||
|
|||
AbstractGameSolver::AbstractGameSolver(double precision, uint_fast64_t maximalNumberOfIterations, bool relative) : precision(precision), maximalNumberOfIterations(maximalNumberOfIterations), relative(relative) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
#ifndef STORM_SOLVER_ABSTRACTGAMESOLVER_H_ |
|||
#define STORM_SOLVER_ABSTRACTGAMESOLVER_H_ |
|||
|
|||
#include <cstdint> |
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
/*! |
|||
* The abstract base class for the game solvers. |
|||
*/ |
|||
class AbstractGameSolver { |
|||
public: |
|||
/*! |
|||
* Creates a game solver with the default parameters. |
|||
*/ |
|||
AbstractGameSolver(); |
|||
|
|||
/*! |
|||
* Creates a game solver with the given parameters. |
|||
* |
|||
* @param precision The precision to achieve. |
|||
* @param maximalNumberOfIterations The maximal number of iterations to perform. |
|||
* @param relative A flag indicating whether a relative or an absolute stopping criterion is to be used. |
|||
*/ |
|||
AbstractGameSolver(double precision, uint_fast64_t maximalNumberOfIterations, bool relative); |
|||
|
|||
protected: |
|||
// The precision to achieve. |
|||
double precision; |
|||
|
|||
// The maximal number of iterations to perform. |
|||
uint_fast64_t maximalNumberOfIterations; |
|||
|
|||
// A flag indicating whether a relative or an absolute stopping criterion is to be used. |
|||
bool relative; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_SOLVER_ABSTRACTGAMESOLVER_H_ */ |
@ -0,0 +1,17 @@ |
|||
#include "src/solver/GameSolver.h"
|
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
GameSolver::GameSolver(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, storm::storage::SparseMatrix<ValueType> const& player2Matrix) : AbstractGameSolver(), player1Matrix(player1Matrix), player2Matrix(player2Matrix) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
GameSolver::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) : AbstractGameSolver(precision, maximalNumberOfIterations, relative), player1Matrix(player1Matrix), player2Matrix(player2Matrix) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
void GameSolver::solveGame(OptimizationDirection player1Goal, OptimizationDirection player2Goal, std::vector<ValueType>& x, storm::dd::Add<Type> const& b) const { |
|||
// TODO
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
#ifndef STORM_SOLVER_GAMESOLVER_H_ |
|||
#define STORM_SOLVER_GAMESOLVER_H_ |
|||
|
|||
#include "src/solver/AbstractGameSolver.h" |
|||
|
|||
namespace storm { |
|||
namespace solver { |
|||
template<typename ValueType> |
|||
class GameSolver : public AbstractGameSolver { |
|||
public: |
|||
/* |
|||
* Constructs a game solver with the given player 1 and player 2 matrices. |
|||
* |
|||
* @param player1Matrix The matrix defining the choices of player 1. |
|||
* @param player2Matrix The matrix defining the choices of player 2. |
|||
*/ |
|||
GameSolver(storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix, storm::storage::SparseMatrix<ValueType> const& player2Matrix); |
|||
|
|||
/* |
|||
* Constructs a game solver with the given player 1 and player 2 matrices and options. |
|||
* |
|||
* @param player1Matrix The matrix defining the choices of player 1. |
|||
* @param player2Matrix The matrix defining the choices of player 2. |
|||
* @param precision The precision that is used to detect convergence. |
|||
* @param maximalNumberOfIterations The maximal number of iterations. |
|||
* @param relative Sets whether or not to detect convergence with a relative or absolute criterion. |
|||
*/ |
|||
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); |
|||
|
|||
/*! |
|||
* 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 in the for of the vector x. |
|||
*/ |
|||
virtual void solveGame(OptimizationDirection player1Goal, OptimizationDirection player2Goal, std::vector<ValueType>& x, storm::dd::Add<Type> const& b) const; |
|||
|
|||
private: |
|||
// The matrix defining the choices of player 1. |
|||
storm::storage::SparseMatrix<storm::storage::sparse::state_type> const& player1Matrix; |
|||
|
|||
// The matrix defining the choices of player 2. |
|||
storm::storage::SparseMatrix<ValueType> const& player2Matrix; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_SOLVER_GAMESOLVER_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue