|
MoochoPack : Framework for Large-Scale Optimization Algorithms 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 #include <ostream> 00030 #include <typeinfo> 00031 #include <iostream> 00032 #include <math.h> 00033 00034 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp" 00035 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp" 00036 #include "AbstractLinAlgPack_VectorStdOps.hpp" 00037 #include "AbstractLinAlgPack_VectorOut.hpp" 00038 #include "NLPInterfacePack_NLPBarrier.hpp" 00039 #include "MoochoPack_PostProcessBarrierLineSearch_Step.hpp" 00040 #include "MoochoPack_IpState.hpp" 00041 #include "MoochoPack_moocho_algo_conversion.hpp" 00042 #include "IterationPack_print_algorithm_step.hpp" 00043 #include "Teuchos_dyn_cast.hpp" 00044 #include "Teuchos_TestForException.hpp" 00045 00046 #define min(a,b) ( (a < b) ? a : b ) 00047 #define max(a,b) ( (a > b) ? a : b ) 00048 00049 namespace MoochoPack { 00050 00051 PostProcessBarrierLineSearch_Step::PostProcessBarrierLineSearch_Step( 00052 Teuchos::RCP<NLPInterfacePack::NLPBarrier> barrier_nlp 00053 ) 00054 : 00055 barrier_nlp_(barrier_nlp) 00056 { 00057 TEST_FOR_EXCEPTION( 00058 !barrier_nlp_.get(), 00059 std::logic_error, 00060 "PostProcessBarrierLineSearch_Step given NULL NLPBarrier." 00061 ); 00062 } 00063 00064 00065 bool PostProcessBarrierLineSearch_Step::do_step( 00066 Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type 00067 ,poss_type assoc_step_poss 00068 ) 00069 { 00070 using Teuchos::dyn_cast; 00071 using IterationPack::print_algorithm_step; 00072 using AbstractLinAlgPack::Vp_StV; 00073 00074 NLPAlgo &algo = dyn_cast<NLPAlgo>(_algo); 00075 IpState &s = dyn_cast<IpState>(_algo.state()); 00076 00077 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level(); 00078 std::ostream& out = algo.track().journal_out(); 00079 00080 // print step header. 00081 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) 00082 { 00083 using IterationPack::print_algorithm_step; 00084 print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out ); 00085 } 00086 00087 // Get iteration quantities... 00088 value_type& f_kp1 = s.f().set_k(+1); 00089 f_kp1 = barrier_nlp_->objective_term(); 00090 00091 VectorMutable& Gf_kp1 = s.Gf().set_k(+1); 00092 Gf_kp1 = *(barrier_nlp_->grad_objective_term()); 00093 00094 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) 00095 { 00096 out << "\nf = " << f_kp1 00097 << "\nbarrier_term = " << barrier_nlp_->barrier_term() << std::endl; 00098 00099 } 00100 00101 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) 00102 { 00103 out << "Gf = \n" << Gf_kp1 00104 << "\ngrad_barrier_term = \n" << *(barrier_nlp_->grad_barrier_term()); 00105 00106 } 00107 return true; 00108 } 00109 00110 00111 void PostProcessBarrierLineSearch_Step::print_step( 00112 const Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type 00113 ,poss_type assoc_step_poss, std::ostream& out, const std::string& L 00114 ) const 00115 { 00116 //const NLPAlgo &algo = rsqp_algo(_algo); 00117 //const NLPAlgoState &s = algo.rsqp_state(); 00118 out << L << "# Process out the temporary barrier term used for line search\n" 00119 << L << "f_k -= barrier_term_k\n"; 00120 } 00121 } // end namespace MoochoPack
1.7.4