13 #include "libmesh/id_types.h" 24 "objective_name",
"Preferred name of reporter value defining the objective.");
25 params.
addParam<std::vector<dof_id_type>>(
27 "Number of parameter values associated with each parameter group in 'parameter_names'.");
28 params.
addParam<ReporterValueName>(
"num_values_name",
29 "Reporter that holds the number of parameter values " 30 "associated with each parameter group in 'parameter_names'.");
31 params.
addParam<std::vector<std::vector<Real>>>(
33 "Initial conditions for each parameter. A vector is given for each parameter group. A " 34 "single value can be given for each group and all parameters in that group will be set to " 35 "that value. The default value is 0.");
36 params.
addParam<std::vector<std::vector<Real>>>(
38 "Lower bound for each parameter. A vector is given for each parameter group. A single " 39 "value can be given for each group and all parameters in that group will be set to that " 41 params.
addParam<std::vector<std::vector<Real>>>(
43 "Upper bound for each parameter. A vector is given for each parameter group. A single " 44 "value can be given for each group and all parameters in that group will be set to that " 48 "constraint data, which are supplied by the reporters and " 49 "postprocessors from the forward and adjoint subapps.");
55 _objective_val(declareValueByName<
Real>(getParam<ReporterValueName>(
"objective_name"),
58 isParamValid(
"num_values_name")
71 Real param_norm_sqr = 0;
73 for (
const auto & param_val : *data)
74 param_norm_sqr += param_val * param_val;
86 "The number of parameters you have is zero and this shouldn't happen. Make sure you are " 87 "running your forward problem on \'INITIAL\' if you are using a reporter transfer to " 101 paramError(
"Need to supply one and only one of num_values_name or num_values.");
106 _nvalues = getParam<std::vector<dof_id_type>>(
"num_values");
114 "There should be a number in \'num_parameters\' for each name in \'parameter_names\'.");
120 std::vector<Real> ic(
parseInputData(
"initial_condition", 0, param_id));
121 std::vector<Real> lb(
122 parseInputData(
"lower_bounds", std::numeric_limits<Real>::lowest(), param_id));
123 std::vector<Real> ub(
124 parseInputData(
"upper_bounds", std::numeric_limits<Real>::max(), param_id));
129 _parameters[param_id]->assign(ic.begin(), ic.end());
std::vector< dof_id_type > * _num_values_reporter
Real & _objective_val
Reporter that will hold the objective value.
const std::vector< ReporterValueName > & _parameter_names
Parameter names.
virtual Real computeObjective() override
Function to compute objective.
virtual dof_id_type getNumParams() const override
Function to get the total number of parameters.
dof_id_type _ndof
Total number of parameters.
const unsigned int _nparams
Number of parameter vectors.
Base class for optimization objects, implements routines for calculating misfit.
bool isParamValid(const std::string &name) const
std::vector< dof_id_type > _nvalues
Number of values for each parameter.
std::vector< Real > parseInputData(std::string type, Real default_value, unsigned int param_id) const
Function to to parse bounds and initial conditions from input file.
std::vector< Real > _lower_bounds
Bounds of the parameters.
void paramError(const std::string ¶m, Args... args) const
std::vector< std::vector< Real > * > _parameters
Parameter values declared as reporter data.
GeneralOptimization(const InputParameters ¶meters)
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("OptimizationApp", GeneralOptimization)
std::vector< std::vector< Real > * > _gradients
Gradient values declared as reporter data.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
std::vector< Real > _upper_bounds
const ReporterMode REPORTER_MODE_REPLICATED
static InputParameters validParams()
const Real _tikhonov_coeff
Tikhonov Coefficient for regularization.
virtual void setICsandBounds() override
Sets the initial conditions and bounds right before it is needed.
Optimization reporter that interfaces with TAO.