- Main Page
- Classes
- Files

- File List
- File Members

# examples/ScalableProblems/MittelmannBndryCntrlDiri3Dsin.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2005, 2007 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Eclipse Public License.
    00004 //
    00005 // $Id: MittelmannBndryCntrlDiri3Dsin.hpp 2005 2011-06-06 12:55:16Z stefan $
    00006 //
    00007 // Authors:  Andreas Waechter             IBM    2005-10-18
    00008 //           Olaf Schenk   (Univ. of Basel)      2007-08-01
    00009 //              modified MittelmannBndryCntrlDiri.hpp for 3-dim problem
    00010
    00011 #ifndef __MITTELMANNBNDRYCNTRLDIRI3DSIN_HPP__
    00012 #define __MITTELMANNBNDRYCNTRLDIRI3DSIN_HPP__
    00013
    00014 #include "RegisteredTNLP.hpp"
    00015
    00016 #ifdef HAVE_CONFIG_H
    00017 #include "config.h"
    00018 #else
    00019 #include "configall_system.h"
    00020 #endif
    00021
    00022 #ifdef HAVE_CMATH
    00023 # include <cmath>
    00024 #else
    00025 # ifdef HAVE_MATH_H
    00026 #  include <math.h>
    00027 # else
    00028 #  error "don't have header file for math"
    00029 # endif
    00030 #endif
    00031
    00032 #ifdef HAVE_CSTDIO
    00033 # include <cstdio>
    00034 #else
    00035 # ifdef HAVE_STDIO_H
    00036 #  include <stdio.h>
    00037 # else
    00038 #  error "don't have header file for stdio"
    00039 # endif
    00040 #endif
    00041
    00042 using namespace Ipopt;
    00043
    00053 class MittelmannBndryCntrlDiriBase3Dsin : public RegisteredTNLP
    00054 {
    00055 public:
    00057   MittelmannBndryCntrlDiriBase3Dsin();
    00058
    00060   virtual ~MittelmannBndryCntrlDiriBase3Dsin();
    00061
    00065   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
    00066                             Index& nnz_h_lag, IndexStyleEnum& index_style);
    00067
    00069   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
    00070                                Index m, Number* g_l, Number* g_u);
    00071
    00073   virtual bool get_starting_point(Index n, bool init_x, Number* x,
    00074                                   bool init_z, Number* z_L, Number* z_U,
    00075                                   Index m, bool init_lambda,
    00076                                   Number* lambda);
    00077
    00079   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
    00080
    00082   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
    00083
    00085   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
    00086
    00091   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
    00092                           Index m, Index nele_jac, Index* iRow, Index *jCol,
    00093                           Number* values);
    00094
    00099   virtual bool eval_h(Index n, const Number* x, bool new_x,
    00100                       Number obj_factor, Index m, const Number* lambda,
    00101                       bool new_lambda, Index nele_hess, Index* iRow,
    00102                       Index* jCol, Number* values);
    00103
    00105
    00107   virtual bool get_scaling_parameters(Number& obj_scaling,
    00108                                       bool& use_x_scaling, Index n,
    00109                                       Number* x_scaling,
    00110                                       bool& use_g_scaling, Index m,
    00111                                       Number* g_scaling);
    00112
    00117   virtual void finalize_solution(SolverReturn status,
    00118                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
    00119                                  Index m, const Number* g, const Number* lambda,
    00120                                  Number obj_valu,
    00121                                  const IpoptData* ip_data,
    00122                                  IpoptCalculatedQuantities* ip_cq);
    00124
    00125 protected:
    00129   void SetBaseParameters(Index N, Number alpha, Number lb_y,
    00130                          Number ub_y, Number lb_u, Number ub_u,
    00131                          Number d_const);
    00132
    00136   virtual Number y_d_cont(Number x1, Number x2, Number x3) const =0;
    00138
    00139 private:
    00151   MittelmannBndryCntrlDiriBase3Dsin(const MittelmannBndryCntrlDiriBase3Dsin&);
    00152   MittelmannBndryCntrlDiriBase3Dsin& operator=(const MittelmannBndryCntrlDiriBase3Dsin&);
    00154
    00158   Index N_;
    00160   Number h_;
    00162   Number hh_;
    00164   Number lb_y_;
    00166   Number ub_y_;
    00168   Number lb_u_;
    00170   Number ub_u_;
    00172   Number d_const_;
    00175   Number alpha_;
    00177   Number* y_d_;
    00179
    00184   inline Index y_index(Index i, Index j, Index k) const
    00185   {
    00186     return k + (N_+2)*j + (N_+2)*(N_+2)*i;
    00187   }
    00190   inline Index pde_index(Index i, Index j, Index k) const
    00191   {
    00192     return (k-1) + N_*(j-1) + N_*N_*(i-1);
    00193   }
    00195   inline Number x1_grid(Index i) const
    00196   {
    00197     return h_*(Number)i;
    00198   }
    00200   inline Number x2_grid(Index i) const
    00201   {
    00202     return h_*(Number)i;
    00203   }
    00205   inline Number x3_grid(Index i) const
    00206   {
    00207     return h_*(Number)i;
    00208   }
    00210 };
    00211
    00213 class MittelmannBndryCntrlDiri3Dsin : public MittelmannBndryCntrlDiriBase3Dsin
    00214 {
    00215 public:
    00216   MittelmannBndryCntrlDiri3Dsin()
    00217   {}
    00218
    00219   virtual ~MittelmannBndryCntrlDiri3Dsin()
    00220   {}
    00221
    00222   virtual bool InitializeProblem(Index N)
    00223   {
    00224     if (N<1) {
    00225       printf("N has to be at least 1.");
    00226       return false;
    00227     }
    00228     printf("olaf N %d has to be at least 1.", N);
    00229     Number alpha = 0.1;
    00230     Number lb_y = -1e20;
    00231     Number ub_y = 3.5;
    00232     Number lb_u = 0.;
    00233     Number ub_u = 10.;
    00234     Number d_const = -20.;
    00235     SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
    00236     return true;
    00237   }
    00238 protected:
    00240   virtual Number y_d_cont(Number x1, Number x2, Number x3)  const
    00241   {
    00242     return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.)*x3*(x3-1.));
    00243   }
    00244 private:
    00247   MittelmannBndryCntrlDiri3Dsin(const MittelmannBndryCntrlDiri3Dsin&);
    00248   MittelmannBndryCntrlDiri3Dsin& operator=(const MittelmannBndryCntrlDiri3Dsin&);
    00250
    00251 };
    00252
    00253
    00254 #endif

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines