MOOCHO (Single Doxygen Collection) Version of the Day
NLPInterfacePack_ExampleNLPObjGrad.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef EXAMPLE_NLP_OBJ_GRADIENT_H
00030 #define EXAMPLE_NLP_OBJ_GRADIENT_H
00031 
00032 #include "NLPInterfacePack_NLPObjGrad.hpp"
00033 #include "AbstractLinAlgPack_VectorMutable.hpp"
00034 #include "AbstractLinAlgPack_VectorSpace.hpp"
00035 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
00036 #include "Teuchos_TestForException.hpp"
00037 
00038 namespace NLPInterfacePack {
00039 
00059 class ExampleNLPObjGrad : virtual public NLPObjGrad {
00060 public:
00061 
00075   ExampleNLPObjGrad(
00076     const VectorSpace::space_ptr_t&  vec_space
00077     ,value_type                      xo
00078     ,bool                            has_bounds
00079     ,bool                            dep_bounded
00080     );
00081 
00084 
00086   virtual Range1D var_dep() const;
00088   virtual Range1D var_indep() const;
00089 
00091 
00094 
00096   void initialize(bool test_setup);
00098   bool is_initialized() const;
00100   size_type n() const;
00102   size_type m() const;
00104   vec_space_ptr_t space_x() const;
00106   vec_space_ptr_t space_c() const;
00108     size_type num_bounded_x() const;
00110   void force_xinit_in_bounds(bool force_xinit_in_bounds);
00112   bool force_xinit_in_bounds() const;
00114   const Vector& xinit() const;
00116   const Vector& xl() const;
00118   const Vector& xu() const;
00120   value_type max_var_bounds_viol() const;
00122   void scale_f( value_type scale_f );
00124   value_type scale_f() const;
00126   void report_final_solution(
00127     const Vector&    x
00128     ,const Vector*   lambda
00129     ,const Vector*   nu
00130     ,bool            optimal
00131     );
00132 
00134 
00135 protected:
00136 
00139 
00141   void imp_calc_f(
00142     const Vector& x, bool newx
00143     ,const ZeroOrderInfo& zero_order_info) const;
00145   void imp_calc_c(
00146     const Vector& x, bool newx
00147     ,const ZeroOrderInfo& zero_order_info) const;
00149   void imp_calc_h(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info) const;
00150 
00152 
00155 
00157   void imp_calc_Gf(
00158     const Vector& x, bool newx
00159     ,const ObjGradInfo& obj_grad_info) const;
00160 
00162 
00163 private:
00164 
00165   // /////////////////////////////////////////
00166   // Private data members
00167 
00168   VectorSpace::space_ptr_t    vec_space_;       // The vector space for dependent and indepenent variables and c(x).
00169   VectorSpace::space_ptr_t    vec_space_comp_;  // Composite vector space for x = [ xD; xI ]
00170   Range1D                     var_dep_;         // Range for dependnet variables.
00171   Range1D                     var_indep_;       // Range for independent variables.
00172 
00173   bool         initialized_;            // flag for if initialized has been called.
00174   value_type   obj_scale_;              // default = 1.0;
00175   bool         has_bounds_;             // default = true
00176   bool         force_xinit_in_bounds_;  // default = true.
00177 
00178   size_type    n_;                      // Number of variables in the problem.
00179   VectorSpace::vec_mut_ptr_t  xinit_;   // Initial guess.
00180   VectorSpace::vec_mut_ptr_t  xl_;      // lower bounds.
00181   VectorSpace::vec_mut_ptr_t  xu_;      // upper bounds.
00182 
00183   // /////////////////////////////////////////
00184   // Private member functions
00185 
00187   void assert_is_initialized() const;
00188 
00189 };  // end class ExampleNLPObjGrad
00190 
00191 // ///////////////////////////////////////////////
00192 // Inline member functions
00193 
00194 inline
00195 void ExampleNLPObjGrad::assert_is_initialized() const
00196 {
00197   typedef NLPInterfacePack::NLP NLP;
00198   TEST_FOR_EXCEPTION(
00199     !is_initialized(), NLP::UnInitialized
00200     ,"ExampleNLPObjGrad::assert_is_initialized() : Error, "
00201     "ExampleNLPObjGrad::initialize() has not been called yet." );
00202 }
00203 
00204 } // end namespace NLPInterfacePack
00205 
00206 #endif  // EXAMPLE_NLP_OBJ_GRADIENT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines