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

#include <SensAmplTNLP.hpp>

+ Inheritance diagram for Ipopt::SensAmplTNLP:

Public Member Functions

 SensAmplTNLP (const SmartPtr< const Journalist > &jnlst, const SmartPtr< RegisteredOptions > regoptions, const SmartPtr< OptionsList > options, char **&argv, SmartPtr< AmplSuffixHandler > suffix_handler=NULL, bool allow_discrete=false, SmartPtr< AmplOptionsList > ampl_options_list=NULL, const char *ampl_option_string=NULL, const char *ampl_invokation_string=NULL, const char *ampl_banner_string=NULL, std::string *nl_file_content=NULL)
 This class is the Sens-wrapper for the ampltnlp, adapts the get bounds function and some others to our needs.
 
virtual ~SensAmplTNLP ()
 
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.
 
void set_sens_solution (Index idx, SmartPtr< IteratesVector > sens_sol)
 
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.
 
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.
 
const intget_index_suffix (const char *suffix_name)
 
std::vector< intget_index_suffix_vec (const char *suffix_name)
 
const Numberget_number_suffix (const char *suffix_name)
 
std::vector< Numberget_number_suffix_vec (const char *suffix_name)
 
const intget_index_suffix_constr (const char *suffix_name)
 
std::vector< intget_index_suffix_constr_vec (const char *suffix_name)
 
const Numberget_number_suffix_constr (const char *suffix_name)
 
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.
 
- Public Member Functions inherited from Ipopt::AmplTNLP
 DECLARE_STD_EXCEPTION (NONPOSITIVE_SCALING_FACTOR)
 Exceptions.
 
void set_active_objective (Index obj_no)
 A method for setting the index of the objective function to be considered.
 
SmartPtr< AmplSuffixHandlerget_suffix_handler ()
 Method for returning the suffix handler.
 
 AmplTNLP (const SmartPtr< const Journalist > &jnlst, const SmartPtr< RegisteredOptions > regoptions, const SmartPtr< OptionsList > options, const char *const *argv, SmartPtr< AmplSuffixHandler > suffix_handler=NULL, bool allow_discrete=false, SmartPtr< AmplOptionsList > ampl_options_list=NULL, const char *ampl_option_string=NULL, const char *ampl_invokation_string=NULL, const char *ampl_banner_string=NULL, std::string *nl_file_content=NULL)
 Constructor.
 
IPOPT_DEPRECATED AmplTNLP (const SmartPtr< const Journalist > &jnlst, const SmartPtr< OptionsList > options, char **&argv, SmartPtr< AmplSuffixHandler > suffix_handler=NULL, bool allow_discrete=false, SmartPtr< AmplOptionsList > ampl_options_list=NULL, const char *ampl_option_string=NULL, const char *ampl_invokation_string=NULL, const char *ampl_banner_string=NULL, std::string *nl_file_content=NULL)
 Constructor without RegisteredOptions.
 
virtual ~AmplTNLP ()
 Default destructor.
 
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_constraints_linearity (Index m, LinearityType *const_types)
 Method to request the constraints linearity.
 
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 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 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.
 
ASL_pfghAmplSolverObject ()
 Return the ampl solver object (ASL*)
 
void write_solution_file (const std::string &message) const
 Write the solution file.
 
void get_discrete_info (Index &nlvb_, Index &nlvbi_, Index &nlvc_, Index &nlvci_, Index &nlvo_, Index &nlvoi_, Index &nbv_, Index &niv_) const
 Give the number of binary and integer variables.
 
void set_string_metadata_for_var (const std::string &tag, const std::vector< std::string > &meta_data)
 
void set_integer_metadata_for_var (const std::string &tag, const std::vector< Index > &meta_data)
 
void set_numeric_metadata_for_var (const std::string &tag, const std::vector< Number > &meta_data)
 
void set_string_metadata_for_con (const std::string &tag, const std::vector< std::string > &meta_data)
 
void set_integer_metadata_for_con (const std::string &tag, const std::vector< Index > &meta_data)
 
void set_numeric_metadata_for_con (const std::string &tag, const std::vector< Number > &meta_data)
 
- Public Member Functions inherited from Ipopt::TNLP
 DECLARE_STD_EXCEPTION (INVALID_TNLP)
 
 TNLP ()
 
virtual ~TNLP ()
 Default destructor.
 
virtual bool get_variables_linearity (Index n, LinearityType *var_types)
 Method to request the variables 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 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.
 
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 Attributes

SmartPtr< const Journalistjnlst_
 local copy of current lower and upper bounds - needed for parameter change
 
SmartPtr< OptionsListoptions_
 
bool have_parameters_
 
Indexparameter_flags_
 
Numberparameter_values_
 
Index n_sens_steps_
 important Options
 
bool run_sens_
 
bool compute_red_hessian_
 
std::vector< SmartPtr< IteratesVector > > sens_sol_
 

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
 
- Protected Member Functions inherited from Ipopt::AmplTNLP
bool internal_objval (const Number *x, Number &obj_val)
 Make the objective call to ampl.
 
bool internal_conval (const Number *x, Index m, Number *g=NULL)
 Make the constraint call to ampl.
 
bool 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.
 
charget_options (const SmartPtr< RegisteredOptions > regoptions, const SmartPtr< OptionsList > &options, SmartPtr< AmplOptionsList > &ampl_options_list, const char *ampl_option_string, const char *ampl_invokation_string, const char *ampl_banner_string, const char *const *argv)
 Method for obtaining the name of the NL file and the options set from AMPL.
 
IPOPT_DEPRECATED charget_options (const SmartPtr< OptionsList > &options, SmartPtr< AmplOptionsList > &ampl_options_list, const char *ampl_option_string, const char *ampl_invokation_string, const char *ampl_banner_string, char **&argv)
 Method for obtaining the name of the NL file and the options set from AMPL.
 
bool nerror_ok (void *nerror)
 whether the ampl nerror code is ok
 
void call_hesset ()
 calls hesset ASL function
 
- Protected Attributes inherited from Ipopt::AmplTNLP
SmartPtr< const Journalistjnlst_
 Journalist.
 
ASL_pfghasl_
 pointer to the main ASL structure
 
Number obj_sign_
 Sign of the objective fn (1 for min, -1 for max)
 
voidOinfo_ptr_
 Pointer to the Oinfo structure.
 
voidnerror_
 nerror flag passed to ampl calls - set to NULL to halt on error
 
SmartPtr< AmplSuffixHandlersuffix_handler_
 Suffix Handler.
 
StringMetaDataMapType var_string_md_
 meta data to pass on to TNLP
 
IntegerMetaDataMapType var_integer_md_
 
NumericMetaDataMapType var_numeric_md_
 
StringMetaDataMapType con_string_md_
 
IntegerMetaDataMapType con_integer_md_
 
NumericMetaDataMapType con_numeric_md_
 
Index nz_h_full_
 number of nonzeros in the full_x Hessian
 
Numberx_sol_
 
Numberz_L_sol_
 
Numberz_U_sol_
 
Numberg_sol_
 
Numberlambda_sol_
 
Number obj_sol_
 
bool objval_called_with_current_x_
 whether the objective value has been calculated with the current x
 
bool conval_called_with_current_x_
 whether the constraint values have been calculated with the current x set to false in apply_new_x, and set to true in internal_conval
 
bool hesset_called_
 whether we have called hesset
 
bool set_active_objective_called_
 whether set_active_objective has been called
 

Detailed Description

Definition at line 40 of file SensAmplTNLP.hpp.

Constructor & Destructor Documentation

◆ SensAmplTNLP()

Ipopt::SensAmplTNLP::SensAmplTNLP ( const SmartPtr< const Journalist > &  jnlst,
const SmartPtr< RegisteredOptions regoptions,
const SmartPtr< OptionsList options,
char **&  argv,
SmartPtr< AmplSuffixHandler suffix_handler = NULL,
bool  allow_discrete = false,
SmartPtr< AmplOptionsList ampl_options_list = NULL,
const char ampl_option_string = NULL,
const char ampl_invokation_string = NULL,
const char ampl_banner_string = NULL,
std::string *  nl_file_content = NULL 
)

This class is the Sens-wrapper for the ampltnlp, adapts the get bounds function and some others to our needs.

constructor

◆ ~SensAmplTNLP()

virtual Ipopt::SensAmplTNLP::~SensAmplTNLP ( )
virtual

Member Function Documentation

◆ get_bounds_info()

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

returns bounds of the nlp.

Overloaded from AmplTNLP

Reimplemented from Ipopt::AmplTNLP.

◆ set_sens_solution()

void Ipopt::SensAmplTNLP::set_sens_solution ( Index  idx,
SmartPtr< IteratesVector sens_sol 
)

◆ finalize_metadata()

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

This method returns any metadata collected during the run of the algorithm.

This method is called just before finalize_solution is called. The returned data includes the metadata provided by TNLP::get_var_con_metadata. Each metadata can be of type string, integer, or numeric. It can be associated to either the variables or the constraints. The metadata that was associated with the primal variable vector is stored in var_..._md. The metadata associated with the constraint multipliers is stored in con_..._md. The metadata associated with the bound multipliers is stored in var_..._md, with the suffixes "_z_L", and "_z_U", denoting lower and upper bounds.

If the user doesn't overload this method in her implementation of the class derived from TNLP, the default implementation does nothing.

Reimplemented from Ipopt::TNLP.

◆ finalize_solution()

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

Reimplemented from Ipopt::AmplTNLP.

◆ get_index_suffix()

const int * Ipopt::SensAmplTNLP::get_index_suffix ( const char suffix_name)

◆ get_index_suffix_vec()

std::vector< int > Ipopt::SensAmplTNLP::get_index_suffix_vec ( const char suffix_name)

◆ get_number_suffix()

const Number * Ipopt::SensAmplTNLP::get_number_suffix ( const char suffix_name)

◆ get_number_suffix_vec()

std::vector< Number > Ipopt::SensAmplTNLP::get_number_suffix_vec ( const char suffix_name)

◆ get_index_suffix_constr()

const int * Ipopt::SensAmplTNLP::get_index_suffix_constr ( const char suffix_name)

◆ get_index_suffix_constr_vec()

std::vector< int > Ipopt::SensAmplTNLP::get_index_suffix_constr_vec ( const char suffix_name)

◆ get_number_suffix_constr()

const Number * Ipopt::SensAmplTNLP::get_number_suffix_constr ( const char suffix_name)

◆ get_var_con_metadata()

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

Method to request meta data for the variables and the constraints.

This method is used to pass meta data about variables or constraints to Ipopt. The data can be either of integer, numeric, or string type. Ipopt passes this data on to its internal problem representation. The meta data type is a std::map with std::string as key type and a std::vector as value type. So far, Ipopt itself makes only use of string meta data under the key idx_names. With this key, variable and constraint names can be passed to Ipopt, which are shown when printing internal vector or matrix data structures if Ipopt is run with a high value for the option. This allows a user to identify the original variables and constraints corresponding to Ipopt's internal problem representation.

If this method is not overloaded, the default implementation does not set any meta data and returns false.

Reimplemented from Ipopt::AmplTNLP.

Member Data Documentation

◆ jnlst_

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

local copy of current lower and upper bounds - needed for parameter change

Definition at line 147 of file SensAmplTNLP.hpp.

◆ options_

SmartPtr<OptionsList> Ipopt::SensAmplTNLP::options_
private

Definition at line 148 of file SensAmplTNLP.hpp.

◆ have_parameters_

bool Ipopt::SensAmplTNLP::have_parameters_
private

Definition at line 150 of file SensAmplTNLP.hpp.

◆ parameter_flags_

Index* Ipopt::SensAmplTNLP::parameter_flags_
private

Definition at line 152 of file SensAmplTNLP.hpp.

◆ parameter_values_

Number* Ipopt::SensAmplTNLP::parameter_values_
private

Definition at line 153 of file SensAmplTNLP.hpp.

◆ n_sens_steps_

Index Ipopt::SensAmplTNLP::n_sens_steps_
private

important Options

Definition at line 156 of file SensAmplTNLP.hpp.

◆ run_sens_

bool Ipopt::SensAmplTNLP::run_sens_
private

Definition at line 157 of file SensAmplTNLP.hpp.

◆ compute_red_hessian_

bool Ipopt::SensAmplTNLP::compute_red_hessian_
private

Definition at line 158 of file SensAmplTNLP.hpp.

◆ sens_sol_

std::vector<SmartPtr<IteratesVector> > Ipopt::SensAmplTNLP::sens_sol_
private

Definition at line 160 of file SensAmplTNLP.hpp.


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