7#ifndef __IPAMPLTNLP_HPP__
8#define __IPAMPLTNLP_HPP__
48 const std::string& suffix_string,
53 suffix_ids_.push_back(suffix_string);
54 suffix_types_.push_back(type);
55 suffix_sources_.push_back(source);
60 const std::string& suffix_string,
65 const std::string& suffix_string,
71 const std::string& suffix_string,
77 const std::string& suffix_string,
143 const std::string& ipopt_option_name,
145 const std::string& description);
149 delete[] description_;
154 return ipopt_option_name_;
196 const std::string& ipopt_name,
201 : ipopt_name_(ipopt_name),
242 const std::string& ampl_option_name,
243 const std::string& ipopt_option_name,
245 const std::string& description
249 ampl_options_map_[ampl_option_name] =
ConstPtr(new_option);
255 return (
Index) ampl_options_map_.size();
328 const char*
const* argv,
330 bool allow_discrete =
false,
332 const char* ampl_option_string = NULL,
333 const char* ampl_invokation_string = NULL,
334 const char* ampl_banner_string = NULL,
335 std::string* nl_file_content = NULL
348 bool allow_discrete =
false,
350 const char* ampl_option_string = NULL,
351 const char* ampl_invokation_string = NULL,
352 const char* ampl_banner_string = NULL,
353 std::string* nl_file_content = NULL
490 Index num_nonlin_vars,
491 Index* pos_nonlin_vars
509 const std::string& message
547 const std::string& tag,
548 const std::vector<std::string>& meta_data
551 var_string_md_[tag] = meta_data;
555 const std::string& tag,
556 const std::vector<Index>& meta_data
559 var_integer_md_[tag] = meta_data;
563 const std::string& tag,
564 const std::vector<Number>& meta_data
567 var_numeric_md_[tag] = meta_data;
571 const std::string& tag,
572 const std::vector<std::string>& meta_data
575 con_string_md_[tag] = meta_data;
579 const std::string& tag,
580 const std::vector<Index>& meta_data
583 con_integer_md_[tag] = meta_data;
587 const std::string& tag,
588 const std::vector<Number>& meta_data
591 con_numeric_md_[tag] = meta_data;
598 return suffix_handler_;
629 const char*
const* argv,
630 bool allow_discrete ,
632 const char* ampl_option_string ,
633 const char* ampl_invokation_string ,
634 const char* ampl_banner_string ,
635 std::string* nl_file_content
721 const char* ampl_option_string,
722 const char* ampl_invokation_string,
723 const char* ampl_banner_string,
724 const char*
const* argv
736 const char* ampl_option_string,
737 const char* ampl_invokation_string,
738 const char* ampl_banner_string,
743 return get_options(NULL, options, ampl_options_list, ampl_option_string, ampl_invokation_string, ampl_banner_string, argv);
#define IPOPT_DEPRECATED
macro to declare symbols as deprecated
Ampl Option class containing name, type and description for an AMPL option.
const std::string & IpoptOptionName() const
AmplOptionType Type() const
AmplOption()
Default Constructor.
AmplOption(const std::string &ipopt_option_name, AmplOptionType type, const std::string &description)
const std::string ipopt_option_name_
void operator=(const AmplOption &)
Default Assignment Operator.
const AmplOptionType type_
AmplOption(const AmplOption &)
Copy Constructor.
char * Description() const
const SmartPtr< OptionsList > & Options() const
const SmartPtr< const Journalist > jnlst_
const SmartPtr< const Journalist > & Jnlst() const
const SmartPtr< OptionsList > options_
const std::string ipopt_name_
const std::string & IpoptName() const
PrivatInfo(const std::string &ipopt_name, SmartPtr< OptionsList > options, SmartPtr< const Journalist > jnlst, void **nerror=NULL)
Class for storing a number of AMPL options that should be registered to the AMPL Solver library inter...
void AddAmplOption(const std::string &l_option_name, const std::string &ipopt_option_name, AmplOptionsList::AmplOptionType type, const std::string &description)
Adding a new AMPL Option.
void PrintLatex(SmartPtr< const Journalist > jnlst)
AmplOptionsList(const AmplOptionsList &)
Default Constructor.
void * Keywords(const SmartPtr< OptionsList > &options, SmartPtr< const Journalist > jnlst, void **nerror)
ASL keywords list for the stored options.
@ WS_Option
this is for AMPL's internal wantsol callback
Index NumberOfAmplOptions()
Number of AMPL Options.
void * keywds_
pointer to the keywords
void PrintDoxygen(SmartPtr< const Journalist > jnlst)
void MakeValidLatexString(std::string source, std::string &dest) const
Index nkeywds_
Number of entries stored in keywds_.
~AmplOptionsList()
Destructor.
void operator=(const AmplOptionsList &)
Default Assignment Operator.
std::map< std::string, SmartPtr< const AmplOption > > ampl_options_map_
map for storing registered AMPL options
AmplOptionsList()
Default Constructor.
const int * GetIntegerSuffixValues(const std::string &suffix_string, Suffix_Source source) const
std::vector< Number > GetNumberSuffixValues(Index n, const std::string &suffix_string, Suffix_Source source) const
std::vector< int > GetIntegerSuffixValues(Index n, const std::string &suffix_string, Suffix_Source source) const
std::vector< Suffix_Source > suffix_sources_
std::vector< std::string > suffix_ids_
void operator=(const AmplSuffixHandler &)
Default Assignment Operator.
const Number * GetNumberSuffixValues(const std::string &suffix_string, Suffix_Source source) const
void PrepareAmplForSuffixes(ASL_pfgh *asl)
Method called by AmplTNLP to prepare the asl for the suffixes.
void AddAvailableSuffix(const std::string &suffix_string, Suffix_Source source, Suffix_Type type)
std::vector< Suffix_Type > suffix_types_
AmplSuffixHandler(const AmplSuffixHandler &)
Default Constructor.
Ampl Interface, implemented as a TNLP.
void * Oinfo_ptr_
Pointer to the Oinfo structure.
SmartPtr< AmplSuffixHandler > get_suffix_handler()
Method for returning the suffix handler.
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.
SmartPtr< AmplSuffixHandler > suffix_handler_
Suffix Handler.
StringMetaDataMapType con_string_md_
void set_string_metadata_for_con(const std::string &tag, const std::vector< std::string > &meta_data)
Number obj_sign_
Sign of the objective fn (1 for min, -1 for max)
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...
AmplTNLP(const AmplTNLP &)
Copy Constructor.
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.
ASL_pfgh * AmplSolverObject()
Return the ampl solver object (ASL*)
Index nz_h_full_
number of nonzeros in the full_x Hessian
void gutsOfConstructor(const SmartPtr< RegisteredOptions > regoptions, const SmartPtr< OptionsList > options, const char *const *argv, bool allow_discrete, SmartPtr< AmplOptionsList > ampl_options_list, const char *ampl_option_string, const char *ampl_invokation_string, const char *ampl_banner_string, std::string *nl_file_content)
IntegerMetaDataMapType var_integer_md_
DECLARE_STD_EXCEPTION(NONPOSITIVE_SCALING_FACTOR)
Exceptions.
StringMetaDataMapType var_string_md_
meta data to pass on to TNLP
bool hesset_called_
whether we have called hesset
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.
AmplTNLP()
Default 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.
SmartPtr< const Journalist > jnlst_
Journalist.
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 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.
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_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
Method to request the gradient of the objective function.
NumericMetaDataMapType var_numeric_md_
virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, Index *pos_nonlin_vars)
Return the indices of all nonlinear variables.
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 get_constraints_linearity(Index m, LinearityType *const_types)
Method to request the constraints linearity.
NumericMetaDataMapType con_numeric_md_
void set_numeric_metadata_for_con(const std::string &tag, const std::vector< Number > &meta_data)
bool internal_conval(const Number *x, Index m, Number *g=NULL)
Make the constraint call to ampl.
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.
char * get_options(const SmartPtr< RegisteredOptions > regoptions, const SmartPtr< OptionsList > &options, SmartPtr< AmplOptionsList > &l_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.
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.
void set_string_metadata_for_var(const std::string &tag, const std::vector< std::string > &meta_data)
IPOPT_DEPRECATED char * get_options(const SmartPtr< OptionsList > &options, SmartPtr< AmplOptionsList > &l_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.
virtual ~AmplTNLP()
Default destructor.
void write_solution_file(const std::string &message) const
Write the solution file.
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 get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
returns bounds of the nlp.
bool conval_called_with_current_x_
whether the constraint values have been calculated with the current x set to false in apply_new_x,...
void set_numeric_metadata_for_var(const std::string &tag, const std::vector< Number > &meta_data)
void call_hesset()
calls hesset ASL function
void set_integer_metadata_for_var(const std::string &tag, const std::vector< Index > &meta_data)
void * nerror_
nerror flag passed to ampl calls - set to NULL to halt on error
bool objval_called_with_current_x_
whether the objective value has been calculated with the current x
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.
bool internal_objval(const Number *x, Number &obj_val)
Make the objective call to ampl.
void set_integer_metadata_for_con(const std::string &tag, const std::vector< Index > &meta_data)
bool set_active_objective_called_
whether set_active_objective has been called
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.
void operator=(const AmplTNLP &)
Default Assignment Operator.
IntegerMetaDataMapType con_integer_md_
void set_active_objective(Index obj_no)
A method for setting the index of the objective function to be considered.
bool nerror_ok(void *nerror)
whether the ampl nerror code is ok
ASL_pfgh * asl_
pointer to the main ASL structure
Class for all IPOPT specific calculated quantities.
Class to organize all the data required by the algorithm.
Storing the reference count of all the smart pointers that currently reference it.
Template class for Smart Pointers.
Base class for all NLP's that use standard triplet matrix form and dense vectors.
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
LinearityType
Linearity-types of variables and constraints.
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
This file contains a base class for all exceptions and a set of macros to help with exceptions.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
SolverReturn
enum for the return from the optimize algorithm
ipindex Index
Type of all indices of vectors, matrices etc.
ipnumber Number
Type of all numbers.