Couenne 0.5.8
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Couenne::CouenneTNLP Class Reference

Class for handling NLPs using CouenneProblem. More...

#include <CouenneTNLP.hpp>

+ Inheritance diagram for Couenne::CouenneTNLP:
+ Collaboration diagram for Couenne::CouenneTNLP:

Public Member Functions

 CouenneTNLP ()
 Empty constructor. More...
 
 CouenneTNLP (CouenneProblem *)
 Constructor. More...
 
 CouenneTNLP (const CouenneTNLP &)
 Copy constructor. More...
 
CouenneTNLPoperator= (const CouenneTNLP &rhs)
 Assignment. More...
 
CouenneTNLPclone ()
 Clone. More...
 
virtual ~CouenneTNLP ()
 Destructor. More...
 
void setInitSol (const double *sol)
 set initial solution More...
 
CouNumbergetSolution ()
 returns best solution (if it exists) More...
 
CouNumber getSolValue ()
 returns value of the best solution More...
 
virtual bool get_nlp_info (Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, enum Ipopt::TNLP::IndexStyleEnum &index_style)
 return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian. More...
 
virtual bool get_bounds_info (Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
 return the information about the bound on the variables and constraints. More...
 
virtual bool get_variables_linearity (Ipopt::Index n, Ipopt::TNLP::LinearityType *var_types)
 return the variables linearity (TNLP::Linear or TNLP::NonLinear). More...
 
virtual bool get_constraints_linearity (Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
 return the constraint linearity. More...
 
virtual bool get_starting_point (Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
 return the starting point. More...
 
virtual bool eval_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
 return the value of the objective function More...
 
virtual bool eval_grad_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
 return the vector of the gradient of the objective w.r.t. x More...
 
virtual bool eval_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
 return the vector of constraint values More...
 
virtual bool eval_jac_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
 return the jacobian of the constraints. More...
 
virtual bool eval_h (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
 return the hessian of the lagrangian. More...
 
virtual void finalize_solution (Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
 This method is called when the algorithm is complete so the TNLP can store/write the solution. More...
 
virtual bool intermediate_callback (Ipopt::AlgorithmMode mode, Ipopt::Index iter, Ipopt::Number obj_value, Ipopt::Number inf_pr, Ipopt::Number inf_du, Ipopt::Number mu, Ipopt::Number d_norm, Ipopt::Number regularization_size, Ipopt::Number alpha_du, Ipopt::Number alpha_pr, Ipopt::Index ls_trials, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
 Intermediate Callback method for the user. More...
 
- Public Member Functions inherited from Ipopt::TNLP
 DECLARE_STD_EXCEPTION (INVALID_TNLP)
 
 TNLP ()
 
virtual ~TNLP ()
 
virtual bool get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)=0
 
virtual bool get_var_con_metadata (Index n, StringMetaDataMapType &var_string_md, IntegerMetaDataMapType &var_integer_md, NumericMetaDataMapType &var_numeric_md, Index m, StringMetaDataMapType &con_string_md, IntegerMetaDataMapType &con_integer_md, NumericMetaDataMapType &con_numeric_md)
 
virtual bool get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)=0
 
virtual bool get_scaling_parameters (Number &obj_scaling, bool &use_x_scaling, Index n, Number *x_scaling, bool &use_g_scaling, Index m, Number *g_scaling)
 
virtual bool get_variables_linearity (Index n, LinearityType *var_types)
 
virtual bool get_constraints_linearity (Index m, LinearityType *const_types)
 
virtual bool get_starting_point (Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)=0
 
virtual bool get_warm_start_iterate (IteratesVector &warm_start_iterate)
 
virtual bool eval_f (Index n, const Number *x, bool new_x, Number &obj_value)=0
 
virtual bool eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f)=0
 
virtual bool eval_g (Index n, const Number *x, bool new_x, Index m, Number *g)=0
 
virtual bool eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)=0
 
virtual bool eval_h (Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
 
virtual Index get_number_of_nonlinear_variables ()
 
virtual bool get_list_of_nonlinear_variables (Index num_nonlin_vars, Index *pos_nonlin_vars)
 
virtual void finalize_solution (SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)=0
 
virtual void finalize_metadata (Index n, const StringMetaDataMapType &var_string_md, const IntegerMetaDataMapType &var_integer_md, const NumericMetaDataMapType &var_numeric_md, Index m, const StringMetaDataMapType &con_string_md, const IntegerMetaDataMapType &con_integer_md, const NumericMetaDataMapType &con_numeric_md)
 
virtual bool intermediate_callback (AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
 
bool get_curr_iterate (const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq, bool scaled, Index n, Number *x, Number *z_L, Number *z_U, Index m, Number *g, Number *lambda) const
 
bool get_curr_violations (const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq, bool scaled, Index n, Number *x_L_violation, Number *x_U_violation, Number *compl_x_L, Number *compl_x_U, Number *grad_lag_x, Index m, Number *nlp_constraint_violation, Number *compl_g) const
 
 TNLP ()
 
virtual ~TNLP ()
 
virtual bool get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)=0
 
virtual bool get_var_con_metadata (Index n, StringMetaDataMapType &var_string_md, IntegerMetaDataMapType &var_integer_md, NumericMetaDataMapType &var_numeric_md, Index m, StringMetaDataMapType &con_string_md, IntegerMetaDataMapType &con_integer_md, NumericMetaDataMapType &con_numeric_md)
 
virtual bool get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)=0
 
virtual bool get_scaling_parameters (Number &obj_scaling, bool &use_x_scaling, Index n, Number *x_scaling, bool &use_g_scaling, Index m, Number *g_scaling)
 
virtual bool get_variables_linearity (Index n, LinearityType *var_types)
 
virtual bool get_constraints_linearity (Index m, LinearityType *const_types)
 
virtual bool get_starting_point (Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)=0
 
virtual bool get_warm_start_iterate (IteratesVector &warm_start_iterate)
 
virtual bool eval_f (Index n, const Number *x, bool new_x, Number &obj_value)=0
 
virtual bool eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f)=0
 
virtual bool eval_g (Index n, const Number *x, bool new_x, Index m, Number *g)=0
 
virtual bool eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)=0
 
virtual bool eval_h (Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
 
virtual Index get_number_of_nonlinear_variables ()
 
virtual bool get_list_of_nonlinear_variables (Index num_nonlin_vars, Index *pos_nonlin_vars)
 
virtual void finalize_solution (SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)=0
 
virtual void finalize_metadata (Index n, const StringMetaDataMapType &var_string_md, const IntegerMetaDataMapType &var_integer_md, const NumericMetaDataMapType &var_numeric_md, Index m, const StringMetaDataMapType &con_string_md, const IntegerMetaDataMapType &con_integer_md, const NumericMetaDataMapType &con_numeric_md)
 
virtual bool intermediate_callback (AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
 
bool get_curr_iterate (const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq, bool scaled, Index n, Number *x, Number *z_L, Number *z_U, Index m, Number *g, Number *lambda) const
 
bool get_curr_violations (const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq, bool scaled, Index n, Number *x_L_violation, Number *x_U_violation, Number *compl_x_L, Number *compl_x_U, Number *grad_lag_x, Index m, Number *nlp_constraint_violation, Number *compl_g) const
 
- Public Member Functions inherited from Ipopt::ReferencedObject
 ReferencedObject ()
 
virtual ~ReferencedObject ()
 
Index ReferenceCount () const
 
void AddRef (const Referencer *referencer) const
 
void ReleaseRef (const Referencer *referencer) const
 

Methods for quasi-Newton approximation. If the second

derivatives are approximated by Ipopt, it is better to do this only in the space of nonlinear variables.

The following methods are call by Ipopt if the quasi-Newton approximation is selected. If -1 is returned as number of nonlinear variables, Ipopt assumes that all variables are nonlinear. Otherwise, it calls get_list_of_nonlinear_variables with an array into which the indices of the nonlinear variables should be written - the array has the lengths num_nonlin_vars, which is identical with the return value of get_number_of_nonlinear_variables (). It is assumed that the indices are counted starting with 1 in the FORTRAN_STYLE, and 0 for the C_STYLE.

virtual Ipopt::Index get_number_of_nonlinear_variables ()
 
virtual bool get_list_of_nonlinear_variables (Ipopt::Index num_nonlin_vars, Ipopt::Index *pos_nonlin_vars)
 get real list More...
 
virtual void setObjective (expression *newObj)
 Change objective function and modify gradient expressions accordingly. More...
 
CouenneSparseMatrix *& optHessian ()
 Get methods. More...
 
bool & getSaveOptHessian ()
 set and get saveOptHessian_ More...
 

Additional Inherited Members

- Public Types inherited from Ipopt::TNLP
enum  LinearityType
 
enum  IndexStyleEnum
 
typedef std::map< std::string, std::vector< std::string > > StringMetaDataMapType
 
typedef std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
 
typedef std::map< std::string, std::vector< Number > > NumericMetaDataMapType
 
- Public Attributes inherited from Ipopt::TNLP
 LINEAR
 
 NON_LINEAR
 
 C_STYLE
 
 FORTRAN_STYLE
 

Detailed Description

Class for handling NLPs using CouenneProblem.

Definition at line 27 of file CouenneTNLP.hpp.

Constructor & Destructor Documentation

◆ CouenneTNLP() [1/3]

Couenne::CouenneTNLP::CouenneTNLP ( )

Empty constructor.

◆ CouenneTNLP() [2/3]

Couenne::CouenneTNLP::CouenneTNLP ( CouenneProblem )

Constructor.

◆ CouenneTNLP() [3/3]

Couenne::CouenneTNLP::CouenneTNLP ( const CouenneTNLP )

Copy constructor.

◆ ~CouenneTNLP()

virtual Couenne::CouenneTNLP::~CouenneTNLP ( )
virtual

Destructor.

Member Function Documentation

◆ operator=()

CouenneTNLP & Couenne::CouenneTNLP::operator= ( const CouenneTNLP rhs)

Assignment.

◆ clone()

CouenneTNLP * Couenne::CouenneTNLP::clone ( )

Clone.

◆ setInitSol()

void Couenne::CouenneTNLP::setInitSol ( const double *  sol)

set initial solution

◆ getSolution()

CouNumber * Couenne::CouenneTNLP::getSolution ( )
inline

returns best solution (if it exists)

Definition at line 53 of file CouenneTNLP.hpp.

◆ getSolValue()

CouNumber Couenne::CouenneTNLP::getSolValue ( )
inline

returns value of the best solution

Definition at line 57 of file CouenneTNLP.hpp.

◆ get_nlp_info()

virtual bool Couenne::CouenneTNLP::get_nlp_info ( Ipopt::Index n,
Ipopt::Index m,
Ipopt::Index nnz_jac_g,
Ipopt::Index nnz_h_lag,
enum Ipopt::TNLP::IndexStyleEnum index_style 
)
virtual

return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian.

The index_style parameter lets you specify C or Fortran style indexing for the sparse matrix iRow and jCol parameters. C_STYLE is 0-based, and FORTRAN_STYLE is 1-based.

Implements Ipopt::TNLP.

◆ get_bounds_info()

virtual bool Couenne::CouenneTNLP::get_bounds_info ( Ipopt::Index  n,
Ipopt::Number x_l,
Ipopt::Number x_u,
Ipopt::Index  m,
Ipopt::Number g_l,
Ipopt::Number g_u 
)
virtual

return the information about the bound on the variables and constraints.

The value that indicates that a bound does not exist is specified in the parameters nlp_lower_bound_inf and nlp_upper_bound_inf. By default, nlp_lower_bound_inf is -1e19 and nlp_upper_bound_inf is 1e19. (see TNLPAdapter)

Implements Ipopt::TNLP.

◆ get_variables_linearity()

virtual bool Couenne::CouenneTNLP::get_variables_linearity ( Ipopt::Index  n,
Ipopt::TNLP::LinearityType var_types 
)
virtual

return the variables linearity (TNLP::Linear or TNLP::NonLinear).

The var_types array should be allocated with length at least n. (default implementation just return false and does not fill the array).

Reimplemented from Ipopt::TNLP.

◆ get_constraints_linearity()

virtual bool Couenne::CouenneTNLP::get_constraints_linearity ( Ipopt::Index  m,
Ipopt::TNLP::LinearityType const_types 
)
virtual

return the constraint linearity.

array should be alocated with length at least n. (default implementation just return false and does not fill the array).

Reimplemented from Ipopt::TNLP.

◆ get_starting_point()

virtual bool Couenne::CouenneTNLP::get_starting_point ( Ipopt::Index  n,
bool  init_x,
Ipopt::Number x,
bool  init_z,
Ipopt::Number z_L,
Ipopt::Number z_U,
Ipopt::Index  m,
bool  init_lambda,
Ipopt::Number lambda 
)
virtual

return the starting point.

The bool variables indicate whether the algorithm wants you to initialize x, z_L/z_u, and lambda, respectively. If, for some reason, the algorithm wants you to initialize these and you cannot, return false, which will cause Ipopt to stop. You will have to run Ipopt with different options then.

Implements Ipopt::TNLP.

◆ eval_f()

virtual bool Couenne::CouenneTNLP::eval_f ( Ipopt::Index  n,
const Ipopt::Number x,
bool  new_x,
Ipopt::Number obj_value 
)
virtual

return the value of the objective function

Implements Ipopt::TNLP.

◆ eval_grad_f()

virtual bool Couenne::CouenneTNLP::eval_grad_f ( Ipopt::Index  n,
const Ipopt::Number x,
bool  new_x,
Ipopt::Number grad_f 
)
virtual

return the vector of the gradient of the objective w.r.t. x

Implements Ipopt::TNLP.

◆ eval_g()

virtual bool Couenne::CouenneTNLP::eval_g ( Ipopt::Index  n,
const Ipopt::Number x,
bool  new_x,
Ipopt::Index  m,
Ipopt::Number g 
)
virtual

return the vector of constraint values

Implements Ipopt::TNLP.

◆ eval_jac_g()

virtual bool Couenne::CouenneTNLP::eval_jac_g ( Ipopt::Index  n,
const Ipopt::Number x,
bool  new_x,
Ipopt::Index  m,
Ipopt::Index  nele_jac,
Ipopt::Index iRow,
Ipopt::Index jCol,
Ipopt::Number values 
)
virtual

return the jacobian of the constraints.

The vectors iRow and jCol only need to be set once. The first call is used to set the structure only (iRow and jCol will be non-NULL, and values will be NULL) For subsequent calls, iRow and jCol will be NULL.

Implements Ipopt::TNLP.

◆ eval_h()

virtual bool Couenne::CouenneTNLP::eval_h ( Ipopt::Index  n,
const Ipopt::Number x,
bool  new_x,
Ipopt::Number  obj_factor,
Ipopt::Index  m,
const Ipopt::Number lambda,
bool  new_lambda,
Ipopt::Index  nele_hess,
Ipopt::Index iRow,
Ipopt::Index jCol,
Ipopt::Number values 
)
virtual

return the hessian of the lagrangian.

The vectors iRow and jCol only need to be set once (during the first call). The first call is used to set the structure only (iRow and jCol will be non-NULL, and values will be NULL) For subsequent calls, iRow and jCol will be NULL. This matrix is symmetric - specify the lower diagonal only. A default implementation is provided, in case the user wants to se quasi-Newton approximations to estimate the second derivatives and doesn't not neet to implement this method.

Reimplemented from Ipopt::TNLP.

◆ finalize_solution()

virtual void Couenne::CouenneTNLP::finalize_solution ( Ipopt::SolverReturn  status,
Ipopt::Index  n,
const Ipopt::Number x,
const Ipopt::Number z_L,
const Ipopt::Number z_U,
Ipopt::Index  m,
const Ipopt::Number g,
const Ipopt::Number lambda,
Ipopt::Number  obj_value,
const Ipopt::IpoptData ip_data,
Ipopt::IpoptCalculatedQuantities ip_cq 
)
virtual

This method is called when the algorithm is complete so the TNLP can store/write the solution.

Implements Ipopt::TNLP.

◆ intermediate_callback()

virtual bool Couenne::CouenneTNLP::intermediate_callback ( Ipopt::AlgorithmMode  mode,
Ipopt::Index  iter,
Ipopt::Number  obj_value,
Ipopt::Number  inf_pr,
Ipopt::Number  inf_du,
Ipopt::Number  mu,
Ipopt::Number  d_norm,
Ipopt::Number  regularization_size,
Ipopt::Number  alpha_du,
Ipopt::Number  alpha_pr,
Ipopt::Index  ls_trials,
const Ipopt::IpoptData ip_data,
Ipopt::IpoptCalculatedQuantities ip_cq 
)
virtual

Intermediate Callback method for the user.

Providing dummy default implementation. For details see IntermediateCallBack in IpNLP.hpp.

◆ get_number_of_nonlinear_variables()

virtual Ipopt::Index Couenne::CouenneTNLP::get_number_of_nonlinear_variables ( )
virtual

Reimplemented from Ipopt::TNLP.

◆ get_list_of_nonlinear_variables()

virtual bool Couenne::CouenneTNLP::get_list_of_nonlinear_variables ( Ipopt::Index  num_nonlin_vars,
Ipopt::Index pos_nonlin_vars 
)
virtual

get real list

Reimplemented from Ipopt::TNLP.

◆ setObjective()

virtual void Couenne::CouenneTNLP::setObjective ( expression newObj)
virtual

Change objective function and modify gradient expressions accordingly.

◆ optHessian()

CouenneSparseMatrix *& Couenne::CouenneTNLP::optHessian ( )
inline

Get methods.

Definition at line 182 of file CouenneTNLP.hpp.

◆ getSaveOptHessian()

bool & Couenne::CouenneTNLP::getSaveOptHessian ( )
inline

set and get saveOptHessian_

Definition at line 186 of file CouenneTNLP.hpp.


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