MoochoPack_MeritFunc_PenaltyParamUpdateMultFree_AddedStep.cpp

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 <ostream>
00032 #include <typeinfo>
00033 
00034 #include "MoochoPack_MeritFunc_PenaltyParamUpdateMultFree_AddedStep.hpp"
00035 #include "MoochoPack_NLPAlgoState.hpp"
00036 #include "AbstractLinAlgPack_Vector.hpp"
00037 #include "AbstractLinAlgPack_VectorStdOps.hpp"
00038 
00039 namespace MoochoPack {
00040 
00041 MeritFunc_PenaltyParamUpdateMultFree_AddedStep::MeritFunc_PenaltyParamUpdateMultFree_AddedStep(
00042   value_type    small_mu
00043   ,value_type   mult_factor
00044   ,value_type   kkt_near_sol
00045   )
00046   :MeritFunc_PenaltyParamUpdateGuts_AddedStep(small_mu,mult_factor,kkt_near_sol)
00047 {}
00048 
00049 // Overridden from MeritFunc_PenaltyParamUpdateGuts_AddedStep
00050 
00051 bool MeritFunc_PenaltyParamUpdateMultFree_AddedStep::min_mu(
00052   NLPAlgoState& s, value_type* min_mu
00053   ) const
00054 {
00055   using AbstractLinAlgPack::dot;
00056 
00057   IterQuantityAccess<VectorMutable>
00058     &Gf_iq    = s.Gf(),
00059     &nu_iq    = s.nu(),
00060     &Ypy_iq   = s.Ypy(),
00061     &c_iq     = s.c();
00062   if ( Gf_iq.updated_k(0) && nu_iq.updated_k(0) && Ypy_iq.updated_k(0) && c_iq.updated_k(0) ) {
00063     // min_mu = abs((Gf_k+nu_k)'*Ypy_k) / norm(c_k,1)
00064     const value_type
00065       dot_Gf_Ypy = dot( Gf_iq.get_k(0), Ypy_iq.get_k(0) ),
00066       dot_nu_Ypy = dot( nu_iq.get_k(0), Ypy_iq.get_k(0) ),
00067       nrm_c      = c_iq.get_k(0).norm_1(),
00068       small_num  = std::numeric_limits<value_type>::min();
00069     *min_mu = ::fabs( dot_Gf_Ypy + dot_nu_Ypy ) / ( nrm_c + small_num );
00070     return true;
00071   }
00072   return false;
00073 }
00074 
00075 void MeritFunc_PenaltyParamUpdateMultFree_AddedStep::print_min_mu_step(
00076   std::ostream& out, const std::string& L ) const
00077 {
00078   out
00079     << L << "if Gf_k, nu_k, Ypy_k and c_k are updated then\n"
00080     << L << "   min_mu = abs((Gf_k+nu_k)'*Ypy_k) / ( norm(c_k,1) + small_num )\n"
00081     << L << "   update_mu = true\n"
00082     << L << "else\n"
00083     << L << "   update_mu = false\n"
00084     << L << "endif\n"
00085     ;
00086 }
00087 
00088 } // end namespace MoochoPack

Generated on Tue Jul 13 09:29:32 2010 for MoochoPack : Framework for Large-Scale Optimization Algorithms by  doxygen 1.4.7