MoochoPack_CheckConvergenceStd_AddedStepSetOptions.cpp

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 
00033 #include "MoochoPack_CheckConvergenceStd_AddedStepSetOptions.hpp"
00034 #include "OptionsFromStreamPack_StringToBool.hpp"
00035 
00036 // Define the options
00037 namespace {
00038 
00039   const int local_num_options = 2;
00040 
00041   enum local_EOptions {
00042     SCALE_KKT_ERROR_BY,
00043     SCALE_OPT_ERROR_BY_GF
00044   };
00045 
00046   const char* local_SOptions[local_num_options] = {
00047     "scale_kkt_error_by",
00048     "scale_opt_error_by_Gf",
00049   };
00050 
00051 }
00052 
00053 namespace MoochoPack {
00054 
00055 CheckConvergenceStd_AddedStepSetOptions::CheckConvergenceStd_AddedStepSetOptions(
00056         CheckConvergenceStd_AddedStep* target
00057       , const char opt_grp_name[] )
00058   : OptionsFromStreamPack::SetOptionsFromStreamNode(
00059         opt_grp_name, local_num_options, local_SOptions )
00060     , OptionsFromStreamPack::SetOptionsToTargetBase<
00061       CheckConvergenceStd_AddedStep >( target )
00062 {}
00063 
00064 void CheckConvergenceStd_AddedStepSetOptions::setOption(
00065   int option_num, const std::string& option_value )
00066 {
00067   using OptionsFromStreamPack::StringToBool;
00068 
00069   typedef CheckConvergenceStd_AddedStep target_t;
00070   switch( (local_EOptions)option_num ) {
00071       case SCALE_KKT_ERROR_BY:
00072     {
00073       const std::string &option = option_value.c_str();
00074       if( option == "SCALE_BY_ONE" )
00075         target().scale_kkt_error_by( target_t::SCALE_BY_ONE );
00076       else if( option == "SCALE_BY_NORM_2_X" )
00077         target().scale_kkt_error_by( target_t::SCALE_BY_NORM_2_X );
00078       else if( option == "SCALE_BY_NORM_INF_X" )
00079         target().scale_kkt_error_by( target_t::SCALE_BY_NORM_INF_X );
00080       else
00081         throw std::invalid_argument( "Error, incorrect value for "
00082           "\"scale_kkt_error_by\".  Only the options "
00083           "SCALE_BY_ONE, SCALE_BY_NORM_2_X, and SCALE_BY_NORM_INF_X "
00084           "are available" );
00085       break;
00086     }
00087     case SCALE_OPT_ERROR_BY_GF: {
00088       target().scale_opt_error_by_Gf(
00089         StringToBool( "scale_opt_error_by_Gf", option_value.c_str() ) );
00090       break;
00091     }
00092     default:
00093       TEST_FOR_EXCEPT(true);  // Local error only?
00094   }
00095 }
00096 
00097 } // end namespace MoochoPack 
00098 
00099 #endif // 0

Generated on Wed May 12 21:32:12 2010 for MoochoPack : Framework for Large-Scale Optimization Algorithms by  doxygen 1.4.7