1#include "storm-config.h"
13class NativeDoublePowerEnvironment {
15 typedef double ValueType;
16 static const bool isExact =
false;
17 static storm::Environment createEnvironment() {
18 storm::Environment env;
26class NativeDoublePowerRegMultEnvironment {
28 typedef double ValueType;
29 static const bool isExact =
false;
30 static storm::Environment createEnvironment() {
31 storm::Environment env;
40class NativeDoubleSoundValueIterationEnvironment {
42 typedef double ValueType;
43 static const bool isExact =
false;
44 static storm::Environment createEnvironment() {
45 storm::Environment env;
48 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::SoundValueIteration);
55class NativeDoubleOptimisticValueIterationEnvironment {
57 typedef double ValueType;
58 static const bool isExact =
false;
59 static storm::Environment createEnvironment() {
60 storm::Environment env;
63 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::OptimisticValueIteration);
70class NativeDoubleIntervalIterationEnvironment {
72 typedef double ValueType;
73 static const bool isExact =
false;
74 static storm::Environment createEnvironment() {
75 storm::Environment env;
85class NativeDoubleGuessingViEnvironment {
87 typedef double ValueType;
88 static const bool isExact =
false;
89 static storm::Environment createEnvironment() {
90 storm::Environment env;
93 env.
solver().
native().
setMethod(storm::solver::NativeLinearEquationSolverMethod::GuessingValueIteration);
100class NativeDoubleJacobiEnvironment {
102 typedef double ValueType;
103 static const bool isExact =
false;
104 static storm::Environment createEnvironment() {
105 storm::Environment env;
113class NativeDoubleGaussSeidelEnvironment {
115 typedef double ValueType;
116 static const bool isExact =
false;
117 static storm::Environment createEnvironment() {
118 storm::Environment env;
126class NativeDoubleSorEnvironment {
128 typedef double ValueType;
129 static const bool isExact =
false;
130 static storm::Environment createEnvironment() {
131 storm::Environment env;
139class NativeDoubleWalkerChaeEnvironment {
141 typedef double ValueType;
142 static const bool isExact =
false;
143 static storm::Environment createEnvironment() {
144 storm::Environment env;
153class NativeRationalRationalSearchEnvironment {
155 typedef storm::RationalNumber ValueType;
156 static const bool isExact =
true;
157 static storm::Environment createEnvironment() {
158 storm::Environment env;
165class EliminationRationalEnvironment {
167 typedef storm::RationalNumber ValueType;
168 static const bool isExact =
true;
169 static storm::Environment createEnvironment() {
170 storm::Environment env;
177class GmmGmresIluEnvironment {
180 static const bool isExact =
false;
181 static storm::Environment createEnvironment() {
182 storm::Environment env;
191class GmmGmresDiagonalEnvironment {
194 static const bool isExact =
false;
195 static storm::Environment createEnvironment() {
196 storm::Environment env;
205class GmmGmresNoneEnvironment {
208 static const bool isExact =
false;
209 static storm::Environment createEnvironment() {
210 storm::Environment env;
219class GmmBicgstabIluEnvironment {
222 static const bool isExact =
false;
223 static storm::Environment createEnvironment() {
224 storm::Environment env;
233class GmmQmrDiagonalEnvironment {
236 static const bool isExact =
false;
237 static storm::Environment createEnvironment() {
238 storm::Environment env;
248class EigenDGmresDiagonalEnvironment {
250 typedef double ValueType;
251 static const bool isExact =
false;
252 static storm::Environment createEnvironment() {
253 storm::Environment env;
262class EigenGmresIluEnvironment {
264 typedef double ValueType;
265 static const bool isExact =
false;
266 static storm::Environment createEnvironment() {
267 storm::Environment env;
276class EigenBicgstabNoneEnvironment {
278 typedef double ValueType;
279 static const bool isExact =
false;
280 static storm::Environment createEnvironment() {
281 storm::Environment env;
290class EigenDoubleLUEnvironment {
292 typedef double ValueType;
293 static const bool isExact =
false;
294 static storm::Environment createEnvironment() {
295 storm::Environment env;
302class EigenRationalLUEnvironment {
304 typedef storm::RationalNumber ValueType;
305 static const bool isExact =
true;
306 static storm::Environment createEnvironment() {
307 storm::Environment env;
314class TopologicalEigenRationalLUEnvironment {
316 typedef storm::RationalNumber ValueType;
317 static const bool isExact =
true;
318 static storm::Environment createEnvironment() {
319 storm::Environment env;
327template<
typename TestType>
328class LinearEquationSolverTest :
public ::testing::Test {
330 typedef typename TestType::ValueType ValueType;
331 LinearEquationSolverTest() : _environment(TestType::createEnvironment()) {}
332 storm::Environment
const& env()
const {
335 ValueType precision()
const {
338 ValueType
parseNumber(std::string
const& input)
const {
343 storm::Environment _environment;
346typedef ::testing::Types<NativeDoublePowerEnvironment, NativeDoublePowerRegMultEnvironment, NativeDoubleSoundValueIterationEnvironment,
347 NativeDoubleOptimisticValueIterationEnvironment, NativeDoubleGuessingViEnvironment, NativeDoubleIntervalIterationEnvironment,
348 NativeDoubleJacobiEnvironment, NativeDoubleGaussSeidelEnvironment, NativeDoubleSorEnvironment, NativeDoubleWalkerChaeEnvironment,
349 NativeRationalRationalSearchEnvironment, EliminationRationalEnvironment,
351 GmmGmresIluEnvironment, GmmGmresDiagonalEnvironment, GmmGmresNoneEnvironment, GmmBicgstabIluEnvironment, GmmQmrDiagonalEnvironment,
353 EigenDGmresDiagonalEnvironment, EigenGmresIluEnvironment, EigenBicgstabNoneEnvironment, EigenDoubleLUEnvironment,
354 EigenRationalLUEnvironment, TopologicalEigenRationalLUEnvironment>
359TYPED_TEST(LinearEquationSolverTest, solveEquationSystem) {
360 typedef typename TestFixture::ValueType
ValueType;
363 ASSERT_NO_THROW(builder.
addNextValue(0, 0, this->parseNumber(
"1/5")));
364 ASSERT_NO_THROW(builder.
addNextValue(0, 1, this->parseNumber(
"2/5")));
365 ASSERT_NO_THROW(builder.
addNextValue(0, 2, this->parseNumber(
"2/5")));
366 ASSERT_NO_THROW(builder.
addNextValue(1, 0, this->parseNumber(
"1/50")));
367 ASSERT_NO_THROW(builder.
addNextValue(1, 1, this->parseNumber(
"48/50")));
368 ASSERT_NO_THROW(builder.
addNextValue(1, 2, this->parseNumber(
"1/50")));
369 ASSERT_NO_THROW(builder.
addNextValue(2, 0, this->parseNumber(
"4/10")));
370 ASSERT_NO_THROW(builder.
addNextValue(2, 1, this->parseNumber(
"3/10")));
371 ASSERT_NO_THROW(builder.
addNextValue(2, 2, this->parseNumber(
"0")));
374 ASSERT_NO_THROW(A = builder.
build());
376 std::vector<ValueType> x(3);
384 auto requirements = factory.getRequirements(this->env());
385 requirements.clearUpperBounds();
386 requirements.clearLowerBounds();
387 ASSERT_FALSE(requirements.hasEnabledRequirement());
388 auto solver = factory.create(this->env(), A);
390 ASSERT_NO_THROW(solver->solveEquations(this->env(), x, b));
391 EXPECT_NEAR(x[0], this->
parseNumber(
"481/9"), this->precision());
392 EXPECT_NEAR(x[1], this->
parseNumber(
"457/9"), this->precision());
393 EXPECT_NEAR(x[2], this->
parseNumber(
"875/18"), this->precision());
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 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