/home/coin/SVN-release/Ipopt-3.9.0/Ipopt/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 Common Public License.
00004 //
00005 // $Id: MittelmannBndryCntrlDiri3Dsin.hpp 1707 2010-07-03 18:25:51Z 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_CMATH
00017 # include <cmath>
00018 #else
00019 # ifdef HAVE_MATH_H
00020 #  include <math.h>
00021 # else
00022 #  error "don't have header file for math"
00023 # endif
00024 #endif
00025 
00026 #include <cstdio>
00027 
00028 using namespace Ipopt;
00029 
00039 class MittelmannBndryCntrlDiriBase3Dsin : public RegisteredTNLP
00040 {
00041 public:
00043   MittelmannBndryCntrlDiriBase3Dsin();
00044 
00046   virtual ~MittelmannBndryCntrlDiriBase3Dsin();
00047 
00051   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00052                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00053 
00055   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00056                                Index m, Number* g_l, Number* g_u);
00057 
00059   virtual bool get_starting_point(Index n, bool init_x, Number* x,
00060                                   bool init_z, Number* z_L, Number* z_U,
00061                                   Index m, bool init_lambda,
00062                                   Number* lambda);
00063 
00065   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00066 
00068   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00069 
00071   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00072 
00077   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00078                           Index m, Index nele_jac, Index* iRow, Index *jCol,
00079                           Number* values);
00080 
00085   virtual bool eval_h(Index n, const Number* x, bool new_x,
00086                       Number obj_factor, Index m, const Number* lambda,
00087                       bool new_lambda, Index nele_hess, Index* iRow,
00088                       Index* jCol, Number* values);
00089 
00091 
00093   virtual bool get_scaling_parameters(Number& obj_scaling,
00094                                       bool& use_x_scaling, Index n,
00095                                       Number* x_scaling,
00096                                       bool& use_g_scaling, Index m,
00097                                       Number* g_scaling);
00098 
00103   virtual void finalize_solution(SolverReturn status,
00104                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
00105                                  Index m, const Number* g, const Number* lambda,
00106                                  Number obj_valu,
00107                                  const IpoptData* ip_data,
00108                                  IpoptCalculatedQuantities* ip_cq);
00110 
00111 protected:
00115   void SetBaseParameters(Index N, Number alpha, Number lb_y,
00116                          Number ub_y, Number lb_u, Number ub_u,
00117                          Number d_const);
00118 
00122   virtual Number y_d_cont(Number x1, Number x2, Number x3) const =0;
00124 
00125 private:
00137   MittelmannBndryCntrlDiriBase3Dsin(const MittelmannBndryCntrlDiriBase3Dsin&);
00138   MittelmannBndryCntrlDiriBase3Dsin& operator=(const MittelmannBndryCntrlDiriBase3Dsin&);
00140 
00144   Index N_;
00146   Number h_;
00148   Number hh_;
00150   Number lb_y_;
00152   Number ub_y_;
00154   Number lb_u_;
00156   Number ub_u_;
00158   Number d_const_;
00161   Number alpha_;
00163   Number* y_d_;
00165 
00170   inline Index y_index(Index i, Index j, Index k) const
00171   {
00172     return k + (N_+2)*j + (N_+2)*(N_+2)*i;
00173   }
00176   inline Index pde_index(Index i, Index j, Index k) const
00177   {
00178     return (k-1) + N_*(j-1) + N_*N_*(i-1);
00179   }
00181   inline Number x1_grid(Index i) const
00182   {
00183     return h_*(Number)i;
00184   }
00186   inline Number x2_grid(Index i) const
00187   {
00188     return h_*(Number)i;
00189   }
00191   inline Number x3_grid(Index i) const
00192   {
00193     return h_*(Number)i;
00194   }
00196 };
00197 
00199 class MittelmannBndryCntrlDiri3Dsin : public MittelmannBndryCntrlDiriBase3Dsin
00200 {
00201 public:
00202   MittelmannBndryCntrlDiri3Dsin()
00203   {}
00204 
00205   virtual ~MittelmannBndryCntrlDiri3Dsin()
00206   {}
00207 
00208   virtual bool InitializeProblem(Index N)
00209   {
00210     if (N<1) {
00211       printf("N has to be at least 1.");
00212       return false;
00213     }
00214     printf("olaf N %d has to be at least 1.", N);
00215     Number alpha = 0.1;
00216     Number lb_y = -1e20;
00217     Number ub_y = 3.5;
00218     Number lb_u = 0.;
00219     Number ub_u = 10.;
00220     Number d_const = -20.;
00221     SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
00222     return true;
00223   }
00224 protected:
00226   virtual Number y_d_cont(Number x1, Number x2, Number x3)  const
00227   {
00228     return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.)*x3*(x3-1.));
00229   }
00230 private:
00233   MittelmannBndryCntrlDiri3Dsin(const MittelmannBndryCntrlDiri3Dsin&);
00234   MittelmannBndryCntrlDiri3Dsin& operator=(const MittelmannBndryCntrlDiri3Dsin&);
00236 
00237 };
00238 
00239 
00240 #endif

Generated on Sat Nov 6 03:10:31 2010 by  doxygen 1.4.7