Ipopt
3.11.4
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
examples
ScalableProblems
MittelmannBndryCntrlDiri3Dsin.hpp
Go to the documentation of this file.
1
// Copyright (C) 2005, 2007 International Business Machines and others.
2
// All Rights Reserved.
3
// This code is published under the Eclipse Public License.
4
//
5
// $Id: MittelmannBndryCntrlDiri3Dsin.hpp 2005 2011-06-06 12:55:16Z stefan $
6
//
7
// Authors: Andreas Waechter IBM 2005-10-18
8
// Olaf Schenk (Univ. of Basel) 2007-08-01
9
// modified MittelmannBndryCntrlDiri.hpp for 3-dim problem
10
11
#ifndef __MITTELMANNBNDRYCNTRLDIRI3DSIN_HPP__
12
#define __MITTELMANNBNDRYCNTRLDIRI3DSIN_HPP__
13
14
#include "
RegisteredTNLP.hpp
"
15
16
#ifdef HAVE_CONFIG_H
17
#include "config.h"
18
#else
19
#include "configall_system.h"
20
#endif
21
22
#ifdef HAVE_CMATH
23
# include <cmath>
24
#else
25
# ifdef HAVE_MATH_H
26
# include <math.h>
27
# else
28
# error "don't have header file for math"
29
# endif
30
#endif
31
32
#ifdef HAVE_CSTDIO
33
# include <cstdio>
34
#else
35
# ifdef HAVE_STDIO_H
36
# include <stdio.h>
37
# else
38
# error "don't have header file for stdio"
39
# endif
40
#endif
41
42
using namespace
Ipopt;
43
53
class
MittelmannBndryCntrlDiriBase3Dsin
:
public
RegisteredTNLP
54
{
55
public
:
57
MittelmannBndryCntrlDiriBase3Dsin
();
58
60
virtual
~
MittelmannBndryCntrlDiriBase3Dsin
();
61
65
virtual
bool
get_nlp_info(
Index
& n,
Index
&
m
,
Index
& nnz_jac_g,
66
Index
& nnz_h_lag,
IndexStyleEnum
&
index_style
);
67
69
virtual
bool
get_bounds_info(
Index
n,
Number
* x_l,
Number
* x_u,
70
Index
m,
Number
* g_l,
Number
* g_u);
71
73
virtual
bool
get_starting_point(
Index
n,
bool
init_x,
Number
*
x
,
74
bool
init_z,
Number
* z_L,
Number
* z_U,
75
Index
m,
bool
init_lambda,
76
Number
* lambda);
77
79
virtual
bool
eval_f
(
Index
n,
const
Number
* x,
bool
new_x,
Number
& obj_value);
80
82
virtual
bool
eval_grad_f
(
Index
n,
const
Number
* x,
bool
new_x,
Number
* grad_f);
83
85
virtual
bool
eval_g
(
Index
n,
const
Number
* x,
bool
new_x,
Index
m,
Number
*
g
);
86
91
virtual
bool
eval_jac_g
(
Index
n,
const
Number
* x,
bool
new_x,
92
Index
m,
Index
nele_jac
,
Index
* iRow,
Index
*jCol,
93
Number
* values);
94
99
virtual
bool
eval_h
(
Index
n,
const
Number
* x,
bool
new_x,
100
Number
obj_factor,
Index
m,
const
Number
* lambda,
101
bool
new_lambda,
Index
nele_hess
,
Index
* iRow,
102
Index
* jCol,
Number
* values);
103
105
107
virtual
bool
get_scaling_parameters(
Number
&
obj_scaling
,
108
bool
& use_x_scaling,
Index
n,
109
Number
*
x_scaling
,
110
bool
& use_g_scaling,
Index
m,
111
Number
*
g_scaling
);
112
117
virtual
void
finalize_solution(
SolverReturn
status,
118
Index
n,
const
Number
* x,
const
Number
* z_L,
const
Number
* z_U,
119
Index
m,
const
Number
* g,
const
Number
* lambda,
120
Number
obj_valu,
121
const
IpoptData
* ip_data,
122
IpoptCalculatedQuantities
* ip_cq);
124
125
protected
:
129
void
SetBaseParameters(
Index
N,
Number
alpha,
Number
lb_y,
130
Number
ub_y,
Number
lb_u,
Number
ub_u,
131
Number
d_const);
132
136
virtual
Number
y_d_cont(
Number
x1,
Number
x2,
Number
x3)
const
=0;
138
139
private
:
151
MittelmannBndryCntrlDiriBase3Dsin
(
const
MittelmannBndryCntrlDiriBase3Dsin
&);
152
MittelmannBndryCntrlDiriBase3Dsin
& operator=(
const
MittelmannBndryCntrlDiriBase3Dsin
&);
154
158
Index
N_
;
160
Number
h_
;
162
Number
hh_
;
164
Number
lb_y_
;
166
Number
ub_y_
;
168
Number
lb_u_
;
170
Number
ub_u_
;
172
Number
d_const_
;
175
Number
alpha_
;
177
Number
*
y_d_
;
179
184
inline
Index
y_index
(
Index
i,
Index
j,
Index
k)
const
185
{
186
return
k + (N_+2)*j + (N_+2)*(N_+2)*i;
187
}
190
inline
Index
pde_index
(
Index
i,
Index
j,
Index
k)
const
191
{
192
return
(k-1) + N_*(j-1) + N_*N_*(i-1);
193
}
195
inline
Number
x1_grid
(
Index
i)
const
196
{
197
return
h_*(
Number
)i;
198
}
200
inline
Number
x2_grid
(
Index
i)
const
201
{
202
return
h_*(
Number
)i;
203
}
205
inline
Number
x3_grid
(
Index
i)
const
206
{
207
return
h_*(
Number
)i;
208
}
210
};
211
213
class
MittelmannBndryCntrlDiri3Dsin
:
public
MittelmannBndryCntrlDiriBase3Dsin
214
{
215
public
:
216
MittelmannBndryCntrlDiri3Dsin
()
217
{}
218
219
virtual
~MittelmannBndryCntrlDiri3Dsin
()
220
{}
221
222
virtual
bool
InitializeProblem
(
Index
N)
223
{
224
if
(N<1) {
225
printf(
"N has to be at least 1."
);
226
return
false
;
227
}
228
printf(
"olaf N %d has to be at least 1."
, N);
229
Number
alpha = 0.1;
230
Number
lb_y = -1e20;
231
Number
ub_y = 3.5;
232
Number
lb_u = 0.;
233
Number
ub_u = 10.;
234
Number
d_const = -20.;
235
SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
236
return
true
;
237
}
238
protected
:
240
virtual
Number
y_d_cont
(
Number
x1,
Number
x2,
Number
x3)
const
241
{
242
return
3. + 5.*(x1*(x1-1.)*x2*(x2-1.)*x3*(x3-1.));
243
}
244
private
:
247
MittelmannBndryCntrlDiri3Dsin
(
const
MittelmannBndryCntrlDiri3Dsin
&);
248
MittelmannBndryCntrlDiri3Dsin
& operator=(
const
MittelmannBndryCntrlDiri3Dsin
&);
250
251
};
252
253
254
#endif
Generated on Mon Oct 21 2013 19:08:14 for Ipopt by
1.8.4