libMesh
optimization_solver.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_OPTIMIZATION_SOLVER_H
21 #define LIBMESH_OPTIMIZATION_SOLVER_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/enum_solver_package.h"
26 #include "libmesh/reference_counted_object.h"
27 #include "libmesh/libmesh.h"
28 #include "libmesh/parallel_object.h"
29 #include "libmesh/auto_ptr.h"
30 #include "libmesh/optimization_system.h"
31 
32 // C++ includes
33 #include <cstddef>
34 
35 namespace libMesh
36 {
37 
38 // forward declarations
39 template <typename T> class SparseMatrix;
40 template <typename T> class NumericVector;
41 template <typename T> class Preconditioner;
42 
51 template <typename T>
52 class OptimizationSolver : public ReferenceCountedObject<OptimizationSolver<T>>,
53  public ParallelObject
54 {
55 public:
60 
64  explicit
65  OptimizationSolver (sys_type & s);
66 
70  virtual ~OptimizationSolver ();
71 
76  static UniquePtr<OptimizationSolver<T>> build(sys_type & s,
77  const SolverPackage solver_package = libMesh::default_solver_package());
78 
83  bool initialized () const { return _is_initialized; }
84 
88  virtual void clear () {}
89 
93  virtual void init () = 0;
94 
98  virtual void solve () = 0;
99 
105  virtual void get_dual_variables()
106  { libmesh_not_implemented(); }
107 
112  virtual void print_converged_reason() { libmesh_not_implemented(); }
113 
123  virtual int get_converged_reason() { return 0; }
124 
130 
136 
142 
148 
153 
159 
164 
169 
174  const sys_type & system () const { return _system; }
175 
180  sys_type & system () { return _system; }
181 
186 
191 
195  bool verbose;
196 
197 protected:
198 
202  sys_type & _system;
203 
208 
209 };
210 
211 } // namespace libMesh
212 
213 
214 #endif // LIBMESH_OPTIMIZATION_SOLVER_H
Abstract base class to be used to calculate the inequality constraints.
OptimizationSystem::ComputeObjective * objective_object
Object that computes the objective function f(X) at the input iterate X.
virtual ~OptimizationSolver()
Destructor.
virtual void clear()
Release all memory and clear data structures.
virtual void print_converged_reason()
Prints a useful message about why the latest optimization solve con(di)verged.
Abstract base class to be used to calculate the objective function for optimization.
Real objective_function_relative_tolerance
Required change in objective function which signals convergence.
static UniquePtr< OptimizationSolver< T > > build(sys_type &s, const SolverPackage solver_package=libMesh::default_solver_package())
Builds an OptimizationSolver using the package specified by solver_package.
SolverPackage
Defines an enum for various linear solver packages.
OptimizationSystem::ComputeGradient * gradient_object
Object that computes the gradient grad_f(X) of the objective function at the input iterate X...
The libMesh namespace provides an interface to certain functionality in the library.
bool _is_initialized
Flag indicating if the data structures have been initialized.
const sys_type & system() const
sys_type & _system
A reference to the system we are solving.
OptimizationSystem::ComputeHessian * hessian_object
Object that computes the Hessian H_f(X) of the objective function at the input iterate X...
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual void solve()=0
Solves the optimization problem.
OptimizationSystem::ComputeInequalityConstraints * inequality_constraints_object
Object that computes the inequality constraints vector C_ineq(X).
SolverPackage default_solver_package()
Definition: libmesh.C:995
virtual void get_dual_variables()
Get the current values of dual variables associated with inequality and equality constraints.
OptimizationSystem::ComputeEqualityConstraintsJacobian * equality_constraints_jacobian_object
Object that computes the Jacobian of C_eq(X).
Abstract base class to be used to calculate the equality constraints.
This System subclass enables us to assemble an objective function, gradient, Hessian and bounds for o...
unsigned int max_objective_function_evaluations
Maximum number of objective function evaluations allowed.
This class implements reference counting.
This class forms the base class for all other classes that are expected to be implemented in parallel...
OptimizationSolver(sys_type &s)
Constructor.
Abstract base class to be used to calculate the gradient of an objective function.
Abstract base class to be used to calculate the Jacobian of the equality constraints.
virtual void init()=0
Initialize data structures if not done so already.
OptimizationSystem::ComputeLowerAndUpperBounds * lower_and_upper_bounds_object
Object that computes the lower and upper bounds vectors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool verbose
Control how much is output from the OptimizationSolver as it&#39;s running.
This base class can be inherited from to provide interfaces to optimization solvers from different pa...
Abstract base class to be used to calculate the Hessian of an objective function. ...
Abstract base class to be used to calculate the lower and upper bounds for all dofs in the system...
OptimizationSystem::ComputeInequalityConstraintsJacobian * inequality_constraints_jacobian_object
Object that computes the Jacobian of C_ineq(X).
OptimizationSystem::ComputeEqualityConstraints * equality_constraints_object
Object that computes the equality constraints vector C_eq(X).
OptimizationSystem sys_type
The type of system.
Abstract base class to be used to calculate the Jacobian of the inequality constraints.