Pipal  1.2.0
Penalty Interior-Point ALgorithm
Loading...
Searching...
No Matches
Pipal::ProblemWrapper< Real > Class Template Reference

Wrapper class for the Problem class. More...

#include <Problem.hxx>

Inherits Pipal::Problem< Real >.

Public Types

using ObjectiveFunc = std::function<bool(Vector<Real> const &, Real &)>
using ConstraintsFunc = std::function<bool(Vector<Real> const &, Vector<Real> &)>
using ObjectiveGradientFunc = std::function<bool(Vector<Real> const &, Vector<Real> &)>
using ConstraintsJacobianFunc = std::function<bool(Vector<Real> const &, SparseMatrix<Real> &)>
using LagrangianHessianFunc = std::function<bool(Vector<Real> const &, Vector<Real> const &, SparseMatrix<Real> &)>
using BoundsFunc = std::function<bool(Vector<Real> &)>
Public Types inherited from Pipal::Problem< Real >
using UniquePtr = std::unique_ptr<Problem>

Public Member Functions

 ProblemWrapper (std::string const &t_name, ObjectiveFunc const &t_objective, ObjectiveGradientFunc const &t_objective_gradient, ConstraintsFunc const &t_constraints, ConstraintsJacobianFunc const &t_constraints_jacobian, LagrangianHessianFunc const &t_lagrangian_hessian, BoundsFunc const &t_primal_lower_bounds, BoundsFunc const &t_primal_upper_bounds, BoundsFunc const &t_constraints_lower_bounds, BoundsFunc const &t_constraints_upper_bounds)
 Constructor for the ProblemWrapper class (without the Hessian of the Lagrangian).
 ~ProblemWrapper () override
 Default destructor for the ProblemWrapper class.
ObjectiveFuncobjective ()
 Get the objective function.
void objective (ObjectiveFunc const &objective)
 Set the objective function.
ObjectiveGradientFuncobjective_gradient ()
 Get the gradient of the objective function.
void objective_gradient (ObjectiveGradientFunc const &objective_gradient)
 Set the gradient of the objective function.
ConstraintsFuncconstraints ()
 Get the constraints function.
void constraints (ConstraintsFunc const &constraints)
 Set the constraints function.
ConstraintsJacobianFuncconstraints_jacobian ()
 Get the Jacobian of the constraints function.
void constraints_jacobian (ConstraintsJacobianFunc const &constraints_jacobian)
 Set the Jacobian of the constraints function.
BoundsFuncprimal_lower_bounds ()
 Get the lower bounds on the primal variables function.
void primal_lower_bounds (BoundsFunc const &primal_lower_bounds)
 Set the lower bounds on the primal variables function.
BoundsFuncprimal_upper_bounds ()
 Get the upper bounds on the primal variables function.
void primal_upper_bounds (BoundsFunc const &primal_upper_bounds)
 Set the upper bounds on the primal variables function.
BoundsFuncconstraints_lower_bounds ()
 Get the lower bounds on the constraints function.
void constraints_lower_bounds (BoundsFunc const &constraints_lower_bounds)
 Set the lower bounds on the constraints function.
BoundsFuncconstraints_upper_bounds ()
 Get the upper bounds on the constraints function.
void constraints_upper_bounds (BoundsFunc const &constraints_upper_bounds)
 Set the upper bounds on the constraints function.
LagrangianHessianFunclagrangian_hessian ()
 Get the Hessian of the Lagrangian function.
void lagrangian_hessian (LagrangianHessianFunc const &lagrangian_hessian)
 Set the Hessian of the Lagrangian function.
bool objective (Vector< Real > const &x, Real &out) const override
 Evaluate the objective function.
bool objective_gradient (Vector< Real > const &x, Vector< Real > &out) const override
 Evaluate the gradient of the objective function.
bool constraints (Vector< Real > const &x, Vector< Real > &out) const override
 Evaluate the constraints function.
bool constraints_jacobian (Vector< Real > const &x, SparseMatrix< Real > &out) const override
 Evaluate the Jacobian of the constraints function.
bool lagrangian_hessian (Vector< Real > const &x, Vector< Real > const &l, SparseMatrix< Real > &out) const override
 Evaluate the Hessian of the Lagrangian function.
bool primal_lower_bounds (Vector< Real > &out) const override
 Lower bounds on the primal variables.
bool primal_upper_bounds (Vector< Real > &out) const override
 Upper bounds on the primal variables.
bool constraints_lower_bounds (Vector< Real > &out) const override
 Lower bounds on the constraints.
bool constraints_upper_bounds (Vector< Real > &out) const override
 Upper bounds on the constraints.
Public Member Functions inherited from Pipal::Problem< Real >
 Problem ()=default
 Default constructor.
 Problem (std::string t_name)
 Problem constructor.
 Problem (Problem const &)=delete
 Deleted copy constructor.
Problemoperator= (Problem const &)=delete
 Deleted assignment operator.
 Problem (Problem &&)=delete
 Deleted move constructor.
Problemoperator= (Problem &&)=delete
 Deleted move assignment operator.
virtual ~Problem ()=default
 Default destructor.
std::string const & name () const
 Get the name of the optimization problem.
void name (std::string const &t_name)
 Set the name of the optimization problem.

Private Attributes

ObjectiveFunc m_objective {nullptr}
ObjectiveGradientFunc m_objective_gradient {nullptr}
ConstraintsFunc m_constraints {nullptr}
ConstraintsJacobianFunc m_constraints_jacobian {nullptr}
LagrangianHessianFunc m_lagrangian_hessian {nullptr}
BoundsFunc m_primal_lower_bounds {nullptr}
BoundsFunc m_primal_upper_bounds {nullptr}
BoundsFunc m_constraints_lower_bounds {nullptr}
BoundsFunc m_constraints_upper_bounds {nullptr}

Detailed Description

template<typename Real>
class Pipal::ProblemWrapper< Real >

The ProblemWrapper class is a simple wrapper around the Problem class. It inherits from the Problem class and can be used to define optimization problems through function handles.

Template Parameters
RealThe real number type.

Member Typedef Documentation

◆ BoundsFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::BoundsFunc = std::function<bool(Vector<Real> &)>

◆ ConstraintsFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::ConstraintsFunc = std::function<bool(Vector<Real> const &, Vector<Real> &)>

◆ ConstraintsJacobianFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::ConstraintsJacobianFunc = std::function<bool(Vector<Real> const &, SparseMatrix<Real> &)>

◆ LagrangianHessianFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::LagrangianHessianFunc = std::function<bool(Vector<Real> const &, Vector<Real> const &, SparseMatrix<Real> &)>

◆ ObjectiveFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::ObjectiveFunc = std::function<bool(Vector<Real> const &, Real &)>

◆ ObjectiveGradientFunc

template<typename Real>
using Pipal::ProblemWrapper< Real >::ObjectiveGradientFunc = std::function<bool(Vector<Real> const &, Vector<Real> &)>

Constructor & Destructor Documentation

◆ ProblemWrapper()

template<typename Real>
Pipal::ProblemWrapper< Real >::ProblemWrapper ( std::string const & t_name,
ObjectiveFunc const & t_objective,
ObjectiveGradientFunc const & t_objective_gradient,
ConstraintsFunc const & t_constraints,
ConstraintsJacobianFunc const & t_constraints_jacobian,
LagrangianHessianFunc const & t_lagrangian_hessian,
BoundsFunc const & t_primal_lower_bounds,
BoundsFunc const & t_primal_upper_bounds,
BoundsFunc const & t_constraints_lower_bounds,
BoundsFunc const & t_constraints_upper_bounds )
inline

Initializes the problem with the provided objective, gradient, constraints, and Jacobian functions.

Parameters
[in]t_nameName of the optimization problem.
[in]t_objectiveObjective function handle.
[in]t_objective_gradientGradient of the objective function handle.
[in]t_constraintsConstraints function handle.
[in]t_constraints_jacobianJacobian of the constraints function handle.
[in]t_lagrangian_hessianHessian of the Lagrangian function handle.
[in]t_primal_lower_boundsLower bounds on the primal variables function handle.
[in]t_primal_upper_boundsUpper bounds on the primal variables function handle.
[in]t_constraints_lower_boundsLower bounds on the constraints function handle.
[in]t_constraints_upper_boundsUpper bounds on the constraints function handle.

◆ ~ProblemWrapper()

template<typename Real>
Pipal::ProblemWrapper< Real >::~ProblemWrapper ( )
inlineoverride

Member Function Documentation

◆ constraints() [1/3]

template<typename Real>
ConstraintsFunc & Pipal::ProblemWrapper< Real >::constraints ( )
inline
Returns
The constraints function.

◆ constraints() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::constraints ( ConstraintsFunc const & constraints)
inline
Parameters
[in]constraintsThe constraints function to set.

◆ constraints() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::constraints ( Vector< Real > const & x,
Vector< Real > & out ) const
inlineoverridevirtual
Parameters
[in]xPrimal variables.
[out]outThe value of the constraints function.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ constraints_jacobian() [1/3]

template<typename Real>
ConstraintsJacobianFunc & Pipal::ProblemWrapper< Real >::constraints_jacobian ( )
inline
Returns
The Jacobian of the constraints function.

◆ constraints_jacobian() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::constraints_jacobian ( ConstraintsJacobianFunc const & constraints_jacobian)
inline
Parameters
[in]constraints_jacobianThe Jacobian of the constraints function to set.

◆ constraints_jacobian() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::constraints_jacobian ( Vector< Real > const & x,
SparseMatrix< Real > & out ) const
inlineoverridevirtual
Parameters
[in]xPrimal variables.
[out]outThe Jacobian matrix of the constraints function.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ constraints_lower_bounds() [1/3]

template<typename Real>
BoundsFunc & Pipal::ProblemWrapper< Real >::constraints_lower_bounds ( )
inline
Returns
The lower bounds on the constraints function.

◆ constraints_lower_bounds() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::constraints_lower_bounds ( BoundsFunc const & constraints_lower_bounds)
inline
Parameters
[in]constraints_lower_boundsThe lower bounds on the constraints function to set.

◆ constraints_lower_bounds() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::constraints_lower_bounds ( Vector< Real > & out) const
inlineoverridevirtual
Parameters
[out]outThe lower bounds on the constraints.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ constraints_upper_bounds() [1/3]

template<typename Real>
BoundsFunc & Pipal::ProblemWrapper< Real >::constraints_upper_bounds ( )
inline
Returns
The upper bounds on the constraints function.

◆ constraints_upper_bounds() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::constraints_upper_bounds ( BoundsFunc const & constraints_upper_bounds)
inline
Parameters
[in]constraints_upper_boundsThe upper bounds on the constraints function to set.

◆ constraints_upper_bounds() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::constraints_upper_bounds ( Vector< Real > & out) const
inlineoverridevirtual
Parameters
[out]outThe upper bounds on the constraints.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ lagrangian_hessian() [1/3]

template<typename Real>
LagrangianHessianFunc & Pipal::ProblemWrapper< Real >::lagrangian_hessian ( )
inline
Returns
The Hessian of the Lagrangian function.

◆ lagrangian_hessian() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::lagrangian_hessian ( LagrangianHessianFunc const & lagrangian_hessian)
inline
Parameters
[in]lagrangian_hessianThe Hessian of the Lagrangian function to set.

◆ lagrangian_hessian() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::lagrangian_hessian ( Vector< Real > const & x,
Vector< Real > const & l,
SparseMatrix< Real > & out ) const
inlineoverridevirtual
Parameters
[in]xPrimal variables.
[in]lDual variables.
[out]outThe Hessian matrix of the Lagrangian function.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ objective() [1/3]

template<typename Real>
ObjectiveFunc & Pipal::ProblemWrapper< Real >::objective ( )
inline
Returns
The objective function.

◆ objective() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::objective ( ObjectiveFunc const & objective)
inline
Parameters
[in]objectiveThe objective function to set.

◆ objective() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::objective ( Vector< Real > const & x,
Real & out ) const
inlineoverridevirtual
Parameters
[in]xPrimal variables.
[out]outThe objective function.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ objective_gradient() [1/3]

template<typename Real>
ObjectiveGradientFunc & Pipal::ProblemWrapper< Real >::objective_gradient ( )
inline
Returns
The gradient of the objective function.

◆ objective_gradient() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::objective_gradient ( ObjectiveGradientFunc const & objective_gradient)
inline
Parameters
[in]objective_gradientThe gradient of the objective function to set.

◆ objective_gradient() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::objective_gradient ( Vector< Real > const & x,
Vector< Real > & out ) const
inlineoverridevirtual
Parameters
[in]xPrimal variables.
[out]outThe gradient of the objective function.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ primal_lower_bounds() [1/3]

template<typename Real>
BoundsFunc & Pipal::ProblemWrapper< Real >::primal_lower_bounds ( )
inline
Returns
The lower bounds on the primal variables function.

◆ primal_lower_bounds() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::primal_lower_bounds ( BoundsFunc const & primal_lower_bounds)
inline
Parameters
[in]primal_lower_boundsThe lower bounds on the primal variables function to set.

◆ primal_lower_bounds() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::primal_lower_bounds ( Vector< Real > & out) const
inlineoverridevirtual
Parameters
[out]outThe lower bounds on the primal variables.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

◆ primal_upper_bounds() [1/3]

template<typename Real>
BoundsFunc & Pipal::ProblemWrapper< Real >::primal_upper_bounds ( )
inline
Returns
The upper bounds on the primal variables function.

◆ primal_upper_bounds() [2/3]

template<typename Real>
void Pipal::ProblemWrapper< Real >::primal_upper_bounds ( BoundsFunc const & primal_upper_bounds)
inline
Parameters
[in]primal_upper_boundsThe upper bounds on the primal variables function to set.

◆ primal_upper_bounds() [3/3]

template<typename Real>
bool Pipal::ProblemWrapper< Real >::primal_upper_bounds ( Vector< Real > & out) const
inlineoverridevirtual
Parameters
[out]outThe upper bounds on the primal variables.
Returns
True if the evaluation was successful, false otherwise.

Implements Pipal::Problem< Real >.

Member Data Documentation

◆ m_constraints

template<typename Real>
ConstraintsFunc Pipal::ProblemWrapper< Real >::m_constraints {nullptr}
private

Constraints function.

◆ m_constraints_jacobian

template<typename Real>
ConstraintsJacobianFunc Pipal::ProblemWrapper< Real >::m_constraints_jacobian {nullptr}
private

Jacobian of the constraints.

◆ m_constraints_lower_bounds

template<typename Real>
BoundsFunc Pipal::ProblemWrapper< Real >::m_constraints_lower_bounds {nullptr}
private

Lower bounds on the constraints.

◆ m_constraints_upper_bounds

template<typename Real>
BoundsFunc Pipal::ProblemWrapper< Real >::m_constraints_upper_bounds {nullptr}
private

Upper bounds on the constraints.

◆ m_lagrangian_hessian

template<typename Real>
LagrangianHessianFunc Pipal::ProblemWrapper< Real >::m_lagrangian_hessian {nullptr}
private

Hessian of the Lagrangian.

◆ m_objective

template<typename Real>
ObjectiveFunc Pipal::ProblemWrapper< Real >::m_objective {nullptr}
private

Objective function.

◆ m_objective_gradient

template<typename Real>
ObjectiveGradientFunc Pipal::ProblemWrapper< Real >::m_objective_gradient {nullptr}
private

Gradient of the objective function.

◆ m_primal_lower_bounds

template<typename Real>
BoundsFunc Pipal::ProblemWrapper< Real >::m_primal_lower_bounds {nullptr}
private

Lower bounds on the primal variables.

◆ m_primal_upper_bounds

template<typename Real>
BoundsFunc Pipal::ProblemWrapper< Real >::m_primal_upper_bounds {nullptr}
private

Upper bounds on the primal variables.


The documentation for this class was generated from the following file: