13 #include "libmesh/petsc_vector.h" 21 "parameter_names",
"List of parameter names, one for each group of parameters.");
23 "tikhonov_coeff", 0.0,
"tikhonov_coeff >= 0",
"Coefficient for Tikhonov Regularization.");
24 params.
addParam<std::vector<ReporterValueName>>(
25 "equality_names", std::vector<ReporterValueName>(),
"List of equality names.");
26 params.
addParam<std::vector<ReporterValueName>>(
27 "inequality_names", std::vector<ReporterValueName>(),
"List of inequality names.");
34 _parameter_names(getParam<
std::vector<ReporterValueName>>(
"parameter_names")),
35 _nparams(_parameter_names.size()),
36 _parameters(_nparams),
38 _tikhonov_coeff(getParam<
Real>(
"tikhonov_coeff")),
39 _equality_names(&getParam<
std::vector<ReporterValueName>>(
"equality_names")),
40 _n_eq_cons(_equality_names->size()),
41 _eq_constraints(_n_eq_cons),
42 _eq_gradients(_n_eq_cons),
43 _inequality_names(&getParam<
std::vector<ReporterValueName>>(
"inequality_names")),
44 _n_ineq_cons(_inequality_names->size()),
45 _ineq_constraints(_n_ineq_cons),
46 _ineq_gradients(_n_ineq_cons)
79 " has changed, expected ",
126 unsigned int param_id)
const 129 std::vector<Real> parsed_data_id(
_nvalues[param_id], default_value);
132 std::vector<std::vector<Real>> parsed_data(
getParam<std::vector<std::vector<Real>>>(
type));
133 parsed_data_id.assign(parsed_data[param_id].begin(), parsed_data[param_id].end());
134 if (parsed_data.size() !=
_nvalues.size())
136 "There must be a vector of ",
138 " per parameter group. The ",
140 " input format is std::vector<std::vector<Real>> so each vector should be " 141 "seperated by \";\" even if it is a single value per group for a constant ",
145 if (parsed_data[param_id].size() == 1)
146 parsed_data_id.assign(
_nvalues[param_id], parsed_data[param_id][0]);
147 else if (parsed_data[param_id].size() !=
_nvalues[param_id])
151 " are given in input file, there must either be a single value per parameter " 152 "group or a value for every parameter in the group.");
155 return parsed_data_id;
177 mooseError(
"The equality jacobian for parameter ",
179 " has changed, expected ",
192 mooseError(
"The inequality jacobian for parameter ",
194 " has changed, expected ",
virtual void setICsandBounds()
Sets the initial conditions and bounds right before it is needed.
const std::vector< ReporterValueName > * _inequality_names
Inequality constraint names.
const std::vector< ReporterValueName > & _parameter_names
Parameter names.
const unsigned int _n_ineq_cons
Number of inequality constraint names.
virtual void computeInequalityConstraints(libMesh::PetscVector< Number > &ineqs_constraints) const
Function to compute the inequality constraints.
Real getLowerBound(dof_id_type i) const
std::vector< std::vector< Real > * > _ineq_gradients
Gradient values declared as reporter data.
dof_id_type _ndof
Total number of parameters.
void copyPetscVectorIntoReporter(const libMesh::PetscVector< Number > &x, std::vector< std::vector< Real > *> reporterVectors)
static InputParameters validParams()
virtual void computeEqualityGradient(libMesh::PetscMatrix< Number > &gradient) const
Function to compute the gradient of the equality constraints/ This is the last call of the equality c...
virtual dof_id_type getNumParams() const
Function to get the total number of parameters.
const unsigned int _nparams
Number of parameter vectors.
std::vector< std::vector< Real > * > _ineq_constraints
Inequality values declared as reporter data.
bool isParamValid(const std::string &name) const
void setInitialCondition(libMesh::PetscVector< Number > ¶m)
Function to initialize petsc vectors from vpp data.
std::vector< std::vector< Real > * > _eq_gradients
Gradient values declared as reporter data.
const std::vector< double > x
std::vector< dof_id_type > _nvalues
Number of values for each parameter.
const std::string & type() const
const T & getParam(const std::string &name) const
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.
std::vector< std::vector< Real > * > _eq_constraints
Equality values declared as reporter data.
const unsigned int _n_eq_cons
Number of equality constraint names.
const std::vector< ReporterValueName > * _equality_names
Equality constraint names.
virtual void computeInequalityGradient(libMesh::PetscMatrix< Number > &gradient) const
Function to compute the gradient of the inequality constraints/ This is the last call of the inequali...
OptimizationReporterBase(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeGradient(libMesh::PetscVector< Number > &gradient) const
Function to compute gradient.
void copyReporterIntoPetscVector(const std::vector< std::vector< Real > *> reporterVectors, libMesh::PetscVector< Number > &x)
std::vector< std::vector< Real > * > _gradients
Gradient values declared as reporter data.
IntRange< T > make_range(T beg, T end)
virtual void updateParameters(const libMesh::PetscVector< Number > &x)
Function to set parameters.
void mooseError(Args &&... args) const
std::vector< Real > _upper_bounds
const ReporterMode REPORTER_MODE_REPLICATED
static InputParameters validParams()
Real getUpperBound(dof_id_type i) const
Upper and lower bounds for each parameter being controlled.
const Real _tikhonov_coeff
Tikhonov Coefficient for regularization.
virtual void computeEqualityConstraints(libMesh::PetscVector< Number > &eqs_constraints) const
Function to compute the equality constraints.
void copyReporterIntoPetscMatrix(const std::vector< std::vector< Real > *> reporterVectors, libMesh::PetscMatrix< Number > &x)