Ipopt Documentation  
 
Loading...
Searching...
No Matches
Ipopt::StdInterfaceTNLP Class Reference

Implementation of a TNLP for the Standard C interface. More...

#include <IpStdInterfaceTNLP.hpp>

+ Inheritance diagram for Ipopt::StdInterfaceTNLP:

Public Member Functions

bool get_curr_iterate (Bool scaled, Index n, Number *x, Number *z_L, Number *z_U, Index m, Number *g, Number *lambda) const
 get_curr_iterate() to be called by GetIpoptCurrentIterate()
 
bool get_curr_violations (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
 get_curr_violations() to be called by GetIpoptCurrentViolations()
 
Constructors/Destructors
 StdInterfaceTNLP (Index n_var, const Number *x_L, const Number *x_U, Index n_con, const Number *g_L, const Number *g_U, Index nele_jac, Index nele_hess, Index index_style, const Number *start_x, const Number *start_lam, const Number *start_z_L, const Number *start_z_U, Eval_F_CB eval_f, Eval_G_CB eval_g, Eval_Grad_F_CB eval_grad_f, Eval_Jac_G_CB eval_jac_g, Eval_H_CB eval_h, Intermediate_CB intermediate_cb, Number *x_sol, Number *z_L_sol, Number *z_U_sol, Number *g_sol, Number *lam_sol, Number *obj_sol, UserDataPtr user_data, Number obj_scaling=1, const Number *x_scaling=NULL, const Number *g_scaling=NULL)
 Constructor, given dimensions of problem, function pointers for evaluation callback functions, and starting points.
 
virtual ~StdInterfaceTNLP ()
 Default destructor.
 
Methods to gather information about the NLP.

These methods are overloaded from TNLP.

See TNLP for their more detailed documentation.

virtual bool get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
 Method to request the initial information about the problem.
 
virtual bool get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
 Method to request bounds on the variables and constraints.
 
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)
 Method to request scaling parameters.
 
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)
 Method to request the starting point before iterating.
 
virtual bool eval_f (Index n, const Number *x, bool new_x, Number &obj_value)
 Method to request the value of the objective function.
 
virtual bool eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f)
 Method to request the gradient of the objective function.
 
virtual bool eval_g (Index n, const Number *x, bool new_x, Index m, Number *g)
 Method to request the constraint values.
 
virtual bool eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
 Method to request either the sparsity structure or the values of the Jacobian of the constraints.
 
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)
 Method to request either the sparsity structure or the values of the Hessian of the Lagrangian.
 
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.
 
Solution Methods
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 has finished (successfully or not) so the TNLP can digest the outcome, e.g., store/write the solution, if any.
 
- Public Member Functions inherited from Ipopt::TNLP
 DECLARE_STD_EXCEPTION (INVALID_TNLP)
 
 TNLP ()
 
virtual ~TNLP ()
 Default destructor.
 
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)
 Method to request meta data for the variables and the constraints.
 
virtual bool get_variables_linearity (Index n, LinearityType *var_types)
 Method to request the variables linearity.
 
virtual bool get_constraints_linearity (Index m, LinearityType *const_types)
 Method to request the constraints linearity.
 
virtual bool get_warm_start_iterate (IteratesVector &warm_start_iterate)
 Method to provide an Ipopt warm start iterate which is already in the form Ipopt requires it internally for warm starts.
 
virtual Index get_number_of_nonlinear_variables ()
 Return the number of variables that appear nonlinearly in the objective function or in at least one constraint function.
 
virtual bool get_list_of_nonlinear_variables (Index num_nonlin_vars, Index *pos_nonlin_vars)
 Return the indices of all nonlinear variables.
 
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 returns any metadata collected during the run of the algorithm.
 
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
 Get primal and dual variable values of the current iterate.
 
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
 Get primal and dual infeasibility of the current iterate.
 
- 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.

 StdInterfaceTNLP ()
 Default Constructor.
 
 StdInterfaceTNLP (const StdInterfaceTNLP &)
 Copy Constructor.
 
void operator= (const StdInterfaceTNLP &)
 Default Assignment Operator.
 

Private Attributes

SmartPtr< const Journalistjnlst_
 Journalist.
 
Numbernon_const_x_
 A non-const copy of x - this is kept up-to-date in apply_new_x.
 
Information about the problem
const Index n_var_
 Number of variables.
 
const Index n_con_
 Number of constraints.
 
const Numberx_L_
 Pointer to Number array containing lower bounds for variables.
 
const Numberx_U_
 Pointer to Number array containing upper bounds for variables.
 
const Numberg_L_
 Pointer to Number array containing lower bounds for constraints.
 
const Numberg_U_
 Pointer to Number array containing upper bounds for constraints.
 
const Index nele_jac_
 Number of non-zero elements in the constraint Jacobian.
 
const Index nele_hess_
 Number of non-zero elements in the Hessian.
 
const Index index_style_
 Starting value of the iRow and jCol parameters for matrices.
 
const Numberstart_x_
 Pointer to Number array containing starting point for variables.
 
const Numberstart_lam_
 Pointer to Number array containing starting values for constraint multipliers.
 
const Numberstart_z_L_
 Pointer to Number array containing starting values for lower bound multipliers.
 
const Numberstart_z_U_
 Pointer to Number array containing starting values for upper bound multipliers.
 
Eval_F_CB eval_f_
 Pointer to callback function evaluating value of objective function.
 
Eval_G_CB eval_g_
 Pointer to callback function evaluating value of constraints.
 
Eval_Grad_F_CB eval_grad_f_
 Pointer to callback function evaluating gradient of objective function.
 
Eval_Jac_G_CB eval_jac_g_
 Pointer to callback function evaluating Jacobian of constraints.
 
Eval_H_CB eval_h_
 Pointer to callback function evaluating Hessian of Lagrangian.
 
Intermediate_CB intermediate_cb_
 Pointer to intermediate callback function giving control to user.
 
UserDataPtr user_data_
 Pointer to user data.
 
Number obj_scaling_
 Objective scaling factor.
 
const Numberx_scaling_
 Scaling factors for variables (if not NULL)
 
const Numberg_scaling_
 Scaling factors for constraints (if not NULL)
 
Pointers to the user provided vectors for solution
Numberx_sol_
 
Numberz_L_sol_
 
Numberz_U_sol_
 
Numberg_sol_
 
Numberlambda_sol_
 
Numberobj_sol_
 

Temporary pointers to IpoptData and IpoptCalculatedQuantities

For implementation of GetIpoptCurrentIterate() and GetIpoptCurrentViolations() (without API change).

const IpoptDataip_data_
 
IpoptCalculatedQuantitiesip_cq_
 
void apply_new_x (bool new_x, Index n, const Number *x)
 Update the internal state if the x value changes.
 

Additional Inherited Members

- Public Types inherited from Ipopt::TNLP
enum  LinearityType { LINEAR , NON_LINEAR }
 Linearity-types of variables and constraints. More...
 
enum  IndexStyleEnum { C_STYLE = 0 , FORTRAN_STYLE = 1 }
 
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

Implementation of a TNLP for the Standard C interface.

The standard C interface is exposed to the user as a single C function that is given problem dimension, starting points, and pointers for functions that evaluate objective function etc.

Definition at line 28 of file IpStdInterfaceTNLP.hpp.

Constructor & Destructor Documentation

◆ StdInterfaceTNLP() [1/3]

Ipopt::StdInterfaceTNLP::StdInterfaceTNLP ( Index  n_var,
const Number x_L,
const Number x_U,
Index  n_con,
const Number g_L,
const Number g_U,
Index  nele_jac,
Index  nele_hess,
Index  index_style,
const Number start_x,
const Number start_lam,
const Number start_z_L,
const Number start_z_U,
Eval_F_CB  eval_f,
Eval_G_CB  eval_g,
Eval_Grad_F_CB  eval_grad_f,
Eval_Jac_G_CB  eval_jac_g,
Eval_H_CB  eval_h,
Intermediate_CB  intermediate_cb,
Number x_sol,
Number z_L_sol,
Number z_U_sol,
Number g_sol,
Number lam_sol,
Number obj_sol,
UserDataPtr  user_data,
Number  obj_scaling = 1,
const Number x_scaling = NULL,
const Number g_scaling = NULL 
)

Constructor, given dimensions of problem, function pointers for evaluation callback functions, and starting points.

Note that the constructor does not make a copy of any of the Number arrays, i.e. it is up to the called to keep them around.

◆ ~StdInterfaceTNLP()

virtual Ipopt::StdInterfaceTNLP::~StdInterfaceTNLP ( )
virtual

Default destructor.

◆ StdInterfaceTNLP() [2/3]

Ipopt::StdInterfaceTNLP::StdInterfaceTNLP ( )
private

Default Constructor.

◆ StdInterfaceTNLP() [3/3]

Ipopt::StdInterfaceTNLP::StdInterfaceTNLP ( const StdInterfaceTNLP )
private

Copy Constructor.

Member Function Documentation

◆ get_nlp_info()

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

Method to request the initial information about the problem.

Ipopt uses this information when allocating the arrays that it will later ask you to fill with values. Be careful in this method since incorrect values will cause memory bugs which may be very difficult to find.

Parameters
n(out) Storage for the number of variables \(x\)
m(out) Storage for the number of constraints \(g(x)\)
nnz_jac_g(out) Storage for the number of nonzero entries in the Jacobian
nnz_h_lag(out) Storage for the number of nonzero entries in the Hessian
index_style(out) Storage for the index style, the numbering style used for row/col entries in the sparse matrix format (TNLP::C_STYLE: 0-based, TNLP::FORTRAN_STYLE: 1-based; see also Triplet Format for Sparse Matrices)

Implements Ipopt::TNLP.

◆ get_bounds_info()

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

Method to request bounds on the variables and constraints.

Parameters
n(in) the number of variables \(x\) in the problem
x_l(out) the lower bounds \(x^L\) for the variables \(x\)
x_u(out) the upper bounds \(x^U\) for the variables \(x\)
m(in) the number of constraints \(g(x)\) in the problem
g_l(out) the lower bounds \(g^L\) for the constraints \(g(x)\)
g_u(out) the upper bounds \(g^U\) for the constraints \(g(x)\)
Returns
true if success, false otherwise.

The values of n and m that were specified in TNLP::get_nlp_info are passed here for debug checking. Setting a lower bound to a value less than or equal to the value of the option nlp_lower_bound_inf will cause Ipopt to assume no lower bound. Likewise, specifying the upper bound above or equal to the value of the option nlp_upper_bound_inf will cause Ipopt to assume no upper bound. These options are set to -1019 and 1019, respectively, by default, but may be modified by changing these options.

Implements Ipopt::TNLP.

◆ get_scaling_parameters()

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

Method to request scaling parameters.

This is only called if the options are set to retrieve user scaling, that is, if nlp_scaling_method is chosen as "user-scaling". The method should provide scaling factors for the objective function as well as for the optimization variables and/or constraints. The return value should be true, unless an error occurred, and the program is to be aborted.

The value returned in obj_scaling determines, how Ipopt should internally scale the objective function. For example, if this number is chosen to be 10, then Ipopt solves internally an optimization problem that has 10 times the value of the original objective function provided by the TNLP. In particular, if this value is negative, then Ipopt will maximize the objective function instead of minimizing it.

The scaling factors for the variables can be returned in x_scaling, which has the same length as x in the other TNLP methods, and the factors are ordered like x. use_x_scaling needs to be set to true, if Ipopt should scale the variables. If it is false, no internal scaling of the variables is done. Similarly, the scaling factors for the constraints can be returned in g_scaling, and this scaling is activated by setting use_g_scaling to true.

As a guideline, we suggest to scale the optimization problem (either directly in the original formulation, or after using scaling factors) so that all sensitivities, i.e., all non-zero first partial derivatives, are typically of the order 0.1-10.

Reimplemented from Ipopt::TNLP.

◆ get_starting_point()

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

Method to request the starting point before iterating.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
init_x(in) if true, this method must provide an initial value for \(x\)
x(out) the initial values for the primal variables \(x\)
init_z(in) if true, this method must provide an initial value for the bound multipliers \(z^L\) and \(z^U\)
z_L(out) the initial values for the bound multipliers \(z^L\)
z_U(out) the initial values for the bound multipliers \(z^U\)
m(in) the number of constraints \(g(x)\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
init_lambda(in) if true, this method must provide an initial value for the constraint multipliers \(\lambda\)
lambda(out) the initial values for the constraint multipliers, \(\lambda\)
Returns
true if success, false otherwise.

The boolean variables indicate whether the algorithm requires to have x, z_L/z_u, and lambda initialized, respectively. If, for some reason, the algorithm requires initializations that cannot be provided, false should be returned and Ipopt will stop. The default options only require initial values for the primal variables \(x\).

Note, that the initial values for bound multiplier components for absent bounds ( \(x^L_i=-\infty\) or \(x^U_i=\infty\)) are ignored.

Implements Ipopt::TNLP.

◆ eval_f()

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

Method to request the value of the objective function.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) the values for the primal variables \(x\) at which the objective function \(f(x)\) is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise. This can be helpful when users have efficient implementations that calculate multiple outputs at once. Ipopt internally caches results from the TNLP and generally, this flag can be ignored.
obj_value(out) storage for the value of the objective function \(f(x)\)
Returns
true if success, false otherwise.

Implements Ipopt::TNLP.

◆ eval_grad_f()

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

Method to request the gradient of the objective function.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) the values for the primal variables \(x\) at which the gradient \(\nabla f(x)\) is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also TNLP::eval_f
grad_f(out) array to store values of the gradient of the objective function \(\nabla f(x)\). The gradient array is in the same order as the \(x\) variables (i.e., the gradient of the objective with respect to x[2] should be put in grad_f[2]).
Returns
true if success, false otherwise.

Implements Ipopt::TNLP.

◆ eval_g()

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

Method to request the constraint values.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) the values for the primal variables \(x\) at which the constraint functions \(g(x)\) are to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also TNLP::eval_f
m(in) the number of constraints \(g(x)\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
g(out) array to store constraint function values \(g(x)\), do not add or subtract the bound values \(g^L\) or \(g^U\).
Returns
true if success, false otherwise.

Implements Ipopt::TNLP.

◆ eval_jac_g()

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

Method to request either the sparsity structure or the values of the Jacobian of the constraints.

The Jacobian is the matrix of derivatives where the derivative of constraint function \(g_i\) with respect to variable \(x_j\) is placed in row \(i\) and column \(j\). See Triplet Format for Sparse Matrices for a discussion of the sparse matrix format used in this method.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) first call: NULL; later calls: the values for the primal variables \(x\) at which the constraint Jacobian \(\nabla g(x)^T\) is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also TNLP::eval_f
m(in) the number of constraints \(g(x)\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
nele_jac(in) the number of nonzero elements in the Jacobian; it will have the same value that was specified in TNLP::get_nlp_info
iRow(out) first call: array of length nele_jac to store the row indices of entries in the Jacobian of the constraints; later calls: NULL
jCol(out) first call: array of length nele_jac to store the column indices of entries in the Jacobian of the constraints; later calls: NULL
values(out) first call: NULL; later calls: array of length nele_jac to store the values of the entries in the Jacobian of the constraints
Returns
true if success, false otherwise.
Note
The arrays iRow and jCol only need to be filled once. If the iRow and jCol arguments are not NULL (first call to this function), then Ipopt expects that the sparsity structure of the Jacobian (the row and column indices only) are written into iRow and jCol. At this call, the arguments x and values will be NULL. If the arguments x and values are not NULL, then Ipopt expects that the value of the Jacobian as calculated from array x is stored in array values (using the same order as used when specifying the sparsity structure). At this call, the arguments iRow and jCol will be NULL.

Implements Ipopt::TNLP.

◆ eval_h()

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

Method to request either the sparsity structure or the values of the Hessian of the Lagrangian.

The Hessian matrix that Ipopt uses is

\[ \sigma_f \nabla^2 f(x_k) + \sum_{i=1}^m\lambda_i\nabla^2 g_i(x_k) \]

for the given values for \(x\), \(\sigma_f\), and \(\lambda\). See Triplet Format for Sparse Matrices for a discussion of the sparse matrix format used in this method.

Parameters
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) first call: NULL; later calls: the values for the primal variables \(x\) at which the Hessian is to be evaluated
new_x(in) false if any evaluation method (eval_*) was previously called with the same values in x, true otherwise; see also TNLP::eval_f
obj_factor(in) factor \(\sigma_f\) in front of the objective term in the Hessian
m(in) the number of constraints \(g(x)\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
lambda(in) the values for the constraint multipliers \(\lambda\) at which the Hessian is to be evaluated
new_lambda(in) false if any evaluation method was previously called with the same values in lambda, true otherwise
nele_hess(in) the number of nonzero elements in the Hessian; it will have the same value that was specified in TNLP::get_nlp_info
iRow(out) first call: array of length nele_hess to store the row indices of entries in the Hessian; later calls: NULL
jCol(out) first call: array of length nele_hess to store the column indices of entries in the Hessian; later calls: NULL
values(out) first call: NULL; later calls: array of length nele_hess to store the values of the entries in the Hessian
Returns
true if success, false otherwise.
Note
The arrays iRow and jCol only need to be filled once. If the iRow and jCol arguments are not NULL (first call to this function), then Ipopt expects that the sparsity structure of the Hessian (the row and column indices only) are written into iRow and jCol. At this call, the arguments x, lambda, and values will be NULL. If the arguments x, lambda, and values are not NULL, then Ipopt expects that the value of the Hessian as calculated from arrays x and lambda are stored in array values (using the same order as used when specifying the sparsity structure). At this call, the arguments iRow and jCol will be NULL.
Attention
As this matrix is symmetric, Ipopt expects that only the lower diagonal entries are specified.

A default implementation is provided, in case the user wants to set quasi-Newton approximations to estimate the second derivatives and doesn't not need to implement this method.

Reimplemented from Ipopt::TNLP.

◆ intermediate_callback()

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

This method is called once per iteration (during the convergence check), and can be used to obtain information about the optimization status while Ipopt solves the problem, and also to request a premature termination.

The information provided by the entities in the argument list correspond to what Ipopt prints in the iteration summary (see also Ipopt Output), except for inf_pr, which by default corresponds to the original problem in the log but to the scaled internal problem in this callback. Further information can be obtained from the ip_data and ip_cq objects. The current iterate and violations of feasibility and optimality can be accessed via the methods Ipopt::TNLP::get_curr_iterate() and Ipopt::TNLP::get_curr_violations(). These methods translate values for the internal representation of the problem from ip_data and ip_cq objects into the TNLP representation.

Returns
If this method returns false, Ipopt will terminate with the User_Requested_Stop status.

It is not required to implement (overload) this method. The default implementation always returns true.

Reimplemented from Ipopt::TNLP.

◆ finalize_solution()

virtual void Ipopt::StdInterfaceTNLP::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 has finished (successfully or not) so the TNLP can digest the outcome, e.g., store/write the solution, if any.

Parameters
status(in) gives the status of the algorithm
  • SUCCESS: Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).
  • MAXITER_EXCEEDED: Maximum number of iterations exceeded (can be specified by an option).
  • CPUTIME_EXCEEDED: Maximum number of CPU seconds exceeded (can be specified by an option).
  • STOP_AT_TINY_STEP: Algorithm proceeds with very little progress.
  • STOP_AT_ACCEPTABLE_POINT: Algorithm stopped at a point that was converged, not to "desired" tolerances, but to "acceptable" tolerances (see the acceptable-... options).
  • LOCAL_INFEASIBILITY: Algorithm converged to a point of local infeasibility. Problem may be infeasible.
  • USER_REQUESTED_STOP: The user call-back function TNLP::intermediate_callback returned false, i.e., the user code requested a premature termination of the optimization.
  • DIVERGING_ITERATES: It seems that the iterates diverge.
  • RESTORATION_FAILURE: Restoration phase failed, algorithm doesn't know how to proceed.
  • ERROR_IN_STEP_COMPUTATION: An unrecoverable error occurred while Ipopt tried to compute the search direction.
  • INVALID_NUMBER_DETECTED: Algorithm received an invalid number (such as NaN or Inf) from the NLP; see also option check_derivatives_for_nan_inf).
  • INTERNAL_ERROR: An unknown internal error occurred.
n(in) the number of variables \(x\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
x(in) the final values for the primal variables
z_L(in) the final values for the lower bound multipliers
z_U(in) the final values for the upper bound multipliers
m(in) the number of constraints \(g(x)\) in the problem; it will have the same value that was specified in TNLP::get_nlp_info
g(in) the final values of the constraint functions
lambda(in) the final values of the constraint multipliers
obj_value(in) the final value of the objective function
ip_data(in) provided for expert users
ip_cq(in) provided for expert users

Implements Ipopt::TNLP.

◆ get_curr_iterate()

bool Ipopt::StdInterfaceTNLP::get_curr_iterate ( Bool  scaled,
Index  n,
Number x,
Number z_L,
Number z_U,
Index  m,
Number g,
Number lambda 
) const
inline

get_curr_iterate() to be called by GetIpoptCurrentIterate()

Since
3.14.0

Definition at line 202 of file IpStdInterfaceTNLP.hpp.

◆ get_curr_violations()

bool Ipopt::StdInterfaceTNLP::get_curr_violations ( 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
inline

get_curr_violations() to be called by GetIpoptCurrentViolations()

Since
3.14.0

Definition at line 218 of file IpStdInterfaceTNLP.hpp.

◆ apply_new_x()

void Ipopt::StdInterfaceTNLP::apply_new_x ( bool  new_x,
Index  n,
const Number x 
)
private

Update the internal state if the x value changes.

◆ operator=()

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

Default Assignment Operator.

Member Data Documentation

◆ jnlst_

SmartPtr<const Journalist> Ipopt::StdInterfaceTNLP::jnlst_
private

Journalist.

Definition at line 236 of file IpStdInterfaceTNLP.hpp.

◆ n_var_

const Index Ipopt::StdInterfaceTNLP::n_var_
private

Number of variables.

Definition at line 241 of file IpStdInterfaceTNLP.hpp.

◆ n_con_

const Index Ipopt::StdInterfaceTNLP::n_con_
private

Number of constraints.

Definition at line 243 of file IpStdInterfaceTNLP.hpp.

◆ x_L_

const Number* Ipopt::StdInterfaceTNLP::x_L_
private

Pointer to Number array containing lower bounds for variables.

Definition at line 245 of file IpStdInterfaceTNLP.hpp.

◆ x_U_

const Number* Ipopt::StdInterfaceTNLP::x_U_
private

Pointer to Number array containing upper bounds for variables.

Definition at line 247 of file IpStdInterfaceTNLP.hpp.

◆ g_L_

const Number* Ipopt::StdInterfaceTNLP::g_L_
private

Pointer to Number array containing lower bounds for constraints.

Definition at line 249 of file IpStdInterfaceTNLP.hpp.

◆ g_U_

const Number* Ipopt::StdInterfaceTNLP::g_U_
private

Pointer to Number array containing upper bounds for constraints.

Definition at line 251 of file IpStdInterfaceTNLP.hpp.

◆ nele_jac_

const Index Ipopt::StdInterfaceTNLP::nele_jac_
private

Number of non-zero elements in the constraint Jacobian.

Definition at line 253 of file IpStdInterfaceTNLP.hpp.

◆ nele_hess_

const Index Ipopt::StdInterfaceTNLP::nele_hess_
private

Number of non-zero elements in the Hessian.

Definition at line 255 of file IpStdInterfaceTNLP.hpp.

◆ index_style_

const Index Ipopt::StdInterfaceTNLP::index_style_
private

Starting value of the iRow and jCol parameters for matrices.

Definition at line 257 of file IpStdInterfaceTNLP.hpp.

◆ start_x_

const Number* Ipopt::StdInterfaceTNLP::start_x_
private

Pointer to Number array containing starting point for variables.

Definition at line 259 of file IpStdInterfaceTNLP.hpp.

◆ start_lam_

const Number* Ipopt::StdInterfaceTNLP::start_lam_
private

Pointer to Number array containing starting values for constraint multipliers.

Definition at line 261 of file IpStdInterfaceTNLP.hpp.

◆ start_z_L_

const Number* Ipopt::StdInterfaceTNLP::start_z_L_
private

Pointer to Number array containing starting values for lower bound multipliers.

Definition at line 263 of file IpStdInterfaceTNLP.hpp.

◆ start_z_U_

const Number* Ipopt::StdInterfaceTNLP::start_z_U_
private

Pointer to Number array containing starting values for upper bound multipliers.

Definition at line 265 of file IpStdInterfaceTNLP.hpp.

◆ eval_f_

Eval_F_CB Ipopt::StdInterfaceTNLP::eval_f_
private

Pointer to callback function evaluating value of objective function.

Definition at line 267 of file IpStdInterfaceTNLP.hpp.

◆ eval_g_

Eval_G_CB Ipopt::StdInterfaceTNLP::eval_g_
private

Pointer to callback function evaluating value of constraints.

Definition at line 269 of file IpStdInterfaceTNLP.hpp.

◆ eval_grad_f_

Eval_Grad_F_CB Ipopt::StdInterfaceTNLP::eval_grad_f_
private

Pointer to callback function evaluating gradient of objective function.

Definition at line 271 of file IpStdInterfaceTNLP.hpp.

◆ eval_jac_g_

Eval_Jac_G_CB Ipopt::StdInterfaceTNLP::eval_jac_g_
private

Pointer to callback function evaluating Jacobian of constraints.

Definition at line 273 of file IpStdInterfaceTNLP.hpp.

◆ eval_h_

Eval_H_CB Ipopt::StdInterfaceTNLP::eval_h_
private

Pointer to callback function evaluating Hessian of Lagrangian.

Definition at line 275 of file IpStdInterfaceTNLP.hpp.

◆ intermediate_cb_

Intermediate_CB Ipopt::StdInterfaceTNLP::intermediate_cb_
private

Pointer to intermediate callback function giving control to user.

Definition at line 277 of file IpStdInterfaceTNLP.hpp.

◆ user_data_

UserDataPtr Ipopt::StdInterfaceTNLP::user_data_
private

Pointer to user data.

Definition at line 279 of file IpStdInterfaceTNLP.hpp.

◆ obj_scaling_

Number Ipopt::StdInterfaceTNLP::obj_scaling_
private

Objective scaling factor.

Definition at line 281 of file IpStdInterfaceTNLP.hpp.

◆ x_scaling_

const Number* Ipopt::StdInterfaceTNLP::x_scaling_
private

Scaling factors for variables (if not NULL)

Definition at line 283 of file IpStdInterfaceTNLP.hpp.

◆ g_scaling_

const Number* Ipopt::StdInterfaceTNLP::g_scaling_
private

Scaling factors for constraints (if not NULL)

Definition at line 285 of file IpStdInterfaceTNLP.hpp.

◆ non_const_x_

Number* Ipopt::StdInterfaceTNLP::non_const_x_
private

A non-const copy of x - this is kept up-to-date in apply_new_x.

Definition at line 289 of file IpStdInterfaceTNLP.hpp.

◆ x_sol_

Number* Ipopt::StdInterfaceTNLP::x_sol_
private

Definition at line 293 of file IpStdInterfaceTNLP.hpp.

◆ z_L_sol_

Number* Ipopt::StdInterfaceTNLP::z_L_sol_
private

Definition at line 294 of file IpStdInterfaceTNLP.hpp.

◆ z_U_sol_

Number* Ipopt::StdInterfaceTNLP::z_U_sol_
private

Definition at line 295 of file IpStdInterfaceTNLP.hpp.

◆ g_sol_

Number* Ipopt::StdInterfaceTNLP::g_sol_
private

Definition at line 296 of file IpStdInterfaceTNLP.hpp.

◆ lambda_sol_

Number* Ipopt::StdInterfaceTNLP::lambda_sol_
private

Definition at line 297 of file IpStdInterfaceTNLP.hpp.

◆ obj_sol_

Number* Ipopt::StdInterfaceTNLP::obj_sol_
private

Definition at line 298 of file IpStdInterfaceTNLP.hpp.

◆ ip_data_

const IpoptData* Ipopt::StdInterfaceTNLP::ip_data_
private

Definition at line 305 of file IpStdInterfaceTNLP.hpp.

◆ ip_cq_

IpoptCalculatedQuantities* Ipopt::StdInterfaceTNLP::ip_cq_
private

Definition at line 306 of file IpStdInterfaceTNLP.hpp.


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