MoochoPack_LineSearchFilter_StepSetOptions.cpp

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

Generated on Tue Oct 20 12:51:47 2009 for MOOCHO (Single Doxygen Collection) by doxygen 1.4.7