[mlpack] 105/149: Refactor GeneralizedRosenbrockTest to deal with intermittent failures better. Also use 4 trials for RastigrinFunctionTest.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Sat May 2 09:11:14 UTC 2015
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 7ca6257c9f4e70ca4ff157eb5d74f4bf1c2b7d46
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Tue Nov 18 23:20:31 2014 +0000
Refactor GeneralizedRosenbrockTest to deal with intermittent failures better.
Also use 4 trials for RastigrinFunctionTest.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17383 9d5b8971-822b-0410-80eb-d18c1038ef23
---
src/mlpack/tests/sa_test.cpp | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/mlpack/tests/sa_test.cpp b/src/mlpack/tests/sa_test.cpp
index 3cbcfed..b4564bc 100644
--- a/src/mlpack/tests/sa_test.cpp
+++ b/src/mlpack/tests/sa_test.cpp
@@ -27,18 +27,29 @@ BOOST_AUTO_TEST_SUITE(SATest);
BOOST_AUTO_TEST_CASE(GeneralizedRosenbrockTest)
{
+ math::RandomSeed(std::time(NULL));
size_t dim = 50;
GeneralizedRosenbrockFunction f(dim);
- ExponentialSchedule schedule(1e-5);
- SA<GeneralizedRosenbrockFunction, ExponentialSchedule>
- sa(f, schedule, 10000000, 1000., 1000, 100, 1e-9, 3, 20, 0.3, 0.3);
- arma::mat coordinates = f.GetInitialPoint();
- const double result = sa.Optimize(coordinates);
+ double iteration = 0;
+ double result = DBL_MAX;
+ arma::mat coordinates;
+ while (result > 1e-6)
+ {
+ ExponentialSchedule schedule(1e-5);
+ SA<GeneralizedRosenbrockFunction, ExponentialSchedule>
+ sa(f, schedule, 10000000, 1000., 1000, 100, 1e-10, 3, 20, 0.3, 0.3);
+ coordinates = f.GetInitialPoint();
+ result = sa.Optimize(coordinates);
+ ++iteration;
+
+ BOOST_REQUIRE_LT(iteration, 3); // No more than three tries.
+ }
+ // 0.1% tolerance for each coordinate.
BOOST_REQUIRE_SMALL(result, 1e-6);
for (size_t j = 0; j < dim; ++j)
- BOOST_REQUIRE_CLOSE(coordinates[j], (double) 1.0, 1e-2);
+ BOOST_REQUIRE_CLOSE(coordinates[j], (double) 1.0, 0.1);
}
// The Rosenbrock function is a simple function to optimize.
@@ -91,11 +102,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 3 times, I'm fine with that. All I want
+ // situations). If this works 1 of 4 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 < 3; ++trial)
+ for (size_t trial = 0; trial < 4; ++trial)
{
RastrigrinFunction f;
ExponentialSchedule schedule(3e-6);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list