1#include "storm-config.h"
15class NativeDoublePowerEnvironment {
17 typedef double ValueType;
18 static const bool isExact =
false;
19 static storm::Environment createEnvironment() {
20 storm::Environment env;
28class NativeDoublePowerRegMultEnvironment {
30 typedef double ValueType;
31 static const bool isExact =
false;
32 static storm::Environment createEnvironment() {
33 storm::Environment env;
42class NativeDoubleSoundValueIterationEnvironment {
44 typedef double ValueType;
45 static const bool isExact =
false;
46 static storm::Environment createEnvironment() {
47 storm::Environment env;
50 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::SoundValueIteration);
57class NativeDoubleOptimisticValueIterationEnvironment {
59 typedef double ValueType;
60 static const bool isExact =
false;
61 static storm::Environment createEnvironment() {
62 storm::Environment env;
65 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::OptimisticValueIteration);
72class NativeDoubleIntervalIterationEnvironment {
74 typedef double ValueType;
75 static const bool isExact =
false;
76 static storm::Environment createEnvironment() {
77 storm::Environment env;
87class NativeDoubleGuessingViEnvironment {
89 typedef double ValueType;
90 static const bool isExact =
false;
91 static storm::Environment createEnvironment() {
92 storm::Environment env;
95 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::GuessingValueIteration);
102class NativeDoubleJacobiEnvironment {
104 typedef double ValueType;
105 static const bool isExact =
false;
106 static storm::Environment createEnvironment() {
107 storm::Environment env;
115class NativeDoubleGaussSeidelEnvironment {
117 typedef double ValueType;
118 static const bool isExact =
false;
119 static storm::Environment createEnvironment() {
120 storm::Environment env;
128class NativeDoubleSorEnvironment {
130 typedef double ValueType;
131 static const bool isExact =
false;
132 static storm::Environment createEnvironment() {
133 storm::Environment env;
141class NativeDoubleWalkerChaeEnvironment {
143 typedef double ValueType;
144 static const bool isExact =
false;
145 static storm::Environment createEnvironment() {
146 storm::Environment env;
155class NativeRationalRationalSearchEnvironment {
157 typedef storm::RationalNumber ValueType;
158 static const bool isExact =
true;
159 static storm::Environment createEnvironment() {
160 storm::Environment env;
167class EliminationRationalEnvironment {
169 typedef storm::RationalNumber ValueType;
170 static const bool isExact =
true;
171 static storm::Environment createEnvironment() {
172 storm::Environment env;
179class GmmGmresIluEnvironment {
182 static const bool isExact =
false;
183 static storm::Environment createEnvironment() {
184 storm::Environment env;
193class GmmGmresDiagonalEnvironment {
196 static const bool isExact =
false;
197 static storm::Environment createEnvironment() {
198 storm::Environment env;
207class GmmGmresNoneEnvironment {
210 static const bool isExact =
false;
211 static storm::Environment createEnvironment() {
212 storm::Environment env;
221class GmmBicgstabIluEnvironment {
224 static const bool isExact =
false;
225 static storm::Environment createEnvironment() {
226 storm::Environment env;
235class GmmQmrDiagonalEnvironment {
238 static const bool isExact =
false;
239 static storm::Environment createEnvironment() {
240 storm::Environment env;
250class EigenDGmresDiagonalEnvironment {
252 typedef double ValueType;
253 static const bool isExact =
false;
254 static storm::Environment createEnvironment() {
255 storm::Environment env;
264class EigenGmresIluEnvironment {
266 typedef double ValueType;
267 static const bool isExact =
false;
268 static storm::Environment createEnvironment() {
269 storm::Environment env;
278class EigenBicgstabNoneEnvironment {
280 typedef double ValueType;
281 static const bool isExact =
false;
282 static storm::Environment createEnvironment() {
283 storm::Environment env;
292class EigenDoubleLUEnvironment {
294 typedef double ValueType;
295 static const bool isExact =
false;
296 static storm::Environment createEnvironment() {
297 storm::Environment env;
304class EigenRationalLUEnvironment {
306 typedef storm::RationalNumber ValueType;
307 static const bool isExact =
true;
308 static storm::Environment createEnvironment() {
309 storm::Environment env;
316class TopologicalEigenRationalLUEnvironment {
318 typedef storm::RationalNumber ValueType;
319 static const bool isExact =
true;
320 static storm::Environment createEnvironment() {
321 storm::Environment env;
329template<
typename TestType>
330class LinearEquationSolverTest :
public ::testing::Test {
332 typedef typename TestType::ValueType ValueType;
333 LinearEquationSolverTest() : _environment(TestType::createEnvironment()) {}
334 storm::Environment
const& env()
const {
337 ValueType precision()
const {
340 ValueType
parseNumber(std::string
const& input)
const {
345 storm::Environment _environment;
348typedef ::testing::Types<NativeDoublePowerEnvironment, NativeDoublePowerRegMultEnvironment, NativeDoubleSoundValueIterationEnvironment,
349 NativeDoubleOptimisticValueIterationEnvironment, NativeDoubleGuessingViEnvironment, NativeDoubleIntervalIterationEnvironment,
350 NativeDoubleJacobiEnvironment, NativeDoubleGaussSeidelEnvironment, NativeDoubleSorEnvironment, NativeDoubleWalkerChaeEnvironment,
351 NativeRationalRationalSearchEnvironment, EliminationRationalEnvironment,
353 GmmGmresIluEnvironment, GmmGmresDiagonalEnvironment, GmmGmresNoneEnvironment, GmmBicgstabIluEnvironment, GmmQmrDiagonalEnvironment,
355 EigenDGmresDiagonalEnvironment, EigenGmresIluEnvironment, EigenBicgstabNoneEnvironment, EigenDoubleLUEnvironment,
356 EigenRationalLUEnvironment, TopologicalEigenRationalLUEnvironment>
361TYPED_TEST(LinearEquationSolverTest, solveEquationSystem) {
362 typedef typename TestFixture::ValueType
ValueType;
365 ASSERT_NO_THROW(builder.
addNextValue(0, 0, this->parseNumber(
"1/5")));
366 ASSERT_NO_THROW(builder.
addNextValue(0, 1, this->parseNumber(
"2/5")));
367 ASSERT_NO_THROW(builder.
addNextValue(0, 2, this->parseNumber(
"2/5")));
368 ASSERT_NO_THROW(builder.
addNextValue(1, 0, this->parseNumber(
"1/50")));
369 ASSERT_NO_THROW(builder.
addNextValue(1, 1, this->parseNumber(
"48/50")));
370 ASSERT_NO_THROW(builder.
addNextValue(1, 2, this->parseNumber(
"1/50")));
371 ASSERT_NO_THROW(builder.
addNextValue(2, 0, this->parseNumber(
"4/10")));
372 ASSERT_NO_THROW(builder.
addNextValue(2, 1, this->parseNumber(
"3/10")));
373 ASSERT_NO_THROW(builder.
addNextValue(2, 2, this->parseNumber(
"0")));
376 ASSERT_NO_THROW(A = builder.
build());
378 std::vector<ValueType> x(3);
386 auto requirements = factory.getRequirements(this->env());
387 requirements.clearUpperBounds();
388 requirements.clearLowerBounds();
389 ASSERT_FALSE(requirements.hasEnabledRequirement());
390 auto solver = factory.create(this->env(), A);
392 ASSERT_NO_THROW(solver->solveEquations(this->env(), x, b));
393 EXPECT_NEAR(x[0], this->
parseNumber(
"481/9"), this->precision());
394 EXPECT_NEAR(x[1], this->
parseNumber(
"457/9"), this->precision());
395 EXPECT_NEAR(x[2], this->
parseNumber(
"875/18"), this->precision());
398template<
typename ValueType>
399void testEliminationWithAbsorbingStates(std::vector<std::vector<std::pair<uint64_t, ValueType>>>
const& rows, std::vector<ValueType>
const& b,
400 std::vector<ValueType>
const& expected) {
402 for (uint64_t row = 0; row < rows.size(); ++row) {
403 for (
auto const& entry : rows[row]) {
407 auto matrix = builder.
build();
412 std::vector<ValueType> x(b.size());
413 ASSERT_NO_THROW(solver.solveEquations(env, x, b));
414 ASSERT_EQ(expected.size(), x.size());
415 for (uint64_t i = 0;
i < x.size(); ++
i) {
416 EXPECT_EQ(expected[i], x[i]);
420TEST(EliminationLinearEquationSolver, AbsorbingState) {
427TEST(EliminationLinearEquationSolver, AbsorbingTwoCycle) {
432 testEliminationWithAbsorbingStates<storm::RationalNumber>({{{1,
one}}, {{0,
one}}}, {
zero,
zero}, {
zero,
zero});
435 testEliminationWithAbsorbingStates<double>({{{1, 1.0}}, {{0, 1.0}}}, {0.0, 0.0}, {0.0, 0.0});
438TEST(EliminationLinearEquationSolver, AbsorbingSinkReachability) {
443 testEliminationWithAbsorbingStates<storm::RationalNumber>({{{1, half}}, {{2,
one}}, {{1,
one}}}, {half,
zero,
zero}, {half,
zero,
zero});
void setPrecision(storm::RationalNumber value)
void setPreconditioner(storm::solver::EigenLinearEquationSolverPreconditioner value)
void setMethod(storm::solver::EigenLinearEquationSolverMethod value)
SolverEnvironment & solver()
void setMethod(storm::solver::GmmxxLinearEquationSolverMethod value)
void setPrecision(storm::RationalNumber value)
void setPreconditioner(storm::solver::GmmxxLinearEquationSolverPreconditioner value)
void setPowerMethodMultiplicationStyle(storm::solver::MultiplicationStyle value)
void setMaximalNumberOfIterations(uint64_t value)
void setMethod(storm::solver::NativeLinearEquationSolverMethod value)
void setRelativeTerminationCriterion(bool value)
void setPrecision(storm::RationalNumber value)
TopologicalSolverEnvironment & topological()
void setLinearEquationSolverType(storm::solver::EquationSolverType const &value, bool isSetFromDefault=false)
EigenSolverEnvironment & eigen()
void setForceSoundness(bool value)
NativeSolverEnvironment & native()
GmmxxSolverEnvironment & gmmxx()
void setUnderlyingEquationSolverType(storm::solver::EquationSolverType value)
A class that uses gaussian elimination to implement the LinearEquationSolver interface.
A class that can be used to build a sparse matrix by adding value by value.
void addNextValue(index_type row, index_type column, value_type const &value)
Sets the matrix entry at the given row and column to the given value.
SparseMatrix< value_type > build(index_type overriddenRowCount=0, index_type overriddenColumnCount=0, index_type overriddenRowGroupCount=0)
A class that holds a possibly non-square matrix in the compressed row storage format.
void convertToEquationSystem()
Transforms the matrix into an equation system.
SFTBDDChecker::ValueType ValueType
NumberType parseNumber(std::string const &value)
Parse number from string.
TargetType convertNumber(SourceType const &number)
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes