Created
August 28, 2019 23:03
-
-
Save rcurtin/e70df70cdb56072d28940ec197ba8036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From bd9b09fe6c48fef623adda139fb496a2da0ef34a Mon Sep 17 00:00:00 2001 | |
From: Ryan Curtin <ryan@ratml.org> | |
Date: Wed, 28 Aug 2019 19:02:43 -0400 | |
Subject: [PATCH] Use operator() not operator[] for bounds checks. | |
--- | |
tests/ada_delta_test.cpp | 12 +- | |
tests/ada_grad_test.cpp | 12 +- | |
tests/adam_test.cpp | 124 +++++++++---------- | |
tests/aug_lagrangian_test.cpp | 22 ++-- | |
tests/callbacks_test.cpp | 10 +- | |
tests/cmaes_test.cpp | 6 +- | |
tests/cne_test.cpp | 36 +++--- | |
tests/eve_test.cpp | 22 ++-- | |
tests/frankwolfe_test.cpp | 30 ++--- | |
tests/ftml_test.cpp | 18 +-- | |
tests/gradient_descent_test.cpp | 10 +- | |
tests/grid_search_test.cpp | 24 ++-- | |
tests/lbfgs_test.cpp | 30 ++--- | |
tests/line_search_test.cpp | 12 +- | |
tests/momentum_sgd_test.cpp | 18 +-- | |
tests/nesterov_momentum_sgd_test.cpp | 12 +- | |
tests/parallel_sgd_test.cpp | 14 +-- | |
tests/pso_test.cpp | 52 ++++---- | |
tests/quasi_hyperbolic_momentum_sgd_test.cpp | 20 +-- | |
tests/rmsprop_test.cpp | 6 +- | |
tests/sa_test.cpp | 14 +-- | |
tests/scd_test.cpp | 26 ++-- | |
tests/sgd_test.cpp | 16 +-- | |
tests/smorms3_test.cpp | 6 +- | |
tests/spsa_test.cpp | 16 +-- | |
tests/swats_test.cpp | 16 +-- | |
tests/test_function_tools.hpp | 18 +-- | |
tests/wn_grad_test.cpp | 16 +-- | |
28 files changed, 309 insertions(+), 309 deletions(-) | |
diff --git a/tests/ada_delta_test.cpp b/tests/ada_delta_test.cpp | |
index 2fe805e..f4de369 100644 | |
--- a/tests/ada_delta_test.cpp | |
+++ b/tests/ada_delta_test.cpp | |
@@ -29,9 +29,9 @@ TEST_CASE("SimpleAdaDeltaTestFunction", "[AdaDeltaTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.003)); | |
} | |
/** | |
@@ -71,9 +71,9 @@ TEST_CASE("SimpleAdaDeltaTestFunctionFMat", "[AdaDeltaTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0f).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.0f).margin(0.01)); | |
- REQUIRE(coordinates[2] == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(2) == Approx(0.0f).margin(0.01)); | |
} | |
/** | |
diff --git a/tests/ada_grad_test.cpp b/tests/ada_grad_test.cpp | |
index e8ad21b..2900a79 100644 | |
--- a/tests/ada_grad_test.cpp | |
+++ b/tests/ada_grad_test.cpp | |
@@ -28,9 +28,9 @@ TEST_CASE("SimpleAdaGradTestFunction", "[AdaGradTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.003)); | |
} | |
/** | |
@@ -69,9 +69,9 @@ TEST_CASE("SimpleAdaGradTestFunctionFMat", "[AdaGradTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0f).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.0f).margin(0.01)); | |
- REQUIRE(coordinates[2] == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.0f).margin(0.01)); | |
+ REQUIRE(coordinates(2) == Approx(0.0f).margin(0.01)); | |
} | |
/** | |
diff --git a/tests/adam_test.cpp b/tests/adam_test.cpp | |
index 482af37..751390f 100644 | |
--- a/tests/adam_test.cpp | |
+++ b/tests/adam_test.cpp | |
@@ -31,8 +31,8 @@ TEST_CASE("AdamSphereFunctionTest", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -46,8 +46,8 @@ TEST_CASE("AdamSphereFunctionTestFMat", "[AdamTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
#if ARMA_VERSION_MAJOR > 9 ||\ | |
@@ -64,8 +64,8 @@ TEST_CASE("AdamSphereFunctionTestSpMat", "[AdamTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -80,8 +80,8 @@ TEST_CASE("AdamSphereFunctionTestSpMatDenseGradient", "[AdamTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize<decltype(f), arma::sp_mat, arma::mat>(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
#endif | |
@@ -97,8 +97,8 @@ TEST_CASE("AdamStyblinskiTangFunctionTest", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
} | |
/** | |
@@ -113,8 +113,8 @@ TEST_CASE("AdamMcCormickFunctionTest", "[AdamTest]") | |
optimizer.Optimize(f, coordinates); | |
// 3% error tolerance. | |
- REQUIRE(coordinates[0] == Approx(-0.547).epsilon(0.03)); | |
- REQUIRE(coordinates[1] == Approx(-1.547).epsilon(0.03)); | |
+ REQUIRE(coordinates(0) == Approx(-0.547).epsilon(0.03)); | |
+ REQUIRE(coordinates(1) == Approx(-1.547).epsilon(0.03)); | |
} | |
/** | |
@@ -129,9 +129,9 @@ TEST_CASE("AdamMatyasFunctionTest", "[AdamTest]") | |
optimizer.Optimize(f, coordinates); | |
// 3% error tolerance. | |
- REQUIRE((std::trunc(100.0 * coordinates[0]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(0)) / 100.0) == | |
Approx(0.0).epsilon(0.003)); | |
- REQUIRE((std::trunc(100.0 * coordinates[1]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(1)) / 100.0) == | |
Approx(0.0).epsilon(0.003)); | |
} | |
@@ -147,9 +147,9 @@ TEST_CASE("AdamEasomFunctionTest", "[AdamTest]") | |
optimizer.Optimize(f, coordinates); | |
// 5% error tolerance. | |
- REQUIRE((std::trunc(100.0 * coordinates[0]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(0)) / 100.0) == | |
Approx(3.14).epsilon(0.005)); | |
- REQUIRE((std::trunc(100.0 * coordinates[1]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(1)) / 100.0) == | |
Approx(3.14).epsilon(0.005)); | |
} | |
@@ -164,8 +164,8 @@ TEST_CASE("AdamBoothFunctionTest", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(0.002)); | |
- REQUIRE(coordinates[1] == Approx(3.0).epsilon(0.002)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(0.002)); | |
+ REQUIRE(coordinates(1) == Approx(3.0).epsilon(0.002)); | |
} | |
/** | |
@@ -179,9 +179,9 @@ TEST_CASE("SimpleAdamTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.3)); | |
} | |
/** | |
@@ -195,9 +195,9 @@ TEST_CASE("SimpleAdaMaxTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.3)); | |
} | |
/** | |
@@ -211,9 +211,9 @@ TEST_CASE("SimpleAMSGradTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.3)); | |
} | |
/** | |
@@ -227,8 +227,8 @@ TEST_CASE("AMSGradSphereFunctionTestFMat", "[AdamTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
#if ARMA_VERSION_MAJOR > 9 || \ | |
@@ -245,8 +245,8 @@ TEST_CASE("AMSGradSphereFunctionTestSpMat", "[AdamTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -261,8 +261,8 @@ TEST_CASE("AMSGradSphereFunctionTestSpMatDenseGradient", "[AdamTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize<decltype(f), arma::sp_mat, arma::mat>(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
#endif | |
@@ -353,9 +353,9 @@ TEST_CASE("SimpleNadamTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.3)); | |
} | |
/** | |
@@ -394,9 +394,9 @@ TEST_CASE("SimpleNadaMaxTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.3)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.3)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.3)); | |
} | |
/** | |
@@ -440,9 +440,9 @@ TEST_CASE("SimpleOptimisticAdamTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- success = (coordinates[0] == Approx(0.0).margin(0.3)) && | |
- (coordinates[1] == Approx(0.0).margin(0.3)) && | |
- (coordinates[2] == Approx(0.0).margin(0.3)); | |
+ success = (coordinates(0) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(1) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(2) == Approx(0.0).margin(0.3)); | |
if (success) | |
break; | |
} | |
@@ -491,9 +491,9 @@ TEST_CASE("SimplePadamTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- success = (coordinates[0] == Approx(0.0).margin(0.3)) && | |
- (coordinates[1] == Approx(0.0).margin(0.3)) && | |
- (coordinates[2] == Approx(0.0).margin(0.3)); | |
+ success = (coordinates(0) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(1) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(2) == Approx(0.0).margin(0.3)); | |
if (success) | |
break; | |
} | |
@@ -537,9 +537,9 @@ TEST_CASE("SimpleQHAdamTestFunction", "[AdamTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- bool success = (coordinates[0] == Approx(0.0).margin(0.3)) && | |
- (coordinates[1] == Approx(0.0).margin(0.3)) && | |
- (coordinates[2] == Approx(0.0).margin(0.3)); | |
+ bool success = (coordinates(0) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(1) == Approx(0.0).margin(0.3)) && | |
+ (coordinates(2) == Approx(0.0).margin(0.3)); | |
REQUIRE(success == true); | |
} | |
@@ -638,8 +638,8 @@ TEST_CASE("AdamAckleyFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("0.02; 0.02"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.001)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.001)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.001)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.001)); | |
} | |
/** | |
@@ -655,8 +655,8 @@ TEST_CASE("AdamBealeFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("2.8; 0.35"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(3.0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.5).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(3.0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.5).margin(0.01)); | |
} | |
/** | |
@@ -672,8 +672,8 @@ TEST_CASE("AdamGoldsteinPriceFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("0.2; -0.5"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-1).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-1).margin(0.01)); | |
} | |
/** | |
@@ -689,8 +689,8 @@ TEST_CASE("AdamLevyFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("0.9; 1.1"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(1).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(1).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(1).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(1).margin(0.01)); | |
} | |
/** | |
@@ -706,8 +706,8 @@ TEST_CASE("AdamHimmelblauFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("2.9; 1.9"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(3.0).margin(0.05)); | |
- REQUIRE(coordinates[1] == Approx(2.0).margin(0.05)); | |
+ REQUIRE(coordinates(0) == Approx(3.0).margin(0.05)); | |
+ REQUIRE(coordinates(1) == Approx(2.0).margin(0.05)); | |
} | |
/** | |
@@ -723,8 +723,8 @@ TEST_CASE("AdamThreeHumpCamelFunctionTest", "[AdamTest]") | |
arma::mat coordinates = arma::mat("1; 1"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.01)); | |
} | |
/** | |
@@ -740,6 +740,6 @@ TEST_CASE("AdamSchafferFunctionN2Test", "[AdamTest]") | |
arma::mat coordinates = arma::mat("1; 1"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.01)); | |
} | |
diff --git a/tests/aug_lagrangian_test.cpp b/tests/aug_lagrangian_test.cpp | |
index 1b50888..0b49e49 100644 | |
--- a/tests/aug_lagrangian_test.cpp | |
+++ b/tests/aug_lagrangian_test.cpp | |
@@ -37,8 +37,8 @@ TEST_CASE("AugLagrangianTestFunctionTest", "[AugLagrangianTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(70.0).epsilon(1e-7)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(4.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(4.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -58,9 +58,9 @@ TEST_CASE("GockenbachFunctionTest", "[AugLagrangianTest]") | |
// Higher tolerance for smaller values. | |
REQUIRE(finalValue == Approx(29.633926).epsilon(1e-7)); | |
- REQUIRE(coords[0] == Approx(0.12288178).epsilon(1e-5)); | |
- REQUIRE(coords[1] == Approx(-1.10778185).epsilon(1e-7)); | |
- REQUIRE(coords[2] == Approx(0.015099932).epsilon(1e-5)); | |
+ REQUIRE(coords(0) == Approx(0.12288178).epsilon(1e-5)); | |
+ REQUIRE(coords(1) == Approx(-1.10778185).epsilon(1e-7)); | |
+ REQUIRE(coords(2) == Approx(0.015099932).epsilon(1e-5)); | |
} | |
/** | |
@@ -81,9 +81,9 @@ TEST_CASE("GockenbachFunctionFMatTest", "[AugLagrangianTest]") | |
// Higher tolerance for smaller values. | |
REQUIRE(finalValue == Approx(29.633926).epsilon(1e-3)); | |
- REQUIRE(coords[0] == Approx(0.12288178).epsilon(0.1)); | |
- REQUIRE(coords[1] == Approx(-1.10778185).epsilon(1e-3)); | |
- REQUIRE(coords[2] == Approx(0.015099932).epsilon(0.1)); | |
+ REQUIRE(coords(0) == Approx(0.12288178).epsilon(0.1)); | |
+ REQUIRE(coords(1) == Approx(-1.10778185).epsilon(1e-3)); | |
+ REQUIRE(coords(2) == Approx(0.015099932).epsilon(0.1)); | |
} | |
/** | |
@@ -104,7 +104,7 @@ TEST_CASE("GockenbachFunctionSpMatTest", "[AugLagrangianTest]") | |
// Higher tolerance for smaller values. | |
REQUIRE(finalValue == Approx(29.633926).epsilon(1e-7)); | |
- REQUIRE(coords[0] == Approx(0.12288178).epsilon(1e-5)); | |
- REQUIRE(coords[1] == Approx(-1.10778185).epsilon(1e-7)); | |
- REQUIRE(coords[2] == Approx(0.015099932).epsilon(1e-5)); | |
+ REQUIRE(coords(0) == Approx(0.12288178).epsilon(1e-5)); | |
+ REQUIRE(coords(1) == Approx(-1.10778185).epsilon(1e-7)); | |
+ REQUIRE(coords(2) == Approx(0.015099932).epsilon(1e-5)); | |
} | |
diff --git a/tests/callbacks_test.cpp b/tests/callbacks_test.cpp | |
index fd9257e..921bf23 100644 | |
--- a/tests/callbacks_test.cpp | |
+++ b/tests/callbacks_test.cpp | |
@@ -401,9 +401,9 @@ TEST_CASE("EarlyStopAtMinLossCallbackTest", "[CallbacksTest]") | |
const double result = s.Optimize(f, coordinates, EarlyStopAtMinLoss(100)); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0005)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-7)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-7)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(1e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-7)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-7)); | |
} | |
/** | |
@@ -456,8 +456,8 @@ TEST_CASE("StoreBestCoordinatesCallbackTest", "[CallbacksTest]") | |
REQUIRE(cb.BestObjective() <= result); | |
REQUIRE(cb.BestObjective() == Approx(-1.0).epsilon(0.0005)); | |
- REQUIRE(cb.BestCoordinates()[0] == Approx(0.0).margin(1e-3)); | |
- REQUIRE(cb.BestCoordinates()[1] == Approx(0.0).margin(1e-7)); | |
+ REQUIRE(cb.BestCoordinates()(0) == Approx(0.0).margin(1e-3)); | |
+ REQUIRE(cb.BestCoordinates()(1) == Approx(0.0).margin(1e-7)); | |
} | |
/** | |
diff --git a/tests/cmaes_test.cpp b/tests/cmaes_test.cpp | |
index c4f6b7e..45c7f17 100644 | |
--- a/tests/cmaes_test.cpp | |
+++ b/tests/cmaes_test.cpp | |
@@ -28,9 +28,9 @@ TEST_CASE("SimpleTestFunction", "[CMAESTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.003)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.003)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.003)); | |
} | |
/** | |
diff --git a/tests/cne_test.cpp b/tests/cne_test.cpp | |
index d99f04a..eedf3c8 100644 | |
--- a/tests/cne_test.cpp | |
+++ b/tests/cne_test.cpp | |
@@ -81,8 +81,8 @@ TEST_CASE("CNECrossInTrayFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("0.8; 1.8"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(abs(coordinates[0]) == Approx(1.34941).margin(0.1)); | |
- REQUIRE(abs(coordinates[1]) == Approx(1.34941).margin(0.1)); | |
+ REQUIRE(abs(coordinates(0)) == Approx(1.34941).margin(0.1)); | |
+ REQUIRE(abs(coordinates(1)) == Approx(1.34941).margin(0.1)); | |
} | |
/** | |
@@ -96,8 +96,8 @@ TEST_CASE("CNEAckleyFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("3; 3"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.1)); | |
} | |
/** | |
@@ -111,8 +111,8 @@ TEST_CASE("CNEBealeFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("3; 3"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(3).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.5).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(3).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.5).margin(0.1)); | |
} | |
/** | |
@@ -126,8 +126,8 @@ TEST_CASE("CNEGoldsteinPriceFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("0.5; -0.5"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(-1).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(-1).margin(0.1)); | |
} | |
/** | |
@@ -141,8 +141,8 @@ TEST_CASE("CNELevyFunctionN13Test", "[CNETest]") | |
arma::mat coordinates = arma::mat("1.5; 0.5"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(1).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(1).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(1).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(1).margin(0.1)); | |
} | |
/** | |
@@ -156,8 +156,8 @@ TEST_CASE("CNEHimmelblauFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("2; 1"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(3.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(2.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(3.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(2.0).margin(0.1)); | |
} | |
/** | |
@@ -171,8 +171,8 @@ TEST_CASE("CNEThreeHumpCamelFunctionTest", "[CNETest]") | |
arma::mat coordinates = arma::mat("1; 1"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.1)); | |
} | |
// TODO: The CNE optimizer with the given parameter occasionally fails to find a | |
@@ -189,8 +189,8 @@ TEST_CASE("CNESchafferFunctionN4Test", "[CNETest]") | |
arma::mat coordinates = arma::mat("0.5; 2"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(abs(coordinates[1]) == Approx(1.25313).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(abs(coordinates(1)) == Approx(1.25313).margin(0.1)); | |
} | |
/** | |
@@ -204,6 +204,6 @@ TEST_CASE("CNESchafferFunctionN2Test", "[CNETest]") | |
arma::mat coordinates = arma::mat("0.5; -0.5"); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.1)); | |
} | |
diff --git a/tests/eve_test.cpp b/tests/eve_test.cpp | |
index 7405e17..cb96df3 100644 | |
--- a/tests/eve_test.cpp | |
+++ b/tests/eve_test.cpp | |
@@ -28,9 +28,9 @@ TEST_CASE("EveSGDFunction","[EveTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -69,8 +69,8 @@ TEST_CASE("EveSphereFunctionTest","[EveTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -84,8 +84,8 @@ TEST_CASE("EveStyblinskiTangFunctionTest","[EveTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
/** | |
@@ -100,8 +100,8 @@ TEST_CASE("EveStyblinskiTangFunctionFMatTest","[EveTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
#if ARMA_VERSION_MAJOR > 9 ||\ | |
@@ -119,8 +119,8 @@ TEST_CASE("EveStyblinskiTangFunctionSpMatTest","[EveTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
#endif | |
diff --git a/tests/frankwolfe_test.cpp b/tests/frankwolfe_test.cpp | |
index a07c555..ad8aff5 100644 | |
--- a/tests/frankwolfe_test.cpp | |
+++ b/tests/frankwolfe_test.cpp | |
@@ -41,9 +41,9 @@ TEST_CASE("FWOMPTest", "[FrankWolfeTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-10)); | |
- REQUIRE(coordinates[0] - 1 == Approx(0.0).margin(1e-10)); | |
- REQUIRE(coordinates[1] - 1 == Approx(0.0).margin(1e-10)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-10)); | |
+ REQUIRE(coordinates(0) - 1 == Approx(0.0).margin(1e-10)); | |
+ REQUIRE(coordinates(1) - 1 == Approx(0.0).margin(1e-10)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-10)); | |
for (int ii = 0; ii < k; ++ii) | |
{ | |
REQUIRE(coordinates[ii + 3] == Approx(0.0).margin(1e-10)); | |
@@ -150,9 +150,9 @@ TEST_CASE("ClassicFW", "[FrankWolfeTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[0] - 0.1 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[1] - 0.2 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[2] - 0.3 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(0) - 0.1 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(1) - 0.2 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(2) - 0.3 == Approx(0.0).margin(1e-4)); | |
} | |
/** | |
@@ -174,9 +174,9 @@ TEST_CASE("ClassicFWFMat", "[FrankWolfeTest]") | |
float result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[0] - 0.1 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[1] - 0.2 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[2] - 0.3 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(0) - 0.1 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(1) - 0.2 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(2) - 0.3 == Approx(0.0).margin(1e-4)); | |
} | |
/** | |
@@ -198,9 +198,9 @@ TEST_CASE("FWLineSearch", "[FrankWolfeTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[0] - 0.1 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[1] - 0.2 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[2] - 0.3 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(0) - 0.1 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(1) - 0.2 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(2) - 0.3 == Approx(0.0).margin(1e-4)); | |
} | |
/** | |
@@ -223,7 +223,7 @@ TEST_CASE("FWLineSearchFMat", "[FrankWolfeTest]") | |
float result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[0] - 0.1 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[1] - 0.2 == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[2] - 0.3 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(0) - 0.1 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(1) - 0.2 == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(2) - 0.3 == Approx(0.0).margin(1e-4)); | |
} | |
diff --git a/tests/ftml_test.cpp b/tests/ftml_test.cpp | |
index ef07208..5125fae 100644 | |
--- a/tests/ftml_test.cpp | |
+++ b/tests/ftml_test.cpp | |
@@ -28,9 +28,9 @@ TEST_CASE("FTMLSGDFunction", "[FTMLTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -68,8 +68,8 @@ TEST_CASE("FTMLSphereFunctionTest", "[FTMLTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -83,8 +83,8 @@ TEST_CASE("FTMLStyblinskiTangFunctionTest", "[FTMLTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
/** | |
@@ -99,8 +99,8 @@ TEST_CASE("FTMLStyblinskiTangFunctionFMatTest", "[FTMLTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
// A test with sp_mat is not done, because FTML uses some parts internally that | |
diff --git a/tests/gradient_descent_test.cpp b/tests/gradient_descent_test.cpp | |
index bef2079..8ee2295 100644 | |
--- a/tests/gradient_descent_test.cpp | |
+++ b/tests/gradient_descent_test.cpp | |
@@ -25,9 +25,9 @@ TEST_CASE("SimpleGDTestFunction", "[GradientDescentTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(1e-2)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-2)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-2)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(1e-2)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-2)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-2)); | |
} | |
TEST_CASE("GDRosenbrockTest", "[GradientDescentTest]") | |
@@ -42,7 +42,7 @@ TEST_CASE("GDRosenbrockTest", "[GradientDescentTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-10)); | |
for (size_t j = 0; j < 2; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
TEST_CASE("GDRosenbrockFMatTest", "[GradientDescentTest]") | |
@@ -57,5 +57,5 @@ TEST_CASE("GDRosenbrockFMatTest", "[GradientDescentTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-5)); | |
for (size_t j = 0; j < 2; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-3)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-3)); | |
} | |
diff --git a/tests/grid_search_test.cpp b/tests/grid_search_test.cpp | |
index 17d5e7e..a73bfa5 100644 | |
--- a/tests/grid_search_test.cpp | |
+++ b/tests/grid_search_test.cpp | |
@@ -28,9 +28,9 @@ class SimpleCategoricalFunction | |
template<typename MatType> | |
typename MatType::elem_type Evaluate(const MatType& x) | |
{ | |
- if (size_t(x[0]) == 0 && | |
- size_t(x[1]) == 2 && | |
- size_t(x[2]) == 1) | |
+ if (size_t(x(0)) == 0 && | |
+ size_t(x(1)) == 2 && | |
+ size_t(x(2)) == 1) | |
return 0.0; | |
else | |
return 10.0; | |
@@ -65,9 +65,9 @@ TEST_CASE("GridSearchTest", "[GridSearchTest]") | |
GridSearch gs; | |
gs.Optimize(c, params, categoricalDimensions, numCategories); | |
- REQUIRE(params[0] == 0); | |
- REQUIRE(params[1] == 2); | |
- REQUIRE(params[2] == 1); | |
+ REQUIRE(params(0) == 0); | |
+ REQUIRE(params(1) == 2); | |
+ REQUIRE(params(2) == 1); | |
} | |
TEST_CASE("GridSearchFMatTest", "[GridSearchTest]") | |
@@ -98,9 +98,9 @@ TEST_CASE("GridSearchFMatTest", "[GridSearchTest]") | |
GridSearch gs; | |
gs.Optimize(c, params, categoricalDimensions, numCategories); | |
- REQUIRE(params[0] == 0); | |
- REQUIRE(params[1] == 2); | |
- REQUIRE(params[2] == 1); | |
+ REQUIRE(params(0) == 0); | |
+ REQUIRE(params(1) == 2); | |
+ REQUIRE(params(2) == 1); | |
} | |
TEST_CASE("GridSearchIMatTest", "[GridSearchTest]") | |
@@ -131,7 +131,7 @@ TEST_CASE("GridSearchIMatTest", "[GridSearchTest]") | |
GridSearch gs; | |
gs.Optimize(c, params, categoricalDimensions, numCategories); | |
- REQUIRE(params[0] == 0); | |
- REQUIRE(params[1] == 2); | |
- REQUIRE(params[2] == 1); | |
+ REQUIRE(params(0) == 0); | |
+ REQUIRE(params(1) == 2); | |
+ REQUIRE(params(2) == 1); | |
} | |
diff --git a/tests/lbfgs_test.cpp b/tests/lbfgs_test.cpp | |
index 068c31b..eb0dc81 100644 | |
--- a/tests/lbfgs_test.cpp | |
+++ b/tests/lbfgs_test.cpp | |
@@ -31,8 +31,8 @@ TEST_CASE("RosenbrockFunctionTest", "[LBFGSTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -50,8 +50,8 @@ TEST_CASE("RosenbrockFunctionFloatTest", "[LBFGSTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -70,8 +70,8 @@ TEST_CASE("RosenbrockFunctionSpGradTest", "[LBFGSTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -89,8 +89,8 @@ TEST_CASE("RosenbrockFunctionSpMatTest", "[LBFGSTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -105,8 +105,8 @@ TEST_CASE("ColvilleFunctionTest", "[LBFGSTest]") | |
arma::vec coords = f.GetInitialPoint(); | |
lbfgs.Optimize(f, coords); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -124,10 +124,10 @@ TEST_CASE("WoodFunctionTest", "[LBFGSTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coords[0] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[1] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[2] == Approx(1.0).epsilon(1e-7)); | |
- REQUIRE(coords[3] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(0) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(1) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(2) == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(3) == Approx(1.0).epsilon(1e-7)); | |
} | |
/** | |
@@ -154,7 +154,7 @@ TEST_CASE("GeneralizedRosenbrockFunctionTest", "[LBFGSTest]") | |
// Test the output to make sure it is correct. | |
REQUIRE(finalValue == Approx(0.0).margin(1e-5)); | |
for (int j = 0; j < dim; j++) | |
- REQUIRE(coords[j] == Approx(1.0).epsilon(1e-7)); | |
+ REQUIRE(coords(j) == Approx(1.0).epsilon(1e-7)); | |
} | |
} | |
diff --git a/tests/line_search_test.cpp b/tests/line_search_test.cpp | |
index 6e13a1d..c1acfd8 100644 | |
--- a/tests/line_search_test.cpp | |
+++ b/tests/line_search_test.cpp | |
@@ -33,9 +33,9 @@ TEST_CASE("FuncFWTest", "[LineSearchTest]") | |
double result = s.Optimize(f, x1, x2); | |
REQUIRE(result == Approx(0.0).margin(1e-10)); | |
- REQUIRE((x2[0] - 0.1) == Approx(0.0).margin(1e-10)); | |
- REQUIRE((x2[1] - 0.2) == Approx(0.0).margin(1e-10)); | |
- REQUIRE((x2[2] - 0.3) == Approx(0.0).margin(1e-10)); | |
+ REQUIRE((x2(0) - 0.1) == Approx(0.0).margin(1e-10)); | |
+ REQUIRE((x2(1) - 0.2) == Approx(0.0).margin(1e-10)); | |
+ REQUIRE((x2(2) - 0.3) == Approx(0.0).margin(1e-10)); | |
} | |
/** | |
@@ -54,7 +54,7 @@ TEST_CASE("FuncFWFMatTest", "[LineSearchTest]") | |
float result = s.Optimize(f, x1, x2); | |
REQUIRE(result == Approx(0.0).margin(1e-5)); | |
- REQUIRE((x2[0] - 0.1) == Approx(0.0).margin(1e-5)); | |
- REQUIRE((x2[1] - 0.2) == Approx(0.0).margin(1e-5)); | |
- REQUIRE((x2[2] - 0.3) == Approx(0.0).margin(1e-5)); | |
+ REQUIRE((x2(0) - 0.1) == Approx(0.0).margin(1e-5)); | |
+ REQUIRE((x2(1) - 0.2) == Approx(0.0).margin(1e-5)); | |
+ REQUIRE((x2(2) - 0.3) == Approx(0.0).margin(1e-5)); | |
} | |
diff --git a/tests/momentum_sgd_test.cpp b/tests/momentum_sgd_test.cpp | |
index f2a5101..9e333ae 100644 | |
--- a/tests/momentum_sgd_test.cpp | |
+++ b/tests/momentum_sgd_test.cpp | |
@@ -27,9 +27,9 @@ TEST_CASE("MomentumSGDSpeedUpTestFunction", "[MomentumSGDTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0015)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.015)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-6)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.015)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-6)); | |
// Compare with SGD with vanilla update. | |
SGDTestFunction f1; | |
@@ -42,9 +42,9 @@ TEST_CASE("MomentumSGDSpeedUpTestFunction", "[MomentumSGDTest]") | |
// Result doesn't converge in 2500000 iterations. | |
REQUIRE((result1 + 1.0) > 0.05); | |
- REQUIRE(coordinates1[0] >= 0.015); | |
- REQUIRE(coordinates1[1] == Approx(0.0).margin(1e-6)); | |
- REQUIRE(coordinates1[2] == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates1(0) >= 0.015); | |
+ REQUIRE(coordinates1(1) == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates1(2) == Approx(0.0).margin(1e-6)); | |
REQUIRE(result < result1); | |
} | |
@@ -65,7 +65,7 @@ TEST_CASE("MomentumSGDGeneralizedRosenbrockTest", "[MomentumSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
} | |
@@ -85,7 +85,7 @@ TEST_CASE("MomentumSGDGeneralizedRosenbrockFMatTest", "[MomentumSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-2)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-3)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-3)); | |
} | |
} | |
@@ -105,6 +105,6 @@ TEST_CASE("MomentumSGDGeneralizedRosenbrockSpMatTest", "[MomentumSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
} | |
diff --git a/tests/nesterov_momentum_sgd_test.cpp b/tests/nesterov_momentum_sgd_test.cpp | |
index 1fe46ba..cd3d0d3 100644 | |
--- a/tests/nesterov_momentum_sgd_test.cpp | |
+++ b/tests/nesterov_momentum_sgd_test.cpp | |
@@ -30,9 +30,9 @@ TEST_CASE("NesterovMomentumSGDSpeedUpTestFunction", "[NesterovMomentumSGDTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0025)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(3e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-6)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(3e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-6)); | |
} | |
/** | |
@@ -54,7 +54,7 @@ TEST_CASE("NesterovMomentumSGDGeneralizedRosenbrockTest", "[NesterovMomentumSGDT | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
} | |
@@ -84,7 +84,7 @@ TEST_CASE("NesterovMomentumSGDGeneralizedRosenbrockFMatTest", | |
REQUIRE(result == Approx(0.0).margin(1e-2)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-2)); | |
} | |
} | |
@@ -108,6 +108,6 @@ TEST_CASE("NesterovMomentumSGDGeneralizedRosenbrockSpMatTest", | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
} | |
diff --git a/tests/parallel_sgd_test.cpp b/tests/parallel_sgd_test.cpp | |
index cf4c82a..1c6b5ed 100644 | |
--- a/tests/parallel_sgd_test.cpp | |
+++ b/tests/parallel_sgd_test.cpp | |
@@ -56,10 +56,10 @@ TEST_CASE("SimpleParallelSGDTest", "[ParallelSGDTest]") | |
REQUIRE(result == Approx(123.75).epsilon(0.0001)); | |
// The co-ordinates should be the vertices of the parabolas. | |
- REQUIRE(coordinates[0] == Approx(2.0).epsilon(0.0002)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(0.0002)); | |
- REQUIRE(coordinates[2] == Approx(1.5).epsilon(0.0002)); | |
- REQUIRE(coordinates[3] == Approx(4.0).epsilon(0.0002)); | |
+ REQUIRE(coordinates(0) == Approx(2.0).epsilon(0.0002)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(0.0002)); | |
+ REQUIRE(coordinates(2) == Approx(1.5).epsilon(0.0002)); | |
+ REQUIRE(coordinates(3) == Approx(4.0).epsilon(0.0002)); | |
} | |
} | |
@@ -86,7 +86,7 @@ TEST_CASE("ParallelSGDGeneralizedRosenbrockTest", "[ParallelSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-8)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(0.0001)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(0.0001)); | |
} | |
} | |
@@ -112,7 +112,7 @@ TEST_CASE("ParallelSGDGeneralizedRosenbrockFMatTest", "[ParallelSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-8)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(0.001)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(0.001)); | |
} | |
} | |
@@ -138,7 +138,7 @@ TEST_CASE("ParallelSGDGeneralizedRosenbrockSpMatTest", "[ParallelSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-8)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(0.0001)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(0.0001)); | |
} | |
} | |
diff --git a/tests/pso_test.cpp b/tests/pso_test.cpp | |
index 44de1f1..4fa234e 100644 | |
--- a/tests/pso_test.cpp | |
+++ b/tests/pso_test.cpp | |
@@ -31,7 +31,7 @@ TEST_CASE("LBestPSOSphereFunctionTest", "[PSOTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue <= 1e-5); | |
for (size_t j = 0; j < 4; ++j) | |
- REQUIRE(coords[j] <= 1e-3); | |
+ REQUIRE(coords(j) <= 1e-3); | |
} | |
/** | |
@@ -49,7 +49,7 @@ TEST_CASE("LBestPSOSphereFunctionFMatTest", "[PSOTest]") | |
double finalValue = f.Evaluate(coords); | |
REQUIRE(finalValue <= 1e-5); | |
for (size_t j = 0; j < 4; ++j) | |
- REQUIRE(coords[j] <= 1e-3); | |
+ REQUIRE(coords(j) <= 1e-3); | |
} | |
/** | |
@@ -71,8 +71,8 @@ TEST_CASE("LBestPSORosenbrockTest","[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(1e-2)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(1e-2)); | |
} | |
/** | |
@@ -94,8 +94,8 @@ TEST_CASE("LBestPSORosenbrockFMatTest","[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(1e-2)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(1e-2)); | |
} | |
/** | |
@@ -116,8 +116,8 @@ TEST_CASE("LBestPSORosenbrockDoubleTest","[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(1e-3)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(1e-3)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(1e-3)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(1e-3)); | |
} | |
/** | |
@@ -138,8 +138,8 @@ TEST_CASE("LBestPSOCrossInTrayFunctionTest", "[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-2.06261).margin(0.01)); | |
- REQUIRE(abs(coordinates[0]) == Approx(1.34941).margin(0.01)); | |
- REQUIRE(abs(coordinates[1]) == Approx(1.34941).margin(0.01)); | |
+ REQUIRE(abs(coordinates(0)) == Approx(1.34941).margin(0.01)); | |
+ REQUIRE(abs(coordinates(1)) == Approx(1.34941).margin(0.01)); | |
} | |
/** | |
@@ -160,8 +160,8 @@ TEST_CASE("LBestPSOAckleyFunctionTest", "[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.01)); | |
} | |
/** | |
@@ -183,8 +183,8 @@ TEST_CASE("LBestPSOBealeFunctionTest", "[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[0] == Approx(3).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0.5).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(3).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0.5).margin(0.01)); | |
} | |
/** | |
@@ -205,8 +205,8 @@ TEST_CASE("LBestPSOGoldsteinPriceFunctionTest", "[PSOTest]") | |
arma::mat coordinates = arma::mat("1; 0"); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-1).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-1).margin(0.01)); | |
} | |
/** | |
@@ -227,8 +227,8 @@ TEST_CASE("LBestPSOLevyFunctionN13Test", "[PSOTest]") | |
arma::mat coordinates = arma::mat("3; 3"); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(1).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(1).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(1).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(1).margin(0.01)); | |
} | |
/** | |
@@ -249,8 +249,8 @@ TEST_CASE("LBestPSOHimmelblauFunctionTest", "[PSOTest]") | |
arma::mat coordinates = arma::mat("2; 1"); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(3.0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(2.0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(3.0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(2.0).margin(0.01)); | |
} | |
/** | |
@@ -271,8 +271,8 @@ TEST_CASE("LBestPSOThreeHumpCamelFunctionTest", "[PSOTest]") | |
arma::mat coordinates = arma::mat("2; 2"); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.01)); | |
} | |
/** | |
@@ -292,8 +292,8 @@ TEST_CASE("LBestPSOSchafferFunctionN2Test", "[PSOTest]") | |
arma::mat coordinates = arma::mat("10; 10"); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.01)); | |
- REQUIRE(coordinates[1] == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(0).margin(0.01)); | |
} | |
// TODO: With future improvements in metaheuristic optimisers in ensmallen, | |
@@ -317,7 +317,7 @@ TEST_CASE("LBestPSOScafferFunctionN4Test", "[PSOTest]") | |
const double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.292579).margin(0.1)); | |
- REQUIRE(coordinates[0] == Approx(0).margin(0.1)); | |
- REQUIRE(abs(coordinates[1]) == Approx(1.25313).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0).margin(0.1)); | |
+ REQUIRE(abs(coordinates(1)) == Approx(1.25313).margin(0.1)); | |
} | |
*/ | |
diff --git a/tests/quasi_hyperbolic_momentum_sgd_test.cpp b/tests/quasi_hyperbolic_momentum_sgd_test.cpp | |
index a50877c..42f68cb 100644 | |
--- a/tests/quasi_hyperbolic_momentum_sgd_test.cpp | |
+++ b/tests/quasi_hyperbolic_momentum_sgd_test.cpp | |
@@ -26,9 +26,9 @@ TEST_CASE("QHSGDTestFunction", "[QHMomentumSGDTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0025)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(3e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-6)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(3e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-6)); | |
} | |
/** | |
@@ -44,9 +44,9 @@ TEST_CASE("QHSGDFMatTestFunction", "[QHMomentumSGDTest]") | |
float result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.025)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(3e-2)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-4)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(3e-2)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-4)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-4)); | |
} | |
/** | |
@@ -63,9 +63,9 @@ TEST_CASE("QHSGDSpMatTestFunction", "[QHMomentumSGDTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0025)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(3e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-6)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(3e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-6)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-6)); | |
} | |
/** | |
@@ -85,6 +85,6 @@ TEST_CASE("QHSGDSGDGeneralizedRosenbrockTest", "[QHMomentumSGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-4)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-4)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-4)); | |
} | |
} | |
diff --git a/tests/rmsprop_test.cpp b/tests/rmsprop_test.cpp | |
index ab0e320..1cf3f43 100644 | |
--- a/tests/rmsprop_test.cpp | |
+++ b/tests/rmsprop_test.cpp | |
@@ -24,9 +24,9 @@ TEST_CASE("RMSPropSGDFunction", "[rmsprop]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(std::abs(coordinates[0]) <= 0.1); | |
- REQUIRE(std::abs(coordinates[1]) <= 0.1); | |
- REQUIRE(std::abs(coordinates[2]) <= 0.1); | |
+ REQUIRE(std::abs(coordinates(0)) <= 0.1); | |
+ REQUIRE(std::abs(coordinates(1)) <= 0.1); | |
+ REQUIRE(std::abs(coordinates(2)) <= 0.1); | |
} | |
/** | |
diff --git a/tests/sa_test.cpp b/tests/sa_test.cpp | |
index b6c8624..b80e0c8 100644 | |
--- a/tests/sa_test.cpp | |
+++ b/tests/sa_test.cpp | |
@@ -41,7 +41,7 @@ TEST_CASE("SAGeneralizedRosenbrockTest","[SATest]") | |
// 0.1% tolerance for each coordinate. | |
REQUIRE(result == Approx(0.0).margin(1e-6)); | |
for (size_t j = 0; j < dim; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(0.001)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(0.001)); | |
} | |
// The Rosenbrock function is a simple function to optimize. | |
@@ -56,8 +56,8 @@ TEST_CASE("SARosenbrockTest", "[SATest]") | |
const double result = sa.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(1e-4)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(1e-4)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(1e-4)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(1e-4)); | |
} | |
// The Rosenbrock function is a simple function to optimize. Use arma::fmat. | |
@@ -72,8 +72,8 @@ TEST_CASE("SARosenbrockFMatTest", "[SATest]") | |
const float result = sa.Optimize(f, coordinates); | |
REQUIRE(result == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[0] == Approx(1.0).epsilon(1e-2)); | |
- REQUIRE(coordinates[1] == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(0) == Approx(1.0).epsilon(1e-2)); | |
+ REQUIRE(coordinates(1) == Approx(1.0).epsilon(1e-2)); | |
} | |
/** | |
@@ -99,8 +99,8 @@ TEST_CASE("RastrigrinFunctionTest", "[SATest]") | |
const double result = sa.Optimize(f, coordinates); | |
if ((std::abs(result) < 1e-3) && | |
- (std::abs(coordinates[0]) < 1e-3) && | |
- (std::abs(coordinates[1]) < 1e-3)) | |
+ (std::abs(coordinates(0)) < 1e-3) && | |
+ (std::abs(coordinates(1)) < 1e-3)) | |
{ | |
++successes; | |
break; // No need to continue. | |
diff --git a/tests/scd_test.cpp b/tests/scd_test.cpp | |
index 0f874b2..1bd1dc0 100644 | |
--- a/tests/scd_test.cpp | |
+++ b/tests/scd_test.cpp | |
@@ -58,10 +58,10 @@ TEST_CASE("DisjointFeatureTest", "[SCDTest]") | |
REQUIRE(result == Approx(123.75).epsilon(0.0001)); | |
// The co-ordinates should be the vertices of the parabolas. | |
- REQUIRE(iterate[0] == Approx(2.0).epsilon(0.0002)); | |
- REQUIRE(iterate[1] == Approx(1.0).epsilon(0.0002)); | |
- REQUIRE(iterate[2] == Approx(1.5).epsilon(0.0002)); | |
- REQUIRE(iterate[3] == Approx(4.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(0) == Approx(2.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(1) == Approx(1.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(2) == Approx(1.5).epsilon(0.0002)); | |
+ REQUIRE(iterate(3) == Approx(4.0).epsilon(0.0002)); | |
} | |
/** | |
@@ -85,10 +85,10 @@ TEST_CASE("DisjointFeatureFMatTest", "[SCDTest]") | |
REQUIRE(result == Approx(123.75).epsilon(0.01)); | |
// The co-ordinates should be the vertices of the parabolas. | |
- REQUIRE(iterate[0] == Approx(2.0).epsilon(0.02)); | |
- REQUIRE(iterate[1] == Approx(1.0).epsilon(0.02)); | |
- REQUIRE(iterate[2] == Approx(1.5).epsilon(0.02)); | |
- REQUIRE(iterate[3] == Approx(4.0).epsilon(0.02)); | |
+ REQUIRE(iterate(0) == Approx(2.0).epsilon(0.02)); | |
+ REQUIRE(iterate(1) == Approx(1.0).epsilon(0.02)); | |
+ REQUIRE(iterate(2) == Approx(1.5).epsilon(0.02)); | |
+ REQUIRE(iterate(3) == Approx(4.0).epsilon(0.02)); | |
} | |
/** | |
@@ -112,10 +112,10 @@ TEST_CASE("DisjointFeatureSpMatTest", "[SCDTest]") | |
REQUIRE(result == Approx(123.75).epsilon(0.0001)); | |
// The co-ordinates should be the vertices of the parabolas. | |
- REQUIRE(iterate[0] == Approx(2.0).epsilon(0.0002)); | |
- REQUIRE(iterate[1] == Approx(1.0).epsilon(0.0002)); | |
- REQUIRE(iterate[2] == Approx(1.5).epsilon(0.0002)); | |
- REQUIRE(iterate[3] == Approx(4.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(0) == Approx(2.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(1) == Approx(1.0).epsilon(0.0002)); | |
+ REQUIRE(iterate(2) == Approx(1.5).epsilon(0.0002)); | |
+ REQUIRE(iterate(3) == Approx(4.0).epsilon(0.0002)); | |
} | |
/** | |
@@ -137,7 +137,7 @@ TEST_CASE("GreedyDescentTest", "[SCDTest]") | |
// Changing the point under consideration, so that the maximum gradient is at | |
// index 1. | |
- point[1] = 10; | |
+ point(1) = 10; | |
REQUIRE(descentPolicy.DescentFeature<SparseTestFunction, | |
arma::mat, | |
diff --git a/tests/sgd_test.cpp b/tests/sgd_test.cpp | |
index b4c7f35..c301812 100644 | |
--- a/tests/sgd_test.cpp | |
+++ b/tests/sgd_test.cpp | |
@@ -29,9 +29,9 @@ TEST_CASE("SimpleSGDTestFunction", "[SGDTest]") | |
double result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0005)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-7)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-7)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(1e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-7)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-7)); | |
} | |
TEST_CASE("GeneralizedRosenbrockTest", "[SGDTest]") | |
@@ -51,7 +51,7 @@ TEST_CASE("GeneralizedRosenbrockTest", "[SGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-10)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-5)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-5)); | |
} | |
} | |
@@ -64,9 +64,9 @@ TEST_CASE("SimpleSGDTestFunctionFloat", "[SGDTest]") | |
float result = s.Optimize(f, coordinates); | |
REQUIRE(result == Approx(-1.0).epsilon(0.0005)); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(1e-3)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(1e-5)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(1e-5)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(1e-3)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(1e-5)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(1e-5)); | |
} | |
TEST_CASE("GeneralizedRosenbrockTestFloat", "[SGDTest]") | |
@@ -84,6 +84,6 @@ TEST_CASE("GeneralizedRosenbrockTestFloat", "[SGDTest]") | |
REQUIRE(result == Approx(0.0).margin(1e-5)); | |
for (size_t j = 0; j < i; ++j) | |
- REQUIRE(coordinates[j] == Approx(1.0).epsilon(1e-3)); | |
+ REQUIRE(coordinates(j) == Approx(1.0).epsilon(1e-3)); | |
} | |
} | |
diff --git a/tests/smorms3_test.cpp b/tests/smorms3_test.cpp | |
index b4a00ff..afa72c7 100644 | |
--- a/tests/smorms3_test.cpp | |
+++ b/tests/smorms3_test.cpp | |
@@ -28,9 +28,9 @@ TEST_CASE("SimpleSMORMS3TestFunction","[SMORMS3Test]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
s.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[2] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(2) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
diff --git a/tests/spsa_test.cpp b/tests/spsa_test.cpp | |
index db316ce..f75b8ff 100644 | |
--- a/tests/spsa_test.cpp | |
+++ b/tests/spsa_test.cpp | |
@@ -30,8 +30,8 @@ TEST_CASE("SPSASphereFunctionTest", "[SPSATest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -45,8 +45,8 @@ TEST_CASE("SPSASphereFunctionFMatTest", "[SPSATest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -60,8 +60,8 @@ TEST_CASE("SPSASphereFunctionSpMatTest", "[SPSATest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -76,9 +76,9 @@ TEST_CASE("SPSAMatyasFunctionTest", "[SPSATest]") | |
optimizer.Optimize(f, coordinates); | |
// 3% error tolerance. | |
- REQUIRE((std::trunc(100.0 * coordinates[0]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(0)) / 100.0) == | |
Approx(0.0).epsilon(0.003)); | |
- REQUIRE((std::trunc(100.0 * coordinates[1]) / 100.0) == | |
+ REQUIRE((std::trunc(100.0 * coordinates(1)) / 100.0) == | |
Approx(0.0).epsilon(0.003)); | |
} | |
diff --git a/tests/swats_test.cpp b/tests/swats_test.cpp | |
index 0438856..72b14f9 100644 | |
--- a/tests/swats_test.cpp | |
+++ b/tests/swats_test.cpp | |
@@ -53,8 +53,8 @@ TEST_CASE("SWATSSphereFunctionTest", "[SWATSTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -68,8 +68,8 @@ TEST_CASE("SWATSStyblinskiTangFunctionTest", "[SWATSTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
/** | |
@@ -83,8 +83,8 @@ TEST_CASE("SWATSStyblinskiTangFunctionFMatTest", "[SWATSTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
#if ARMA_VERSION_MAJOR > 9 ||\ | |
@@ -101,8 +101,8 @@ TEST_CASE("SWATSStyblinskiTangFunctionSpMatTest", "[SWATSTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); | |
} | |
#endif | |
diff --git a/tests/test_function_tools.hpp b/tests/test_function_tools.hpp | |
index 9571e9b..0847fab 100644 | |
--- a/tests/test_function_tools.hpp | |
+++ b/tests/test_function_tools.hpp | |
@@ -41,14 +41,14 @@ inline void LogisticRegressionTestData(MatType& data, | |
// The first Gaussian is centered at (1, 1, 1) and has covariance I. | |
data.col(i) = arma::randn<arma::Col<typename MatType::elem_type>>(3) + | |
arma::Col<typename MatType::elem_type>("1.0 1.0 1.0"); | |
- responses[i] = 0; | |
+ responses(i) = 0; | |
} | |
for (size_t i = 500; i < 1000; ++i) | |
{ | |
// The second Gaussian is centered at (9, 9, 9) and has covariance I. | |
data.col(i) = arma::randn<arma::Col<typename MatType::elem_type>>(3) + | |
arma::Col<typename MatType::elem_type>("9.0 9.0 9.0"); | |
- responses[i] = 1; | |
+ responses(i) = 1; | |
} | |
// Shuffle the dataset. | |
@@ -58,8 +58,8 @@ inline void LogisticRegressionTestData(MatType& data, | |
shuffledResponses = arma::Row<size_t>(1000); | |
for (size_t i = 0; i < data.n_cols; ++i) | |
{ | |
- shuffledData.col(i) = data.col(indices[i]); | |
- shuffledResponses[i] = responses[indices[i]]; | |
+ shuffledData.col(i) = data.col(indices(i)); | |
+ shuffledResponses(i) = responses[indices(i)]; | |
} | |
// Create a test set. | |
@@ -69,13 +69,13 @@ inline void LogisticRegressionTestData(MatType& data, | |
{ | |
testData.col(i) = arma::randn<arma::Col<typename MatType::elem_type>>(3) + | |
arma::Col<typename MatType::elem_type>("1.0 1.0 1.0"); | |
- testResponses[i] = 0; | |
+ testResponses(i) = 0; | |
} | |
for (size_t i = 500; i < 1000; ++i) | |
{ | |
testData.col(i) = arma::randn<arma::Col<typename MatType::elem_type>>(3) + | |
arma::Col<typename MatType::elem_type>("9.0 9.0 9.0"); | |
- testResponses[i] = 1; | |
+ testResponses(i) = 1; | |
} | |
} | |
@@ -90,10 +90,10 @@ inline void CheckMatrices(const MatType& a, | |
for (size_t i = 0; i < a.n_elem; ++i) | |
{ | |
- if (std::abs(a[i]) < tolerance / 2) | |
- REQUIRE(b[i] == Approx(0.0).margin(tolerance / 2.0)); | |
+ if (std::abs(a(i)) < tolerance / 2) | |
+ REQUIRE(b(i) == Approx(0.0).margin(tolerance / 2.0)); | |
else | |
- REQUIRE(a[i] == Approx(b[i]).epsilon(tolerance)); | |
+ REQUIRE(a(i) == Approx(b(i)).epsilon(tolerance)); | |
} | |
} | |
diff --git a/tests/wn_grad_test.cpp b/tests/wn_grad_test.cpp | |
index c52a54f..bcd9da9 100644 | |
--- a/tests/wn_grad_test.cpp | |
+++ b/tests/wn_grad_test.cpp | |
@@ -53,8 +53,8 @@ TEST_CASE("WNGradSphereFunctionTest","[WNGradTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(0.0).margin(0.1)); | |
- REQUIRE(coordinates[1] == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(0) == Approx(0.0).margin(0.1)); | |
+ REQUIRE(coordinates(1) == Approx(0.0).margin(0.1)); | |
} | |
/** | |
@@ -68,8 +68,8 @@ TEST_CASE("WNGradStyblinskiTangFunctionTest","[WNGradTest]") | |
arma::mat coordinates = f.GetInitialPoint(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
} | |
/** | |
@@ -83,8 +83,8 @@ TEST_CASE("WNGradStyblinskiTangFunctionFMatTest", "[WNGradTest]") | |
arma::fmat coordinates = f.GetInitialPoint<arma::fmat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
} | |
/** | |
@@ -98,6 +98,6 @@ TEST_CASE("WNGradStyblinskiTangFunctionSpMatTest", "[WNGradTest]") | |
arma::sp_mat coordinates = f.GetInitialPoint<arma::sp_mat>(); | |
optimizer.Optimize(f, coordinates); | |
- REQUIRE(coordinates[0] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
- REQUIRE(coordinates[1] == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(0) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
+ REQUIRE(coordinates(1) == Approx(-2.9).epsilon(0.01)); // 1% error tolerance. | |
} | |
-- | |
2.23.0.rc0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment