ConstrainedOptPack_MeritFuncNLPL1.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 <math.h>
00030 
00031 #include "ConstrainedOptPack_MeritFuncNLPL1.hpp"
00032 #include "AbstractLinAlgPack_Vector.hpp"
00033 #include "AbstractLinAlgPack_VectorStdOps.hpp"
00034 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
00035 #include "Teuchos_TestForException.hpp"
00036 #include "Teuchos_dyn_cast.hpp"
00037 
00038 namespace ConstrainedOptPack {
00039 
00040 MeritFuncNLPL1::MeritFuncNLPL1()
00041   : deriv_(0.0), mu_(0.0)
00042 {}
00043 
00044 // Overridden from MeritFuncNLP
00045 
00046 MeritFuncNLP& MeritFuncNLPL1::operator=(const MeritFuncNLP& merit_func)
00047 {
00048   using Teuchos::dyn_cast;
00049   const MeritFuncNLPL1 &merit_func_l1 = dyn_cast<const MeritFuncNLPL1>(merit_func);
00050   if(this == &merit_func_l1)
00051     return *this; // assignment to self
00052   this->deriv_   = merit_func_l1.deriv_;
00053   this->mu_      = merit_func_l1.mu_;
00054   return *this;
00055 }
00056 
00057 value_type MeritFuncNLPL1::value(
00058   value_type       f
00059   ,const Vector    *c
00060   ,const Vector    *h
00061   ,const Vector    *hl
00062   ,const Vector    *hu
00063   ) const
00064 {
00065   value_type phi_val_h = 0.0;
00066   if(h) {
00067     size_type   max_viol_i;
00068     value_type  max_viol, h_i, hlu_i;
00069     int         bnd_type;
00070     AbstractLinAlgPack::max_inequ_viol(*h,*hl,*hu,&max_viol_i,&max_viol,&h_i,&bnd_type,&hlu_i);
00071     if(max_viol_i) phi_val_h += mu_ * fabs(h_i - hlu_i);
00072   }
00073   return f + ( c ? mu_ * c->norm_1() : 0.0) + phi_val_h;
00074 }
00075 
00076 value_type MeritFuncNLPL1::deriv() const
00077 {
00078   return deriv_;
00079 }
00080 
00081 void MeritFuncNLPL1::print_merit_func(std::ostream& out
00082   , const std::string& L ) const
00083 {
00084   out
00085     << L << "*** Define L1 merit funciton (assumes Gc_k'*d_k + c_k = 0):\n"
00086     << L << "phi(f,c) = f + mu_k*( norm(c,1) + max_viol( hl <= h <= hu ) )\n"
00087     << L << "Dphi(x_k,d_k) = Gf_k' * d_k - mu*( norm(c_k,1)  + max_viol( hl <= h_k <= hu ) )\n";
00088 }
00089 
00090 // Overridden from MeritFuncNLPDirecDeriv
00091 
00092 value_type MeritFuncNLPL1::calc_deriv(
00093   const Vector    &Gf_k
00094   ,const Vector   *c_k
00095   ,const Vector   *h_k
00096   ,const Vector   *hl
00097   ,const Vector   *hu
00098   ,const Vector   &d_k
00099   )
00100 {
00101   using AbstractLinAlgPack::dot;
00102   TEST_FOR_EXCEPTION(
00103     h_k || hl || hu, std::logic_error
00104     ,"MeritFuncNLPL1::value(...) : Error! general inequalities are not supported yet" );
00105   return deriv_ = dot( Gf_k, d_k ) - ( c_k ? mu_ * c_k->norm_1() : 0.0 );
00106 }
00107 
00108 // Overridden from MeritFuncPenaltyParam
00109 
00110 void MeritFuncNLPL1::mu(value_type mu)
00111 {
00112   mu_ = mu;
00113 }
00114 
00115 value_type MeritFuncNLPL1::mu() const
00116 {
00117   return mu_;
00118 }
00119 
00120 } // end namespace ConstrainedOptPack 

Generated on Wed May 12 21:52:28 2010 for MOOCHO (Single Doxygen Collection) by  doxygen 1.4.7