File: active_cmaes_test.cpp

package info (click to toggle)
ensmallen 3.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,952 kB
  • sloc: cpp: 44,963; sh: 186; makefile: 35
file content (68 lines) | stat: -rw-r--r-- 2,323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * @file active_cmaes_test.cpp
 * @author Suvarsha Chennareddy
 *
 * ensmallen is free software; you may redistribute it and/or modify it under
 * the terms of the 3-clause BSD license.  You should have received a copy of
 * the 3-clause BSD license along with ensmallen.  If not, see
 * http://www.opensource.org/licenses/BSD-3-Clause for more information.
 */

#include <ensmallen.hpp>
#include "catch.hpp"
#include "test_function_tools.hpp"
#include "test_types.hpp"

using namespace ens;
using namespace ens::test;

/**
 * Run Active CMA-ES with the full selection policy on Rosenbrock function and
 * make sure the results are acceptable.
 */
TEMPLATE_TEST_CASE("ActiveCMAESRosenbrockFunctionTest", "[ActiveCMAES]",
    ENS_TEST_TYPES)
{
  BoundaryBoxConstraint<TestType> b(0, 10);
  ActiveCMAES<FullSelection, BoundaryBoxConstraint<TestType>>
      activecmaes(0, b, 1, 0, Tolerances<TestType>::Obj);
  activecmaes.StepSize() = 0.01;
  FunctionTest<RosenbrockFunction, TestType>(activecmaes,
      100 * Tolerances<TestType>::LargeObj,
      10 * Tolerances<TestType>::LargeCoord,
      10);
}

/**
 * Run Active CMA-ES with the random selection policy on Rosenbrock function and
 * make sure the results are acceptable.
 */
TEMPLATE_TEST_CASE("ApproxActiveCMAESRosenbrockFunctionTest", "[ActiveCMAES]",
    ENS_TEST_TYPES)
{
  BoundaryBoxConstraint<TestType> b(0, 10);
  ApproxActiveCMAES<BoundaryBoxConstraint<TestType>>
      activecmaes(2048, b, 1, 0, Tolerances<TestType>::Obj / 100);
  activecmaes.StepSize() = 0.01;
  FunctionTest<RosenbrockFunction, TestType>(activecmaes,
      100 * Tolerances<TestType>::LargeObj,
      10 * Tolerances<TestType>::LargeCoord,
      10);
}

/**
 * Run Active CMA-ES with the random selection and empty transformation policies
 * on  Rosenbrock function and make sure the results are acceptable.
 * Use arma::fmat.
 */
TEMPLATE_TEST_CASE("ApproxActiveCMAESEmptyTransformationLogisticRegressionTest",
    "[ActiveCMAES]", ENS_TEST_TYPES)
{
  ApproxActiveCMAES<EmptyTransformation<TestType>>
      activecmaes(0, EmptyTransformation<TestType>(), 16, 0,
                  10 * Tolerances<TestType>::Obj);

  activecmaes.StepSize() = 0.55;
  LogisticRegressionFunctionTest<TestType>(activecmaes,
      Tolerances<TestType>::LRTrainAcc, Tolerances<TestType>::LRTestAcc, 5);
}