|
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
|
An interface for solving an optimization problem with TAO where the problem itself is defined by a separate Problem class. More...
#include <TaoUtil.hh>
Public Member Functions | |
| TaoBasicSolver (MPI_Comm comm, const std::string &tao_type, Problem &prob) | |
Construct a solver to solve prob using TAO algorithm tao_type. | |
| virtual | ~TaoBasicSolver () |
| virtual std::shared_ptr< TerminationReason > | solve () |
| Solve the minimization problem. | |
| virtual void | setMaximumIterations (int max_it) |
| virtual Problem & | problem () |
Protected Attributes | |
| MPI_Comm | m_comm |
| petsc::Tao | m_tao |
| Problem & | m_problem |
An interface for solving an optimization problem with TAO where the problem itself is defined by a separate Problem class.
The primary interface to a TAO optimization problem is mediated by a PETSc-style TaoSolver object. The PISM TaoBasicSolver C++ class wraps a TaoSolver and some of its initialization boilierplate, and allows a separate class to define the function to be minimized.
To use a TaoBasicSolver you create a Problem class that defines the objective function and initial guess, as well any auxilliary callbacks desired. The Problem class must define a
method which gives the Problem an opportunity to register its methods as callbacks to the solver, perhaps taking advantage of the various TaoFooCallback classes provided in TaoUtil.hh to facilitate this. For example, a problem class MyProblem that did nothing more than register a combined objective/gradient callback could define
In addition to the connect method, a Problem must define
which allows the problem to set the initial guess for optimization. If the minimization is successful, the solution will be found in the same vector that was returned by this method.
Assuming a MyProblem called problem has been constructed, solution of the minimization is done using, for example, the TAO algorithm tao_cg:
Definition at line 92 of file TaoUtil.hh.