|
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #include "MoochoPack_NewDecompositionSelectionStd_Strategy.hpp" 00043 #include "MoochoPack_MoochoAlgorithmStepNames.hpp" 00044 #include "MoochoPack_NLPAlgo.hpp" 00045 #include "MoochoPack_NLPAlgoState.hpp" 00046 00047 namespace MoochoPack { 00048 00049 NewDecompositionSelectionStd_Strategy::NewDecompositionSelectionStd_Strategy( 00050 const decomp_sys_handler_ptr_t &decomp_sys_handler 00051 ) 00052 :decomp_sys_handler_(decomp_sys_handler) 00053 {} 00054 00055 bool NewDecompositionSelectionStd_Strategy::new_decomposition( 00056 NLPAlgo& algo, Algorithm::poss_type step_poss 00057 ,IterationPack::EDoStepType type, Algorithm::poss_type assoc_step_poss 00058 ) 00059 { 00060 NLPAlgoState &s = algo.rsqp_state(); 00061 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level(); 00062 std::ostream& out = algo.track().journal_out(); 00063 00064 // Check to see if we have a decomposition system set 00065 if( !get_decomp_sys_handler().get() ) { 00066 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) { 00067 out << "\nWe are asked to select a new basis but there is no\n" 00068 "decomposition system set so we have no choice but to terminiate\n" 00069 "the algorithm" 00070 << " (k = " << algo.state().k() << ")\n"; 00071 } 00072 algo.terminate(false); 00073 return false; 00074 } 00075 00076 // We may get an infinite loop here so make sure we are under the max 00077 // number of iterations. 00078 if( s.k() >= algo.algo_cntr().max_iter() ) { 00079 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) { 00080 out << "\nThe maximum number of rSQP iterations\n" 00081 << " have been exceeded so quit " 00082 << " (k = " << algo.state().k() << ")\n"; 00083 } 00084 algo.terminate(false); 00085 return false; 00086 } 00087 00088 // Select a new decomposition 00089 decomp_sys_handler().select_new_decomposition(true); 00090 if( (int)olevel >= (int)PRINT_ALGORITHM_STEPS ) { 00091 out << "x_kp1 = x_k\n" 00092 << "k=k+1\n" 00093 << "goto EvalNewPoint\n"; 00094 } 00095 s.x().set_k(1) = s.x().get_k(0); 00096 s.alpha().set_k(0) = 0.0; // Show that no step was taken. 00097 algo.track().output_iteration( algo ); 00098 s.next_iteration(); 00099 algo.do_step_next( EvalNewPoint_name ); 00100 return false; 00101 } 00102 00103 void NewDecompositionSelectionStd_Strategy::print_new_decomposition( 00104 const NLPAlgo& algo, Algorithm::poss_type step_poss 00105 ,IterationPack::EDoStepType type, Algorithm::poss_type assoc_step_poss 00106 ,std::ostream& out, const std::string& L 00107 ) const 00108 { 00109 out 00110 << L << "if k > max_iter then\n" 00111 << L << " terminate the algorithm\n" 00112 << L << "end\n" 00113 << L << "Select a new basis at current point\n" 00114 << L << "x_kp1 = x_k\n" 00115 << L << "alpha_k = 0\n" 00116 << L << "k=k+1\n" 00117 << L << "goto EvalNewPoint\n"; 00118 } 00119 00120 } // end namespace MoochoPack
1.7.6.1