10 #ifndef __MITTELMANNDISTRCNTRLNEUMB_HPP__
11 #define __MITTELMANNDISTRCNTRLNEUMB_HPP__
19 #include "configall_system.h"
28 # error "don't have header file for math"
38 # error "don't have header file for stdio"
42 using namespace Ipopt;
106 bool& use_x_scaling,
Index n,
108 bool& use_g_scaling,
Index m,
242 return (N_+2)*(N_+2) + (j-1) + (N_)*(i-1);
248 return (j-1) + N_*(i-1);
279 printf(
"N has to be at least 1.");
290 Number u_init = (ub_u + lb_u)/2.;
292 SetBaseParameters(N, lb_y, ub_y, lb_u, ub_u, b_0j, b_1j, b_i0, b_i1, u_init);
299 return sin(2.*pi_*x1)*sin(2.*pi_*x2);
304 Number diff_y = y-y_d_cont(x1,x2);
305 return 0.5*(diff_y*diff_y + alpha_*u*u);
310 return y-y_d_cont(x1,x2);
426 printf(
"N has to be at least 1.");
437 Number u_init = (ub_u + lb_u)/2.;
439 SetBaseParameters(N, lb_y, ub_y, lb_u, ub_u, b_0j, b_1j, b_i0, b_i1, u_init);
446 return sin(2.*pi_*x1)*sin(2.*pi_*x2);
451 Number diff_y = y-y_d_cont(x1,x2);
452 return 0.5*diff_y*diff_y;
457 return y-y_d_cont(x1,x2);
574 printf(
"N has to be at least 1.");
585 Number u_init = (ub_u + lb_u)/2.;
587 SetBaseParameters(N, lb_y, ub_y, lb_u, ub_u, b_0j, b_1j, b_i0, b_i1, u_init);
599 return u*(M_*u - K_*y);
610 return 2.*M_*u - K_*y;
648 return y*(u + b_*y - a(x1,x2));
653 return (u + 2.*b_*y -a(x1,x2));
710 return 7. + 4.*sin(2.*pi_*x1*x2);
Number * x
Input: Starting point Output: Optimal solution.
Number Number Index Number Number Index Index nele_hess
Number of non-zero elements in Hessian of Lagrangian.
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
Number Number Index Number Number Index nele_jac
Number of non-zero elements in constraint Jacobian.
Number Number * x_scaling
Number Number Number * g_scaling
Number Number Index m
Number of constraints.
Number Number Index Number Number Index Index Index index_style
indexing style for iRow & jCol, 0 for C style, 1 for Fortran style
Class for all IPOPT specific calculated quantities.
Class to organize all the data required by the algorithm.
IndexStyleEnum
overload this method to return the number of variables and constraints, and the number of non-zeros i...
Class implementating Example 4.
virtual Number fint_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
virtual Number fint_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual bool d_cont_dydy_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual bool fint_cont_dydy_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual bool d_cont_dydu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual bool fint_cont_dudu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t y,y.
const Number pi_
Value of pi (made available for convenience)
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
virtual ~MittelmannDistCntrlNeumB1()
virtual Number d_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumB1()
const Number alpha_
Value for parameter alpha in objective functin.
MittelmannDistCntrlNeumB1(const MittelmannDistCntrlNeumB1 &)
virtual Number fint_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumB1 & operator=(const MittelmannDistCntrlNeumB1 &)
virtual Number fint_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
virtual Number fint_cont(Number x1, Number x2, Number y, Number u) const
Integrant in objective function.
virtual bool d_cont_dudu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual Number fint_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual bool fint_cont_dydu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Class implementating Example 5.
const Number pi_
Value of pi (made available for convenience)
virtual Number fint_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
virtual ~MittelmannDistCntrlNeumB2()
virtual Number fint_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
virtual Number fint_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual Number fint_cont(Number x1, Number x2, Number y, Number u) const
Integrant in objective function.
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual bool d_cont_dydy_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual bool fint_cont_dydy_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
MittelmannDistCntrlNeumB2()
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
virtual bool d_cont_dydu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual bool fint_cont_dydu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
virtual bool d_cont_dudu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
MittelmannDistCntrlNeumB2(const MittelmannDistCntrlNeumB2 &)
virtual bool fint_cont_dudu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
virtual Number d_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t y,y.
virtual Number d_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
virtual Number fint_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
MittelmannDistCntrlNeumB2 & operator=(const MittelmannDistCntrlNeumB2 &)
virtual Number fint_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
Class implementating Example 6.
virtual Number d_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumB3()
virtual Number fint_cont_dydu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual ~MittelmannDistCntrlNeumB3()
const Number pi_
Value of pi (made available for convenience)
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
virtual bool fint_cont_dudu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual Number fint_cont(Number x1, Number x2, Number y, Number u) const
Integrant in objective function.
virtual bool d_cont_dydy_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual bool d_cont_dydu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual bool fint_cont_dydy_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
virtual Number fint_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual bool d_cont_dudu_alwayszero() const
returns true if second partial derivative of d_cont w.r.t.
virtual Number fint_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dudu(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumB3 & operator=(const MittelmannDistCntrlNeumB3 &)
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
virtual bool fint_cont_dydu_alwayszero() const
returns true if second partial derivative of fint_cont w.r.t.
MittelmannDistCntrlNeumB3(const MittelmannDistCntrlNeumB3 &)
virtual Number fint_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
Number a(Number x1, Number x2) const
virtual Number y_d_cont(Number x1, Number x2) const
Profile function for initial y.
virtual Number d_cont_dydy(Number x1, Number x2, Number y, Number u) const
Second partial derivative of forcing function w.r.t y,y.
virtual Number fint_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of fint_cont w.r.t.
Base class for distributed control problems with homogeneous Neumann boundary conditions,...
Number b_1j_
Value of beta function (in Neumann boundary condition) for (1,x2) bounray.
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of forcing function w.r.t.
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
Method to return the bounds for my problem.
Number x2_grid(Index i) const
Compute the grid coordinate for given index in x2 direction.
Number ub_u_
overall upper bound on u
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const =0
Forcing function for the elliptic equation.
Number b_i0_
Value of beta function (in Neumann boundary condition) for (x1,0) bounray.
virtual bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
Method to return: 1) The structure of the jacobian (if "values" is NULL) 2) The values of the jacobia...
Number ub_y_
overall upper bound on y
virtual Number fint_cont_dydy(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dudu(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of forcing function w.r.t.
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
Method to return the objective value.
Index u_index(Index i, Index j) const
Translation of mesh point indices to NLP variable indices for u(x_ij)
Number b_i1_
Value of beta function (in Neumann boundary condition) for (x1,1) bounray.
virtual Number d_cont_dydy(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumBBase & operator=(const MittelmannDistCntrlNeumBBase &)
virtual Number fint_cont_du(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of fint_cont w.r.t.
Number x1_grid(Index i) const
Compute the grid coordinate for given index in x1 direction.
void SetBaseParameters(Index N, Number lb_y, Number ub_y, Number lb_u, Number ub_u, Number b_0j, Number b_1j, Number b_i0, Number b_i1, Number u_init)
Method for setting the internal parameters that define the problem.
virtual bool d_cont_dydu_alwayszero() const =0
returns true if second partial derivative of d_cont w.r.t.
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
Method to return the gradient of the objective.
virtual bool eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is NULL) 2) The valu...
Number lb_y_
overall lower bound on y
virtual bool get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)
Method to return the starting point for the algorithm.
virtual Number fint_cont_dy(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of fint_cont w.r.t.
Number lb_u_
overall lower bound on u
virtual bool d_cont_dudu_alwayszero() const =0
returns true if second partial derivative of d_cont w.r.t.
Index pde_index(Index i, Index j) const
Translation of interior mesh point indices to the corresponding PDE constraint number.
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of forcing function w.r.t.
MittelmannDistCntrlNeumBBase()
Constructor.
virtual bool fint_cont_dudu_alwayszero() const =0
returns true if second partial derivative of fint_cont w.r.t.
virtual Number fint_cont_dudu(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of fint_cont w.r.t.
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 after the optimization, and could write an output file with the optimal profile...
Number u_init_
Initial value for the constrols u.
Number b_0j_
Value of beta function (in Neumann boundary condition) for (0,x2) bounray.
virtual bool fint_cont_dydy_alwayszero() const =0
returns true if second partial derivative of fint_cont w.r.t.
Number * y_d_
Array for the target profile for y.
virtual bool get_scaling_parameters(Number &obj_scaling, bool &use_x_scaling, Index n, Number *x_scaling, bool &use_g_scaling, Index m, Number *g_scaling)
Method for returning scaling parameters.
virtual Number fint_cont(Number x1, Number x2, Number y, Number u) const =0
Integrant in objective function.
virtual Number y_d_cont(Number x1, Number x2) const =0
Target profile function for y (and initial guess function)
MittelmannDistCntrlNeumBBase(const MittelmannDistCntrlNeumBBase &)
virtual ~MittelmannDistCntrlNeumBBase()
Default destructor.
Index y_index(Index i, Index j) const
Translation of mesh point indices to NLP variable indices for y(x_ij)
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
Method to return some info about the nlp.
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)
Method to return the constraint residuals.
virtual bool fint_cont_dydu_alwayszero() const =0
returns true if second partial derivative of fint_cont w.r.t.
virtual Number d_cont_dydu(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of forcing function w.r.t.
Index N_
Number of mesh points in one dimension (excluding boundary)
virtual bool d_cont_dydy_alwayszero() const =0
returns true if second partial derivative of d_cont w.r.t.
virtual Number fint_cont_dydu(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of fint_cont w.r.t.
Class implemented the NLP discretization of.
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
int Index
Type of all indices of vectors, matrices etc.
double Number
Type of all numbers.