Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpStdInterfaceTNLP.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2010 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpStdInterfaceTNLP.hpp 1861 2010-12-21 21:34:47Z andreasw $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPSTDINTERFACETNLP_HPP__
10 #define __IPSTDINTERFACETNLP_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpTNLP.hpp"
14 #include "IpJournalist.hpp"
15 #include "IpException.hpp"
16 #include "IpStdCInterface.h"
17 #include "IpSmartPtr.hpp"
18
19 namespace Ipopt
20 {
23 DECLARE_STD_EXCEPTION(INVALID_STDINTERFACE_NLP);
24
30 class StdInterfaceTNLP : public TNLP
31 {
32 public:
39 StdInterfaceTNLP(Index n_var,
40 const Number* x_L, const Number* x_U,
41 Index n_con,
42 const Number* g_L, const Number* g_U,
43 Index nele_jac,
44 Index nele_hess,
45 Index index_style,
46 const Number* start_x,
47 const Number* start_lam,
48 const Number* start_z_L,
49 const Number* start_z_U,
50 Eval_F_CB eval_f,
51 Eval_G_CB eval_g,
52 Eval_Grad_F_CB eval_grad_f,
53 Eval_Jac_G_CB eval_jac_g,
54 Eval_H_CB eval_h,
55 Intermediate_CB intermediate_cb,
56 Number* x_sol,
57 Number* z_L_sol,
58 Number* z_U_sol,
59 Number* g_sol,
60 Number* lam_sol,
61 Number* obj_sol,
62 UserDataPtr user_data,
63 Number obj_scaling=1,
64 const Number* x_scaling = NULL,
65 const Number* g_scaling = NULL);
66
68 virtual ~StdInterfaceTNLP();
70
75 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
76 Index& nnz_h_lag, IndexStyleEnum& index_style);
77
79 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
80 Index m, Number* g_l, Number* g_u);
81
84 virtual bool get_scaling_parameters(Number& obj_scaling,
85 bool& use_x_scaling, Index n,
86 Number* x_scaling,
87 bool& use_g_scaling, Index m,
88 Number* g_scaling);
89
91 virtual bool get_starting_point(Index n, bool init_x, Number* x,
92 bool init_z, Number* z_L, Number* z_U,
93 Index m, bool init_lambda, Number* lambda);
94
96 virtual bool eval_f(Index n, const Number* x, bool new_x,
97 Number& obj_value);
98
101 virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
102 Number* grad_f);
103
105 virtual bool eval_g(Index n, const Number* x, bool new_x, Index m,
106 Number* g);
107
111 virtual bool eval_jac_g(Index n, const Number* x, bool new_x, Index m,
112 Index nele_jac, Index* iRow, Index *jCol,
113 Number* values);
114
117 virtual bool eval_h(Index n, const Number* x, bool new_x,
118 Number obj_factor, Index m, const Number* lambda,
119 bool new_lambda, Index nele_hess, Index* iRow,
120 Index* jCol, Number* values);
121
123 virtual bool intermediate_callback(AlgorithmMode mode,
124 Index iter, Number obj_value,
125 Number inf_pr, Number inf_du,
126 Number mu, Number d_norm,
127 Number regularization_size,
128 Number alpha_du, Number alpha_pr,
129 Index ls_trials,
130 const IpoptData* ip_data,
131 IpoptCalculatedQuantities* ip_cq);
133
136 virtual void finalize_solution(SolverReturn status,
137 Index n, const Number* x, const Number* z_L, const Number* z_U,
138 Index m, const Number* g, const Number* lambda,
139 Number obj_value,
140 const IpoptData* ip_data,
141 IpoptCalculatedQuantities* ip_cq);
143
144 private:
146 SmartPtr<const Journalist> jnlst_;
147
151 const Index n_var_;
153 const Index n_con_;
155 const Number* x_L_;
157 const Number* x_U_;
159 const Number* g_L_;
161 const Number* g_U_;
163 const Index nele_jac_;
165 const Index nele_hess_;
167 const Index index_style_;
169 const Number* start_x_;
172 const Number* start_lam_;
175 const Number* start_z_L_;
178 const Number* start_z_U_;
180 Eval_F_CB eval_f_;
182 Eval_G_CB eval_g_;
185 Eval_Grad_F_CB eval_grad_f_;
187 Eval_Jac_G_CB eval_jac_g_;
189 Eval_H_CB eval_h_;
191 Intermediate_CB intermediate_cb_;
193 UserDataPtr user_data_;
195 Number obj_scaling_;
197 const Number* x_scaling_;
199 const Number* g_scaling_;
201
202
204 Number* non_const_x_;
205
207 Number* x_sol_;
208 Number* z_L_sol_;
209 Number* z_U_sol_;
210 Number* g_sol_;
211 Number* lambda_sol_;
212 Number* obj_sol_;
213
216 void apply_new_x(bool new_x, Index n, const Number* x);
217
227 StdInterfaceTNLP();
228
230 StdInterfaceTNLP(const StdInterfaceTNLP&);
231
233 void operator=(const StdInterfaceTNLP&);
235
236 };
237
238 } // namespace Ipopt
239
240 #endif
Intermediate_CB
Bool(* Intermediate_CB)(Index alg_mod, Index iter_count, 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, UserDataPtr user_data)
Type defining the callback function for giving intermediate execution control to the user...
Definition: IpStdCInterface.h:108
Ipopt::StdInterfaceTNLP::x_U_
const Number * x_U_
Pointer to Number array containing upper bounds for variables.
Definition: IpStdInterfaceTNLP.hpp:157
Eval_Grad_F_CB
Bool(* Eval_Grad_F_CB)(Index n, Number *x, Bool new_x, Number *grad_f, UserDataPtr user_data)
Type defining the callback function for evaluating the gradient of the objective function.
Definition: IpStdCInterface.h:76
Eval_F_CB
Bool(* Eval_F_CB)(Index n, Number *x, Bool new_x, Number *obj_value, UserDataPtr user_data)
Type defining the callback function for evaluating the value of the objective function.
Definition: IpStdCInterface.h:70
x
Number * x
Input: Starting point Output: Optimal solution.
Definition: IpStdCInterface.h:238
Ipopt::StdInterfaceTNLP::nele_hess_
const Index nele_hess_
Number of non-zero elements in the Hessian.
Definition: IpStdInterfaceTNLP.hpp:165
Ipopt::StdInterfaceTNLP
Implementation of a TNLP for the Standard C interface.
Definition: IpStdInterfaceTNLP.hpp:30
Ipopt::IpoptCalculatedQuantities
Class for all IPOPT specific calculated quantities.
Definition: IpIpoptCalculatedQuantities.hpp:81
IpUtils.hpp
Ipopt::StdInterfaceTNLP::StdInterfaceTNLP
StdInterfaceTNLP()
Default Constructor.
index_style
Number Number Index Number Number Index Index Index index_style
indexing style for iRow &amp; jCol, 0 for C style, 1 for Fortran style
Definition: IpStdCInterface.h:137
Ipopt::StdInterfaceTNLP::eval_h
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)
specifies the structure of the hessian of the lagrangian (if values is NULL) and evaluates the values...
Ipopt::StdInterfaceTNLP::eval_f_
Eval_F_CB eval_f_
Pointer to callback function evaluating value of objective function.
Definition: IpStdInterfaceTNLP.hpp:180
Ipopt::StdInterfaceTNLP::start_z_U_
const Number * start_z_U_
Pointer to Number array containing starting values for upper bound multipliers.
Definition: IpStdInterfaceTNLP.hpp:178
Ipopt::StdInterfaceTNLP::index_style_
const Index index_style_
Starting value of the iRow and jCol parameters for matrices.
Definition: IpStdInterfaceTNLP.hpp:167
m
Number Number Index m
Number of constraints.
Definition: IpStdCInterface.h:137
Ipopt::StdInterfaceTNLP::x_scaling_
const Number * x_scaling_
Scaling factors for variables (if not NULL)
Definition: IpStdInterfaceTNLP.hpp:197
Ipopt::StdInterfaceTNLP::non_const_x_
Number * non_const_x_
A non-const copy of x - this is kept up-to-date in apply_new_x.
Definition: IpStdInterfaceTNLP.hpp:204
Ipopt::StdInterfaceTNLP::start_x_
const Number * start_x_
Pointer to Number array containing starting point for variables.
Definition: IpStdInterfaceTNLP.hpp:169
Ipopt::StdInterfaceTNLP::eval_g
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)
evaluates the constraint residuals for the nlp.
Ipopt::StdInterfaceTNLP::x_sol_
Number * x_sol_
Pointers to the user provided vectors for solution.
Definition: IpStdInterfaceTNLP.hpp:207
g
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
Definition: IpStdCInterface.h:238
Ipopt::AlgorithmMode
AlgorithmMode
enum to indicate the mode in which the algorithm is
Definition: IpReturnCodes.hpp:43
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Ipopt::StdInterfaceTNLP::get_scaling_parameters
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)
returns scaling parameters (if nlp_scaling_method is selected as user-scaling).
Ipopt::StdInterfaceTNLP::nele_jac_
const Index nele_jac_
Number of non-zero elements in the constraint Jacobian.
Definition: IpStdInterfaceTNLP.hpp:163
Ipopt::StdInterfaceTNLP::finalize_solution
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...
g_U
Number Number Index Number Number * g_U
Upper bounds on constraints.
Definition: IpStdCInterface.h:137
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::StdInterfaceTNLP::obj_scaling_
Number obj_scaling_
Objective scaling factor.
Definition: IpStdInterfaceTNLP.hpp:195
Ipopt::StdInterfaceTNLP::g_U_
const Number * g_U_
Pointer to Number array containing upper bounds for constraints.
Definition: IpStdInterfaceTNLP.hpp:161
Ipopt::StdInterfaceTNLP::eval_g_
Eval_G_CB eval_g_
Pointer to callback function evaluating value of constraints.
Definition: IpStdInterfaceTNLP.hpp:182
Ipopt::SolverReturn
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
Ipopt::StdInterfaceTNLP::eval_jac_g
virtual bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
specifies the jacobian structure (if values is NULL) and evaluates the jacobian values (if values is ...
Ipopt::StdInterfaceTNLP::n_con_
const Index n_con_
Number of constraints.
Definition: IpStdInterfaceTNLP.hpp:153
Ipopt::StdInterfaceTNLP::lambda_sol_
Number * lambda_sol_
Definition: IpStdInterfaceTNLP.hpp:211
nele_jac
Number Number Index Number Number Index nele_jac
Number of non-zero elements in constraint Jacobian.
Definition: IpStdCInterface.h:137
Ipopt::StdInterfaceTNLP::start_lam_
const Number * start_lam_
Poitner to Number array containing starting values for constraint multipliers.
Definition: IpStdInterfaceTNLP.hpp:172
Ipopt::StdInterfaceTNLP::jnlst_
SmartPtr< const Journalist > jnlst_
Journlist.
Definition: IpStdInterfaceTNLP.hpp:146
Ipopt::StdInterfaceTNLP::eval_grad_f_
Eval_Grad_F_CB eval_grad_f_
Pointer to callback function evaluating gradient of objective function.
Definition: IpStdInterfaceTNLP.hpp:185
Ipopt::IpoptData
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
x_L
Number * x_L
Lower bounds on variables.
Definition: IpStdCInterface.h:137
Ipopt::StdInterfaceTNLP::obj_sol_
Number * obj_sol_
Definition: IpStdInterfaceTNLP.hpp:212
g_L
Number Number Index Number * g_L
Lower bounds on constraints.
Definition: IpStdCInterface.h:137
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::StdInterfaceTNLP::eval_grad_f
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
evaluates the gradient of the objective for the nlp.
x_U
Number Number * x_U
Upper bounds on variables.
Definition: IpStdCInterface.h:137
IpStdCInterface.h
x_scaling
Number Number * x_scaling
Definition: IpStdCInterface.h:210
Ipopt::StdInterfaceTNLP::z_U_sol_
Number * z_U_sol_
Definition: IpStdInterfaceTNLP.hpp:209
Eval_Jac_G_CB
Bool(* Eval_Jac_G_CB)(Index n, Number *x, Bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)
Type defining the callback function for evaluating the Jacobian of the constrant functions.
Definition: IpStdCInterface.h:88
IpTNLP.hpp
nele_hess
Number Number Index Number Number Index Index nele_hess
Number of non-zero elements in Hessian of Lagrangian.
Definition: IpStdCInterface.h:137
Ipopt::StdInterfaceTNLP::get_bounds_info
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
returns bounds of the nlp.
Ipopt::StdInterfaceTNLP::eval_jac_g_
Eval_Jac_G_CB eval_jac_g_
Pointer to callback function evaluating Jacobian of constraints.
Definition: IpStdInterfaceTNLP.hpp:187
Ipopt::DECLARE_STD_EXCEPTION
DECLARE_STD_EXCEPTION(SUFFIX_EMPTY)
Ipopt::StdInterfaceTNLP::get_starting_point
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)
provides a starting point for the nlp variables.
IpJournalist.hpp
Ipopt::StdInterfaceTNLP::eval_f
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
evaluates the objective value for the nlp.
Ipopt::StdInterfaceTNLP::n_var_
const Index n_var_
Number of variables.
Definition: IpStdInterfaceTNLP.hpp:151
Ipopt::StdInterfaceTNLP::intermediate_cb_
Intermediate_CB intermediate_cb_
Pointer to intermediate callback function giving control to user.
Definition: IpStdInterfaceTNLP.hpp:191
g_scaling
Number Number Number * g_scaling
Definition: IpStdCInterface.h:210
Ipopt::StdInterfaceTNLP::intermediate_callback
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.
Ipopt::TNLP::IndexStyleEnum
IndexStyleEnum
overload this method to return the number of variables and constraints, and the number of non-zeros i...
Definition: IpTNLP.hpp:80
Ipopt::StdInterfaceTNLP::g_sol_
Number * g_sol_
Definition: IpStdInterfaceTNLP.hpp:210
Ipopt::StdInterfaceTNLP::get_nlp_info
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
returns dimensions of the nlp.
Ipopt::StdInterfaceTNLP::g_L_
const Number * g_L_
Pointer to Number array containing lower bounds for constraints.
Definition: IpStdInterfaceTNLP.hpp:159
Ipopt::StdInterfaceTNLP::user_data_
UserDataPtr user_data_
Pointer to user data.
Definition: IpStdInterfaceTNLP.hpp:193
Ipopt::TNLP
Base class for all NLP&#39;s that use standard triplet matrix form and dense vectors. ...
Definition: IpTNLP.hpp:50
Eval_G_CB
Bool(* Eval_G_CB)(Index n, Number *x, Bool new_x, Index m, Number *g, UserDataPtr user_data)
Type defining the callback function for evaluating the value of the constraint functions.
Definition: IpStdCInterface.h:82
UserDataPtr
void * UserDataPtr
A pointer for anything that is to be passed between the called and individual callback function...
Definition: IpStdCInterface.h:65
Ipopt::StdInterfaceTNLP::eval_h_
Eval_H_CB eval_h_
Pointer to callback function evaluating Hessian of Lagrangian.
Definition: IpStdInterfaceTNLP.hpp:189
Ipopt::StdInterfaceTNLP::apply_new_x
void apply_new_x(bool new_x, Index n, const Number *x)
Internal function to update the internal and ampl state if the x value changes.
Ipopt::StdInterfaceTNLP::x_L_
const Number * x_L_
Pointer to Number array containing lower bounds for variables.
Definition: IpStdInterfaceTNLP.hpp:155
Ipopt::StdInterfaceTNLP::g_scaling_
const Number * g_scaling_
Scaling factors for constraints (if not NULL)
Definition: IpStdInterfaceTNLP.hpp:199
Eval_H_CB
Bool(* Eval_H_CB)(Index n, Number *x, Bool new_x, Number obj_factor, Index m, Number *lambda, Bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values, UserDataPtr user_data)
Type defining the callback function for evaluating the Hessian of the Lagrangian function.
Definition: IpStdCInterface.h:96
user_data
Number Number Number Number Number Number UserDataPtr user_data
Pointer to user data.
Definition: IpStdCInterface.h:238
Ipopt::StdInterfaceTNLP::operator=
void operator=(const StdInterfaceTNLP &)
Overloaded Equals Operator.
IpException.hpp
Ipopt::StdInterfaceTNLP::start_z_L_
const Number * start_z_L_
Pointer to Number array containing starting values for lower bound multipliers.
Definition: IpStdInterfaceTNLP.hpp:175
obj_scaling
Number obj_scaling
Definition: IpStdCInterface.h:210
intermediate_cb
Intermediate_CB intermediate_cb
Definition: IpStdCInterface.h:224
IpSmartPtr.hpp
Ipopt::StdInterfaceTNLP::z_L_sol_
Number * z_L_sol_
Definition: IpStdInterfaceTNLP.hpp:208
Ipopt::StdInterfaceTNLP::~StdInterfaceTNLP
virtual ~StdInterfaceTNLP()
Default destructor.