MoochoPack_EvalNewPointStd_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_EvalNewPointStd_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 = 3;
00039 
00040   enum local_EOptions {
00041     FD_DERIV_TESTING
00042     ,DECOMP_SYS_TESTING
00043     ,DECOMP_SYS_TESTING_PRINT_LEVEL
00044   };
00045 
00046   const char* local_SOptions[local_num_options] = {
00047     "fd_deriv_testing"
00048     ,"decomp_sys_testing"
00049     ,"decomp_sys_testing_print_level"
00050   };
00051 
00052 }
00053 
00054 namespace MoochoPack {
00055 
00056 EvalNewPointStd_StepSetOptions::EvalNewPointStd_StepSetOptions(
00057         EvalNewPointStd_Step* target
00058       , const char opt_grp_name[] )
00059   : OptionsFromStreamPack::SetOptionsFromStreamNode(
00060         opt_grp_name, local_num_options, local_SOptions )
00061     , OptionsFromStreamPack::SetOptionsToTargetBase<
00062       EvalNewPointStd_Step >( target )
00063 {}
00064 
00065 void EvalNewPointStd_StepSetOptions::setOption(
00066   int option_num, const std::string& option_value )
00067 {
00068   using OptionsFromStreamPack::StringToBool;
00069 
00070   typedef EvalNewPointStd_Step target_t;
00071   switch( (local_EOptions)option_num ) {
00072       case FD_DERIV_TESTING:
00073     {
00074       const std::string &option = option_value.c_str();
00075       if( option == "FD_DEFAULT" )
00076         target().fd_deriv_testing( target_t::FD_DEFAULT );
00077       else if( option == "FD_TEST" )
00078         target().fd_deriv_testing( target_t::FD_TEST );
00079       else if( option == "FD_NO_TEST" )
00080         target().fd_deriv_testing( target_t::FD_NO_TEST );
00081       else
00082         TEST_FOR_EXCEPTION(
00083           true, std::invalid_argument
00084           ,"Error, incorrect value for "
00085           "\"fd_deriv_testing\".  Only the options "
00086           "FD_DEFAULT, FD_TEST, and FD_NO_TEST "
00087           "are available" );
00088       break;
00089     }
00090       case DECOMP_SYS_TESTING:
00091     {
00092       const std::string &option = option_value.c_str();
00093       if( option == "DST_DEFAULT" )
00094         target().decomp_sys_testing( DecompositionSystemHandler_Strategy::DST_DEFAULT );
00095       else if( option == "DST_TEST" )
00096         target().decomp_sys_testing( DecompositionSystemHandler_Strategy::DST_TEST );
00097       else if( option == "DST_NO_TEST" )
00098         target().decomp_sys_testing( DecompositionSystemHandler_Strategy::DST_NO_TEST );
00099       else
00100         TEST_FOR_EXCEPTION(
00101           true, std::invalid_argument
00102           ,"Error, incorrect value for "
00103           "\"decomp_sys_testing\".  Only the options "
00104           "DST_DEFAULT, DST_TEST, and DST_NO_TEST "
00105           "are available" );
00106       break;
00107     }
00108       case DECOMP_SYS_TESTING_PRINT_LEVEL:
00109     {
00110       const std::string &option = option_value.c_str();
00111       if( option == "DSPL_USE_GLOBAL" )
00112         target().decomp_sys_testing_print_level( DecompositionSystemHandler_Strategy::DSPL_USE_GLOBAL);
00113       else if( option == "DSPL_LEAVE_DEFAULT" )
00114         target().decomp_sys_testing_print_level( DecompositionSystemHandler_Strategy::DSPL_LEAVE_DEFAULT);
00115       else
00116         TEST_FOR_EXCEPTION(
00117           true, std::invalid_argument
00118           ,"Error, incorrect value for "
00119           "\"decomp_sys_testing_print_level\".  Only the options "
00120           "DSPL_USE_GLOBAL and DSPL_LEAVE_DEFAULT are available" );
00121       break;
00122     }
00123     default:
00124       TEST_FOR_EXCEPT(true);  // Local error only?
00125   }
00126 }
00127 
00128 } // end namespace MoochoPack 

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