Ipopt Documentation  
 
Loading...
Searching...
No Matches
IpTNLP.hpp
Go to the documentation of this file.
1// Copyright (C) 2004, 2009 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6
7#ifndef __IPTNLP_HPP__
8#define __IPTNLP_HPP__
9
10#include "IpUtils.hpp"
11#include "IpReferenced.hpp"
12#include "IpException.hpp"
13#include "IpAlgTypes.hpp"
14#include "IpReturnCodes.hpp"
15
16#include <map>
17
18namespace Ipopt
19{
20// forward declarations
21class IpoptData;
22class IpoptCalculatedQuantities;
23class IteratesVector;
24
48{
49public:
50
53 {
55 NON_LINEAR
56 };
57
61 { }
62
64 virtual ~TNLP()
65 { }
67
68 DECLARE_STD_EXCEPTION(INVALID_TNLP);
69
72
74 {
75 C_STYLE = 0,
76 FORTRAN_STYLE = 1
77 };
78
94 // [TNLP_get_nlp_info]
95 virtual bool get_nlp_info(
96 Index& n,
97 Index& m,
98 Index& nnz_jac_g,
99 Index& nnz_h_lag,
100 IndexStyleEnum& index_style
101 ) = 0;
102 // [TNLP_get_nlp_info]
103
104 typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType;
105 typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType;
106 typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType;
107
125 // [TNLP_get_var_con_metadata]
127 Index n,
128 StringMetaDataMapType& var_string_md,
129 IntegerMetaDataMapType& var_integer_md,
130 NumericMetaDataMapType& var_numeric_md,
131 Index m,
132 StringMetaDataMapType& con_string_md,
133 IntegerMetaDataMapType& con_integer_md,
134 NumericMetaDataMapType& con_numeric_md
135 )
136 // [TNLP_get_var_con_metadata]
137 {
138 (void) n;
139 (void) var_string_md;
140 (void) var_integer_md;
141 (void) var_numeric_md;
142 (void) m;
143 (void) con_string_md;
144 (void) con_integer_md;
145 (void) con_numeric_md;
146 return false;
147 }
148
169 // [TNLP_get_bounds_info]
170 virtual bool get_bounds_info(
171 Index n,
172 Number* x_l,
173 Number* x_u,
174 Index m,
175 Number* g_l,
176 Number* g_u
177 ) = 0;
178 // [TNLP_get_bounds_info]
179
210 // [TNLP_get_scaling_parameters]
212 Number& obj_scaling,
213 bool& use_x_scaling,
214 Index n,
215 Number* x_scaling,
216 bool& use_g_scaling,
217 Index m,
218 Number* g_scaling
219 )
220 // [TNLP_get_scaling_parameters]
221 {
222 (void) obj_scaling;
223 (void) use_x_scaling;
224 (void) n;
225 (void) x_scaling;
226 (void) use_g_scaling;
227 (void) m;
228 (void) g_scaling;
229 return false;
230 }
231
242 // [TNLP_get_variables_linearity]
244 Index n,
245 LinearityType* var_types
246 )
247 // [TNLP_get_variables_linearity]
248 {
249 (void) n;
250 (void) var_types;
251 return false;
252 }
253
264 // [TNLP_get_constraints_linearity]
266 Index m,
267 LinearityType* const_types
268 )
269 // [TNLP_get_constraints_linearity]
270 {
271 (void) m;
272 (void) const_types;
273 return false;
274 }
275
300 // [TNLP_get_starting_point]
301 virtual bool get_starting_point(
302 Index n,
303 bool init_x,
304 Number* x,
305 bool init_z,
306 Number* z_L,
307 Number* z_U,
308 Index m,
309 bool init_lambda,
310 Number* lambda
311 ) = 0;
312 // [TNLP_get_starting_point]
313
321 // [TNLP_get_warm_start_iterate]
323 IteratesVector& warm_start_iterate
324 )
325 {
326 (void) warm_start_iterate;
327 return false;
328 }
329 // [TNLP_get_warm_start_iterate]
330
342 // [TNLP_eval_f]
343 virtual bool eval_f(
344 Index n,
345 const Number* x,
346 bool new_x,
347 Number& obj_value
348 ) = 0;
349 // [TNLP_eval_f]
350
362 // [TNLP_eval_grad_f]
363 virtual bool eval_grad_f(
364 Index n,
365 const Number* x,
366 bool new_x,
367 Number* grad_f
368 ) = 0;
369 // [TNLP_eval_grad_f]
370
381 // [TNLP_eval_g]
382 virtual bool eval_g(
383 Index n,
384 const Number* x,
385 bool new_x,
386 Index m,
387 Number* g
388 ) = 0;
389 // [TNLP_eval_g]
390
420 // [TNLP_eval_jac_g]
421 virtual bool eval_jac_g(
422 Index n,
423 const Number* x,
424 bool new_x,
425 Index m,
426 Index nele_jac,
427 Index* iRow,
428 Index* jCol,
429 Number* values
430 ) = 0;
431 // [TNLP_eval_jac_g]
432
471 // [TNLP_eval_h]
472 virtual bool eval_h(
473 Index n,
474 const Number* x,
475 bool new_x,
476 Number obj_factor,
477 Index m,
478 const Number* lambda,
479 bool new_lambda,
480 Index nele_hess,
481 Index* iRow,
482 Index* jCol,
483 Number* values
484 )
485 // [TNLP_eval_h]
486 {
487 (void) n;
488 (void) x;
489 (void) new_x;
490 (void) obj_factor;
491 (void) m;
492 (void) lambda;
493 (void) new_lambda;
494 (void) nele_hess;
495 (void) iRow;
496 (void) jCol;
497 (void) values;
498 return false;
499 }
501
504
533 // [TNLP_finalize_solution]
534 virtual void finalize_solution(
535 SolverReturn status,
536 Index n,
537 const Number* x,
538 const Number* z_L,
539 const Number* z_U,
540 Index m,
541 const Number* g,
542 const Number* lambda,
543 Number obj_value,
544 const IpoptData* ip_data,
546 ) = 0;
547 // [TNLP_finalize_solution]
548
564 // [TNLP_finalize_metadata]
565 virtual void finalize_metadata(
566 Index n,
567 const StringMetaDataMapType& var_string_md,
568 const IntegerMetaDataMapType& var_integer_md,
569 const NumericMetaDataMapType& var_numeric_md,
570 Index m,
571 const StringMetaDataMapType& con_string_md,
572 const IntegerMetaDataMapType& con_integer_md,
573 const NumericMetaDataMapType& con_numeric_md
574 )
575 // [TNLP_finalize_metadata]
576 {
577 (void) n;
578 (void) var_string_md;
579 (void) var_integer_md;
580 (void) var_numeric_md;
581 (void) m;
582 (void) con_string_md;
583 (void) con_integer_md;
584 (void) con_numeric_md;
585 }
586
657 // [TNLP_intermediate_callback]
659 AlgorithmMode mode,
660 Index iter,
661 Number obj_value,
662 Number inf_pr,
663 Number inf_du,
664 Number mu,
665 Number d_norm,
666 Number regularization_size,
667 Number alpha_du,
668 Number alpha_pr,
669 Index ls_trials,
670 const IpoptData* ip_data,
672 )
673 // [TNLP_intermediate_callback]
674 {
675 (void) mode;
676 (void) iter;
677 (void) obj_value;
678 (void) inf_pr;
679 (void) inf_du;
680 (void) mu;
681 (void) d_norm;
682 (void) regularization_size;
683 (void) alpha_du;
684 (void) alpha_pr;
685 (void) ls_trials;
686 (void) ip_data;
687 (void) ip_cq;
688 return true;
689 }
691
716 // [TNLP_get_number_of_nonlinear_variables]
718 // [TNLP_get_number_of_nonlinear_variables]
719 {
720 return -1;
721 }
722
733 // [TNLP_get_list_of_nonlinear_variables]
735 Index num_nonlin_vars,
736 Index* pos_nonlin_vars
737 )
738 // [TNLP_get_list_of_nonlinear_variables]
739 {
740 (void) num_nonlin_vars;
741 (void) pos_nonlin_vars;
742 return false;
743 }
745
746private:
756
758 const TNLP&
759 );
760
763 const TNLP&
764 );
766};
767
768} // namespace Ipopt
769
770#endif
AlgorithmMode
enum to indicate the mode in which the algorithm is
Class for all IPOPT specific calculated quantities.
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:98
Specialized CompoundVector class specifically for the algorithm iterates.
Storing the reference count of all the smart pointers that currently reference it.
Base class for all NLP's that use standard triplet matrix form and dense vectors.
Definition: IpTNLP.hpp:48
virtual Index get_number_of_nonlinear_variables()
Return the number of variables that appear nonlinearly in the objective function or in at least one c...
Definition: IpTNLP.hpp:717
virtual ~TNLP()
Default destructor.
Definition: IpTNLP.hpp:64
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
Method to request the starting point before iterating.
DECLARE_STD_EXCEPTION(INVALID_TNLP)
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.
Definition: IpTNLP.hpp:472
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 internal...
Definition: IpTNLP.hpp:322
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.
Definition: IpTNLP.hpp:658
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
This method is called when the algorithm has finished (successfully or not) so the TNLP can digest th...
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.
Definition: IpTNLP.hpp:211
virtual bool get_constraints_linearity(Index m, LinearityType *const_types)
Method to request the constraints linearity.
Definition: IpTNLP.hpp:265
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)=0
Method to request the gradient of the objective function.
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)=0
Method to request the initial information about the problem.
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)=0
Method to request the value of the objective function.
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.
Definition: IpTNLP.hpp:565
virtual bool get_variables_linearity(Index n, LinearityType *var_types)
Method to request the variables linearity.
Definition: IpTNLP.hpp:243
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
Definition: IpTNLP.hpp:105
virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, Index *pos_nonlin_vars)
Return the indices of all nonlinear variables.
Definition: IpTNLP.hpp:734
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
Definition: IpTNLP.hpp:106
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
Method to request either the sparsity structure or the values of the Jacobian of the constraints.
void operator=(const TNLP &)
Default Assignment Operator.
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)=0
Method to request bounds on the variables and constraints.
LinearityType
Linearity-types of variables and constraints.
Definition: IpTNLP.hpp:53
@ LINEAR
Constraint/Variable is linear.
Definition: IpTNLP.hpp:54
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
Definition: IpTNLP.hpp:104
TNLP(const TNLP &)
Copy Constructor.
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.
Definition: IpTNLP.hpp:126
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)=0
Method to request the constraint values.
#define IPOPTLIB_EXPORT
This file contains a base class for all exceptions and a set of macros to help with exceptions.
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:20
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
double Number
Type of all numbers.
Definition: IpTypes.hpp:15