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:
34  SUFFIX_EMPTY();
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<RegisteredOptions> regoptions,
50  const SmartPtr<OptionsList> options,
51  char**& argv,
52  SmartPtr<AmplSuffixHandler> suffix_handler = NULL,
53  bool allow_discrete = false,
54  SmartPtr<AmplOptionsList> ampl_options_list = NULL,
55  const char* ampl_option_string = NULL,
56  const char* ampl_invokation_string = NULL,
57  const char* ampl_banner_string = NULL,
58  std::string* nl_file_content = NULL,
59  bool checkinterrupt = false
60  );
61 
62  virtual ~SensAmplTNLP();
63 
65  virtual bool get_bounds_info(
66  Index n,
67  Number* x_l,
68  Number* x_u,
69  Index m,
70  Number* g_l,
71  Number* g_u
72  );
73 
74  void set_sens_solution(
75  Index idx,
77  );
78 
79  virtual void finalize_metadata(
80  Index n,
81  const StringMetaDataMapType& var_string_md,
82  const IntegerMetaDataMapType& var_integer_md,
83  const NumericMetaDataMapType& var_numeric_md,
84  Index m,
85  const StringMetaDataMapType& con_string_md,
86  const IntegerMetaDataMapType& con_integer_md,
87  const NumericMetaDataMapType& con_numeric_md
88  );
89 
90  virtual void finalize_solution(
91  SolverReturn status,
92  Index n,
93  const Number* x,
94  const Number* z_L,
95  const Number* z_U,
96  Index m,
97  const Number* g,
98  const Number* lambda,
99  Number obj_value,
100  const IpoptData* ip_data,
102  );
103 
104  const int* get_index_suffix(
105  const char* suffix_name
106  );
107 
108  std::vector<int> get_index_suffix_vec(
109  const char* suffix_name
110  );
111 
112  const Number* get_number_suffix(
113  const char* suffix_name
114  );
115 
116  std::vector<Number> get_number_suffix_vec(
117  const char* suffix_name
118  );
119 
120  const int* get_index_suffix_constr(
121  const char* suffix_name
122  );
123 
124  std::vector<int> get_index_suffix_constr_vec(
125  const char* suffix_name
126  );
127 
129  const char* suffix_name
130  );
131 
132  virtual bool get_var_con_metadata(
133  Index n,
134  StringMetaDataMapType& var_string_md,
135  IntegerMetaDataMapType& var_integer_md,
136  NumericMetaDataMapType& var_numeric_md,
137  Index m,
138  StringMetaDataMapType& con_string_md,
139  IntegerMetaDataMapType& con_integer_md,
140  NumericMetaDataMapType& con_numeric_md
141  );
142 
143 private:
144 
146  // Number* x_L;
147  // Number* x_U;
150 
152 
155 
158  bool run_sens_;
160 
161  std::vector<SmartPtr<IteratesVector> > sens_sol_;
162 };
163 
164 }
165 
166 #endif
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
Definition: IpTNLP.hpp:72
void set_sens_solution(Index idx, SmartPtr< IteratesVector > sens_sol)
Class for all IPOPT specific calculated quantities.
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, bool checkinterrupt=false)
This class is the Sens-wrapper for the ampltnlp, adapts the get bounds function and some others to ou...
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.
const int * get_index_suffix(const char *suffix_name)
This is the base class for all exceptions.
Definition: IpException.hpp:57
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...
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
This file contains a base class for all exceptions and a set of macros to help with exceptions...
void operator=(const SUFFIX_EMPTY &)
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
SolverReturn
enum for the return from the optimize algorithm
Definition: IpAlgTypes.hpp:19
SmartPtr< const Journalist > jnlst_
local copy of current lower and upper bounds - needed for parameter change
const Number * get_number_suffix(const char *suffix_name)
std::vector< Number > get_number_suffix_vec(const char *suffix_name)
Class to organize all the data required by the algorithm.
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
const Number * get_number_suffix_constr(const char *suffix_name)
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
Definition: IpTNLP.hpp:71
Index n_sens_steps_
important Options
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
Definition: IpTNLP.hpp:70
Ampl Interface, implemented as a TNLP.
Definition: AmplTNLP.hpp:316
virtual ~SensAmplTNLP()
const int * get_index_suffix_constr(const char *suffix_name)
std::vector< int > get_index_suffix_constr_vec(const char *suffix_name)
SUFFIX_EMPTY(const SUFFIX_EMPTY &copy)
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.
std::vector< SmartPtr< IteratesVector > > sens_sol_
SUFFIX_EMPTY(std::string msg, std::string fname, Ipopt::Index line)
std::vector< int > get_index_suffix_vec(const char *suffix_name)
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.
SmartPtr< OptionsList > options_