[mlpack-git] master: Increase tolerance for Rastrigrin function optimization. (e9da451)

gitdub at mlpack.org gitdub at mlpack.org
Sat Sep 17 10:21:33 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/635e37c4de03cdabfc4b493ad2ab5e9e51f9823e...e9da451589e35766730bbd2aa9f81d07c9fe854a

>---------------------------------------------------------------

commit e9da451589e35766730bbd2aa9f81d07c9fe854a
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Sep 17 10:21:33 2016 -0400

    Increase tolerance for Rastrigrin function optimization.


>---------------------------------------------------------------

e9da451589e35766730bbd2aa9f81d07c9fe854a
 src/mlpack/tests/sa_test.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mlpack/tests/sa_test.cpp b/src/mlpack/tests/sa_test.cpp
index 3d87e5d..671adc9 100644
--- a/src/mlpack/tests/sa_test.cpp
+++ b/src/mlpack/tests/sa_test.cpp
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(RosenbrockTest)
 }
 
 /**
- * The Rastigrin function, a (not very) simple nonconvex function.  It is
+ * The Rastrigrin function, a (not very) simple nonconvex function.  It is
  * defined by
  *
  *   f(x) = 10n + \sum_{i = 1}^{n} (x_i^2 - 10 cos(2 \pi x_i)).
@@ -101,11 +101,11 @@ class RastrigrinFunction
 BOOST_AUTO_TEST_CASE(RastrigrinFunctionTest)
 {
   // Simulated annealing isn't guaranteed to converge (except in very specific
-  // situations).  If this works 1 of 5 times, I'm fine with that.  All I want
+  // situations).  If this works 1 of 8 times, I'm fine with that.  All I want
   // to know is that this implementation will escape from local minima.
   size_t successes = 0;
 
-  for (size_t trial = 0; trial < 5; ++trial)
+  for (size_t trial = 0; trial < 8; ++trial)
   {
     RastrigrinFunction f;
     ExponentialSchedule schedule(3e-6);
@@ -118,7 +118,10 @@ BOOST_AUTO_TEST_CASE(RastrigrinFunctionTest)
     if ((std::abs(result) < 1e-3) &&
         (std::abs(coordinates[0]) < 1e-3) &&
         (std::abs(coordinates[1]) < 1e-3))
+    {
       ++successes;
+      break; // No need to continue.
+    }
   }
 
   BOOST_REQUIRE_GE(successes, 1);




More information about the mlpack-git mailing list