File: PlanCases.cpp

package info (click to toggle)
bornagain 23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,948 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (87 lines) | stat: -rw-r--r-- 3,646 bytes parent folder | download | duplicates (2)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Tests/Functional/Mumufit/PlanCases.cpp
//! @brief     Defines collection of FunctionTestPlan classes.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#include "Tests/Functional/Mumufit/PlanCases.h"
#include "Tests/Functional/Mumufit/ClassicalTestFunctions.h"

namespace {

const double loose_tolerance = 0.1;
} // namespace

using namespace mumufit;

//! Plan to minimize a Rosenbrock function.
//! start point: F(-1.2,1.0) = 24.20
//! minimum    : F(1.0,1.0)  = 0.

RosenbrockPlan::RosenbrockPlan()
    : ScalarTestPlan("RosenbrockPlan", TestFunctions::RosenBrock, 0.0)
{
    addParameter(Parameter("par0", -1.2, AttLimits::limited(-5.0, 5.0), 0.01), 1.0);
    addParameter(Parameter("par1", 1.0, AttLimits::limited(-5.0, 5.0), 0.01), 1.0);
}

EasyRosenbrockPlan::EasyRosenbrockPlan()
    : ScalarTestPlan("EasyRosenbrockPlan", TestFunctions::RosenBrock, 0.0, loose_tolerance)
{
    // narrow parameter limits and big tolerance for stochastic minimizers
    const double tolerance = 0.1;
    addParameter(Parameter("par0", 1.1, AttLimits::limited(0.8, 1.2), 0.01), 1.0, tolerance);
    addParameter(Parameter("par1", 1.1, AttLimits::limited(0.8, 1.2), 0.01), 1.0, tolerance);
}

//! Plan for WoodFour function
//!   start point: F(-3,-1,-3,-1) = 19192
//!   minimum    : F(1,1,1,1)  =   0.

WoodFourPlan::WoodFourPlan()
    : ScalarTestPlan("WoodFourPlan", TestFunctions::WoodFour, 0.0)
{
    addParameter(Parameter("par0", -3.0, AttLimits::limited(-5.0, 5.0)), 1.0);
    addParameter(Parameter("par1", -1.0, AttLimits::limited(-5.0, 5.0)), 1.0);
    addParameter(Parameter("par2", -3.0, AttLimits::limited(-5.0, 5.0)), 1.0);
    addParameter(Parameter("par3", -1.0, AttLimits::limited(-5.0, 5.0)), 1.0);
}

EasyWoodFourPlan::EasyWoodFourPlan()
    : ScalarTestPlan("EasyWoodFourPlan", TestFunctions::WoodFour, 0.0, loose_tolerance)
{
    // narrow parameter limits and big tolerance for stochastic minimizers
    const double tolerance = 0.1;
    addParameter(Parameter("par0", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance);
    addParameter(Parameter("par1", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance);
    addParameter(Parameter("par2", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance);
    addParameter(Parameter("par3", 1.1, AttLimits::limited(0.8, 1.2)), 1.0, tolerance);
}

DecayingSinPlan::DecayingSinPlan()
    : ResidualTestPlan("DecayingSinPlan", TestFunctions::DecayingSin)
{
    addParameter(Parameter("amp", 1.0, AttLimits::nonnegative()), 10.0);
    addParameter(Parameter("frequency", 1.0, AttLimits::nonnegative()), 4.0);
    addParameter(Parameter("phase", 0.1, AttLimits::limited(0.0, 3.1)), 1.0);
    addParameter(Parameter("decay", 0.1, AttLimits::nonnegative()), 0.05);
    finalizeParameters();
}

DecayingSinPlanV2::DecayingSinPlanV2()
    : ResidualTestPlan("DecayingSinPlanV2", TestFunctions::DecayingSin)
{
    addParameter(Parameter("amp", 1.0, AttLimits::limitless()), 2.0);
    addParameter(Parameter("frequency", 1.0, AttLimits::limitless()), 2.0);
    addParameter(Parameter("phase", 1.0, AttLimits::fixed()), 1.0);
    addParameter(Parameter("decay", 0.05, AttLimits::fixed()), 0.05);
    finalizeParameters();
}