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 "UpperConfidenceBound.h" 11 : #include <cmath> 12 : 13 : registerMooseObject("StochasticToolsApp", UpperConfidenceBound); 14 : 15 : InputParameters 16 8 : UpperConfidenceBound::validParams() 17 : { 18 8 : InputParameters params = ParallelAcquisitionFunctionBase::validParams(); 19 8 : params.addClassDescription("Upper Confidence Bound acquisition function."); 20 24 : params.addRangeCheckedParam<Real>( 21 16 : "tuning", 1.0, "tuning > 0", "Tuning parameter to control exploration vs exploitation."); 22 8 : return params; 23 0 : } 24 : 25 4 : UpperConfidenceBound::UpperConfidenceBound(const InputParameters & parameters) 26 8 : : ParallelAcquisitionFunctionBase(parameters), _tuning(getParam<Real>("tuning")) 27 : { 28 4 : } 29 : 30 : void 31 16 : UpperConfidenceBound::computeAcquisitionInternal( 32 : std::vector<Real> & acq, 33 : const std::vector<Real> & gp_mean, 34 : const std::vector<Real> & gp_std, 35 : const std::vector<std::vector<Real>> & /*test_inputs*/, 36 : const std::vector<std::vector<Real>> & /*train_inputs*/, 37 : const std::vector<Real> & /*generic*/) const 38 : { 39 16016 : for (unsigned int i = 0; i < gp_mean.size(); ++i) 40 16000 : acq[i] = gp_mean[i] + _tuning * gp_std[i]; 41 16 : }