Ipopt Documentation  
 
Loading...
Searching...
No Matches
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
13namespace Ipopt
14{
15// same as DECLARE_STD_EXCEPTION, but not using any export
17{
18public:
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
33private:
36 const SUFFIX_EMPTY&
37 );
38};
39
41{
45public:
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
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
141private:
142
144 // Number* x_L;
145 // Number* x_U;
148
150
153
158
159 std::vector<SmartPtr<IteratesVector> > sens_sol_;
160};
161
162}
163
164#endif
Ampl Interface, implemented as a TNLP.
Definition: AmplTNLP.hpp:317
Class for all IPOPT specific calculated quantities.
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:98
This is the base class for all exceptions.
Definition: IpException.hpp:58
SUFFIX_EMPTY(std::string msg, std::string fname, Ipopt::Index line)
SUFFIX_EMPTY(const SUFFIX_EMPTY &copy)
void operator=(const SUFFIX_EMPTY &)
void set_sens_solution(Index idx, SmartPtr< IteratesVector > sens_sol)
SmartPtr< const Journalist > jnlst_
local copy of current lower and upper bounds - needed for parameter change
std::vector< Index > 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.
std::vector< Number > get_number_suffix_vec(const char *suffix_name)
virtual ~SensAmplTNLP()
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...
Index n_sens_steps_
important Options
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 Number * get_number_suffix_constr(const char *suffix_name)
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< Index > get_index_suffix_constr_vec(const char *suffix_name)
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...
const Number * get_number_suffix(const char *suffix_name)
const Index * get_index_suffix_constr(const char *suffix_name)
std::vector< SmartPtr< IteratesVector > > sens_sol_
const Index * get_index_suffix(const char *suffix_name)
SmartPtr< OptionsList > options_
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
std::map< std::string, std::vector< Index > > IntegerMetaDataMapType
Definition: IpTNLP.hpp:105
std::map< std::string, std::vector< Number > > NumericMetaDataMapType
Definition: IpTNLP.hpp:106
std::map< std::string, std::vector< std::string > > StringMetaDataMapType
Definition: IpTNLP.hpp:104
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