|
NLPInterfacePack: C++ Interfaces and Implementation for Non-Linear Programs Version of the Day
|
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 NLP_H 00030 #define NLP_H 00031 00032 #include <stdexcept> 00033 #include <string> 00034 00035 #include "NLPInterfacePack_Types.hpp" 00036 #include "AbstractLinAlgPack_VectorMutable.hpp" 00037 #include "AbstractLinAlgPack_Permutation.hpp" 00038 #include "StandardCompositionRelationshipsPack.hpp" 00039 #include "Teuchos_RCP.hpp" 00040 #include "Teuchos_VerboseObject.hpp" 00041 00042 namespace OptionsFromStreamPack { 00043 class OptionsFromStream; 00044 } 00045 00046 namespace NLPInterfacePack { 00047 00290 class NLP : virtual public Teuchos::VerboseObject<NLP> { 00291 public: 00292 00293 typedef AbstractLinAlgPack::Vector Vector; // doxygen likes typedef? 00294 typedef AbstractLinAlgPack::VectorMutable VectorMutable; // doxygen likes typedef? 00295 00297 typedef Teuchos::RCP<const VectorSpace> vec_space_ptr_t; 00298 00300 typedef Teuchos::RCP< 00301 const OptionsFromStreamPack::OptionsFromStream> options_ptr_t; 00302 00305 00307 class UnInitialized : public std::logic_error 00308 {public: UnInitialized(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00309 00311 class InvalidInitialization : public std::logic_error 00312 {public: InvalidInitialization(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00313 00315 class IncompatibleType : public std::logic_error 00316 {public: IncompatibleType(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00317 00319 class NoBounds : public std::logic_error 00320 {public: NoBounds(const std::string& what_arg) : std::logic_error(what_arg) {}}; 00321 00323 00325 static value_type infinite_bound(); 00326 00329 00331 NLP(); 00333 virtual ~NLP(); 00334 00336 00339 00348 virtual void force_xinit_in_bounds(bool force_xinit_in_bounds) = 0; 00351 virtual bool force_xinit_in_bounds() const = 0; 00363 virtual void set_options( const options_ptr_t& options ); 00368 virtual const options_ptr_t& get_options() const; 00382 virtual void initialize( bool test_setup = false ); 00385 virtual bool is_initialized() const = 0; 00386 00388 00391 00400 virtual size_type n() const; 00409 virtual size_type m() const; 00410 00412 00415 00426 virtual vec_space_ptr_t space_x() const = 0; 00438 virtual vec_space_ptr_t space_c() const = 0; 00439 00441 00444 00452 virtual size_type num_bounded_x() const = 0; 00461 virtual const Vector& xl() const = 0; 00470 virtual const Vector& xu() const = 0; 00471 00482 virtual value_type max_var_bounds_viol() const = 0; 00483 00485 00488 00499 virtual const Vector& xinit() const = 0; 00518 virtual void get_init_lagrange_mult( 00519 VectorMutable* lambda 00520 ,VectorMutable* nu 00521 ) const; 00522 00524 00527 00540 virtual void set_f(value_type* f); 00547 virtual value_type* get_f(); 00555 virtual value_type& f(); 00563 virtual const value_type& f() const; 00564 00566 00569 00584 virtual void set_c(VectorMutable* c); 00587 virtual VectorMutable* get_c(); 00595 virtual VectorMutable& c(); 00603 virtual const Vector& c() const; 00604 00606 00609 00626 virtual void unset_quantities(); 00627 00629 00632 00643 virtual void scale_f( value_type scale_f ) = 0; 00650 virtual value_type scale_f() const = 0; 00673 virtual void calc_f(const Vector& x, bool newx = true) const; 00696 virtual void calc_c(const Vector& x, bool newx = true) const; 00697 00699 00702 00717 virtual void report_final_solution( 00718 const Vector& x 00719 ,const Vector* lambda 00720 ,const Vector* nu 00721 ,bool is_optimal 00722 ); 00723 00725 00728 00736 virtual size_type num_f_evals() const; 00744 virtual size_type num_c_evals() const; 00745 00747 00750 00756 virtual size_type ns() const; 00757 00771 virtual vec_space_ptr_t space_c_breve() const; 00772 00786 virtual vec_space_ptr_t space_h_breve() const; 00787 00799 virtual const Vector& hl_breve() const; 00800 00811 virtual const Vector& hu_breve() const; 00812 00827 virtual void set_c_breve(VectorMutable* c_breve); 00830 virtual VectorMutable* get_c_breve(); 00838 virtual VectorMutable& c_breve(); 00846 virtual const Vector& c_breve() const; 00847 00862 virtual void set_h_breve(VectorMutable* h_breve); 00865 virtual VectorMutable* get_h_breve(); 00873 virtual VectorMutable& h_breve(); 00881 virtual const Vector& h_breve() const; 00882 00895 virtual const Permutation& P_var() const; 00896 00910 virtual const Permutation& P_equ() const; 00911 00935 virtual void calc_c_breve(const Vector& x, bool newx = true) const; 00936 00960 virtual void calc_h_breve(const Vector& x, bool newx = true) const; 00961 00963 00969 struct ZeroOrderInfo { 00970 public: 00972 ZeroOrderInfo() : f(NULL), c(NULL), h(NULL) 00973 {} 00975 ZeroOrderInfo( value_type* f_in, VectorMutable* c_in, VectorMutable* h_in ) 00976 : f(f_in), c(c_in), h(h_in) 00977 {} 00979 value_type* f; 00981 VectorMutable* c; 00983 VectorMutable* h; 00984 }; // end struct ZeroOrderInfo 00985 00987 const ZeroOrderInfo zero_order_info() const; 00988 00990 const ZeroOrderInfo zero_order_info_breve() const; 00991 00992 protected: 00993 00996 01017 virtual void imp_calc_f(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info) const = 0; 01038 virtual void imp_calc_c(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info) const = 0; 01058 virtual void imp_calc_c_breve(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info_breve) const; 01078 virtual void imp_calc_h_breve(const Vector& x, bool newx, const ZeroOrderInfo& zero_order_info_breve) const; 01079 01081 01083 template<class T> 01084 void assert_ref_set(T* p, std::string info) const { 01085 StandardCompositionRelationshipsPack::assert_role_name_set(p, false, info); 01086 } 01087 01088 private: 01089 01090 // //////////////////////////////////////// 01091 // Private data members 01092 01093 #ifdef DOXYGEN_COMPILE 01094 AbstractLinAlgPack::VectorSpace *space_x; 01095 AbstractLinAlgPack::VectorSpace *space_c; 01096 AbstractLinAlgPack::VectorSpace *space_c_breve; 01097 AbstractLinAlgPack::VectorSpace *space_h_breve; 01098 Permutation *P_var; 01099 Permtuation *P_equ; 01100 #else 01101 Teuchos::RCP<Permutation> P_var_; 01102 Teuchos::RCP<Permutation> P_equ_; 01103 #endif 01104 mutable ZeroOrderInfo first_order_info_; 01105 mutable ZeroOrderInfo first_order_info_breve_; 01106 mutable size_type num_f_evals_; 01107 mutable size_type num_c_evals_; 01108 01109 }; // end class NLP 01110 01111 // ///////////////// 01112 // Inline members 01113 01114 inline 01115 const NLP::ZeroOrderInfo NLP::zero_order_info() const 01116 { 01117 return first_order_info_; 01118 } 01119 01120 inline 01121 const NLP::ZeroOrderInfo NLP::zero_order_info_breve() const 01122 { 01123 return first_order_info_breve_; 01124 } 01125 01126 } // end namespace NLPInterfacePack 01127 01128 #endif // NLP_H
1.7.4