44 #include "MoochoPack_CheckConvergence_Strategy.hpp"
45 #include "OptionsFromStreamPack_StringToBool.hpp"
47 namespace MoochoPack {
55 EOptErrorCheck opt_error_check,
56 EScaleKKTErrorBy scale_opt_error_by,
57 EScaleKKTErrorBy scale_feas_error_by,
58 EScaleKKTErrorBy scale_comp_error_by,
59 bool scale_opt_error_by_Gf
62 opt_error_check_(opt_error_check),
63 scale_opt_error_by_(scale_opt_error_by),
64 scale_feas_error_by_(scale_feas_error_by),
65 scale_comp_error_by_(scale_comp_error_by),
66 scale_opt_error_by_Gf_(scale_opt_error_by_Gf)
77 const int local_num_options = 4;
87 const char* local_SOptions[local_num_options] =
90 "scale_feas_error_by",
91 "scale_comp_error_by",
92 "scale_opt_error_by_Gf",
99 const char opt_grp_name[] )
101 OptionsFromStreamPack::SetOptionsFromStreamNode(
102 opt_grp_name, local_num_options, local_SOptions ),
103 OptionsFromStreamPack::SetOptionsToTargetBase<
110 const std::string& option_value )
112 using OptionsFromStreamPack::StringToBool;
115 switch( (local_EOptions)option_num )
117 case SCALE_OPT_ERROR_BY:
118 case SCALE_FEAS_ERROR_BY:
119 case SCALE_COMP_ERROR_BY:
121 const std::string &option = option_value.c_str();
122 CheckConvergence_Strategy::EScaleKKTErrorBy scale_by = target_t::SCALE_BY_ONE;
124 if( option ==
"SCALE_BY_ONE" )
125 { scale_by = target_t::SCALE_BY_ONE; }
126 else if( option ==
"SCALE_BY_NORM_2_X" )
127 { scale_by = target_t::SCALE_BY_NORM_2_X; }
128 else if( option ==
"SCALE_BY_NORM_INF_X" )
129 { scale_by = target_t::SCALE_BY_NORM_INF_X; }
132 throw std::invalid_argument(
"Error, incorrect value for "
133 "\"scale_kkt_error_by\". Only the options "
134 "SCALE_BY_ONE, SCALE_BY_NORM_2_X, and SCALE_BY_NORM_INF_X "
139 if ((local_EOptions) option_num == SCALE_OPT_ERROR_BY)
141 target().scale_opt_error_by(scale_by);
143 else if ((local_EOptions) option_num == SCALE_FEAS_ERROR_BY)
145 target().scale_feas_error_by(scale_by);
147 else if ((local_EOptions) option_num == SCALE_COMP_ERROR_BY)
149 target().scale_comp_error_by(scale_by);
155 "Unaccounted for option_num in CheckConvergence_Strategy.cpp"
161 case SCALE_OPT_ERROR_BY_GF:
163 target().scale_opt_error_by_Gf(
164 StringToBool(
"scale_opt_error_by_Gf", option_value.c_str() ) );
CheckConvergence_StrategySetOptions(CheckConvergence_Strategy *target=0, const char opt_grp_name[]="CheckConvergenceStrategy")
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void setOption(int option_num, const std::string &option_value)
Overridden from SetOptionsFromStreamNode.
Strategy interface for performing convergence checks.
CheckConvergence_Strategy(EOptErrorCheck opt_error_check=OPT_ERROR_REDUCED_GRADIENT_LAGR, EScaleKKTErrorBy scale_opt_error_by=SCALE_BY_ONE, EScaleKKTErrorBy scale_feas_error_by=SCALE_BY_ONE, EScaleKKTErrorBy scale_comp_error_by=SCALE_BY_ONE, bool scale_opt_error_by_Gf=true)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)