solveObject to interface with Petsc Tao More...
#include <OptimizeSolve.h>
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. More... | |
virtual void | initialSetup () |
virtual void | setInnerSolve (SolveObject &solve) |
virtual bool | enabled () const |
std::shared_ptr< MooseObject > | getSharedPtr () |
std::shared_ptr< const MooseObject > | getSharedPtr () const |
MooseApp & | getMooseApp () const |
const std::string & | type () const |
virtual const std::string & | name () const |
std::string | typeAndName () const |
std::string | errorPrefix (const std::string &error_type) const |
void | callMooseError (std::string msg, const bool with_prefix) const |
MooseObjectParameterName | uniqueParameterName (const std::string ¶meter_name) const |
const InputParameters & | parameters () const |
MooseObjectName | uniqueName () const |
const T & | getParam (const std::string &name) const |
std::vector< std::pair< T1, T2 > > | getParam (const std::string ¶m1, const std::string ¶m2) 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 &nm) const |
void | paramError (const std::string ¶m, Args... args) const |
void | paramWarning (const std::string ¶m, Args... args) const |
void | paramInfo (const std::string ¶m, Args... args) const |
void | connectControllableParams (const std::string ¶meter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const |
void | mooseError (Args &&... args) const |
void | mooseErrorNonPrefixed (Args &&... args) const |
void | mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const |
void | mooseWarning (Args &&... args) const |
void | mooseWarningNonPrefixed (Args &&... args) const |
void | mooseDeprecated (Args &&... args) const |
void | mooseInfo (Args &&... args) const |
std::string | getDataFileName (const std::string ¶m) 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 ¶m_name, const unsigned int index=0) const |
bool | hasPostprocessor (const std::string ¶m_name, const unsigned int index=0) const |
bool | hasPostprocessorByName (const PostprocessorName &name) const |
std::size_t | coupledPostprocessors (const std::string ¶m_name) const |
const PostprocessorName & | getPostprocessorName (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValue (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValue (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValueOld (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValueOld (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValueOlder (const std::string ¶m_name, const unsigned int index=0) const |
const PostprocessorValue & | getPostprocessorValueOlder (const std::string ¶m_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 () |
Public Attributes | |
const ConsoleStream | _console |
Protected Member Functions | |
virtual PetscErrorCode | variableBounds (Tao tao) |
Bounds routine. More... | |
virtual Real | objectiveFunction () |
Objective routine. More... | |
virtual void | gradientFunction (libMesh::PetscVector< Number > &gradient) |
Gradient routine. More... | |
virtual PetscErrorCode | applyHessian (libMesh::PetscVector< Number > &s, libMesh::PetscVector< Number > &Hs) |
Hessian application routine. More... | |
OptimizationReporterBase * | getObjFunction () |
function to get the objective reporter More... | |
PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level) const |
PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const |
std::string | timedSectionName (const std::string §ion_name) const |
virtual void | addPostprocessorDependencyHelper (const PostprocessorName &) const |
Protected Attributes | |
const libMesh::Parallel::Communicator | _my_comm |
Communicator used for operations. More... | |
const ExecFlagEnum & | _solve_on |
List of execute flags for when to solve the system. More... | |
OptimizationReporterBase * | _obj_function = nullptr |
objective function defining objective, gradient, and hessian More... | |
Tao | _tao |
Tao optimization object. More... | |
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 |
const std::string | _type |
const std::string | _name |
const InputParameters & | _pars |
Factory & | _factory |
ActionFactory & | _action_factory |
MooseApp & | _pg_moose_app |
const std::string | _prefix |
const Parallel::Communicator & | _communicator |
Private Member Functions | |
PetscErrorCode | taoSolve () |
Here is where we call tao and solve. More... | |
void | setTaoSolutionStatus (double f, int its, double gnorm, double cnorm, double xdiff) |
output optimization iteration solve data More... | |
PetscErrorCode | taoALCreate () |
Used for creating petsc structures when using the ALMM algorithm. More... | |
PetscErrorCode | taoALDestroy () |
Used for destroying petsc structures when using the ALMM algorithm. More... | |
Static Private Member Functions | |
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 More... | |
bool | _output_opt_iters |
Use time step as the iteration counter for purposes of outputting. More... | |
std::vector< int > | _total_iterate_vec |
total solves per iteration More... | |
std::vector< int > | _obj_iterate_vec |
number of objective solves per iteration More... | |
std::vector< int > | _grad_iterate_vec |
gradient solves per iteration More... | |
std::vector< int > | _hess_iterate_vec |
Hessian solves per iteration. More... | |
std::vector< int > | _function_solve_vec |
total solves per iteration More... | |
std::vector< double > | _f_vec |
objective value per iteration More... | |
std::vector< double > | _gnorm_vec |
gradient norm per iteration More... | |
std::vector< double > | _cnorm_vec |
infeasibility norm per iteration More... | |
std::vector< double > | _xdiff_vec |
step length per iteration More... | |
enum OptimizeSolve::TaoSolverEnum | _tao_solver_enum |
dof_id_type | _ndof |
Number of parameters being optimized. More... | |
std::unique_ptr< libMesh::PetscVector< Number > > | _parameters |
Parameters (solution) given to TAO. More... | |
Mat | _hessian |
Hessian (matrix) - usually a matrix-free representation. More... | |
Vec | _ce |
Equality constraint vector. More... | |
Vec | _ci |
Inequality constraint vector. More... | |
Mat | _gradient_e |
Equality constraint gradient. More... | |
Mat | _gradient_i |
Inequality constraint gradient. More... | |
int | _obj_iterate = 0 |
int | _grad_iterate = 0 |
int | _hess_iterate = 0 |
Moose::PetscSupport::PetscOptions | _petsc_options |
SolverParams | _solver_params |
solveObject to interface with Petsc Tao
Definition at line 28 of file OptimizeSolve.h.
|
strongprivate |
Enum of tao solver types.
Definition at line 154 of file OptimizeSolve.h.
OptimizeSolve::OptimizeSolve | ( | Executioner & | ex | ) |
Definition at line 43 of file OptimizeSolve.C.
|
protectedvirtual |
Hessian application routine.
Definition at line 435 of file OptimizeSolve.C.
|
staticprivate |
Definition at line 370 of file OptimizeSolve.C.
Referenced by hessianFunctionWrapper().
|
staticprivate |
Definition at line 492 of file OptimizeSolve.C.
Referenced by taoALCreate().
|
staticprivate |
Definition at line 505 of file OptimizeSolve.C.
Referenced by taoALCreate().
|
inlineprotected |
function to get the objective reporter
Definition at line 84 of file OptimizeSolve.h.
|
inline |
Definition at line 36 of file OptimizeSolve.h.
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.
tot_iters | total solves per iteration |
gnorm | gradient norm per iteration |
obj_iters | number of objective solves per iteration |
cnorm | infeasibility norm per iteration |
grad_iters | gradient solves per iteration |
xdiff | step length per iteration |
hess_iters | Hessian solves per iteration |
f | objective value per iteration |
tot_solves | total solves per iteration |
Definition at line 233 of file OptimizeSolve.C.
Referenced by OptimizationInfo::execute().
|
protectedvirtual |
Gradient routine.
Definition at line 417 of file OptimizeSolve.C.
|
staticprivate |
Definition at line 358 of file OptimizeSolve.C.
Referenced by taoSolve().
|
staticprivate |
Definition at line 520 of file OptimizeSolve.C.
Referenced by taoALCreate().
|
staticprivate |
Definition at line 533 of file OptimizeSolve.C.
Referenced by taoALCreate().
|
staticprivate |
Definition at line 311 of file OptimizeSolve.C.
Referenced by taoSolve().
|
staticprivate |
Definition at line 341 of file OptimizeSolve.C.
Referenced by taoSolve().
|
protectedvirtual |
Objective routine.
Definition at line 394 of file OptimizeSolve.C.
|
staticprivate |
Function wrappers for tao
Definition at line 327 of file OptimizeSolve.C.
Referenced by taoSolve().
|
private |
output optimization iteration solve data
Definition at line 269 of file OptimizeSolve.C.
Referenced by monitor().
|
overridevirtual |
Implements SolveObject.
Definition at line 61 of file OptimizeSolve.C.
Referenced by Optimize::execute().
|
private |
Used for creating petsc structures when using the ALMM algorithm.
Definition at line 548 of file OptimizeSolve.C.
Referenced by taoSolve().
|
private |
Used for destroying petsc structures when using the ALMM algorithm.
Definition at line 606 of file OptimizeSolve.C.
Referenced by taoSolve().
|
private |
Here is where we call tao and solve.
Definition at line 85 of file OptimizeSolve.C.
Referenced by solve().
|
static |
Definition at line 18 of file OptimizeSolve.C.
Referenced by Optimize::validParams().
|
protectedvirtual |
Bounds routine.
Definition at line 472 of file OptimizeSolve.C.
|
staticprivate |
Definition at line 384 of file OptimizeSolve.C.
Referenced by taoSolve().
|
private |
Equality constraint vector.
Definition at line 183 of file OptimizeSolve.h.
Referenced by taoALCreate(), and taoALDestroy().
|
private |
Inequality constraint vector.
Definition at line 186 of file OptimizeSolve.h.
Referenced by taoALCreate(), and taoALDestroy().
|
private |
infeasibility norm per iteration
Definition at line 117 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
objective value per iteration
Definition at line 113 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
total solves per iteration
Definition at line 111 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
gradient norm per iteration
Definition at line 115 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
Definition at line 99 of file OptimizeSolve.h.
Referenced by gradientFunction(), and setTaoSolutionStatus().
|
private |
gradient solves per iteration
Definition at line 107 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
Equality constraint gradient.
Definition at line 189 of file OptimizeSolve.h.
Referenced by taoALCreate(), and taoALDestroy().
|
private |
Inequality constraint gradient.
Definition at line 192 of file OptimizeSolve.h.
Referenced by taoALCreate(), and taoALDestroy().
|
private |
Definition at line 100 of file OptimizeSolve.h.
Referenced by applyHessian(), and setTaoSolutionStatus().
|
private |
Hessian solves per iteration.
Definition at line 109 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
Hessian (matrix) - usually a matrix-free representation.
Definition at line 180 of file OptimizeSolve.h.
Referenced by taoSolve().
|
protected |
Communicator used for operations.
Definition at line 75 of file OptimizeSolve.h.
Referenced by taoALCreate(), taoSolve(), and variableBounds().
|
private |
Number of parameters being optimized.
Definition at line 174 of file OptimizeSolve.h.
Referenced by solve(), taoALCreate(), and taoSolve().
|
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().
|
private |
count individual solves for output
Definition at line 98 of file OptimizeSolve.h.
Referenced by objectiveFunction(), and setTaoSolutionStatus().
|
private |
number of objective solves per iteration
Definition at line 105 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
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().
|
private |
Parameters (solution) given to TAO.
Definition at line 177 of file OptimizeSolve.h.
Referenced by gradientFunction(), objectiveFunction(), solve(), and taoSolve().
|
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().
|
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().
|
private |
Definition at line 127 of file OptimizeSolve.h.
Referenced by applyHessian(), gradientFunction(), objectiveFunction(), and taoSolve().
|
protected |
Tao optimization object.
Definition at line 87 of file OptimizeSolve.h.
Referenced by taoALCreate(), and taoSolve().
|
private |
Referenced by taoSolve().
|
private |
total solves per iteration
Definition at line 103 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().
|
private |
control optimization executioner output
Definition at line 91 of file OptimizeSolve.h.
Referenced by setTaoSolutionStatus().
|
private |
step length per iteration
Definition at line 119 of file OptimizeSolve.h.
Referenced by getTaoSolutionStatus(), and setTaoSolutionStatus().