libMesh
optimization_system.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_SYSTEM_H
21 #define LIBMESH_OPTIMIZATION_SYSTEM_H
22 
23 // Local Includes
24 #include "libmesh/implicit_system.h"
25 
26 // C++ includes
27 
28 namespace libMesh
29 {
30 
31 
32 // Forward declarations
33 template<typename T> class OptimizationSolver;
34 
35 
44 {
45 public:
46 
52  const std::string & name,
53  const unsigned int number);
54 
58  virtual ~OptimizationSystem ();
59 
64 
69 
75  {
76  public:
77  virtual ~ComputeObjective () {}
78 
86  virtual Number objective (const NumericVector<Number> & X,
87  sys_type & S) = 0;
88  };
89 
90 
96  {
97  public:
98  virtual ~ComputeGradient () {}
99 
106  virtual void gradient (const NumericVector<Number> & X,
107  NumericVector<Number> & grad_f,
108  sys_type & S) = 0;
109  };
110 
111 
117  {
118  public:
119  virtual ~ComputeHessian () {}
120 
127  virtual void hessian (const NumericVector<Number> & X,
128  SparseMatrix<Number> & H_f,
129  sys_type & S) = 0;
130  };
131 
136  {
137  public:
139 
144  virtual void equality_constraints (const NumericVector<Number> & X,
146  sys_type & S) = 0;
147  };
148 
154  {
155  public:
157 
161  virtual void equality_constraints_jacobian (const NumericVector<Number> & X,
163  sys_type & S) = 0;
164  };
165 
170  {
171  public:
173 
178  virtual void inequality_constraints (const NumericVector<Number> & X,
180  sys_type & S) = 0;
181  };
182 
188  {
189  public:
191 
195  virtual void inequality_constraints_jacobian (const NumericVector<Number> & X,
197  sys_type & S) = 0;
198  };
199 
205  {
206  public:
208 
214  virtual void lower_and_upper_bounds (sys_type & S) = 0;
215  };
216 
220  sys_type & system () { return *this; }
221 
226  virtual void clear () libmesh_override;
227 
231  virtual void init_data () libmesh_override;
232 
237  virtual void reinit () libmesh_override;
238 
242  virtual void solve () libmesh_override;
243 
251  void initialize_equality_constraints_storage(const std::vector<std::set<numeric_index_type>> & constraint_jac_sparsity);
252 
257  void initialize_inequality_constraints_storage(const std::vector<std::set<numeric_index_type>> & constraint_jac_sparsity);
258 
263  virtual std::string system_type () const libmesh_override { return "Optimization"; }
264 
269 
274 
279 
284 
289 
296 
301  std::vector<std::set<numeric_index_type>> eq_constraint_jac_sparsity;
302  std::vector<std::set<numeric_index_type>> ineq_constraint_jac_sparsity;
303 };
304 
305 } // namespace libMesh
306 
307 #endif // LIBMESH_OPTIMIZATION_SYSTEM_H
Abstract base class to be used to calculate the inequality constraints.
This is the EquationSystems class.
OptimizationSystem sys_type
The type of system.
virtual void reinit() libmesh_override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
void initialize_inequality_constraints_storage(const std::vector< std::set< numeric_index_type >> &constraint_jac_sparsity)
Initialize storage for the inequality constraints, as per initialize_equality_constraints_storage.
Abstract base class to be used to calculate the objective function for optimization.
UniquePtr< NumericVector< Number > > lambda_ineq
virtual std::string system_type() const libmesh_override
ImplicitSystem Parent
The type of the parent.
virtual void solve() libmesh_override
Solves the optimization problem.
UniquePtr< OptimizationSolver< Number > > optimization_solver
The OptimizationSolver that is used for performing the optimization.
The libMesh namespace provides an interface to certain functionality in the library.
virtual void init_data() libmesh_override
Initializes new data members of the system.
UniquePtr< NumericVector< Number > > lambda_eq
Vectors to store the dual variables associated with equality and inequality constraints.
virtual void clear() libmesh_override
Clear all the data structures associated with the system.
const std::string & name() const
Definition: system.h:1998
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
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...
UniquePtr< SparseMatrix< Number > > C_eq_jac
The sparse matrix that stores the Jacobian of C_eq.
std::vector< std::set< numeric_index_type > > ineq_constraint_jac_sparsity
std::vector< std::set< numeric_index_type > > eq_constraint_jac_sparsity
A copy of the equality and inequality constraint Jacobian sparsity patterns.
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 Number objective(const NumericVector< Number > &X, sys_type &S)=0
This function will be called to compute the objective function to be minimized, and must be implement...
void initialize_equality_constraints_storage(const std::vector< std::set< numeric_index_type >> &constraint_jac_sparsity)
Initialize storage for the equality constraints, and the corresponding Jacobian.
virtual ~OptimizationSystem()
Destructor.
unsigned int number() const
Definition: system.h:2006
Abstract base class to be used to calculate the Hessian of an objective function. ...
UniquePtr< NumericVector< Number > > C_eq
The vector that stores equality constraints.
OptimizationSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Abstract base class to be used to calculate the lower and upper bounds for all dofs in the system...
UniquePtr< SparseMatrix< Number > > C_ineq_jac
The sparse matrix that stores the Jacobian of C_ineq.
UniquePtr< NumericVector< Number > > C_ineq
The vector that stores inequality constraints.
This class provides a specific system class.
Abstract base class to be used to calculate the Jacobian of the inequality constraints.