|
MoochoPack : Framework for Large-Scale Optimization Algorithms Version of the Day
|
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 #include <math.h> 00031 00032 #include "MoochoPack_TangentialStepWithInequStd_StepSetOptions.hpp" 00033 #include "OptionsFromStreamPack_StringToBool.hpp" 00034 #include "Teuchos_TestForException.hpp" 00035 00036 // Define the options 00037 namespace { 00038 00039 const int local_num_options = 4; 00040 00041 enum local_EOptions { 00042 WARM_START_FRAC 00043 ,QP_TESTING 00044 ,PRIMAL_FEASIBLE_POINT_ERROR 00045 ,DUAL_FEASIBLE_POINT_ERROR 00046 }; 00047 00048 const char* local_SOptions[local_num_options] = { 00049 "warm_start_frac" 00050 ,"qp_testing" 00051 ,"primal_feasible_point_error" 00052 ,"dual_feasible_point_error" 00053 }; 00054 00055 } 00056 00057 namespace MoochoPack { 00058 00059 TangentialStepWithInequStd_StepSetOptions::TangentialStepWithInequStd_StepSetOptions( 00060 TangentialStepWithInequStd_Step* target 00061 ,const char opt_grp_name[] 00062 ) 00063 :OptionsFromStreamPack::SetOptionsFromStreamNode( 00064 opt_grp_name, local_num_options, local_SOptions ) 00065 ,OptionsFromStreamPack::SetOptionsToTargetBase< 00066 TangentialStepWithInequStd_Step >( target ) 00067 {} 00068 00069 void TangentialStepWithInequStd_StepSetOptions::setOption( 00070 int option_num, const std::string& option_value ) 00071 { 00072 using OptionsFromStreamPack::StringToBool; 00073 00074 typedef TangentialStepWithInequStd_Step target_t; 00075 switch( (local_EOptions)option_num ) { 00076 case WARM_START_FRAC: 00077 target().warm_start_frac(std::fabs(std::atof(option_value.c_str()))); 00078 break; 00079 case QP_TESTING: 00080 { 00081 const std::string &option = option_value.c_str(); 00082 if( option == "QP_TEST_DEFAULT" ) 00083 target().qp_testing( target_t::QP_TEST_DEFAULT ); 00084 else if( option == "QP_TEST" ) 00085 target().qp_testing( target_t::QP_TEST ); 00086 else if( option == "QP_NO_TEST" ) 00087 target().qp_testing( target_t::QP_NO_TEST ); 00088 else 00089 TEST_FOR_EXCEPTION( 00090 true, std::invalid_argument 00091 ,"Error, incorrect value \'" << option << "\' for " 00092 "\"qp_testing\". Only the options " 00093 "QP_TEST_DEFAULT, QP_TEST, and QP_NO_TEST " 00094 "are available" ); 00095 break; 00096 } 00097 case PRIMAL_FEASIBLE_POINT_ERROR: 00098 target().primal_feasible_point_error(StringToBool("primal_feasible_point_error",option_value.c_str())); 00099 break; 00100 case DUAL_FEASIBLE_POINT_ERROR: 00101 target().dual_feasible_point_error(StringToBool("dual_feasible_point_error",option_value.c_str())); 00102 break; 00103 default: 00104 TEST_FOR_EXCEPT(true); // Local error only? 00105 } 00106 } 00107 00108 } // end namespace MoochoPack
1.7.4