LCOV - code coverage report
Current view: top level - src/acquisitions - ExpectedImprovement.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #32971 (54bef8) with base c6cf66 Lines: 15 16 93.8 %
Date: 2026-05-29 20:40:35 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      16             : InputParameters
      17          48 : ExpectedImprovement::validParams()
      18             : {
      19          48 :   InputParameters params = ParallelAcquisitionFunctionBase::validParams();
      20          48 :   params.addClassDescription("Expected improvement acquisition function.");
      21         144 :   params.addRangeCheckedParam<Real>(
      22          96 :       "tuning", 0.001, "tuning > 0", "Tuning parameter to control exploration vs exploitation.");
      23          48 :   return params;
      24           0 : }
      25             : 
      26          24 : ExpectedImprovement::ExpectedImprovement(const InputParameters & parameters)
      27          48 :   : ParallelAcquisitionFunctionBase(parameters), _tuning(getParam<Real>("tuning"))
      28             : {
      29          24 : }
      30             : 
      31             : void
      32          24 : ExpectedImprovement::computeAcquisitionInternal(
      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       24024 :   for (unsigned int i = 0; i < gp_mean.size(); ++i)
      43             :   {
      44       24000 :     z = gp_mean[i] - *maxIt - _tuning;
      45       24000 :     acq[i] = (gp_mean[i] - *maxIt) * Normal::cdf(z, 0.0, gp_std[i]) +
      46       24000 :              gp_std[i] * Normal::pdf(z, 0.0, gp_std[i]);
      47             :   }
      48          24 : }

Generated by: LCOV version 1.14