Ipopt  3.12.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Private Attributes | List of all members
Ipopt::TNLPReducer Class Reference

This is a wrapper around a given TNLP class that takes out a list of constraints that are given to the constructor. More...

#include <IpTNLPReducer.hpp>

+ Inheritance diagram for Ipopt::TNLPReducer:

Public Member Functions

Constructors/Destructors
 TNLPReducer (TNLP &tnlp, Index n_g_skip, const Index *index_g_skip, Index n_xL_skip, const Index *index_xL_skip, Index n_xU_skip, const Index *index_xU_skip, Index n_x_fix, const Index *index_f_fix)
 Constructor is given the indices of the constraints that should be taken out of the problem statement, as well as the original TNLP. More...
 
virtual ~TNLPReducer ()
 Default destructor. More...
 
Overloaded methods from TNLP
virtual bool get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
 
virtual bool get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
 overload this method to return the information about the bound on the variables and constraints. More...
 
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)
 overload this method to return scaling parameters. More...
 
virtual bool get_variables_linearity (Index n, LinearityType *var_types)
 overload this method to return the variables linearity (TNLP::LINEAR or TNLP::NON_LINEAR). More...
 
virtual bool get_constraints_linearity (Index m, LinearityType *const_types)
 overload this method to return the constraint linearity. More...
 
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)
 overload this method to return the starting point. More...
 
virtual bool get_warm_start_iterate (IteratesVector &warm_start_iterate)
 overload this method to provide an Ipopt iterate (already in the form Ipopt requires it internally) for a warm start. More...
 
virtual bool eval_f (Index n, const Number *x, bool new_x, Number &obj_value)
 overload this method to return the value of the objective function More...
 
virtual bool eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f)
 overload this method to return the vector of the gradient of the objective w.r.t. More...
 
virtual bool eval_g (Index n, const Number *x, bool new_x, Index m, Number *g)
 overload this method to return the vector of constraint values More...
 
virtual bool eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
 overload this method to return the jacobian of the constraints. More...
 
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)
 overload this method to return the hessian of the lagrangian. More...
 
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)
 This method is called when the algorithm is complete so the TNLP can store/write the solution. More...
 
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)
 Intermediate Callback method for the user. More...
 
virtual Index get_number_of_nonlinear_variables ()
 
virtual bool get_list_of_nonlinear_variables (Index num_nonlin_vars, Index *pos_nonlin_vars)
 
- Public Member Functions inherited from Ipopt::TNLP
 DECLARE_STD_EXCEPTION (INVALID_TNLP)
 
 TNLP ()
 
virtual ~TNLP ()
 Default destructor. More...
 
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)
 This method is called just before finalize_solution. More...
 
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)
 overload this method to return any meta data for the variables and the constraints More...
 
- 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
 

Private Member Functions

Default Compiler Generated Methods

(Hidden to avoid implicit creation/calling).

These methods are not implemented and we do not want the compiler to implement them for us, so we declare them private and do not define them. This ensures that they will not be implicitly created/called.

 TNLPReducer ()
 Default Constructor. More...
 
 TNLPReducer (const TNLPReducer &)
 Copy Constructor. More...
 
void operator= (const TNLPReducer &)
 Overloaded Equals Operator. More...
 

Private Attributes

Index n_g_skip_
 Number of constraints to be skipped. More...
 
Indexindex_g_skip_
 Array of indices of the constraints that are to be skipped. More...
 
IndexStyleEnum index_style_orig_
 Index style for original problem. More...
 
Indexg_keep_map_
 Map from original constraints to new constraints. More...
 
Index m_reduced_
 Number of constraints in reduced NLP. More...
 
Index nnz_jac_g_reduced_
 Number of Jacobian nonzeros in the reduced NLP. More...
 
Index nnz_jac_g_skipped_
 Number of Jacobian nonzeros that are skipped. More...
 
Indexjac_g_skipped_
 Array of Jacobian elements that are to be skipped. More...
 
Index n_xL_skip_
 Number of lower variable bounds to be skipped. More...
 
Indexindex_xL_skip_
 Array of indices of the lower variable bounds to be skipped. More...
 
Index n_xU_skip_
 Number of upper variable bounds to be skipped. More...
 
Indexindex_xU_skip_
 Array of indices of the upper variable bounds to be skipped. More...
 
Index n_x_fix_
 Number of variables that are to be fixed to initial value. More...
 
Indexindex_x_fix_
 Array of indices of the variables that are to be fixed. More...
 
original TNLP
SmartPtr< TNLPtnlp_
 
Index m_orig_
 
Index nnz_jac_g_orig_
 

Additional Inherited Members

- Public Types inherited from Ipopt::TNLP
enum  LinearityType { LINEAR, NON_LINEAR }
 Type of the constraints. More...
 
enum  IndexStyleEnum { C_STYLE =0, FORTRAN_STYLE =1 }
 overload this method to return the number of variables and constraints, and the number of non-zeros in the jacobian and the hessian. More...
 
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
 

Detailed Description

This is a wrapper around a given TNLP class that takes out a list of constraints that are given to the constructor.

It is provided for convenience, if one wants to experiment with problems that consist of only a subset of the constraints. But keep in mind that this is not efficient, since behind the scenes we are still evaluation all functions and derivatives, and are making copies of the original data.

Definition at line 23 of file IpTNLPReducer.hpp.

Constructor & Destructor Documentation

Ipopt::TNLPReducer::TNLPReducer ( TNLP tnlp,
Index  n_g_skip,
const Index index_g_skip,
Index  n_xL_skip,
const Index index_xL_skip,
Index  n_xU_skip,
const Index index_xU_skip,
Index  n_x_fix,
const Index index_f_fix 
)

Constructor is given the indices of the constraints that should be taken out of the problem statement, as well as the original TNLP.

virtual Ipopt::TNLPReducer::~TNLPReducer ( )
virtual

Default destructor.

Ipopt::TNLPReducer::TNLPReducer ( )
private

Default Constructor.

Ipopt::TNLPReducer::TNLPReducer ( const TNLPReducer )
private

Copy Constructor.

Member Function Documentation

virtual bool Ipopt::TNLPReducer::get_nlp_info ( Index n,
Index m,
Index nnz_jac_g,
Index nnz_h_lag,
IndexStyleEnum index_style 
)
virtual

Implements Ipopt::TNLP.

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

overload this method to 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.

virtual bool Ipopt::TNLPReducer::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

overload this method to return scaling parameters.

This is only called if the options are set to retrieve user scaling. There, use_x_scaling (or use_g_scaling) should get set to true only if the variables (or constraints) are to be scaled. This method should return true only if the scaling parameters could be provided.

Reimplemented from Ipopt::TNLP.

virtual bool Ipopt::TNLPReducer::get_variables_linearity ( Index  n,
LinearityType var_types 
)
virtual

overload this method to return the variables linearity (TNLP::LINEAR or TNLP::NON_LINEAR).

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

Reimplemented from Ipopt::TNLP.

virtual bool Ipopt::TNLPReducer::get_constraints_linearity ( Index  m,
LinearityType const_types 
)
virtual

overload this method to return the constraint linearity.

array has been allocated with length at least n. (default implementation just return false and does not fill the array).

Reimplemented from Ipopt::TNLP.

virtual bool Ipopt::TNLPReducer::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 
)
virtual

overload this method to 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.

virtual bool Ipopt::TNLPReducer::get_warm_start_iterate ( IteratesVector warm_start_iterate)
virtual

overload this method to provide an Ipopt iterate (already in the form Ipopt requires it internally) for a warm start.

Since this is only for expert users, a default dummy implementation is provided and returns false.

Reimplemented from Ipopt::TNLP.

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

overload this method to return the value of the objective function

Implements Ipopt::TNLP.

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

overload this method to return the vector of the gradient of the objective w.r.t.

x

Implements Ipopt::TNLP.

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

overload this method to return the vector of constraint values

Implements Ipopt::TNLP.

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

overload this method to 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.

virtual bool Ipopt::TNLPReducer::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

overload this method to 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.

virtual void Ipopt::TNLPReducer::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 
)
virtual

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

Implements Ipopt::TNLP.

virtual bool Ipopt::TNLPReducer::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 
)
virtual

Intermediate Callback method for the user.

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

Reimplemented from Ipopt::TNLP.

virtual Index Ipopt::TNLPReducer::get_number_of_nonlinear_variables ( )
virtual

Reimplemented from Ipopt::TNLP.

virtual bool Ipopt::TNLPReducer::get_list_of_nonlinear_variables ( Index  num_nonlin_vars,
Index pos_nonlin_vars 
)
virtual

Reimplemented from Ipopt::TNLP.

void Ipopt::TNLPReducer::operator= ( const TNLPReducer )
private

Overloaded Equals Operator.

Member Data Documentation

SmartPtr<TNLP> Ipopt::TNLPReducer::tnlp_
private

Definition at line 126 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::m_orig_
private

Definition at line 127 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::nnz_jac_g_orig_
private

Definition at line 128 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::n_g_skip_
private

Number of constraints to be skipped.

Definition at line 132 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::index_g_skip_
private

Array of indices of the constraints that are to be skipped.

This is provided at the beginning in the constructor.

Definition at line 136 of file IpTNLPReducer.hpp.

IndexStyleEnum Ipopt::TNLPReducer::index_style_orig_
private

Index style for original problem.

Internally, we use C-Style now.

Definition at line 140 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::g_keep_map_
private

Map from original constraints to new constraints.

A -1 means that a constraint is skipped.

Definition at line 144 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::m_reduced_
private

Number of constraints in reduced NLP.

Definition at line 147 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::nnz_jac_g_reduced_
private

Number of Jacobian nonzeros in the reduced NLP.

Definition at line 150 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::nnz_jac_g_skipped_
private

Number of Jacobian nonzeros that are skipped.

Definition at line 153 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::jac_g_skipped_
private

Array of Jacobian elements that are to be skipped.

This is in increasing order.

Definition at line 157 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::n_xL_skip_
private

Number of lower variable bounds to be skipped.

Definition at line 160 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::index_xL_skip_
private

Array of indices of the lower variable bounds to be skipped.

Definition at line 163 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::n_xU_skip_
private

Number of upper variable bounds to be skipped.

Definition at line 166 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::index_xU_skip_
private

Array of indices of the upper variable bounds to be skipped.

Definition at line 169 of file IpTNLPReducer.hpp.

Index Ipopt::TNLPReducer::n_x_fix_
private

Number of variables that are to be fixed to initial value.

Definition at line 172 of file IpTNLPReducer.hpp.

Index* Ipopt::TNLPReducer::index_x_fix_
private

Array of indices of the variables that are to be fixed.

Definition at line 175 of file IpTNLPReducer.hpp.


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