optimization_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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
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 
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 
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 () override;
227 
231  virtual void init_data () override;
232 
237  virtual void reinit () override;
238 
242  virtual void solve () 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 override { return "Optimization"; }
264 
268  std::unique_ptr<OptimizationSolver<Number>> optimization_solver;
269 
273  std::unique_ptr<NumericVector<Number>> C_eq;
274 
278  std::unique_ptr<SparseMatrix<Number>> C_eq_jac;
279 
283  std::unique_ptr<NumericVector<Number>> C_ineq;
284 
288  std::unique_ptr<SparseMatrix<Number>> C_ineq_jac;
289 
294  std::unique_ptr<NumericVector<Number>> lambda_eq;
295  std::unique_ptr<NumericVector<Number>> lambda_ineq;
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
Manages multiples systems of equations.
void initialize_inequality_constraints_storage(const std::vector< std::set< numeric_index_type >> &constraint_jac_sparsity)
virtual void gradient(const NumericVector< Number > &X, NumericVector< Number > &grad_f, sys_type &S)=0
std::unique_ptr< NumericVector< Number > > lambda_ineq
virtual void hessian(const NumericVector< Number > &X, SparseMatrix< Number > &H_f, sys_type &S)=0
virtual void solve() override
virtual void init_data() override
virtual void inequality_constraints_jacobian(const NumericVector< Number > &X, SparseMatrix< Number > &C_ineq_jac, sys_type &S)=0
std::unique_ptr< NumericVector< Number > > C_eq
std::unique_ptr< SparseMatrix< Number > > C_ineq_jac
virtual std::string system_type() const override
unsigned int number() const
Definition: system.h:2025
virtual void reinit() override
std::vector< std::set< numeric_index_type > > ineq_constraint_jac_sparsity
std::vector< std::set< numeric_index_type > > eq_constraint_jac_sparsity
std::unique_ptr< SparseMatrix< Number > > C_eq_jac
virtual void equality_constraints(const NumericVector< Number > &X, NumericVector< Number > &C_eq, sys_type &S)=0
std::unique_ptr< OptimizationSolver< Number > > optimization_solver
std::unique_ptr< NumericVector< Number > > lambda_eq
virtual Number objective(const NumericVector< Number > &X, sys_type &S)=0
virtual void equality_constraints_jacobian(const NumericVector< Number > &X, SparseMatrix< Number > &C_eq_jac, sys_type &S)=0
void initialize_equality_constraints_storage(const std::vector< std::set< numeric_index_type >> &constraint_jac_sparsity)
virtual void clear() override
const std::string & name() const
Definition: system.h:2017
OptimizationSystem(EquationSystems &es, const std::string &name, const unsigned int number)
virtual void inequality_constraints(const NumericVector< Number > &X, NumericVector< Number > &C_ineq, sys_type &S)=0
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...
std::unique_ptr< NumericVector< Number > > C_ineq
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...