ConstrainedOptPack_DirectLineSearchArmQuad_StrategySetOptions.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 "ConstrainedOptPack_DirectLineSearchArmQuad_StrategySetOptions.hpp"
00032 #include "OptionsFromStreamPack_StringToBool.hpp"
00033 
00034 // Define the options
00035 namespace {
00036 
00037   const int local_num_options = 5;
00038 
00039   enum local_EOptions {
00040     SLOPE_FRAC,
00041     MIN_FRAC_STEP,
00042     MAX_FRAC_STEP,
00043     MAX_LS_ITER,
00044     MAX_OUT_LS_ITER
00045   };
00046 
00047   const char* local_SOptions[local_num_options] = {
00048     "slope_frac",
00049     "min_frac_step",
00050     "max_frac_step",
00051     "max_ls_iter",
00052     "max_out_ls_iter"
00053   };
00054 
00055 }
00056 
00057 namespace ConstrainedOptPack {
00058 
00059 DirectLineSearchArmQuad_StrategySetOptions::DirectLineSearchArmQuad_StrategySetOptions(
00060         DirectLineSearchArmQuad_Strategy* qp_solver
00061       , const char opt_grp_name[] )
00062   : OptionsFromStreamPack::SetOptionsFromStreamNode(
00063         opt_grp_name, local_num_options, local_SOptions )
00064     , OptionsFromStreamPack::SetOptionsToTargetBase<
00065       DirectLineSearchArmQuad_Strategy >( qp_solver )
00066 {}
00067 
00068 void DirectLineSearchArmQuad_StrategySetOptions::setOption(
00069   int option_num, const std::string& option_value )
00070 {
00071   using OptionsFromStreamPack::StringToBool;
00072   switch( (local_EOptions)option_num ) {
00073     case SLOPE_FRAC: {
00074       target().eta( std::atof( option_value.c_str() ) );
00075       break;
00076     }
00077     case MIN_FRAC_STEP: {
00078       target().min_frac( std::atof( option_value.c_str() ) );
00079       break;
00080     }
00081     case MAX_FRAC_STEP: {
00082       target().max_frac( std::atof( option_value.c_str() ) );
00083       break;
00084     }
00085     case MAX_LS_ITER: {
00086       target().set_max_iter( std::atof( option_value.c_str() ) );
00087       break;
00088     }
00089     case MAX_OUT_LS_ITER: {
00090       target().max_out_iter( StringToBool( "max_out_ls_iter", option_value.c_str() ) );
00091       break;
00092     }
00093     default:
00094       TEST_FOR_EXCEPT(true);  // Local error only?
00095   }
00096 }
00097 
00098 } // end namespace ConstrainedOptPack 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:10:57 2011 for MOOCHO (Single Doxygen Collection) by  doxygen 1.6.3