Go to the documentation of this file.
10 #ifndef __MITTELMANNDISTRCNTRLDIRI_HPP__
11 #define __MITTELMANNDISTRCNTRLDIRI_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,
198 return (N_+2)*(N_+2) + (j-1) + (N_)*(i-1);
204 return (j-1) + N_*(i-1);
232 printf(
"N has to be at least 1.");
240 Number u_init = (ub_u+lb_u)/2.;
242 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, u_init);
249 return 1. + 2.*(x1*(x1-1.)+x2*(x2-1.));
254 return pow(y,3) - y - u;
290 printf(
"N has to be at least 1.");
298 Number u_init = (ub_u+lb_u)/2.;
300 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, u_init);
307 return 1. + 2.*(x1*(x1-1.)+x2*(x2-1.));
312 return pow(y,3) - y - u;
350 printf(
"N has to be at least 1.");
358 Number u_init = (ub_u+lb_u)/2.;
360 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, u_init);
367 return sin(2.*pi_*x1)*sin(2.*pi_*x2);
411 printf(
"N has to be at least 1.");
419 Number u_init = (ub_u+lb_u)/2.;
421 SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, u_init);
428 return sin(2.*pi_*x1)*sin(2.*pi_*x2);
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(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
Number x2_grid(Index i) const
Compute the grid coordinate for given index in x2 direction.
MittelmannDistCntrlDiriBase & operator=(const MittelmannDistCntrlDiriBase &)
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 InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
Number alpha_
Weighting parameter for the control target deviation functional in the objective.
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
Class to organize all the data required by the algorithm.
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
MittelmannDistCntrlDiri1()
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...
const Number pi_
Value of pi (made available for convenience)
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
Class implemented the NLP discretization of.
Base class for distributed control problems with Dirichlet boundary conditions, as formulated by Hans...
Class for all IPOPT specific calculated quantities.
MittelmannDistCntrlDiri3 & operator=(const MittelmannDistCntrlDiri3 &)
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
double Number
Type of all numbers.
virtual Number y_d_cont(Number x1, Number x2) const =0
Target profile function for y.
const Number pi_
Value of pi (made available for convenience)
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(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
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.
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
Index pde_index(Index i, Index j) const
Translation of interior mesh point indices to the corresponding PDE constraint number.
virtual Number d_cont(Number x1, Number x2, Number y, Number u) const =0
Forcing function for the elliptic equation.
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...
virtual ~MittelmannDistCntrlDiriBase()
Default destructor.
virtual Number d_cont_dydy(Number x1, Number x2, Number y, Number u) const =0
Second partial derivative of forcing function w.r.t.
Number * x
Input: Starting point Output: Optimal solution.
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of forcing function w.r.t.
Number Number Index Number Number Index Index nele_hess
Number of non-zero elements in Hessian of Lagrangian.
virtual ~MittelmannDistCntrlDiri1()
Number Number Index Number Number Index nele_jac
Number of non-zero elements in constraint Jacobian.
int Index
Type of all indices of vectors, matrices etc.
virtual Number d_cont_dy(Number x1, Number x2, Number y, Number u) const =0
First partial derivative of forcing function w.r.t.
Number ub_u_
overall upper bound on u
MittelmannDistCntrlDiri2 & operator=(const MittelmannDistCntrlDiri2 &)
Number ub_y_
overall upper bound on y
MittelmannDistCntrlDiri2(const MittelmannDistCntrlDiri2 &)
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Index N_
Number of mesh points in one dimension (excluding boundary)
Number x1_grid(Index i) const
Compute the grid coordinate for given index in x1 direction.
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Class implementating Example 2.
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 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_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual ~MittelmannDistCntrlDiri3a()
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 eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)
Method to return the constraint residuals.
Index u_index(Index i, Index j) const
Translation of mesh point indices to NLP variable indices for u(x_ij)
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
virtual ~MittelmannDistCntrlDiri3()
Number * y_d_
Array for the target profile for y.
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 eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
Method to return the gradient of the objective.
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.
MittelmannDistCntrlDiri3()
Class implementating Example 1.
Number Number Number * g_scaling
MittelmannDistCntrlDiri2()
MittelmannDistCntrlDiri1(const MittelmannDistCntrlDiri1 &)
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.
MittelmannDistCntrlDiri3a()
MittelmannDistCntrlDiriBase(const MittelmannDistCntrlDiriBase &)
Number Number * g
Values of constraint at final point (output only - ignored if set to NULL)
MittelmannDistCntrlDiri1 & operator=(const MittelmannDistCntrlDiri1 &)
IndexStyleEnum
overload this method to return the number of variables and constraints, and the number of non-zeros i...
MittelmannDistCntrlDiri3(const MittelmannDistCntrlDiri3 &)
MittelmannDistCntrlDiriBase()
Constructor.
Number lb_u_
overall lower bound on u
virtual Number d_cont_du(Number x1, Number x2, Number y, Number u) const
First partial derivative of forcing function w.r.t.
virtual ~MittelmannDistCntrlDiri2()
SolverReturn
enum for the return from the optimize algorithm (obviously we need to add more)
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 d_cont(Number x1, Number x2, Number y, Number u) const
Forcing function for the elliptic equation.
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
Method to return the objective value.
Class implementating Example 3.
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...
void SetBaseParameters(Index N, Number alpha, Number lb_y, Number ub_y, Number lb_u, Number ub_u, Number u_init)
Method for setting the internal parameters that define the problem.
Index y_index(Index i, Index j) const
Translation of mesh point indices to NLP variable indices for y(x_ij)
MittelmannDistCntrlDiri3a(const MittelmannDistCntrlDiri3a &)
Number u_init_
Initial value for the constrols u.
Number Number Index Number Number Index Index Index index_style
indexing style for iRow & jCol, 0 for C style, 1 for Fortran style
virtual Number y_d_cont(Number x1, Number x2) const
Target profile function for y.
Number lb_y_
overall lower bound on y
Number Number * x_scaling
MittelmannDistCntrlDiri3a & operator=(const MittelmannDistCntrlDiri3a &)
Number Number Index m
Number of constraints.
virtual bool InitializeProblem(Index N)
Initialize internal parameters, where N is a parameter determining the problme size.