4
// ***********************************************************************
6
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
7
// Copyright (2003) Sandia Corporation
9
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10
// license for use of this work by or on behalf of the U.S. Government.
12
// This library is free software; you can redistribute it and/or modify
13
// it under the terms of the GNU Lesser General Public License as
14
// published by the Free Software Foundation; either version 2.1 of the
15
// License, or (at your option) any later version.
17
// This library is distributed in the hope that it will be useful, but
18
// WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
// Lesser General Public License for more details.
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
28
// ***********************************************************************
33
#include "MoochoPack_CheckConvergenceStd_AddedStepSetOptions.hpp"
34
#include "OptionsFromStreamPack_StringToBool.hpp"
39
const int local_num_options = 2;
46
const char* local_SOptions[local_num_options] = {
48
"scale_opt_error_by_Gf",
53
namespace MoochoPack {
55
CheckConvergenceStd_AddedStepSetOptions::CheckConvergenceStd_AddedStepSetOptions(
56
CheckConvergenceStd_AddedStep* target
57
, const char opt_grp_name[] )
58
: OptionsFromStreamPack::SetOptionsFromStreamNode(
59
opt_grp_name, local_num_options, local_SOptions )
60
, OptionsFromStreamPack::SetOptionsToTargetBase<
61
CheckConvergenceStd_AddedStep >( target )
64
void CheckConvergenceStd_AddedStepSetOptions::setOption(
65
int option_num, const std::string& option_value )
67
using OptionsFromStreamPack::StringToBool;
69
typedef CheckConvergenceStd_AddedStep target_t;
70
switch( (local_EOptions)option_num ) {
71
case SCALE_KKT_ERROR_BY:
73
const std::string &option = option_value.c_str();
74
if( option == "SCALE_BY_ONE" )
75
target().scale_kkt_error_by( target_t::SCALE_BY_ONE );
76
else if( option == "SCALE_BY_NORM_2_X" )
77
target().scale_kkt_error_by( target_t::SCALE_BY_NORM_2_X );
78
else if( option == "SCALE_BY_NORM_INF_X" )
79
target().scale_kkt_error_by( target_t::SCALE_BY_NORM_INF_X );
81
throw std::invalid_argument( "Error, incorrect value for "
82
"\"scale_kkt_error_by\". Only the options "
83
"SCALE_BY_ONE, SCALE_BY_NORM_2_X, and SCALE_BY_NORM_INF_X "
87
case SCALE_OPT_ERROR_BY_GF: {
88
target().scale_opt_error_by_Gf(
89
StringToBool( "scale_opt_error_by_Gf", option_value.c_str() ) );
93
TEST_FOR_EXCEPT(true); // Local error only?
97
} // end namespace MoochoPack