LCOV - code coverage report
Current view: top level - src/acquisitions - ExpectedImprovementGlobalFit.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #32971 (54bef8) with base c6cf66 Lines: 20 21 95.2 %
Date: 2026-05-29 20:40:35 Functions: 4 4 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 "ExpectedImprovementGlobalFit.h"
      11             : #include <cmath>
      12             : 
      13             : registerMooseObject("StochasticToolsApp", ExpectedImprovementGlobalFit);
      14             : 
      15             : InputParameters
      16           8 : ExpectedImprovementGlobalFit::validParams()
      17             : {
      18           8 :   InputParameters params = ParallelAcquisitionFunctionBase::validParams();
      19           8 :   params.addClassDescription("Expected improvement for global fit (EIGF) by Lam and Notz 2008.");
      20           8 :   return params;
      21           0 : }
      22             : 
      23           4 : ExpectedImprovementGlobalFit::ExpectedImprovementGlobalFit(const InputParameters & parameters)
      24           4 :   : ParallelAcquisitionFunctionBase(parameters)
      25             : {
      26           4 : }
      27             : 
      28             : void
      29          16 : ExpectedImprovementGlobalFit::computeAcquisitionInternal(
      30             :     std::vector<Real> & acq,
      31             :     const std::vector<Real> & gp_mean,
      32             :     const std::vector<Real> & gp_std,
      33             :     const std::vector<std::vector<Real>> & test_inputs,
      34             :     const std::vector<std::vector<Real>> & train_inputs,
      35             :     const std::vector<Real> & generic) const
      36             : {
      37             :   unsigned int ref_ind;
      38       16016 :   for (unsigned int i = 0; i < test_inputs.size(); ++i)
      39             :   {
      40       16000 :     computeDistance(ref_ind, test_inputs[i], train_inputs);
      41       16000 :     acq[i] = Utility::pow<2>(gp_mean[i] - generic[ref_ind]) + Utility::pow<2>(gp_std[i]);
      42             :   }
      43          16 : }
      44             : 
      45             : void
      46       16000 : ExpectedImprovementGlobalFit::computeDistance(unsigned int & req_index,
      47             :                                               const std::vector<Real> & current_input,
      48             :                                               const std::vector<std::vector<Real>> & train_inputs)
      49             : {
      50             :   Real ref_distance = std::numeric_limits<Real>::max();
      51             :   Real distance;
      52       16000 :   req_index = 0;
      53      216000 :   for (unsigned int i = 0; i < train_inputs.size(); ++i)
      54             :   {
      55             :     distance = 0.0;
      56      600000 :     for (unsigned int j = 0; j < current_input.size(); ++j)
      57      400000 :       distance += Utility::pow<2>(current_input[j] - train_inputs[i][j]);
      58      200000 :     if (distance <= ref_distance)
      59             :     {
      60             :       ref_distance = distance;
      61       41680 :       req_index = i;
      62             :     }
      63             :   }
      64       16000 : }

Generated by: LCOV version 1.14