MoochoPack_LineSearchFilter_Step.hpp

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 LINE_SEARCH_FILTER_STEP_H
00030 #define LINE_SEARCH_FILTER_STEP_H
00031 
00032 #include <list>
00033 
00034 #include "MoochoPack_Types.hpp"
00035 #include "IterationPack_AlgorithmStep.hpp"
00036 #include "IterationPack_CastIQMember.hpp"
00037 #include "Teuchos_StandardCompositionMacros.hpp"
00038 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00039 
00040 #include "IterationPack_AlgorithmState.hpp"
00041 
00042 namespace MoochoPack {
00043  
00044 // structure for storing filter points 
00045 class FilterEntry 
00046 {
00047 public:
00048   FilterEntry( value_type new_f, value_type new_theta, int new_iter)
00049     : f(new_f), theta(new_theta), iter(new_iter) {}
00050     
00051   value_type f;
00052   value_type theta;
00053   int iter;
00054 };
00055 
00056 // It is critical that an std::list be used because of the way iterators are
00057 // used!
00058 typedef std::list< FilterEntry > Filter_T;
00059 
00060 const std::string FILTER_IQ_STRING = "LS_FilterEntries";
00061 
00066 class LineSearchFilter_Step
00067   : public IterationPack::AlgorithmStep // doxygen needs full path
00068 {
00069 public:
00070     
00073 
00075   static value_type F_MIN_UNBOUNDED;
00076   
00078   
00081   
00086   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, gamma_theta );
00087 
00092   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, gamma_f );
00093 
00100   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, f_min );
00101 
00106   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, gamma_alpha );
00107 
00112   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, delta );
00113   
00118   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, s_f );
00119 
00124   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, s_theta );
00125 
00131   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, theta_small_fact );
00132 
00137   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, theta_max );
00138 
00143   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, eta_f );
00144 
00149   STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, back_track_frac );
00150 
00153   LineSearchFilter_Step(
00154     Teuchos::RCP<NLPInterfacePack::NLP> nlp
00155     ,const std::string         obj_iq_name      = "f"
00156     ,const std::string         grad_obj_iq_name = "Gf"
00157     ,const value_type          &gamma_theta      = 1e-5
00158     ,const value_type          &gamma_f          = 1e-5
00159     ,const value_type          &f_min            = F_MIN_UNBOUNDED
00160     ,const value_type          &gamma_alpha      = 5e-2
00161     ,const value_type          &delta            = 1e-4
00162     ,const value_type          &s_theta          = 1.1
00163     ,const value_type          &s_f              = 2.3
00164     ,const value_type          &theta_small_fact = 1e-4 
00165     ,const value_type          &theta_max        = 1e10
00166     ,const value_type          &eta_f            = 1e-4
00167     ,const value_type          &back_track_frac  = 0.5
00168     );
00169 
00171   
00174   ~LineSearchFilter_Step();
00175 
00177 
00181   bool do_step( Algorithm& algo, poss_type step_poss,
00182                 IterationPack::EDoStepType type,
00183                 poss_type assoc_step_poss);
00185   void print_step( const Algorithm& algo, poss_type step_poss,
00186                    IterationPack::EDoStepType type,
00187                    poss_type assoc_step_poss, std::ostream& out,
00188                    const std::string& leading_str ) const;
00190 
00191 private:
00192 
00193   // /////////////////////////////
00194   // Private data members
00195 
00196   // Private Data
00197   CastIQMember<Filter_T> filter_;
00198 
00200   CastIQMember<value_type> obj_f_;
00201 
00203   CastIQMember<VectorMutable> grad_obj_f_;
00204 
00205   // nlp to use for calculations
00206   Teuchos::RCP<NLPInterfacePack::NLP> nlp_;
00207 
00208   // /////////////////////////////
00209   // Private member functions
00210 
00211   // Validate input parameters - fix if possible
00212   bool ValidatePoint(
00213     const IterQuantityAccess<VectorMutable>& x,
00214     const IterQuantityAccess<value_type>& f,
00215     const IterQuantityAccess<VectorMutable>* c,
00216     const IterQuantityAccess<VectorMutable>* h,
00217     const bool throw_excpt
00218     ) const;
00219 
00220   // Check that new point is not within taboo region of filter
00221   bool CheckFilterAcceptability(
00222     const value_type f, 
00223     const value_type theta,
00224     const AlgorithmState& s
00225     ) const;
00226   
00227   // Check the Armijo condition on f
00228   bool CheckArmijo(
00229     const value_type Gf_t_dk, 
00230     const value_type alpha_k, 
00231     const IterQuantityAccess<value_type>& f_iq
00232     ) const;
00233 
00234   // Check if f or c has sufficient reduction
00235   bool CheckFractionalReduction(
00236     const IterQuantityAccess<value_type>& f_iq,
00237     const value_type gamma_f_used,
00238     const value_type theta_kp1, 
00239     const value_type theta_k
00240     ) const;
00241 
00242   // Calculate the new point given d and alpha
00243   void UpdatePoint(
00244     const VectorMutable& d,
00245     value_type alpha, 
00246     IterQuantityAccess<VectorMutable>& x,
00247     IterQuantityAccess<value_type>& f,
00248     IterQuantityAccess<VectorMutable>* c,
00249     IterQuantityAccess<VectorMutable>* h,
00250     NLP& nlp
00251     ) const;
00252 
00253   // Calculate the minimum alpha before hitting restoration phase
00254   value_type CalculateAlphaMin(
00255     const value_type gamma_f_used,
00256     const value_type Gf_t_dk, 
00257     const value_type theta_k,
00258     const value_type theta_small
00259     ) const;
00260 
00261   // Calculate the constraint norm
00262   value_type CalculateTheta_k(
00263     const IterQuantityAccess<VectorMutable>* c,
00264     const IterQuantityAccess<VectorMutable>* h,
00265     int k
00266     ) const;
00267 
00268   // Calculate the value of gamma_k to use
00269   value_type CalculateGammaFUsed(
00270     const IterQuantityAccess<value_type> &f,
00271     const value_type theta_k,
00272     const EJournalOutputLevel olevel,
00273     std::ostream &out
00274     ) const;
00275 
00276   // decide if we should switch to Armijo for objective
00277   bool ShouldSwitchToArmijo(
00278     const value_type Gf_t_dk,
00279     const value_type alpha_k,
00280     const value_type theta_k,
00281     const value_type theta_small
00282     ) const;
00283 
00284   // Update the filter from the last iteration
00285   void UpdateFilter( IterationPack::AlgorithmState& s ) const;
00286 
00287   // Update the filter from the last iteration and Augment it with
00288   // the new point
00289   void AugmentFilter(
00290     const value_type gamma_f_used,
00291     const value_type f_with_boundary,
00292     const value_type theta_with_boundary,
00293     IterationPack::AlgorithmState& s,
00294     const EJournalOutputLevel olevel,
00295     std::ostream &out
00296     ) const;
00297     
00298 };  // end class LineSearchFilter_Step
00299 
00300 } // end namespace MoochoPack 
00301 
00302 #endif  // LINE_SEARCH_FILTER_STEP_H

Generated on Wed May 12 21:32:13 2010 for MoochoPack : Framework for Large-Scale Optimization Algorithms by  doxygen 1.4.7