https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
OptimizeSolve Class Reference

solveObject to interface with Petsc Tao More...

#include <OptimizeSolve.h>

Inheritance diagram for OptimizeSolve:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 OptimizeSolve (Executioner &ex)
 
virtual bool solve () override
 
const OptimizationReporterBase & getOptimizationReporter () const
 
void getTaoSolutionStatus (std::vector< int > &tot_iters, std::vector< double > &gnorm, std::vector< int > &obj_iters, std::vector< double > &cnorm, std::vector< int > &grad_iters, std::vector< double > &xdiff, std::vector< int > &hess_iters, std::vector< double > &f, std::vector< int > &tot_solves) const
 Record tao TaoGetSolutionStatus data for output by a reporter.
 
virtual void initialSetup ()
 
virtual void setInnerSolve (SolveObject &solve)
 
virtual bool enabled () const
 
std::shared_ptr< MooseObject > getSharedPtr ()
 
std::shared_ptr< const MooseObject > getSharedPtr () const
 
bool isKokkosObject () const
 
MooseApp & getMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParameters & parameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
PerfGraph & perfGraph ()
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValue & getPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValue & getPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

virtual PetscErrorCode variableBounds (Tao tao)
 Bounds routine.
 
virtual Real objectiveFunction ()
 Objective routine.
 
virtual void gradientFunction (libMesh::PetscVector< Number > &gradient)
 Gradient routine.
 
virtual PetscErrorCode applyHessian (libMesh::PetscVector< Number > &s, libMesh::PetscVector< Number > &Hs)
 Hessian application routine.
 
OptimizationReporterBase * getObjFunction ()
 function to get the objective reporter
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 

Protected Attributes

const libMesh::Parallel::Communicator _my_comm
 Communicator used for operations.
 
const ExecFlagEnum & _solve_on
 List of execute flags for when to solve the system.
 
OptimizationReporterBase * _obj_function = nullptr
 objective function defining objective, gradient, and hessian
 
Tao _tao
 Tao optimization object.
 
Executioner & _executioner
 
FEProblemBase & _problem
 
DisplacedProblem * _displaced_problem
 
MooseMesh & _mesh
 
MooseMesh * _displaced_mesh
 
SystemBase & _solver_sys
 
AuxiliarySystem & _aux
 
SolveObject * _inner_solve
 
const bool & _enabled
 
MooseApp & _app
 
Factory & _factory
 
ActionFactory & _action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters & _pars
 
MooseApp & _pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Types

enum class  TaoSolverEnum {
  NEWTON_TRUST_REGION , BOUNDED_NEWTON_TRUST_REGION , BOUNDED_CONJUGATE_GRADIENT , NEWTON_LINE_SEARCH ,
  BOUNDED_NEWTON_LINE_SEARCH , BOUNDED_QUASI_NEWTON_TRUST_REGION , NEWTON_TRUST_LINE , BOUNDED_NEWTON_TRUST_LINE ,
  NELDER_MEAD , BOUNDED_QUASI_NEWTON_LINE_SEARCH , ORTHANT_QUASI_NEWTON , GRADIENT_PROJECTION_CONJUGATE_GRADIENT ,
  BUNDLE_RISK_MIN , AUGMENTED_LAGRANGIAN_MULTIPLIER_METHOD
}
 Enum of tao solver types. More...
 

Private Member Functions

PetscErrorCode taoSolve ()
 Here is where we call tao and solve.
 
void setTaoSolutionStatus (double f, int its, double gnorm, double cnorm, double xdiff)
 output optimization iteration solve data
 
PetscErrorCode taoALCreate ()
 Used for creating petsc structures when using the ALMM algorithm.
 
PetscErrorCode taoALDestroy ()
 Used for destroying petsc structures when using the ALMM algorithm.
 
const PostprocessorName & getPostprocessorNameInternal (const std::string &param_name, const unsigned int index, const bool allow_default_value=true) const
 
bool isDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
PostprocessorValue getDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
void checkParam (const std::string &param_name, const unsigned int index=std::numeric_limits< unsigned int >::max()) const
 
bool postprocessorsAdded () const
 
const PostprocessorValue & getPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 
static PetscErrorCode objectiveFunctionWrapper (Tao tao, Vec x, Real *objective, void *ctx)
 
static PetscErrorCode hessianFunctionWrapper (Tao tao, Vec x, Mat hessian, Mat pc, void *ctx)
 
static PetscErrorCode applyHessianWrapper (Mat H, Vec s, Vec Hs)
 
static PetscErrorCode objectiveAndGradientFunctionWrapper (Tao tao, Vec x, Real *objective, Vec gradient, void *ctx)
 
static PetscErrorCode variableBoundsWrapper (Tao, Vec xl, Vec xu, void *ctx)
 
static PetscErrorCode monitor (Tao tao, void *ctx)
 
static PetscErrorCode equalityFunctionWrapper (Tao tao, Vec x, Vec ce, void *ctx)
 
static PetscErrorCode equalityGradientFunctionWrapper (Tao tao, Vec x, Mat gradient_e, Mat gradient_epre, void *ctx)
 
static PetscErrorCode inequalityFunctionWrapper (Tao tao, Vec x, Vec ci, void *ctx)
 
static PetscErrorCode inequalityGradientFunctionWrapper (Tao tao, Vec x, Mat gradient_i, Mat gradient_ipre, void *ctx)
 

Private Attributes

bool _verbose
 control optimization executioner output
 
bool _output_opt_iters
 Use time step as the iteration counter for purposes of outputting.
 
std::vector< int > _total_iterate_vec
 total solves per iteration
 
std::vector< int > _obj_iterate_vec
 number of objective solves per iteration
 
std::vector< int > _grad_iterate_vec
 gradient solves per iteration
 
std::vector< int > _hess_iterate_vec
 Hessian solves per iteration.
 
std::vector< int > _function_solve_vec
 total solves per iteration
 
std::vector< double > _f_vec
 objective value per iteration
 
std::vector< double > _gnorm_vec
 gradient norm per iteration
 
std::vector< double > _cnorm_vec
 infeasibility norm per iteration
 
std::vector< double > _xdiff_vec
 step length per iteration
 
enum OptimizeSolve::TaoSolverEnum _tao_solver_enum
 
dof_id_type _ndof
 Number of parameters being optimized.
 
std::unique_ptr< libMesh::PetscVector< Number > > _parameters
 Parameters (solution) given to TAO.
 
Mat _hessian
 Hessian (matrix) - usually a matrix-free representation.
 
Vec _ce
 Equality constraint vector.
 
Vec _ci
 Inequality constraint vector.
 
Mat _gradient_e
 Equality constraint gradient.
 
Mat _gradient_i
 Inequality constraint gradient.
 
const ParallelParamObject & _parent
 
const MooseBase & _si_moose_base
 
const FEProblemBase * _si_problem
 
const MooseObject & _ppi_moose_object
 
const InputParameters & _ppi_params
 
const FEProblemBase & _ppi_feproblem
 
std::map< PostprocessorName, std::unique_ptr< PostprocessorValue > > _default_values
 
int _obj_iterate = 0
 
int _grad_iterate = 0
 
int _hess_iterate = 0
 
Moose::PetscSupport::PetscOptions _petsc_options
 
SolverParams _solver_params
 

Detailed Description

solveObject to interface with Petsc Tao

Definition at line 28 of file OptimizeSolve.h.

Member Enumeration Documentation

◆ TaoSolverEnum

enum class OptimizeSolve::TaoSolverEnum
strongprivate

Enum of tao solver types.

Enumerator
NEWTON_TRUST_REGION 
BOUNDED_NEWTON_TRUST_REGION 
BOUNDED_CONJUGATE_GRADIENT 
NEWTON_LINE_SEARCH 
BOUNDED_NEWTON_LINE_SEARCH 
BOUNDED_QUASI_NEWTON_TRUST_REGION 
NEWTON_TRUST_LINE 
BOUNDED_NEWTON_TRUST_LINE 
NELDER_MEAD 
BOUNDED_QUASI_NEWTON_LINE_SEARCH 
ORTHANT_QUASI_NEWTON 
GRADIENT_PROJECTION_CONJUGATE_GRADIENT 
BUNDLE_RISK_MIN 
AUGMENTED_LAGRANGIAN_MULTIPLIER_METHOD 

Definition at line 154 of file OptimizeSolve.h.

154 {
enum OptimizeSolve::TaoSolverEnum _tao_solver_enum

Constructor & Destructor Documentation

◆ OptimizeSolve()

OptimizeSolve::OptimizeSolve ( Executioner &  ex)

Definition at line 42 of file OptimizeSolve.C.

43 : SolveObject(ex),
44 _my_comm(MPI_COMM_SELF),
45 _solve_on(getParam<ExecFlagEnum>("solve_on")),
46 _verbose(getParam<bool>("verbose")),
47 _output_opt_iters(getParam<bool>("output_optimization_iterations")),
48 _tao_solver_enum(getParam<MooseEnum>("tao_solver").getEnum<TaoSolverEnum>()),
50{
51 if (_problem.numThreads() > 1)
52 mooseError("OptimizeSolve does not currently support threaded execution");
53
56 "moose", 27225, "Outputting for transient executioners has not been implemented.");
57}
virtual bool isTransient() const override
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
void mooseError(Args &&... args) const
const libMesh::Parallel::Communicator _my_comm
Communicator used for operations.
std::unique_ptr< libMesh::PetscVector< Number > > _parameters
Parameters (solution) given to TAO.
const ExecFlagEnum & _solve_on
List of execute flags for when to solve the system.
bool _verbose
control optimization executioner output
bool _output_opt_iters
Use time step as the iteration counter for purposes of outputting.
FEProblemBase & _problem
THREAD_ID numThreads() const

Member Function Documentation

◆ applyHessian()

PetscErrorCode OptimizeSolve::applyHessian ( libMesh::PetscVector< Number > &  s,
libMesh::PetscVector< Number > &  Hs 
)
protectedvirtual

Hessian application routine.

Definition at line 427 of file OptimizeSolve.C.

428{
430 TIME_SECTION("applyHessian", 2, "Hessian forward/adjoint solve");
431 // What happens for material inversion when the Hessian
432 // is dependent on the parameters? Deal with it later???
433 // see notes on how this needs to change for Material inversion
434 if (_problem.hasMultiApps() &&
436 mooseError("Hessian based optimization algorithms require a sub-app with:\n"
437 " execute_on = HOMOGENEOUS_FORWARD");
439
444 mooseError("Homogeneous forward solve multiapp failed!");
447
448 // The adjoint solve below applies the misfit as its source. For the Hessian action, that source
449 // is the simulated values from the homogeneous forward solve, so the input must transfer
450 // 'simulation_values' from the homogeneous forward sub-app into 'misfit_values'.
455 mooseError("Adjoint solve multiapp failed!");
458
461 PetscFunctionReturn(PETSC_SUCCESS);
462}
PetscFunctionBegin
bool hasMultiApps() const
void restoreMultiApps(ExecFlagType type, bool force=false)
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
virtual void execute(const ExecFlagType &exec_type)
bool isValueSet(const std::string &value) const
virtual void computeGradient(libMesh::PetscVector< Number > &gradient) const
Function to compute gradient.
virtual void updateParameters(const libMesh::PetscVector< Number > &x)
Function to set parameters.
Moose::PetscSupport::PetscOptions _petsc_options
OptimizationReporterBase * _obj_function
objective function defining objective, gradient, and hessian
SolverParams _solver_params
SolveObject * _inner_solve
virtual bool solve()=0
void petscSetOptions(const PetscOptions &po, const SolverParams &solver_params, FEProblemBase *const problem=nullptr)
const ExecFlagType EXEC_ADJOINT
const ExecFlagType EXEC_HOMOGENEOUS_FORWARD
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ applyHessianWrapper()

PetscErrorCode OptimizeSolve::applyHessianWrapper ( Mat  H,
Vec  s,
Vec  Hs 
)
staticprivate

Definition at line 362 of file OptimizeSolve.C.

363{
364 void * ctx;
365
367 LibmeshPetscCallQ(MatShellGetContext(H, &ctx));
368
369 auto * solver = static_cast<OptimizeSolve *>(ctx);
370 libMesh::PetscVector<Number> sbar(s, solver->_my_comm);
371 libMesh::PetscVector<Number> Hsbar(Hs, solver->_my_comm);
372 return solver->applyHessian(sbar, Hsbar);
373}
solveObject to interface with Petsc Tao
void * ctx
LibmeshPetscCallQ(DMShellGetContext(dm, &ctx))

Referenced by hessianFunctionWrapper().

◆ equalityFunctionWrapper()

PetscErrorCode OptimizeSolve::equalityFunctionWrapper ( Tao  tao,
Vec  x,
Vec  ce,
void *  ctx 
)
staticprivate

Definition at line 485 of file OptimizeSolve.C.

486{
488 // grab the solver
489 auto * solver = static_cast<OptimizeSolve *>(ctx);
490 libMesh::PetscVector<Number> eq_con(ce, solver->_my_comm);
491 // use the OptimizationReporterBase class to actually compute equality constraints
492 OptimizationReporterBase * obj_func = solver->getObjFunction();
493 obj_func->computeEqualityConstraints(eq_con);
494 PetscFunctionReturn(PETSC_SUCCESS);
495}
Base class for optimization objects, implements routines for calculating misfit.
virtual void computeEqualityConstraints(libMesh::PetscVector< Number > &eqs_constraints) const
Function to compute the equality constraints.

Referenced by taoALCreate().

◆ equalityGradientFunctionWrapper()

PetscErrorCode OptimizeSolve::equalityGradientFunctionWrapper ( Tao  tao,
Vec  x,
Mat  gradient_e,
Mat  gradient_epre,
void *  ctx 
)
staticprivate

Definition at line 498 of file OptimizeSolve.C.

500{
502 // grab the solver
503 auto * solver = static_cast<OptimizeSolve *>(ctx);
504 libMesh::PetscMatrix<Number> grad_eq(gradient_e, solver->_my_comm);
505 // use the OptimizationReporterBase class to actually compute equality
506 // constraints gradient
507 OptimizationReporterBase * obj_func = solver->getObjFunction();
508 obj_func->computeEqualityGradient(grad_eq);
509 PetscFunctionReturn(PETSC_SUCCESS);
510}
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...

Referenced by taoALCreate().

◆ getObjFunction()

OptimizationReporterBase * OptimizeSolve::getObjFunction ( )
inlineprotected

function to get the objective reporter

Definition at line 84 of file OptimizeSolve.h.

84{ return _obj_function; }

◆ getOptimizationReporter()

const OptimizationReporterBase & OptimizeSolve::getOptimizationReporter ( ) const
inline

Definition at line 36 of file OptimizeSolve.h.

36{ return *_obj_function; }

◆ getTaoSolutionStatus()

void OptimizeSolve::getTaoSolutionStatus ( std::vector< int > &  tot_iters,
std::vector< double > &  gnorm,
std::vector< int > &  obj_iters,
std::vector< double > &  cnorm,
std::vector< int > &  grad_iters,
std::vector< double > &  xdiff,
std::vector< int > &  hess_iters,
std::vector< double > &  f,
std::vector< int > &  tot_solves 
) const

Record tao TaoGetSolutionStatus data for output by a reporter.

Parameters
tot_iterstotal solves per iteration
gnormgradient norm per iteration
obj_itersnumber of objective solves per iteration
cnorminfeasibility norm per iteration
grad_itersgradient solves per iteration
xdiffstep length per iteration
hess_itersHessian solves per iteration
fobjective value per iteration
tot_solvestotal solves per iteration

Definition at line 225 of file OptimizeSolve.C.

234{
235 const auto num = _total_iterate_vec.size();
236 tot_iters.resize(num);
237 obj_iters.resize(num);
238 grad_iters.resize(num);
239 hess_iters.resize(num);
240 tot_solves.resize(num);
241 f.resize(num);
242 gnorm.resize(num);
243 cnorm.resize(num);
244 xdiff.resize(num);
245
246 for (const auto i : make_range(num))
247 {
248 tot_iters[i] = _total_iterate_vec[i];
249 obj_iters[i] = _obj_iterate_vec[i];
250 grad_iters[i] = _grad_iterate_vec[i];
251 hess_iters[i] = _hess_iterate_vec[i];
252 tot_solves[i] = _function_solve_vec[i];
253 f[i] = _f_vec[i];
254 gnorm[i] = _gnorm_vec[i];
255 cnorm[i] = _cnorm_vec[i];
256 xdiff[i] = _xdiff_vec[i];
257 }
258}
Real f(Real x)
Test function for Brents method.
std::vector< double > _f_vec
objective value per iteration
std::vector< int > _grad_iterate_vec
gradient solves per iteration
std::vector< int > _obj_iterate_vec
number of objective solves per iteration
std::vector< int > _hess_iterate_vec
Hessian solves per iteration.
std::vector< double > _xdiff_vec
step length per iteration
std::vector< int > _total_iterate_vec
total solves per iteration
std::vector< double > _cnorm_vec
infeasibility norm per iteration
std::vector< int > _function_solve_vec
total solves per iteration
std::vector< double > _gnorm_vec
gradient norm per iteration
IntRange< T > make_range(T beg, T end)

Referenced by OptimizationInfo::execute().

◆ gradientFunction()

void OptimizeSolve::gradientFunction ( libMesh::PetscVector< Number > &  gradient)
protectedvirtual

Gradient routine.

Definition at line 409 of file OptimizeSolve.C.

◆ hessianFunctionWrapper()

PetscErrorCode OptimizeSolve::hessianFunctionWrapper ( Tao  tao,
Vec  x,
Mat  hessian,
Mat  pc,
void *  ctx 
)
staticprivate

Definition at line 350 of file OptimizeSolve.C.

352{
354 // Define Hessian-vector multiplication routine
355 auto * solver = static_cast<OptimizeSolve *>(ctx);
356 LibmeshPetscCallQ(MatShellSetOperation(
357 solver->_hessian, MATOP_MULT, (void (*)(void))OptimizeSolve::applyHessianWrapper));
358 PetscFunctionReturn(PETSC_SUCCESS);
359}
static PetscErrorCode applyHessianWrapper(Mat H, Vec s, Vec Hs)

Referenced by taoSolve().

◆ inequalityFunctionWrapper()

PetscErrorCode OptimizeSolve::inequalityFunctionWrapper ( Tao  tao,
Vec  x,
Vec  ci,
void *  ctx 
)
staticprivate

Definition at line 513 of file OptimizeSolve.C.

514{
516 // grab the solver
517 auto * solver = static_cast<OptimizeSolve *>(ctx);
518 libMesh::PetscVector<Number> ineq_con(ci, solver->_my_comm);
519 // use the OptimizationReporterBase class to actually compute equality constraints
520 OptimizationReporterBase * obj_func = solver->getObjFunction();
521 obj_func->computeInequalityConstraints(ineq_con);
522 PetscFunctionReturn(PETSC_SUCCESS);
523}
virtual void computeInequalityConstraints(libMesh::PetscVector< Number > &ineqs_constraints) const
Function to compute the inequality constraints.

Referenced by taoALCreate().

◆ inequalityGradientFunctionWrapper()

PetscErrorCode OptimizeSolve::inequalityGradientFunctionWrapper ( Tao  tao,
Vec  x,
Mat  gradient_i,
Mat  gradient_ipre,
void *  ctx 
)
staticprivate

Definition at line 526 of file OptimizeSolve.C.

528{
530 // grab the solver
531 auto * solver = static_cast<OptimizeSolve *>(ctx);
532 libMesh::PetscMatrix<Number> grad_ineq(gradient_i, solver->_my_comm);
533 // use the OptimizationReporterBase class to actually compute equality
534 // constraints gradient
535 OptimizationReporterBase * obj_func = solver->getObjFunction();
536 obj_func->computeInequalityGradient(grad_ineq);
537 PetscFunctionReturn(PETSC_SUCCESS);
538}
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...

Referenced by taoALCreate().

◆ monitor()

PetscErrorCode OptimizeSolve::monitor ( Tao  tao,
void *  ctx 
)
staticprivate

Definition at line 303 of file OptimizeSolve.C.

304{
305 TaoConvergedReason reason;
306 PetscInt its;
307 PetscReal f, gnorm, cnorm, xdiff;
308
310 LibmeshPetscCallQ(TaoGetSolutionStatus(tao, &its, &f, &gnorm, &cnorm, &xdiff, &reason));
311
312 auto * solver = static_cast<OptimizeSolve *>(ctx);
313 solver->setTaoSolutionStatus((double)f, (int)its, (double)gnorm, (double)cnorm, (double)xdiff);
314
315 PetscFunctionReturn(PETSC_SUCCESS);
316}
void ErrorVector unsigned int
void setTaoSolutionStatus(double f, int its, double gnorm, double cnorm, double xdiff)
output optimization iteration solve data

Referenced by taoSolve().

◆ objectiveAndGradientFunctionWrapper()

PetscErrorCode OptimizeSolve::objectiveAndGradientFunctionWrapper ( Tao  tao,
Vec  x,
Real *  objective,
Vec  gradient,
void *  ctx 
)
staticprivate

Definition at line 333 of file OptimizeSolve.C.

335{
337 auto * solver = static_cast<OptimizeSolve *>(ctx);
338
339 libMesh::PetscVector<Number> param(x, solver->_my_comm);
340 solver->_parameters->swap(param);
341
342 (*objective) = solver->objectiveFunction();
343 libMesh::PetscVector<Number> grad(gradient, solver->_my_comm);
344 solver->gradientFunction(grad);
345 solver->_parameters->swap(param);
346 PetscFunctionReturn(PETSC_SUCCESS);
347}
const std::vector< double > x
std::string grad(const std::string &var)
Definition NS.h:92

Referenced by taoSolve().

◆ objectiveFunction()

Real OptimizeSolve::objectiveFunction ( )
protectedvirtual

Objective routine.

Definition at line 386 of file OptimizeSolve.C.

387{
388 TIME_SECTION("objectiveFunction", 2, "Objective forward solve");
390
393
396 {
397 // We do this so we can output for failed solves.
399 mooseError("Forward solve multiapp failed!");
400 }
403
404 _obj_iterate++;
406}
virtual void outputStep(ExecFlagType type)
virtual Real computeObjective()=0
Function to compute objective.
const ExecFlagType EXEC_FORWARD

◆ objectiveFunctionWrapper()

PetscErrorCode OptimizeSolve::objectiveFunctionWrapper ( Tao  tao,
Vec  x,
Real *  objective,
void *  ctx 
)
staticprivate

Function wrappers for tao

Definition at line 319 of file OptimizeSolve.C.

320{
322 auto * solver = static_cast<OptimizeSolve *>(ctx);
323
324 libMesh::PetscVector<Number> param(x, solver->_my_comm);
325 solver->_parameters->swap(param);
326
327 (*objective) = solver->objectiveFunction();
328 solver->_parameters->swap(param);
329 PetscFunctionReturn(PETSC_SUCCESS);
330}

Referenced by taoSolve().

◆ setTaoSolutionStatus()

void OptimizeSolve::setTaoSolutionStatus ( double  f,
int  its,
double  gnorm,
double  cnorm,
double  xdiff 
)
private

output optimization iteration solve data

Definition at line 261 of file OptimizeSolve.C.

262{
263 // set data from TAO
264 _total_iterate_vec.push_back(its);
265 _f_vec.push_back(f);
266 _gnorm_vec.push_back(gnorm);
267 _cnorm_vec.push_back(cnorm);
268 _xdiff_vec.push_back(xdiff);
269 // set data we collect on this optimization iteration and then reset for next iteration
273 // count total number of FE solves
274 int solves = _obj_iterate + _grad_iterate + 2 * _hess_iterate;
275 _function_solve_vec.push_back(solves);
276 _obj_iterate = 0;
277 _grad_iterate = 0;
278 _hess_iterate = 0;
279
280 // Pass down the iteration number if the subapp is of the Steady/SteadyAndAdjoint type.
281 // This enables exodus per-iteration output.
282 for (auto & sub_app : _app.getExecutioner()->feProblem().getMultiAppWarehouse().getObjects())
283 {
284 if (auto steady = dynamic_cast<Steady *>(sub_app->getExecutioner(0)))
285 steady->setIterationNumberOutput((unsigned int)its);
286 }
287
288 // Output the converged iteration outputs
290
291 // Increment timestep. In steady problems timestep = time for outputting.
292 // See Output.C
294 _problem.timeStep() += 1;
295
296 // print verbose per iteration output
297 if (_verbose)
298 _console << "TAO SOLVER: iteration=" << its << "\tf=" << f << "\tgnorm=" << gnorm
299 << "\tcnorm=" << cnorm << "\txdiff=" << xdiff << std::endl;
300}
const ConsoleStream _console
virtual int & timeStep() const
MooseApp & _app

Referenced by monitor().

◆ solve()

bool OptimizeSolve::solve ( )
overridevirtual

Implements SolveObject.

Definition at line 60 of file OptimizeSolve.C.

61{
62 TIME_SECTION("optimizeSolve", 1, "Optimization Solve");
63 // Initial solve
65
66 // Grab objective function
67 if (!_problem.hasUserObject("OptimizationReporter"))
68 mooseError("No OptimizationReporter object found.");
70
71 // Initialize solution and matrix
73 _ndof = _parameters->size();
74
75 // time step defaults 1, we want to start at 0 for first iteration to be
76 // consistent with TAO iterations.
78 _problem.timeStep() = 0;
79 bool solveInfo = (taoSolve() == 0);
80 return solveInfo;
81}
T & getUserObject(const std::string &name, unsigned int tid=0) const
bool hasUserObject(const std::string &name) const
void setInitialCondition(libMesh::PetscVector< Number > &param)
Function to initialize petsc vectors from vpp data.
dof_id_type _ndof
Number of parameters being optimized.
PetscErrorCode taoSolve()
Here is where we call tao and solve.

Referenced by Optimize::execute().

◆ taoALCreate()

PetscErrorCode OptimizeSolve::taoALCreate ( )
private

Used for creating petsc structures when using the ALMM algorithm.

Definition at line 541 of file OptimizeSolve.C.

542{
545 {
546 // Create equality vector
547 LibmeshPetscCallQ(VecCreate(_my_comm.get(), &_ce));
550 LibmeshPetscCallQ(VecSetFromOptions(_ce));
551 LibmeshPetscCallQ(VecSetUp(_ce));
552
553 // Set equality jacobian matrix
555 LibmeshPetscCallQ(MatSetSizes(
557 LibmeshPetscCallQ(MatSetFromOptions(_gradient_e));
559
560 // Set the Equality Constraints
561 LibmeshPetscCallQ(TaoSetEqualityConstraintsRoutine(_tao, _ce, equalityFunctionWrapper, this));
562
563 // Set the Equality Constraints Jacobian
564 LibmeshPetscCallQ(TaoSetJacobianEqualityRoutine(
566 }
567
569 {
570 // Create inequality vector
571 LibmeshPetscCallQ(VecCreate(_my_comm.get(), &_ci));
574 LibmeshPetscCallQ(VecSetFromOptions(_ci));
575 LibmeshPetscCallQ(VecSetUp(_ci));
576
577 // Set inequality jacobian matrix
579 LibmeshPetscCallQ(MatSetSizes(_gradient_i,
581 _ndof,
583 _ndof));
584 LibmeshPetscCallQ(MatSetFromOptions(_gradient_i));
586
587 // Set the Inequality constraints
589 TaoSetInequalityConstraintsRoutine(_tao, _ci, inequalityFunctionWrapper, this));
590
591 // Set the Inequality constraints Jacobian
592 LibmeshPetscCallQ(TaoSetJacobianInequalityRoutine(
594 }
595 PetscFunctionReturn(PETSC_SUCCESS);
596}
dof_id_type getNumEqCons() const
Function to get the total number of equalities.
dof_id_type getNumInEqCons() const
Function to get the total number of inequalities.
static PetscErrorCode equalityFunctionWrapper(Tao tao, Vec x, Vec ce, void *ctx)
Mat _gradient_e
Equality constraint gradient.
Mat _gradient_i
Inequality constraint gradient.
Vec _ce
Equality constraint vector.
static PetscErrorCode inequalityGradientFunctionWrapper(Tao tao, Vec x, Mat gradient_i, Mat gradient_ipre, void *ctx)
static PetscErrorCode equalityGradientFunctionWrapper(Tao tao, Vec x, Mat gradient_e, Mat gradient_epre, void *ctx)
static PetscErrorCode inequalityFunctionWrapper(Tao tao, Vec x, Vec ci, void *ctx)
Tao _tao
Tao optimization object.
Vec _ci
Inequality constraint vector.

Referenced by taoSolve().

◆ taoALDestroy()

PetscErrorCode OptimizeSolve::taoALDestroy ( )
private

Used for destroying petsc structures when using the ALMM algorithm.

Definition at line 599 of file OptimizeSolve.C.

600{
603 {
604 LibmeshPetscCallQ(VecDestroy(&_ce));
605 LibmeshPetscCallQ(MatDestroy(&_gradient_e));
606 }
608 {
609 LibmeshPetscCallQ(VecDestroy(&_ci));
610 LibmeshPetscCallQ(MatDestroy(&_gradient_i));
611 }
612
613 PetscFunctionReturn(PETSC_SUCCESS);
614}

Referenced by taoSolve().

◆ taoSolve()

PetscErrorCode OptimizeSolve::taoSolve ( )
private

Here is where we call tao and solve.

Definition at line 84 of file OptimizeSolve.C.

85{
87 // Initialize tao object
88 LibmeshPetscCallQ(TaoCreate(_my_comm.get(), &_tao));
89
90#if PETSC_RELEASE_LESS_THAN(3, 21, 0)
91 LibmeshPetscCallQ(TaoSetMonitor(_tao, monitor, this, nullptr));
92#else
93 LibmeshPetscCallQ(TaoMonitorSet(_tao, monitor, this, nullptr));
94#endif
95
96 switch (_tao_solver_enum)
97 {
99 LibmeshPetscCallQ(TaoSetType(_tao, TAONTR));
100 break;
102 LibmeshPetscCallQ(TaoSetType(_tao, TAOBNTR));
103 break;
105 LibmeshPetscCallQ(TaoSetType(_tao, TAOBNCG));
106 break;
108 LibmeshPetscCallQ(TaoSetType(_tao, TAONLS));
109 break;
111 LibmeshPetscCallQ(TaoSetType(_tao, TAOBNLS));
112 break;
114 LibmeshPetscCallQ(TaoSetType(_tao, TAOBQNKTR));
115 break;
117 LibmeshPetscCallQ(TaoSetType(_tao, TAONTL));
118 break;
120 LibmeshPetscCallQ(TaoSetType(_tao, TAOBNTL));
121 break;
123 LibmeshPetscCallQ(TaoSetType(_tao, TAONM));
124 break;
125
127 LibmeshPetscCallQ(TaoSetType(_tao, TAOBQNLS));
128 break;
130 LibmeshPetscCallQ(TaoSetType(_tao, TAOOWLQN));
131 break;
133 LibmeshPetscCallQ(TaoSetType(_tao, TAOGPCG));
134 break;
136 LibmeshPetscCallQ(TaoSetType(_tao, TAOBMRM));
137 break;
139#if !PETSC_VERSION_LESS_THAN(3, 15, 0)
140 LibmeshPetscCallQ(TaoSetType(_tao, TAOALMM));
141 // Need to cancel monitors for ALMM, if not there is a segfault at MOOSE destruction. Setup
142 // default constraint monitor.
143#if PETSC_RELEASE_GREATER_EQUALS(3, 21, 0)
144 LibmeshPetscCallQ(TaoMonitorCancel(_tao));
145#else
146 LibmeshPetscCallQ(TaoCancelMonitors(_tao));
147#endif
148 LibmeshPetscCallQ(PetscOptionsSetValue(NULL, "-tao_cmonitor", NULL));
149 break;
150#else
151 mooseError("ALMM is only compatible with PETSc versions above 3.14. ");
152#endif
153
154 default:
155 mooseError("Invalid Tao solve type");
156 }
157
158 // Set objective and gradient functions
159#if !PETSC_VERSION_LESS_THAN(3, 17, 0)
160 LibmeshPetscCallQ(TaoSetObjective(_tao, objectiveFunctionWrapper, this));
161#else
162 LibmeshPetscCallQ(TaoSetObjectiveRoutine(_tao, objectiveFunctionWrapper, this));
163#endif
164#if !PETSC_VERSION_LESS_THAN(3, 17, 0)
166 TaoSetObjectiveAndGradient(_tao, NULL, objectiveAndGradientFunctionWrapper, this));
167#else
169 TaoSetObjectiveAndGradientRoutine(_tao, objectiveAndGradientFunctionWrapper, this));
170#endif
171
172 // Set matrix-free version of the Hessian function
173 LibmeshPetscCallQ(MatCreateShell(_my_comm.get(), _ndof, _ndof, _ndof, _ndof, this, &_hessian));
174 // Link matrix-free Hessian to Tao
175#if !PETSC_VERSION_LESS_THAN(3, 17, 0)
177#else
178 LibmeshPetscCallQ(TaoSetHessianRoutine(_tao, _hessian, _hessian, hessianFunctionWrapper, this));
179#endif
180
181 // Set initial guess
182#if !PETSC_VERSION_LESS_THAN(3, 17, 0)
183 LibmeshPetscCallQ(TaoSetSolution(_tao, _parameters->vec()));
184#else
185 LibmeshPetscCallQ(TaoSetInitialVector(_tao, _parameters->vec()));
186#endif
187
188 // Set TAO petsc options
189 LibmeshPetscCallQ(TaoSetFromOptions(_tao));
190
191 // save nonTAO PETSC options to reset before every call to execute()
193 // We only use a single system solve at this point
195
196 // Set bounds for bounded optimization
197 LibmeshPetscCallQ(TaoSetVariableBoundsRoutine(_tao, variableBoundsWrapper, this));
198
201
202 // Backup multiapps so transient problems start with the same initial condition
206
207 // Solve optimization
208 LibmeshPetscCallQ(TaoSolve(_tao));
209
210 // Print solve statistics
211 if (getParam<bool>("verbose"))
212 LibmeshPetscCallQ(TaoView(_tao, PETSC_VIEWER_STDOUT_WORLD));
213
214 LibmeshPetscCallQ(TaoDestroy(&_tao));
215
216 LibmeshPetscCallQ(MatDestroy(&_hessian));
217
220
221 PetscFunctionReturn(PETSC_SUCCESS);
222}
SolverParams & solverParams(unsigned int solver_sys_num=0)
void backupMultiApps(ExecFlagType type)
Moose::PetscSupport::PetscOptions & getPetscOptions()
static PetscErrorCode objectiveFunctionWrapper(Tao tao, Vec x, Real *objective, void *ctx)
static PetscErrorCode monitor(Tao tao, void *ctx)
static PetscErrorCode variableBoundsWrapper(Tao, Vec xl, Vec xu, void *ctx)
Mat _hessian
Hessian (matrix) - usually a matrix-free representation.
PetscErrorCode taoALCreate()
Used for creating petsc structures when using the ALMM algorithm.
static PetscErrorCode hessianFunctionWrapper(Tao tao, Vec x, Mat hessian, Mat pc, void *ctx)
static PetscErrorCode objectiveAndGradientFunctionWrapper(Tao tao, Vec x, Real *objective, Vec gradient, void *ctx)
PetscErrorCode taoALDestroy()
Used for destroying petsc structures when using the ALMM algorithm.

Referenced by solve().

◆ validParams()

InputParameters OptimizeSolve::validParams ( )
static

Definition at line 18 of file OptimizeSolve.C.

19{
21 MooseEnum tao_solver_enum("taontr taobntr taobncg taonls taobnls taobqnktr taontl taobntl "
22 "taonm taobqnls taoowlqn taogpcg taobmrm taoalmm");
24 "tao_solver", tao_solver_enum, "Tao solver to use for optimization.");
25 ExecFlagEnum exec_enum = ExecFlagEnum();
26 exec_enum.addAvailableFlags(EXEC_NONE,
33 params.addParam<ExecFlagEnum>(
34 "solve_on", exec_enum, "List of flags indicating when inner system solve should occur.");
35 params.addParam<bool>(
36 "output_optimization_iterations",
37 false,
38 "Use the time step as the current iteration for outputting optimization history.");
39 return params;
40}
InputParameters emptyInputParameters()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)

Referenced by Optimize::validParams().

◆ variableBounds()

PetscErrorCode OptimizeSolve::variableBounds ( Tao  tao)
protectedvirtual

Bounds routine.

Definition at line 465 of file OptimizeSolve.C.

466{
468 unsigned int sz = _obj_function->getNumParams();
469
472
473 // copy values from upper and lower bounds to xl and xu
474 for (const auto i : make_range(sz))
475 {
476 xl.set(i, _obj_function->getLowerBound(i));
477 xu.set(i, _obj_function->getUpperBound(i));
478 }
479 // set upper and lower bounds in tao solver
480 LibmeshPetscCallQ(TaoSetVariableBounds(tao, xl.vec(), xu.vec()));
481 PetscFunctionReturn(PETSC_SUCCESS);
482}
Real getLowerBound(dof_id_type i) const
Real getUpperBound(dof_id_type i) const
Upper and lower bounds for each parameter being controlled.
virtual dof_id_type getNumParams() const
Function to get the total number of parameters.

◆ variableBoundsWrapper()

PetscErrorCode OptimizeSolve::variableBoundsWrapper ( Tao  tao,
Vec  xl,
Vec  xu,
void *  ctx 
)
staticprivate

Definition at line 376 of file OptimizeSolve.C.

377{
379 auto * solver = static_cast<OptimizeSolve *>(ctx);
380
381 LibmeshPetscCallQ(solver->variableBounds(tao));
382 PetscFunctionReturn(PETSC_SUCCESS);
383}

Referenced by taoSolve().

Member Data Documentation

◆ _ce

Vec OptimizeSolve::_ce
private

Equality constraint vector.

Definition at line 181 of file OptimizeSolve.h.

Referenced by taoALCreate(), and taoALDestroy().

◆ _ci

Vec OptimizeSolve::_ci
private

Inequality constraint vector.

Definition at line 184 of file OptimizeSolve.h.

Referenced by taoALCreate(), and taoALDestroy().

◆ _cnorm_vec

std::vector<double> OptimizeSolve::_cnorm_vec
private

infeasibility norm per iteration

Definition at line 117 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _f_vec

std::vector<double> OptimizeSolve::_f_vec
private

objective value per iteration

Definition at line 113 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _function_solve_vec

std::vector<int> OptimizeSolve::_function_solve_vec
private

total solves per iteration

Definition at line 111 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _gnorm_vec

std::vector<double> OptimizeSolve::_gnorm_vec
private

gradient norm per iteration

Definition at line 115 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _grad_iterate

int OptimizeSolve::_grad_iterate = 0
private

Definition at line 99 of file OptimizeSolve.h.

Referenced by gradientFunction(), and setTaoSolutionStatus().

◆ _grad_iterate_vec

std::vector<int> OptimizeSolve::_grad_iterate_vec
private

gradient solves per iteration

Definition at line 107 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _gradient_e

Mat OptimizeSolve::_gradient_e
private

Equality constraint gradient.

Definition at line 187 of file OptimizeSolve.h.

Referenced by taoALCreate(), and taoALDestroy().

◆ _gradient_i

Mat OptimizeSolve::_gradient_i
private

Inequality constraint gradient.

Definition at line 190 of file OptimizeSolve.h.

Referenced by taoALCreate(), and taoALDestroy().

◆ _hess_iterate

int OptimizeSolve::_hess_iterate = 0
private

Definition at line 100 of file OptimizeSolve.h.

Referenced by applyHessian(), and setTaoSolutionStatus().

◆ _hess_iterate_vec

std::vector<int> OptimizeSolve::_hess_iterate_vec
private

Hessian solves per iteration.

Definition at line 109 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _hessian

Mat OptimizeSolve::_hessian
private

Hessian (matrix) - usually a matrix-free representation.

Definition at line 178 of file OptimizeSolve.h.

Referenced by taoSolve().

◆ _my_comm

const libMesh::Parallel::Communicator OptimizeSolve::_my_comm
protected

Communicator used for operations.

Definition at line 75 of file OptimizeSolve.h.

Referenced by taoALCreate(), taoSolve(), and variableBounds().

◆ _ndof

dof_id_type OptimizeSolve::_ndof
private

Number of parameters being optimized.

Definition at line 172 of file OptimizeSolve.h.

Referenced by solve(), taoALCreate(), and taoSolve().

◆ _obj_function

OptimizationReporterBase* OptimizeSolve::_obj_function = nullptr
protected

objective function defining objective, gradient, and hessian

Definition at line 81 of file OptimizeSolve.h.

Referenced by applyHessian(), getObjFunction(), getOptimizationReporter(), gradientFunction(), objectiveFunction(), solve(), taoALCreate(), taoALDestroy(), and variableBounds().

◆ _obj_iterate

int OptimizeSolve::_obj_iterate = 0
private

count individual solves for output

Definition at line 98 of file OptimizeSolve.h.

Referenced by objectiveFunction(), and setTaoSolutionStatus().

◆ _obj_iterate_vec

std::vector<int> OptimizeSolve::_obj_iterate_vec
private

number of objective solves per iteration

Definition at line 105 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _output_opt_iters

bool OptimizeSolve::_output_opt_iters
private

Use time step as the iteration counter for purposes of outputting.

Definition at line 94 of file OptimizeSolve.h.

Referenced by OptimizeSolve(), setTaoSolutionStatus(), and solve().

◆ _parameters

std::unique_ptr<libMesh::PetscVector<Number> > OptimizeSolve::_parameters
private

Parameters (solution) given to TAO.

Definition at line 175 of file OptimizeSolve.h.

Referenced by gradientFunction(), objectiveFunction(), solve(), and taoSolve().

◆ _petsc_options

Moose::PetscSupport::PetscOptions OptimizeSolve::_petsc_options
private

These are needed to reset the petsc options for the optimization solve using Moose::PetscSupport::petscSetOptions This only sets the finite difference options, the other optimizeSolve options are set-up in TAO using TaoSetFromOptions()

Definition at line 126 of file OptimizeSolve.h.

Referenced by applyHessian(), gradientFunction(), objectiveFunction(), and taoSolve().

◆ _solve_on

const ExecFlagEnum& OptimizeSolve::_solve_on
protected

List of execute flags for when to solve the system.

Definition at line 78 of file OptimizeSolve.h.

Referenced by applyHessian(), gradientFunction(), and objectiveFunction().

◆ _solver_params

SolverParams OptimizeSolve::_solver_params
private

Definition at line 127 of file OptimizeSolve.h.

Referenced by applyHessian(), gradientFunction(), objectiveFunction(), and taoSolve().

◆ _tao

Tao OptimizeSolve::_tao
protected

Tao optimization object.

Definition at line 87 of file OptimizeSolve.h.

Referenced by taoALCreate(), and taoSolve().

◆ _tao_solver_enum

enum OptimizeSolve::TaoSolverEnum OptimizeSolve::_tao_solver_enum
private

Referenced by taoSolve().

◆ _total_iterate_vec

std::vector<int> OptimizeSolve::_total_iterate_vec
private

total solves per iteration

Definition at line 103 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().

◆ _verbose

bool OptimizeSolve::_verbose
private

control optimization executioner output

Definition at line 91 of file OptimizeSolve.h.

Referenced by setTaoSolutionStatus().

◆ _xdiff_vec

std::vector<double> OptimizeSolve::_xdiff_vec
private

step length per iteration

Definition at line 119 of file OptimizeSolve.h.

Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().


The documentation for this class was generated from the following files: