https://mooseframework.inl.gov
ExpectedImprovement.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "ExpectedImprovement.h"
11 #include "Normal.h"
12 #include <cmath>
13 
14 registerMooseObject("StochasticToolsApp", ExpectedImprovement);
15 
18 {
20  params.addClassDescription("Expected improvement acquisition function.");
21  params.addRangeCheckedParam<Real>(
22  "tuning", 0.001, "tuning > 0", "Tuning parameter to control exploration vs exploitation.");
23  return params;
24 }
25 
27  : ParallelAcquisitionFunctionBase(parameters), _tuning(getParam<Real>("tuning"))
28 {
29 }
30 
31 void
33  std::vector<Real> & acq,
34  const std::vector<Real> & gp_mean,
35  const std::vector<Real> & gp_std,
36  const std::vector<std::vector<Real>> & /*test_inputs*/,
37  const std::vector<std::vector<Real>> & /*train_inputs*/,
38  const std::vector<Real> & generic) const
39 {
40  auto maxIt = std::max_element(generic.begin(), generic.end());
41  Real z;
42  for (unsigned int i = 0; i < gp_mean.size(); ++i)
43  {
44  z = gp_mean[i] - *maxIt - _tuning;
45  acq[i] = (gp_mean[i] - *maxIt) * Normal::cdf(z, 0.0, gp_std[i]) +
46  gp_std[i] * Normal::pdf(z, 0.0, gp_std[i]);
47  }
48 }
void computeAcquisitionInternal(std::vector< Real > &acq, const std::vector< Real > &gp_mean, const std::vector< Real > &gp_std, const std::vector< std::vector< Real >> &test_inputs, const std::vector< std::vector< Real >> &train_inputs, const std::vector< Real > &generic) const override
Implementation hook for derived classes (no size checks here).
virtual Real cdf(const Real &x) const override
Definition: Normal.C:74
ExpectedImprovement(const InputParameters &parameters)
static InputParameters validParams()
All ParallelAcquisition functions should inherit from this class.
virtual Real pdf(const Real &x) const override
Definition: Normal.C:68
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
const Real & _tuning
Tuning parameter to control exploration vs exploitation.
registerMooseObject("StochasticToolsApp", ExpectedImprovement)