https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Rosenbrock.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 "Rosenbrock.h"
11
12registerMooseObject("StochasticToolsTestApp", Rosenbrock);
13
19
21
22Real
23Rosenbrock::function(const std::vector<Real> & x) const
24{
25 return rosen(x);
26}
27
28Real
29Rosenbrock::rosen(const std::vector<Real> & x)
30{
31 if (x.size() < 2)
32 return 0.0;
33
34 PostprocessorValue sum = 0.0;
35 for (const auto i : make_range(x.size() - 1))
36 sum += 100.0 * Utility::pow<2>(x[i + 1] - x[i] * x[i]) + Utility::pow<2>(1 - x[i]);
37 return sum;
38}
const std::vector< double > x
Real PostprocessorValue
registerMooseObject("StochasticToolsTestApp", Rosenbrock)
static InputParameters validParams()
Rosenbrock(const InputParameters &parameters)
Definition Rosenbrock.C:20
static InputParameters validParams()
Definition Rosenbrock.C:15
static Real rosen(const std::vector< Real > &x)
https://en.wikipedia.org/wiki/Test_functions_for_optimization
Definition Rosenbrock.C:29
Real function(const std::vector< Real > &x) const override final
Definition Rosenbrock.C:23