Ipopt Documentation  
SensAmplTNLP.hpp
Go to the documentation of this file.
1 // Copyright 2009 Hans Pirnay
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Date : 2009-05-11
6 
7 #ifndef __SENSAMPLTNLP_HPP__
8 #define __SENSAMPLTNLP_HPP__
9 
10 #include "AmplTNLP.hpp"
11 #include "SensUtils.hpp"
12 
13 namespace Ipopt
14 {
15 // same as DECLARE_STD_EXCEPTION, but not using any export
17 {
18 public:
20  std::string msg,
21  std::string fname,
22  Ipopt::Index line
23  )
24  : Ipopt::IpoptException(msg, fname, line, "SUFFIX_EMPTY")
25  { }
26 
28  const SUFFIX_EMPTY& copy
29  )
30  : Ipopt::IpoptException(copy)
31  { }
32 
33 private:
35  void operator=(
36  const SUFFIX_EMPTY&
37  );
38 };
39 
40 class SensAmplTNLP: public AmplTNLP
41 {
45 public:
48  const SmartPtr<const Journalist>& jnlst,
49  const SmartPtr<OptionsList> options,
50  char**& argv,
51  SmartPtr<AmplSuffixHandler> suffix_handler = NULL,
52  bool allow_discrete = false,
53  SmartPtr<AmplOptionsList> ampl_options_list = NULL,
54  const char* ampl_option_string = NULL,
55  const char* ampl_invokation_string = NULL,
56  const char* ampl_banner_string = NULL,
57  std::string* nl_file_content = NULL
58  );
59 
60  virtual ~SensAmplTNLP();
61 
63  virtual bool get_bounds_info(
64  Index n,
65  Number* x_l,
66  Number* x_u,
67  Index m,
68  Number* g_l,
69  Number* g_u
70  );
71 
73  Index idx,
75  );
76 
77  virtual void finalize_metadata(
78  Index n,
79  const StringMetaDataMapType& var_string_md,
80  const IntegerMetaDataMapType& var_integer_md,
81  const NumericMetaDataMapType& var_numeric_md,
82  Index m,
83  const StringMetaDataMapType& con_string_md,
84  const IntegerMetaDataMapType& con_integer_md,
85  const NumericMetaDataMapType& con_numeric_md
86  );
87 
88  virtual void finalize_solution(
89  SolverReturn status,
90  Index n,
91  const Number* x,
92  const Number* z_L,
93  const Number* z_U,
94  Index m,
95  const Number* g,
96  const Number* lambda,
97  Number obj_value,
98  const IpoptData* ip_data,
100  );
101 
103  const char* suffix_name
104  );
105 
106  std::vector<Index> get_index_suffix_vec(
107  const char* suffix_name
108  );
109 
111  const char* suffix_name
112  );
113 
114  std::vector<Number> get_number_suffix_vec(
115  const char* suffix_name
116  );
117 
119  const char* suffix_name
120  );
121 
122  std::vector<Index> get_index_suffix_constr_vec(
123  const char* suffix_name
124  );
125 
127  const char* suffix_name
128  );
129 
130  virtual bool get_var_con_metadata(
131  Index n,
132  StringMetaDataMapType& var_string_md,
133  IntegerMetaDataMapType& var_integer_md,
134  NumericMetaDataMapType& var_numeric_md,
135  Index m,
136  StringMetaDataMapType& con_string_md,
137  IntegerMetaDataMapType& con_integer_md,
138  NumericMetaDataMapType& con_numeric_md
139  );
140 
141 private:
142 
144  // Number* x_L;
145  // Number* x_U;
148 
150 
153 
156  bool run_sens_;
158 
159  std::vector<SmartPtr<IteratesVector> > sens_sol_;
160 };
161 
162 }
163 
164 #endif
Ipopt::SensAmplTNLP::compute_red_hessian_
bool compute_red_hessian_
Definition: SensAmplTNLP.hpp:157
Ipopt::IpoptData
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:98
Ipopt::SensAmplTNLP::n_sens_steps_
Index n_sens_steps_
important Options
Definition: SensAmplTNLP.hpp:155
SensUtils.hpp
Ipopt::SensAmplTNLP::get_index_suffix_constr
const Index * get_index_suffix_constr(const char *suffix_name)
Ipopt::SUFFIX_EMPTY
Definition: SensAmplTNLP.hpp:17
Ipopt::AmplTNLP
Ampl Interface, implemented as a TNLP.
Definition: AmplTNLP.hpp:317
Ipopt::IpoptCalculatedQuantities
Class for all IPOPT specific calculated quantities.
Definition: IpIpoptCalculatedQuantities.hpp:89
Ipopt::TNLP::IntegerMetaDataMapType
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
Definition: IpTNLP.hpp:105
Ipopt
This file contains a base class for all exceptions and a set of macros to help with exceptions.
Definition: IpInexactAlgBuilder.hpp:14
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
Ipopt::SensAmplTNLP
Definition: SensAmplTNLP.hpp:41
Ipopt::SensAmplTNLP::get_number_suffix
const Number * get_number_suffix(const char *suffix_name)
Ipopt::SensAmplTNLP::parameter_flags_
Index * parameter_flags_
Definition: SensAmplTNLP.hpp:151
Ipopt::SUFFIX_EMPTY::SUFFIX_EMPTY
SUFFIX_EMPTY(std::string msg, std::string fname, Ipopt::Index line)
Definition: SensAmplTNLP.hpp:19
Ipopt::SensAmplTNLP::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::IpoptException
This is the base class for all exceptions.
Definition: IpException.hpp:58
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
Ipopt::SensAmplTNLP::run_sens_
bool run_sens_
Definition: SensAmplTNLP.hpp:156
Ipopt::SensAmplTNLP::~SensAmplTNLP
virtual ~SensAmplTNLP()
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
AmplTNLP.hpp
Ipopt::SensAmplTNLP::sens_sol_
std::vector< SmartPtr< IteratesVector > > sens_sol_
Definition: SensAmplTNLP.hpp:159
Ipopt::SensAmplTNLP::get_number_suffix_constr
const Number * get_number_suffix_constr(const char *suffix_name)
Ipopt::SUFFIX_EMPTY::SUFFIX_EMPTY
SUFFIX_EMPTY(const SUFFIX_EMPTY &copy)
Definition: SensAmplTNLP.hpp:27
Ipopt::TNLP::NumericMetaDataMapType
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
Definition: IpTNLP.hpp:106
Ipopt::SensAmplTNLP::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 has finished (successfully or not) so the TNLP can digest th...
Ipopt::SensAmplTNLP::get_index_suffix_constr_vec
std::vector< Index > get_index_suffix_constr_vec(const char *suffix_name)
Ipopt::SensAmplTNLP::options_
SmartPtr< OptionsList > options_
Definition: SensAmplTNLP.hpp:147
Ipopt::SensAmplTNLP::have_parameters_
bool have_parameters_
Definition: SensAmplTNLP.hpp:149
Ipopt::SUFFIX_EMPTY::operator=
void operator=(const SUFFIX_EMPTY &)
Ipopt::SensAmplTNLP::get_index_suffix_vec
std::vector< Index > get_index_suffix_vec(const char *suffix_name)
Ipopt::TNLP::StringMetaDataMapType
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
Definition: IpTNLP.hpp:104
Ipopt::SensAmplTNLP::get_number_suffix_vec
std::vector< Number > get_number_suffix_vec(const char *suffix_name)
Ipopt::SUFFIX_EMPTY::SUFFIX_EMPTY
SUFFIX_EMPTY()
Ipopt::SensAmplTNLP::finalize_metadata
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.
Ipopt::SolverReturn
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:20
Ipopt::SensAmplTNLP::set_sens_solution
void set_sens_solution(Index idx, SmartPtr< IteratesVector > sens_sol)
Ipopt::SensAmplTNLP::get_var_con_metadata
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.
Ipopt::SensAmplTNLP::get_index_suffix
const Index * get_index_suffix(const char *suffix_name)
Ipopt::SensAmplTNLP::SensAmplTNLP
SensAmplTNLP(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)
This class is the Sens-wrapper for the ampltnlp, adapts the get bounds function and some others to ou...
Ipopt::SensAmplTNLP::parameter_values_
Number * parameter_values_
Definition: SensAmplTNLP.hpp:152
Ipopt::SensAmplTNLP::jnlst_
SmartPtr< const Journalist > jnlst_
local copy of current lower and upper bounds - needed for parameter change
Definition: SensAmplTNLP.hpp:146