Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MittelmannBndryCntrlDiri.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: MittelmannBndryCntrlDiri.hpp 2005 2011-06-06 12:55:16Z stefan $
6 //
7 // Authors: Andreas Waechter IBM 2005-10-18
8 // based on MyNLP.hpp
9
10 #ifndef __MITTELMANNBNDRYCNTRLDIRI_HPP__
11 #define __MITTELMANNBNDRYCNTRLDIRI_HPP__
12
13 #include "RegisteredTNLP.hpp"
14
15 #ifdef HAVE_CONFIG_H
16 #include "config.h"
17 #else
18 #include "configall_system.h"
19 #endif
20
21 #ifdef HAVE_CMATH
22 # include <cmath>
23 #else
24 # ifdef HAVE_MATH_H
25 # include <math.h>
26 # else
27 # error "don't have header file for math"
28 # endif
29 #endif
30
31 #ifdef HAVE_CSTDIO
32 # include <cstdio>
33 #else
34 # ifdef HAVE_STDIO_H
35 # include <stdio.h>
36 # else
37 # error "don't have header file for stdio"
38 # endif
39 #endif
40
41 using namespace Ipopt;
42
52 class MittelmannBndryCntrlDiriBase : public RegisteredTNLP
53 {
54 public:
56 MittelmannBndryCntrlDiriBase();
57
59 virtual ~MittelmannBndryCntrlDiriBase();
60
64 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
65 Index& nnz_h_lag, IndexStyleEnum& index_style);
66
68 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
69 Index m, Number* g_l, Number* g_u);
70
72 virtual bool get_starting_point(Index n, bool init_x, Number* x,
73 bool init_z, Number* z_L, Number* z_U,
74 Index m, bool init_lambda,
75 Number* lambda);
76
78 virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
79
81 virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
82
84 virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
85
90 virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
91 Index m, Index nele_jac, Index* iRow, Index *jCol,
92 Number* values);
93
98 virtual bool eval_h(Index n, const Number* x, bool new_x,
99 Number obj_factor, Index m, const Number* lambda,
100 bool new_lambda, Index nele_hess, Index* iRow,
101 Index* jCol, Number* values);
102
104
106 virtual bool get_scaling_parameters(Number& obj_scaling,
107 bool& use_x_scaling, Index n,
108 Number* x_scaling,
109 bool& use_g_scaling, Index m,
110 Number* g_scaling);
111
116 virtual void finalize_solution(SolverReturn status,
117 Index n, const Number* x, const Number* z_L, const Number* z_U,
118 Index m, const Number* g, const Number* lambda,
119 Number obj_valu,
120 const IpoptData* ip_data,
121 IpoptCalculatedQuantities* ip_cq);
123
124 protected:
128 void SetBaseParameters(Index N, Number alpha, Number lb_y,
129 Number ub_y, Number lb_u, Number ub_u,
130 Number d_const);
131
135 virtual Number y_d_cont(Number x1, Number x2) const =0;
137
138 private:
150 MittelmannBndryCntrlDiriBase(const MittelmannBndryCntrlDiriBase&);
151 MittelmannBndryCntrlDiriBase& operator=(const MittelmannBndryCntrlDiriBase&);
153
157 Index N_;
159 Number h_;
161 Number hh_;
163 Number lb_y_;
165 Number ub_y_;
167 Number lb_u_;
169 Number ub_u_;
171 Number d_const_;
174 Number alpha_;
176 Number* y_d_;
178
183 inline Index y_index(Index i, Index j) const
184 {
185 return j + (N_+2)*i;
186 }
189 inline Index pde_index(Index i, Index j) const
190 {
191 return (j-1) + N_*(i-1);
192 }
194 inline Number x1_grid(Index i) const
195 {
196 return h_*(Number)i;
197 }
199 inline Number x2_grid(Index i) const
200 {
201 return h_*(Number)i;
202 }
204 };
205
207 class MittelmannBndryCntrlDiri1 : public MittelmannBndryCntrlDiriBase
208 {
209 public:
210 MittelmannBndryCntrlDiri1()
211 {}
212
213 virtual ~MittelmannBndryCntrlDiri1()
214 {}
215
216 virtual bool InitializeProblem(Index N)
217 {
218 if (N<1) {
219 printf("N has to be at least 1.");
220 return false;
221 }
222 Number alpha = 0.01;
223 Number lb_y = -1e20;
224 Number ub_y = 3.5;
225 Number lb_u = 0.;
226 Number ub_u = 10.;
227 Number d_const = -20.;
228 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
229 return true;
230 }
231 protected:
233 virtual Number y_d_cont(Number x1, Number x2) const
234 {
235 return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.));
236 }
237 private:
240 MittelmannBndryCntrlDiri1(const MittelmannBndryCntrlDiri1&);
241 MittelmannBndryCntrlDiri1& operator=(const MittelmannBndryCntrlDiri1&);
243 };
244
246 class MittelmannBndryCntrlDiri2 : public MittelmannBndryCntrlDiriBase
247 {
248 public:
249 MittelmannBndryCntrlDiri2()
250 {}
251
252 virtual ~MittelmannBndryCntrlDiri2()
253 {}
254
255 virtual bool InitializeProblem(Index N)
256 {
257 if (N<1) {
258 printf("N has to be at least 1.");
259 return false;
260 }
261 Number alpha = 0.;
262 Number lb_y = -1e20;
263 Number ub_y = 3.5;
264 Number lb_u = 0.;
265 Number ub_u = 10.;
266 Number d_const = -20.;
267 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
268 return true;
269 }
270 protected:
272 virtual Number y_d_cont(Number x1, Number x2) const
273 {
274 return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.));
275 }
276 private:
279 MittelmannBndryCntrlDiri2(const MittelmannBndryCntrlDiri2&);
280 MittelmannBndryCntrlDiri2& operator=(const MittelmannBndryCntrlDiri2&);
282 };
283
285 class MittelmannBndryCntrlDiri3 : public MittelmannBndryCntrlDiriBase
286 {
287 public:
288 MittelmannBndryCntrlDiri3()
289 {}
290
291 virtual ~MittelmannBndryCntrlDiri3()
292 {}
293
294 virtual bool InitializeProblem(Index N)
295 {
296 if (N<1) {
297 printf("N has to be at least 1.");
298 return false;
299 }
300 Number alpha = 0.01;
301 Number lb_y = -1e20;
302 Number ub_y = 3.2;
303 Number lb_u = 1.6;
304 Number ub_u = 2.3;
305 Number d_const = -20.;
306 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
307 return true;
308 }
309 protected:
311 virtual Number y_d_cont(Number x1, Number x2) const
312 {
313 return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.));
314 }
315 private:
318 MittelmannBndryCntrlDiri3(const MittelmannBndryCntrlDiri3&);
319 MittelmannBndryCntrlDiri3& operator=(const MittelmannBndryCntrlDiri3&);
321 };
322
324 class MittelmannBndryCntrlDiri4 : public MittelmannBndryCntrlDiriBase
325 {
326 public:
327 MittelmannBndryCntrlDiri4()
328 {}
329
330 virtual ~MittelmannBndryCntrlDiri4()
331 {}
332
333 virtual bool InitializeProblem(Index N)
334 {
335 if (N<1) {
336 printf("N has to be at least 1.");
337 return false;
338 }
339 Number alpha = 0.;
340 Number lb_y = -1e20;
341 Number ub_y = 3.2;
342 Number lb_u = 1.6;
343 Number ub_u = 2.3;
344 Number d_const = -20.;
345 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
346 return true;
347 }
348 protected:
350 virtual Number y_d_cont(Number x1, Number x2) const
351 {
352 return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.));
353 }
354 private:
357 MittelmannBndryCntrlDiri4(const MittelmannBndryCntrlDiri4&);
358 MittelmannBndryCntrlDiri4& operator=(const MittelmannBndryCntrlDiri4&);
360 };
361
362 #endif
x
Number * x
Input: Starting point Output: Optimal solution.
Definition: IpStdCInterface.h:238
MittelmannBndryCntrlDiriBase::hh_
Number hh_
h_ squaredd
Definition: MittelmannBndryCntrlDiri.hpp:161
MittelmannBndryCntrlDiri3::~MittelmannBndryCntrlDiri3
virtual ~MittelmannBndryCntrlDiri3()
Definition: MittelmannBndryCntrlDiri.hpp:291
Ipopt::IpoptCalculatedQuantities
Class for all IPOPT specific calculated quantities.
Definition: IpIpoptCalculatedQuantities.hpp:81
index_style
Number Number Index Number Number Index Index Index index_style
indexing style for iRow &amp; jCol, 0 for C style, 1 for Fortran style
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri3
Class implementating Example 3.
Definition: MittelmannBndryCntrlDiri.hpp:285
m
Number Number Index m
Number of constraints.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri1
Class implementating Example 1.
Definition: MittelmannBndryCntrlDiri.hpp:207
MittelmannBndryCntrlDiriBase::y_index
Index y_index(Index i, Index j) const
Translation of mesh point indices to NLP variable indices for y(x_ij)
Definition: MittelmannBndryCntrlDiri.hpp:183
MittelmannBndryCntrlDiriBase::N_
Index N_
Number of mesh points in one dimension (excluding boundary)
Definition: MittelmannBndryCntrlDiri.hpp:157
MittelmannBndryCntrlDiriBase::pde_index
Index pde_index(Index i, Index j) const
Translation of interior mesh point indices to the corresponding PDE constraint number.
Definition: MittelmannBndryCntrlDiri.hpp:189
g
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
Definition: IpStdCInterface.h:238
MittelmannBndryCntrlDiriBase::h_
Number h_
Step size.
Definition: MittelmannBndryCntrlDiri.hpp:159
eval_h
Number Number Index Number Number Index Index Index Eval_F_CB Eval_G_CB Eval_Grad_F_CB Eval_Jac_G_CB Eval_H_CB eval_h
Callback function for evaluating Hessian of Lagrangian function.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri4::~MittelmannBndryCntrlDiri4
virtual ~MittelmannBndryCntrlDiri4()
Definition: MittelmannBndryCntrlDiri.hpp:330
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
MittelmannBndryCntrlDiri1::~MittelmannBndryCntrlDiri1
virtual ~MittelmannBndryCntrlDiri1()
Definition: MittelmannBndryCntrlDiri.hpp:213
eval_grad_f
Number Number Index Number Number Index Index Index Eval_F_CB Eval_G_CB Eval_Grad_F_CB eval_grad_f
Callback function for evaluating gradient of objective function.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri4
Class implementating Example 4.
Definition: MittelmannBndryCntrlDiri.hpp:324
MittelmannBndryCntrlDiri2
Class implementating Example 2.
Definition: MittelmannBndryCntrlDiri.hpp:246
MittelmannBndryCntrlDiri1::y_d_cont
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Definition: MittelmannBndryCntrlDiri.hpp:233
MittelmannBndryCntrlDiriBase::x2_grid
Number x2_grid(Index i) const
Compute the grid coordinate for given index in x2 direction.
Definition: MittelmannBndryCntrlDiri.hpp:199
MittelmannBndryCntrlDiri2::y_d_cont
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Definition: MittelmannBndryCntrlDiri.hpp:272
eval_jac_g
Number Number Index Number Number Index Index Index Eval_F_CB Eval_G_CB Eval_Grad_F_CB Eval_Jac_G_CB eval_jac_g
Callback function for evaluating Jacobian of constraint functions.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiriBase::ub_u_
Number ub_u_
overall upper bound on u
Definition: MittelmannBndryCntrlDiri.hpp:169
MittelmannBndryCntrlDiriBase::d_const_
Number d_const_
Constant value of d appearing in elliptical equation.
Definition: MittelmannBndryCntrlDiri.hpp:171
Ipopt::SolverReturn
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
Definition: IpAlgTypes.hpp:22
MittelmannBndryCntrlDiri2::MittelmannBndryCntrlDiri2
MittelmannBndryCntrlDiri2()
Definition: MittelmannBndryCntrlDiri.hpp:249
RegisteredTNLP.hpp
nele_jac
Number Number Index Number Number Index nele_jac
Number of non-zero elements in constraint Jacobian.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiriBase::ub_y_
Number ub_y_
overall upper bound on y
Definition: MittelmannBndryCntrlDiri.hpp:165
MittelmannBndryCntrlDiriBase::lb_u_
Number lb_u_
overall lower bound on u
Definition: MittelmannBndryCntrlDiri.hpp:167
MittelmannBndryCntrlDiri1::MittelmannBndryCntrlDiri1
MittelmannBndryCntrlDiri1()
Definition: MittelmannBndryCntrlDiri.hpp:210
MittelmannBndryCntrlDiri4::y_d_cont
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Definition: MittelmannBndryCntrlDiri.hpp:350
MittelmannBndryCntrlDiri4::InitializeProblem
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Definition: MittelmannBndryCntrlDiri.hpp:333
Ipopt::IpoptData
Class to organize all the data required by the algorithm.
Definition: IpIpoptData.hpp:83
eval_g
Number Number Index Number Number Index Index Index Eval_F_CB Eval_G_CB eval_g
Callback function for evaluating constraint functions.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri3::y_d_cont
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Definition: MittelmannBndryCntrlDiri.hpp:311
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
MittelmannBndryCntrlDiriBase::alpha_
Number alpha_
Weighting parameter for the control target deviation functional in the objective. ...
Definition: MittelmannBndryCntrlDiri.hpp:174
x_scaling
Number Number * x_scaling
Definition: IpStdCInterface.h:210
nele_hess
Number Number Index Number Number Index Index nele_hess
Number of non-zero elements in Hessian of Lagrangian.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiri4::MittelmannBndryCntrlDiri4
MittelmannBndryCntrlDiri4()
Definition: MittelmannBndryCntrlDiri.hpp:327
MittelmannBndryCntrlDiriBase
Base class for boundary control problems with Dirichlet boundary conditions, as formulated by Hans Mi...
Definition: MittelmannBndryCntrlDiri.hpp:52
MittelmannBndryCntrlDiri2::InitializeProblem
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Definition: MittelmannBndryCntrlDiri.hpp:255
MittelmannBndryCntrlDiri3::MittelmannBndryCntrlDiri3
MittelmannBndryCntrlDiri3()
Definition: MittelmannBndryCntrlDiri.hpp:288
RegisteredTNLP
Class implemented the NLP discretization of.
Definition: RegisteredTNLP.hpp:20
MittelmannBndryCntrlDiriBase::y_d_
Number * y_d_
Array for the target profile for y.
Definition: MittelmannBndryCntrlDiri.hpp:176
g_scaling
Number Number Number * g_scaling
Definition: IpStdCInterface.h:210
Ipopt::TNLP::IndexStyleEnum
IndexStyleEnum
overload this method to return the number of variables and constraints, and the number of non-zeros i...
Definition: IpTNLP.hpp:80
MittelmannBndryCntrlDiriBase::lb_y_
Number lb_y_
overall lower bound on y
Definition: MittelmannBndryCntrlDiri.hpp:163
MittelmannBndryCntrlDiri1::InitializeProblem
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Definition: MittelmannBndryCntrlDiri.hpp:216
MittelmannBndryCntrlDiri3::InitializeProblem
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Definition: MittelmannBndryCntrlDiri.hpp:294
MittelmannBndryCntrlDiri2::~MittelmannBndryCntrlDiri2
virtual ~MittelmannBndryCntrlDiri2()
Definition: MittelmannBndryCntrlDiri.hpp:252
obj_scaling
Number obj_scaling
Definition: IpStdCInterface.h:210
eval_f
Number Number Index Number Number Index Index Index Eval_F_CB eval_f
Callback function for evaluating objective function.
Definition: IpStdCInterface.h:137
MittelmannBndryCntrlDiriBase::x1_grid
Number x1_grid(Index i) const
Compute the grid coordinate for given index in x1 direction.
Definition: MittelmannBndryCntrlDiri.hpp:194