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 : #pragma once 11 : 12 : #include "StochasticToolsApp.h" 13 : #include "MooseObject.h" 14 : #include "libmesh/utility.h" 15 : 16 : /** 17 : * All ParallelAcquisition functions should inherit from this class 18 : */ 19 0 : class ParallelAcquisitionFunctionBase : public MooseObject 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : ParallelAcquisitionFunctionBase(const InputParameters & parameters); 24 : 25 : /** 26 : * Compute the acquisition function values. Performs all argument/size checks, 27 : * then dispatches to computeAcquisitionInternal implemented by derived classes. 28 : * @param acq The computed acquisition function values 29 : * @param gp_mean The provided GP mean values 30 : * @param gp_std The provided GP standard deviation values 31 : * @param test_inputs All the input values under which the GP has to be tested 32 : * @param train_inputs All the input values under which the GP has been trained 33 : * @param generic A generic parameter (can be output values under which the GP has been trained or 34 : * threshold parameter under the U-Function etc.) 35 : */ 36 : void computeAcquisition(std::vector<Real> & acq, 37 : const std::vector<Real> & gp_mean, 38 : const std::vector<Real> & gp_std, 39 : const std::vector<std::vector<Real>> & test_inputs, 40 : const std::vector<std::vector<Real>> & train_inputs, 41 : const std::vector<Real> & generic) const; 42 : 43 : /** 44 : * Return the modified acquisition function values and sorted indices considering local 45 : * penalization (inspired from Zhan et al. 2017) 46 : * @param modified_acq The modified acquisition function values 47 : * @param sorted_indices The sorted indices modified acquisition function values 48 : * @param acq The originally acquisition function values 49 : * @param length_scales The length scales to compute the correlation between inputs 50 : * @param inputs All the input values under which acquisition needs to be computed 51 : * @param penalize Bool to indicate whether to compute the correlations or not 52 : */ 53 : void penalizeAcquisition(std::vector<Real> & modified_acq, 54 : std::vector<unsigned int> & sorted_indices, 55 : const std::vector<Real> & acq, 56 : const std::vector<Real> & length_scales, 57 : const std::vector<std::vector<Real>> & inputs); 58 : 59 : /** 60 : * Compute the correlation between two inputs using the length scales 61 : * @param corr The computed correlation value 62 : * @param input1 The first input 63 : * @param input2 The second input 64 : * @param length_scales The length scales to compute the correlation between inputs 65 : */ 66 : void computeCorrelation(Real & corr, 67 : const std::vector<Real> & input1, 68 : const std::vector<Real> & input2, 69 : const std::vector<Real> & length_scales); 70 : 71 : protected: 72 : /** 73 : * Implementation hook for derived classes (no size checks here). 74 : * @param acq The computed acquisition function values 75 : * @param gp_mean The provided GP mean values 76 : * @param gp_std The provided GP standard deviation values 77 : * @param test_inputs All the input values under which the GP has to be tested 78 : * @param train_inputs All the input values under which the GP has been trained 79 : * @param generic A generic parameter (can be output values under which the GP has been trained or 80 : * threshold parameter under the U-Function etc.) 81 : */ 82 : virtual void computeAcquisitionInternal(std::vector<Real> & acq, 83 : const std::vector<Real> & gp_mean, 84 : const std::vector<Real> & gp_std, 85 : const std::vector<std::vector<Real>> & test_inputs, 86 : const std::vector<std::vector<Real>> & train_inputs, 87 : const std::vector<Real> & generic) const = 0; 88 : };