https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Eggholder.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "Eggholder.h"
11
12registerMooseObject("StochasticToolsTestApp", Eggholder);
13
19
21
22Real
23Eggholder::function(const std::vector<Real> & x) const
24{
25 if (x.size() != 2)
26 paramError("x", "Eggholder problem requires exactly 2 inputs, but ", x.size(), " were given.");
27
28 return eggholder(x);
29}
30
31Real
32Eggholder::eggholder(const std::vector<Real> & x)
33{
34
35 mooseAssert(x.size() == 2, "Eggholder problem requires exactly 2 inputs.");
36
37 return -(x[1] + 47.0) * std::sin(std::sqrt(std::abs(x[0] / 2.0 + (x[1] + 47.0)))) -
38 x[0] * std::sin(std::sqrt(abs(x[0] - (x[1] + 47.0))));
39}
registerMooseObject("StochasticToolsTestApp", Eggholder)
const std::vector< double > x
static InputParameters validParams()
Definition Eggholder.C:15
Real function(const std::vector< Real > &x) const override final
Definition Eggholder.C:23
static Real eggholder(const std::vector< Real > &x)
https://en.wikipedia.org/wiki/Test_functions_for_optimization
Definition Eggholder.C:32
Eggholder(const InputParameters &parameters)
Definition Eggholder.C:20
void paramError(const std::string &param, Args... args) const
static InputParameters validParams()