libMesh
|
This class encapsulate all functionality required for assembling the objective function, gradient, and hessian. More...
Public Member Functions | |
AssembleOptimization (OptimizationSystem &sys_in) | |
Constructor. More... | |
void | assemble_A_and_F () |
The optimization problem we consider here is: min_U 0.5*U^T A U - U^T F. More... | |
virtual Number | objective (const NumericVector< Number > &soln, OptimizationSystem &) |
Evaluate the objective function. More... | |
virtual void | gradient (const NumericVector< Number > &soln, NumericVector< Number > &grad_f, OptimizationSystem &) |
Evaluate the gradient. More... | |
virtual void | hessian (const NumericVector< Number > &soln, SparseMatrix< Number > &H_f, OptimizationSystem &) |
Evaluate the Hessian. More... | |
AssembleOptimization (OptimizationSystem &sys_in) | |
Constructor. More... | |
void | assemble_A_and_F () |
The optimization problem we consider here is: min_U 0.5*U^T A U - U^T F. More... | |
virtual Number | objective (const NumericVector< Number > &soln, OptimizationSystem &) |
Evaluate the objective function. More... | |
virtual void | gradient (const NumericVector< Number > &soln, NumericVector< Number > &grad_f, OptimizationSystem &) |
Evaluate the gradient. More... | |
virtual void | hessian (const NumericVector< Number > &soln, SparseMatrix< Number > &H_f, OptimizationSystem &) |
Evaluate the Hessian. More... | |
virtual void | equality_constraints (const NumericVector< Number > &X, NumericVector< Number > &C_eq, OptimizationSystem &) |
Evaluate the equality constraints. More... | |
virtual void | equality_constraints_jacobian (const NumericVector< Number > &X, SparseMatrix< Number > &C_eq_jac, OptimizationSystem &) |
Evaluate the equality constraints Jacobian. More... | |
virtual void | inequality_constraints (const NumericVector< Number > &X, NumericVector< Number > &C_ineq, OptimizationSystem &) |
Evaluate the inequality constraints. More... | |
virtual void | inequality_constraints_jacobian (const NumericVector< Number > &X, SparseMatrix< Number > &C_ineq_jac, OptimizationSystem &) |
Evaluate the inequality constraints Jacobian. More... | |
virtual void | lower_and_upper_bounds (OptimizationSystem &sys) |
Evaluate the lower and upper bounds vectors. More... | |
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 implemented by the user in a derived class. More... | |
virtual void | gradient (const NumericVector< Number > &X, NumericVector< Number > &grad_f, sys_type &S)=0 |
This function will be called to compute the gradient of the objective function, and must be implemented by the user in a derived class. More... | |
virtual void | hessian (const NumericVector< Number > &X, SparseMatrix< Number > &H_f, sys_type &S)=0 |
This function will be called to compute the Hessian of the objective function, and must be implemented by the user in a derived class. More... | |
virtual void | equality_constraints (const NumericVector< Number > &X, NumericVector< Number > &C_eq, sys_type &S)=0 |
This function will be called to evaluate the equality constraints vector C_eq(X). More... | |
virtual void | equality_constraints_jacobian (const NumericVector< Number > &X, SparseMatrix< Number > &C_eq_jac, sys_type &S)=0 |
This function will be called to evaluate the Jacobian of C_eq(X). More... | |
virtual void | inequality_constraints (const NumericVector< Number > &X, NumericVector< Number > &C_ineq, sys_type &S)=0 |
This function will be called to evaluate the equality constraints vector C_ineq(X). More... | |
virtual void | inequality_constraints_jacobian (const NumericVector< Number > &X, SparseMatrix< Number > &C_ineq_jac, sys_type &S)=0 |
This function will be called to evaluate the Jacobian of C_ineq(X). More... | |
virtual void | lower_and_upper_bounds (sys_type &S)=0 |
This function should update the following two vectors: this->get_vector("lower_bounds"), this->get_vector("upper_bounds"). More... | |
Public Attributes | |
SparseMatrix< Number > * | A_matrix |
Sparse matrix for storing the matrix A. More... | |
NumericVector< Number > * | F_vector |
Vector for storing F. More... | |
Private Attributes | |
OptimizationSystem & | _sys |
Keep a reference to the OptimizationSystem. More... | |
This class encapsulate all functionality required for assembling the objective function, gradient, and hessian.
This class encapsulate all functionality required for assembling the objective function, gradient, hessian, and constraints.
Definition at line 66 of file optimization_ex1.C.
AssembleOptimization::AssembleOptimization | ( | OptimizationSystem & | sys_in | ) |
Constructor.
Definition at line 126 of file optimization_ex1.C.
AssembleOptimization::AssembleOptimization | ( | OptimizationSystem & | sys_in | ) |
Constructor.
void AssembleOptimization::assemble_A_and_F | ( | ) |
The optimization problem we consider here is: min_U 0.5*U^T A U - U^T F.
In this method, we assemble A and F.
Definition at line 130 of file optimization_ex1.C.
References _sys, A_matrix, libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::DofMap::constrain_element_matrix_and_vector(), libMesh::FEType::default_quadrature_order(), dim, libMesh::DofMap::dof_indices(), F_vector, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofMap::is_constrained_dof(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::System::variable_number(), libMesh::DofMap::variable_type(), libMesh::NumericVector< T >::zero(), and libMesh::SparseMatrix< T >::zero().
Referenced by main().
void AssembleOptimization::assemble_A_and_F | ( | ) |
The optimization problem we consider here is: min_U 0.5*U^T A U - U^T F.
In this method, we assemble A and F.
|
virtual |
Evaluate the equality constraints.
Definition at line 276 of file optimization_ex2.C.
References libMesh::ParallelObject::comm(), libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::init(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::localize(), libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), and libMesh::NumericVector< T >::zero().
|
pure virtualinherited |
This function will be called to evaluate the equality constraints vector C_eq(X).
This will impose the constraints C_eq(X) = 0.
Referenced by libMesh::__libmesh_nlopt_equality_constraints(), and libMesh::__libmesh_tao_equality_constraints().
|
virtual |
Evaluate the equality constraints Jacobian.
Definition at line 298 of file optimization_ex2.C.
References libMesh::OptimizationSystem::C_eq, libMesh::SparseMatrix< T >::set(), value, and libMesh::SparseMatrix< T >::zero().
|
pure virtualinherited |
This function will be called to evaluate the Jacobian of C_eq(X).
Referenced by libMesh::__libmesh_nlopt_equality_constraints(), and libMesh::__libmesh_tao_equality_constraints_jacobian().
|
virtual |
Evaluate the gradient.
Definition at line 216 of file optimization_ex1.C.
References A_matrix, libMesh::NumericVector< T >::add(), F_vector, libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().
|
virtual |
Evaluate the gradient.
|
pure virtualinherited |
This function will be called to compute the gradient of the objective function, and must be implemented by the user in a derived class.
Set grad_f
to be the gradient at the iterate X
.
Referenced by libMesh::__libmesh_nlopt_objective(), and libMesh::__libmesh_tao_gradient().
|
virtual |
Evaluate the Hessian.
|
virtual |
Evaluate the Hessian.
Definition at line 230 of file optimization_ex1.C.
References A_matrix, libMesh::SparseMatrix< T >::add(), and libMesh::SparseMatrix< T >::zero().
|
pure virtualinherited |
This function will be called to compute the Hessian of the objective function, and must be implemented by the user in a derived class.
Set H_f
to be the gradient at the iterate X
.
Referenced by libMesh::__libmesh_tao_hessian().
|
virtual |
Evaluate the inequality constraints.
Definition at line 335 of file optimization_ex2.C.
References libMesh::ParallelObject::comm(), libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::init(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::localize(), libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), and libMesh::NumericVector< T >::zero().
|
pure virtualinherited |
This function will be called to evaluate the equality constraints vector C_ineq(X).
This will impose the constraints C_ineq(X) >= 0.
Referenced by libMesh::__libmesh_nlopt_inequality_constraints(), and libMesh::__libmesh_tao_inequality_constraints().
|
virtual |
Evaluate the inequality constraints Jacobian.
Definition at line 354 of file optimization_ex2.C.
References libMesh::OptimizationSystem::C_ineq, libMesh::ParallelObject::comm(), libMesh::NumericVector< T >::init(), libMesh::NumericVector< T >::localize(), libMesh::SERIAL, libMesh::SparseMatrix< T >::set(), libMesh::NumericVector< T >::size(), value, and libMesh::SparseMatrix< T >::zero().
|
pure virtualinherited |
This function will be called to evaluate the Jacobian of C_ineq(X).
Referenced by libMesh::__libmesh_nlopt_inequality_constraints(), and libMesh::__libmesh_tao_inequality_constraints_jacobian().
|
virtual |
Evaluate the lower and upper bounds vectors.
Definition at line 387 of file optimization_ex2.C.
References libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::System::get_dof_map(), libMesh::System::get_vector(), and libMesh::NumericVector< T >::set().
|
pure virtualinherited |
This function should update the following two vectors: this->get_vector("lower_bounds"), this->get_vector("upper_bounds").
|
pure virtualinherited |
This function will be called to compute the objective function to be minimized, and must be implemented by the user in a derived class.
X
. Referenced by libMesh::__libmesh_nlopt_objective(), and libMesh::__libmesh_tao_objective().
|
virtual |
Evaluate the objective function.
|
virtual |
Evaluate the objective function.
Definition at line 202 of file optimization_ex1.C.
References A_matrix, libMesh::NumericVector< T >::dot(), F_vector, libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero_clone().
|
private |
Keep a reference to the OptimizationSystem.
Definition at line 76 of file optimization_ex1.C.
Referenced by assemble_A_and_F().
SparseMatrix< Number > * AssembleOptimization::A_matrix |
Sparse matrix for storing the matrix A.
We use this to facilitate computation of objective, gradient and hessian.
Definition at line 117 of file optimization_ex1.C.
Referenced by assemble_A_and_F(), gradient(), hessian(), main(), and objective().
NumericVector< Number > * AssembleOptimization::F_vector |
Vector for storing F.
We use this to facilitate computation of objective, gradient and hessian.
Definition at line 123 of file optimization_ex1.C.
Referenced by assemble_A_and_F(), gradient(), main(), and objective().