From b99a063ccea413abb02e97ffaaa255e95f0c360a Mon Sep 17 00:00:00 2001 From: PBerger Date: Thu, 23 Jun 2016 00:23:55 +0200 Subject: [PATCH] Replaced calls to std::abs with calls to std::fabs and included cmath. Former-commit-id: 40fb587e2fc33b9f5919b0a7a79bb3be111c8f11 --- test/functional/solver/GlpkLpSolverTest.cpp | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/test/functional/solver/GlpkLpSolverTest.cpp b/test/functional/solver/GlpkLpSolverTest.cpp index 4aea94cf7..737f8b56e 100644 --- a/test/functional/solver/GlpkLpSolverTest.cpp +++ b/test/functional/solver/GlpkLpSolverTest.cpp @@ -13,6 +13,8 @@ #include "src/storage/expressions/Expressions.h" #include "src/solver/OptimizationDirection.h" +#include + TEST(GlpkLpSolver, LPOptimizeMax) { storm::solver::GlpkLpSolver solver(storm::OptimizationDirection::Maximize); storm::expressions::Variable x; @@ -34,16 +36,16 @@ TEST(GlpkLpSolver, LPOptimizeMax) { ASSERT_FALSE(solver.isInfeasible()); double xValue = 0; ASSERT_NO_THROW(xValue = solver.getContinuousValue(x)); - ASSERT_LT(std::abs(xValue - 1), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(xValue - 1), storm::settings::getModule().getPrecision()); double yValue = 0; ASSERT_NO_THROW(yValue = solver.getContinuousValue(y)); - ASSERT_LT(std::abs(yValue - 6.5), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(yValue - 6.5), storm::settings::getModule().getPrecision()); double zValue = 0; ASSERT_NO_THROW(zValue = solver.getContinuousValue(z)); - ASSERT_LT(std::abs(zValue - 2.75), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(zValue - 2.75), storm::settings::getModule().getPrecision()); double objectiveValue = 0; ASSERT_NO_THROW(objectiveValue = solver.getObjectiveValue()); - ASSERT_LT(std::abs(objectiveValue - 14.75), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(objectiveValue - 14.75), storm::settings::getModule().getPrecision()); } TEST(GlpkLpSolver, LPOptimizeMin) { @@ -67,16 +69,16 @@ TEST(GlpkLpSolver, LPOptimizeMin) { ASSERT_FALSE(solver.isInfeasible()); double xValue = 0; ASSERT_NO_THROW(xValue = solver.getContinuousValue(x)); - ASSERT_LT(std::abs(xValue - 1), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(xValue - 1), storm::settings::getModule().getPrecision()); double yValue = 0; ASSERT_NO_THROW(yValue = solver.getContinuousValue(y)); - ASSERT_LT(std::abs(yValue - 0), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(yValue - 0), storm::settings::getModule().getPrecision()); double zValue = 0; ASSERT_NO_THROW(zValue = solver.getContinuousValue(z)); - ASSERT_LT(std::abs(zValue - 5.7), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(zValue - 5.7), storm::settings::getModule().getPrecision()); double objectiveValue = 0; ASSERT_NO_THROW(objectiveValue = solver.getObjectiveValue()); - ASSERT_LT(std::abs(objectiveValue - (-6.7)), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(objectiveValue - (-6.7)), storm::settings::getModule().getPrecision()); } TEST(GlpkLpSolver, MILPOptimizeMax) { @@ -106,10 +108,10 @@ TEST(GlpkLpSolver, MILPOptimizeMax) { ASSERT_EQ(6, yValue); double zValue = 0; ASSERT_NO_THROW(zValue = solver.getContinuousValue(z)); - ASSERT_LT(std::abs(zValue - 3), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(zValue - 3), storm::settings::getModule().getPrecision()); double objectiveValue = 0; ASSERT_NO_THROW(objectiveValue = solver.getObjectiveValue()); - ASSERT_LT(std::abs(objectiveValue - 14), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(objectiveValue - 14), storm::settings::getModule().getPrecision()); } TEST(GlpkLpSolver, MILPOptimizeMin) { @@ -139,10 +141,10 @@ TEST(GlpkLpSolver, MILPOptimizeMin) { ASSERT_EQ(0, yValue); double zValue = 0; ASSERT_NO_THROW(zValue = solver.getContinuousValue(z)); - ASSERT_LT(std::abs(zValue - 5), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(zValue - 5), storm::settings::getModule().getPrecision()); double objectiveValue = 0; ASSERT_NO_THROW(objectiveValue = solver.getObjectiveValue()); - ASSERT_LT(std::abs(objectiveValue - (-6)), storm::settings::getModule().getPrecision()); + ASSERT_LT(std::fabs(objectiveValue - (-6)), storm::settings::getModule().getPrecision()); } TEST(GlpkLpSolver, LPInfeasible) { @@ -244,4 +246,4 @@ TEST(GlpkLpSolver, MILPUnbounded) { ASSERT_THROW(solver.getContinuousValue(z), storm::exceptions::InvalidAccessException); ASSERT_THROW(solver.getObjectiveValue(), storm::exceptions::InvalidAccessException); } -#endif \ No newline at end of file +#endif