|
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 <assert.h> 00043 00044 #include "MoochoPack_LineSearchFilter_StepSetOptions.hpp" 00045 #include "OptionsFromStreamPack_StringToBool.hpp" 00046 #include "Teuchos_Assert.hpp" 00047 00048 // Define the options 00049 namespace { 00050 00051 const int local_num_options = 11; 00052 00053 enum local_EOptions 00054 { 00055 GAMMA_THETA 00056 ,GAMMA_F 00057 ,F_MIN 00058 ,GAMMA_ALPHA 00059 ,DELTA 00060 ,S_THETA 00061 ,S_F 00062 ,THETA_SMALL_FACT 00063 ,THETA_MAX 00064 ,ETA_F 00065 ,BACK_TRACK_FRAC 00066 }; 00067 00068 const char* local_SOptions[local_num_options] = 00069 { 00070 "gamma_theta" 00071 ,"gamma_f" 00072 ,"f_min" 00073 ,"gamma_alpha" 00074 ,"delta" 00075 ,"s_theta" 00076 ,"s_f" 00077 ,"theta_small_fact" 00078 ,"theta_max" 00079 ,"eta_f" 00080 ,"back_track_frac" 00081 }; 00082 00083 } 00084 00085 namespace MoochoPack { 00086 00087 LineSearchFilter_StepSetOptions::LineSearchFilter_StepSetOptions( 00088 LineSearchFilter_Step* target 00089 , const char opt_grp_name[] ) 00090 : 00091 OptionsFromStreamPack::SetOptionsFromStreamNode( 00092 opt_grp_name, local_num_options, local_SOptions ), 00093 OptionsFromStreamPack::SetOptionsToTargetBase< LineSearchFilter_Step >( target ) 00094 { 00095 } 00096 00097 void LineSearchFilter_StepSetOptions::setOption( 00098 int option_num, const std::string& option_value ) 00099 { 00100 using OptionsFromStreamPack::StringToBool; 00101 00102 typedef LineSearchFilter_Step target_t; 00103 switch( (local_EOptions)option_num ) { 00104 case GAMMA_THETA: 00105 target().gamma_theta(std::atof(option_value.c_str())); 00106 break; 00107 case GAMMA_F: 00108 target().gamma_f(std::atof(option_value.c_str())); 00109 break; 00110 case F_MIN: { 00111 if( option_value == "UNBOUNDED" ) 00112 target().f_min(target_t::F_MIN_UNBOUNDED); 00113 else 00114 target().f_min(std::atof(option_value.c_str())); 00115 break; 00116 } 00117 case GAMMA_ALPHA: 00118 target().gamma_alpha(std::atof(option_value.c_str())); 00119 break; 00120 case DELTA: 00121 target().delta(std::atof(option_value.c_str())); 00122 break; 00123 case S_THETA: 00124 target().s_theta(std::atof(option_value.c_str())); 00125 break; 00126 case S_F: 00127 target().s_f(std::atof(option_value.c_str())); 00128 break; 00129 case THETA_SMALL_FACT: 00130 target().theta_small_fact(std::atof(option_value.c_str())); 00131 break; 00132 case THETA_MAX: 00133 target().theta_max(std::atof(option_value.c_str())); 00134 break; 00135 case ETA_F: 00136 target().eta_f(std::atof(option_value.c_str())); 00137 break; 00138 case BACK_TRACK_FRAC: 00139 target().back_track_frac(std::atof(option_value.c_str())); 00140 break; 00141 default: 00142 TEUCHOS_TEST_FOR_EXCEPT(true); // Local error only? 00143 } 00144 } 00145 00146 } // end namespace MoochoPack
1.7.6.1