|
MoochoPack : Framework for Large-Scale Optimization Algorithms Version of the Day
|
00001 #if 0 00002 00003 // @HEADER 00004 // *********************************************************************** 00005 // 00006 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00007 // Copyright (2003) Sandia Corporation 00008 // 00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00010 // license for use of this work by or on behalf of the U.S. Government. 00011 // 00012 // This library is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU Lesser General Public License as 00014 // published by the Free Software Foundation; either version 2.1 of the 00015 // License, or (at your option) any later version. 00016 // 00017 // This library is distributed in the hope that it will be useful, but 00018 // WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // Lesser General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with this library; if not, write to the Free Software 00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00025 // USA 00026 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00027 // 00028 // *********************************************************************** 00029 // @HEADER 00030 00031 #include <assert.h> 00032 #include <math.h> 00033 00034 #include "MoochoPack_ReducedHessianSecantUpdateLPBFGS_StrategySetOptions.hpp" 00035 #include "OptionsFromStreamPack_StringToBool.hpp" 00036 00037 // Define the options 00038 namespace { 00039 00040 const int local_num_options = 4; 00041 00042 enum local_EOptions { 00043 MIN_NUM_UPDATES_PROJ_START 00044 ,MAX_NUM_UPDATES_PROJ_START 00045 ,NUM_SUPERBASICS_SWITCH_DENSE 00046 ,NUM_ADD_RECENT_UPDATES 00047 }; 00048 00049 const char* local_SOptions[local_num_options] = { 00050 "min_num_updates_proj_start" 00051 ,"max_num_updates_proj_start" 00052 ,"num_superbasics_switch_dense" 00053 ,"num_add_recent_updates" 00054 }; 00055 00056 } 00057 00058 namespace MoochoPack { 00059 00060 ReducedHessianSecantUpdateLPBFGS_StrategySetOptions::ReducedHessianSecantUpdateLPBFGS_StrategySetOptions( 00061 ReducedHessianSecantUpdateLPBFGS_Strategy* target 00062 , const char opt_grp_name[] ) 00063 : OptionsFromStreamPack::SetOptionsFromStreamNode( 00064 opt_grp_name, local_num_options, local_SOptions ) 00065 , OptionsFromStreamPack::SetOptionsToTargetBase< ReducedHessianSecantUpdateLPBFGS_Strategy >( target ) 00066 {} 00067 00068 void ReducedHessianSecantUpdateLPBFGS_StrategySetOptions::setOption( 00069 int option_num, const std::string& option_value ) 00070 { 00071 switch( (local_EOptions)option_num ) { 00072 case MIN_NUM_UPDATES_PROJ_START: { 00073 target().min_num_updates_proj_start( ::abs( ::atoi( option_value.c_str() ) ) ); 00074 break; 00075 } 00076 case MAX_NUM_UPDATES_PROJ_START: { 00077 target().max_num_updates_proj_start( ::abs( ::atoi( option_value.c_str() ) ) ); 00078 break; 00079 } 00080 case NUM_SUPERBASICS_SWITCH_DENSE: { 00081 target().num_superbasics_switch_dense( ::abs( ::atoi( option_value.c_str() ) ) ); 00082 break; 00083 } 00084 case NUM_ADD_RECENT_UPDATES: { 00085 target().num_add_recent_updates( ::abs( ::atoi( option_value.c_str() ) ) ); 00086 break; 00087 } 00088 default: 00089 TEST_FOR_EXCEPT(true); // Local error only? 00090 } 00091 } 00092 00093 } // end namespace MoochoPack 00094 00095 #endif // 0
1.7.4