00001 #if 0
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <assert.h>
00032 #include <math.h>
00033
00034 #include "ReducedHessianBFGSStd_StepSetOptions.h"
00035 #include "OptionsFromStreamPack_StringToBool.hpp"
00036
00037
00038 namespace {
00039
00040 const int local_num_options = 5;
00041
00042 enum local_EOptions {
00043 RESCALE_INIT_IDENTITY
00044 ,USE_DAMPENING
00045 ,SECANT_TESTING
00046 ,SECANT_WARNING_TOL
00047 ,SECANT_ERROR_TOL
00048 };
00049
00050 const char* local_SOptions[local_num_options] = {
00051 "rescale_init_identity"
00052 ,"use_dampening"
00053 ,"secant_testing"
00054 ,"secant_warning_tol"
00055 ,"secant_error_tol"
00056 };
00057
00058 }
00059
00060 namespace MoochoPack {
00061
00062 ReducedHessianBFGSStd_StepSetOptions::ReducedHessianBFGSStd_StepSetOptions(
00063 ReducedHessianBFGSStd_Step* target
00064 , const char opt_grp_name[] )
00065 : OptionsFromStreamPack::SetOptionsFromStreamNode(
00066 opt_grp_name, local_num_options, local_SOptions )
00067 , OptionsFromStreamPack::SetOptionsToTargetBase<
00068 ReducedHessianBFGSStd_Step >( target )
00069 {}
00070
00071 void ReducedHessianBFGSStd_StepSetOptions::setOption(
00072 int option_num, const std::string& option_value )
00073 {
00074 using OptionsFromStreamPack::StringToBool;
00075 typedef ReducedHessianBFGSStd_Step target_t;
00076 switch( (local_EOptions)option_num ) {
00077 case RESCALE_INIT_IDENTITY:
00078 target().rescale_init_identity(
00079 StringToBool( "rescale_init_identity", option_value.c_str() ));
00080 break;
00081 case USE_DAMPENING:
00082 target().use_dampening(
00083 StringToBool( "use_dampening", option_value.c_str() ));
00084 break;
00085 case SECANT_TESTING:
00086 {
00087 const std::string &option = option_value.c_str();
00088 if( option == "DEFAULT" )
00089 target().secant_testing( target_t::SECANT_TEST_DEFAULT );
00090 else if( option == "TEST" )
00091 target().secant_testing( target_t::SECANT_TEST_ALWAYS );
00092 else if( option == "NO_TEST" )
00093 target().secant_testing( target_t::SECANT_NO_TEST );
00094 else
00095 throw std::invalid_argument( "Error, incorrect value for "
00096 "\"secant_testing\"." );
00097 break;
00098 }
00099 case SECANT_WARNING_TOL:
00100 target().secant_warning_tol(::fabs(::atof(option_value.c_str())));
00101 break;
00102 case SECANT_ERROR_TOL:
00103 target().secant_error_tol(::fabs(::atof(option_value.c_str())));
00104 break;
00105 default:
00106 TEST_FOR_EXCEPT(true);
00107 }
00108 }
00109
00110 }
00111
00112 #endif // 0