NLPInterfacePack_NLPObjGrad.cpp

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 #include "NLPInterfacePack_NLPObjGrad.hpp"
00030 #include "AbstractLinAlgPack_VectorMutable.hpp"
00031 
00032 namespace {
00033   const char name_Gf[] = "Gf";
00034 } // end namespace
00035 
00036 namespace NLPInterfacePack {
00037 
00038 // constructors
00039 
00040 NLPObjGrad::NLPObjGrad()
00041   : Gf_(NULL)
00042 {}
00043 
00044 void NLPObjGrad::initialize(bool test_setup) {
00045   num_Gf_evals_ = 0;
00046   NLP::initialize(test_setup);
00047 }
00048 
00049 // Information
00050 
00051 bool NLPObjGrad::supports_Gf() const
00052 {
00053   return true;
00054 }
00055 
00056 bool NLPObjGrad::supports_Gf_prod() const
00057 {
00058   return false;
00059 }
00060 
00061 // <<std aggr>> members for Gf
00062 
00063 void NLPObjGrad::set_Gf(VectorMutable* Gf)
00064 {
00065   Gf_ = Gf;
00066 }
00067 
00068 AbstractLinAlgPack::VectorMutable* NLPObjGrad::get_Gf()
00069 {
00070   return StandardCompositionRelationshipsPack::get_role_name(Gf_, false, name_Gf);
00071 }
00072 
00073 AbstractLinAlgPack::VectorMutable& NLPObjGrad::Gf()
00074 {
00075   return StandardCompositionRelationshipsPack::role_name(Gf_, false, name_Gf);
00076 }
00077 
00078 const AbstractLinAlgPack::Vector& NLPObjGrad::Gf() const
00079 {
00080   return StandardCompositionRelationshipsPack::role_name(Gf_, false, name_Gf);
00081 }
00082 
00083 void NLPObjGrad::unset_quantities()
00084 {
00085   NLP::unset_quantities();
00086   Gf_ = NULL;
00087 }
00088 
00089 // calculations
00090 
00091 void NLPObjGrad::calc_Gf(const Vector& x, bool newx) const
00092 {
00093   StandardCompositionRelationshipsPack::assert_role_name_set(Gf_, "NLP::calc_Gf()", name_Gf);
00094   imp_calc_Gf(x,newx,obj_grad_info());
00095   num_Gf_evals_++;
00096 }
00097 
00098 value_type NLPObjGrad::calc_Gf_prod(const Vector& x, const Vector& d, bool newx) const
00099 {
00100   TEST_FOR_EXCEPTION(
00101     true,std::logic_error
00102     ,"Error, the function calc_Gf_prod(...) is not implemented for the class "
00103     << typeid(*this).name() << "!"
00104     );
00105 }
00106 
00107 size_type NLPObjGrad::num_Gf_evals() const
00108 {
00109   return num_Gf_evals_;
00110 }
00111 
00112 } // end namespace NLPInterfacePack 

Generated on Thu Sep 18 12:35:19 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1