/home/coin/SVN-release/CoinAll-1.1.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: MittelmannBndryCntrlDiri.hpp 1010 2007-06-21 15:54:36Z andreasw $
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 using namespace Ipopt;
00027 
00037 class MittelmannBndryCntrlDiriBase3Dsin : public RegisteredTNLP
00038 {
00039 public:
00041   MittelmannBndryCntrlDiriBase3Dsin();
00042 
00044   virtual ~MittelmannBndryCntrlDiriBase3Dsin();
00045 
00049   virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
00050                             Index& nnz_h_lag, IndexStyleEnum& index_style);
00051 
00053   virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
00054                                Index m, Number* g_l, Number* g_u);
00055 
00057   virtual bool get_starting_point(Index n, bool init_x, Number* x,
00058                                   bool init_z, Number* z_L, Number* z_U,
00059                                   Index m, bool init_lambda,
00060                                   Number* lambda);
00061 
00063   virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value);
00064 
00066   virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f);
00067 
00069   virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g);
00070 
00075   virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
00076                           Index m, Index nele_jac, Index* iRow, Index *jCol,
00077                           Number* values);
00078 
00083   virtual bool eval_h(Index n, const Number* x, bool new_x,
00084                       Number obj_factor, Index m, const Number* lambda,
00085                       bool new_lambda, Index nele_hess, Index* iRow,
00086                       Index* jCol, Number* values);
00087 
00089 
00091   virtual bool get_scaling_parameters(Number& obj_scaling,
00092                                       bool& use_x_scaling, Index n,
00093                                       Number* x_scaling,
00094                                       bool& use_g_scaling, Index m,
00095                                       Number* g_scaling);
00096 
00101   virtual void finalize_solution(SolverReturn status,
00102                                  Index n, const Number* x, const Number* z_L, const Number* z_U,
00103                                  Index m, const Number* g, const Number* lambda,
00104                                  Number obj_valu,
00105                                  const IpoptData* ip_data,
00106                                  IpoptCalculatedQuantities* ip_cq);
00108 
00109 protected:
00113   void SetBaseParameters(Index N, Number alpha, Number lb_y,
00114                          Number ub_y, Number lb_u, Number ub_u,
00115                          Number d_const);
00116 
00120   virtual Number y_d_cont(Number x1, Number x2, Number x3) const =0;
00122 
00123 private:
00135   MittelmannBndryCntrlDiriBase3Dsin(const MittelmannBndryCntrlDiriBase3Dsin&);
00136   MittelmannBndryCntrlDiriBase3Dsin& operator=(const MittelmannBndryCntrlDiriBase3Dsin&);
00138 
00142   Index N_;
00144   Number h_;
00146   Number hh_;
00148   Number lb_y_;
00150   Number ub_y_;
00152   Number lb_u_;
00154   Number ub_u_;
00156   Number d_const_;
00159   Number alpha_;
00161   Number* y_d_;
00163 
00168   inline Index y_index(Index i, Index j, Index k) const
00169   {
00170     return k + (N_+2)*j + (N_+2)*(N_+2)*i;
00171   }
00174   inline Index pde_index(Index i, Index j, Index k) const
00175   {
00176     return (k-1) + N_*(j-1) + N_*N_*(i-1);
00177   }
00179   inline Number x1_grid(Index i) const
00180   {
00181     return h_*(Number)i;
00182   }
00184   inline Number x2_grid(Index i) const
00185   {
00186     return h_*(Number)i;
00187   }
00189   inline Number x3_grid(Index i) const
00190   {
00191     return h_*(Number)i;
00192   }
00194 };
00195 
00197 class MittelmannBndryCntrlDiri3Dsin : public MittelmannBndryCntrlDiriBase3Dsin
00198 {
00199 public:
00200   MittelmannBndryCntrlDiri3Dsin()
00201   {}
00202 
00203   virtual ~MittelmannBndryCntrlDiri3Dsin()
00204   {}
00205 
00206   virtual bool InitializeProblem(Index N)
00207   {
00208     if (N<1) {
00209       printf("N has to be at least 1.");
00210       return false;
00211     }
00212     printf("olaf N %d has to be at least 1.", N);
00213     Number alpha = 0.1;
00214     Number lb_y = -1e20;
00215     Number ub_y = 3.5;
00216     Number lb_u = 0.;
00217     Number ub_u = 10.;
00218     Number d_const = -20.;
00219     SetBaseParameters(N, alpha, lb_y, ub_y, lb_u, ub_u, d_const);
00220     return true;
00221   }
00222 protected:
00224   virtual Number y_d_cont(Number x1, Number x2, Number x3)  const
00225   {
00226     return 3. + 5.*(x1*(x1-1.)*x2*(x2-1.)*x3*(x3-1.));
00227   }
00228 private:
00231   MittelmannBndryCntrlDiri3Dsin(const MittelmannBndryCntrlDiri3Dsin&);
00232   MittelmannBndryCntrlDiri3Dsin& operator=(const MittelmannBndryCntrlDiri3Dsin&);
00234 
00235 };
00236 
00237 
00238 #endif

Generated on Sun Nov 14 14:06:34 2010 for Coin-All by  doxygen 1.4.7