ConstrainedOptPack_QPSolverRelaxedQPSchurSetOptions.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 #include <math.h>
00031 
00032 #include "ConstrainedOptPack_QPSolverRelaxedQPSchurSetOptions.hpp"
00033 #include "OptionsFromStreamPack_StringToBool.hpp"
00034 
00035 // Define the options
00036 namespace {
00037 
00038   const int local_num_options = 22;
00039 
00040   enum local_EOptions {
00041     MAX_QP_ITER_FRAC
00042     ,MAX_REAL_RUNTIME
00043     ,INEQUALITY_PICK_POLICY
00044     ,BOUND_TOL
00045     ,INEQUALITY_TOL
00046     ,EQUALITY_TOL
00047     ,LOOSE_FEAS_TOL
00048     ,DUAL_INFEAS_TOL
00049     ,HUGE_PRIMAL_STEP
00050     ,HUGE_DUAL_STEP
00051     ,BIGM
00052     ,WARNING_TOL
00053     ,ERROR_TOL
00054     ,ITER_REFINE_MIN_ITER
00055     ,ITER_REFINE_MAX_ITER
00056     ,ITER_REFINE_OPT_TOL
00057     ,ITER_REFINE_FEAS_TOL
00058     ,ITER_REFINE_AT_SOLUTION
00059     ,PIVOT_WARNING_TOL
00060     ,PIVOT_SINGULAR_TOL
00061     ,PIVOT_WRONG_INERTIA_TOL
00062     ,PRINT_LEVEL
00063   };
00064 
00065   const char* local_SOptions[local_num_options] = {
00066     "max_qp_iter_frac"
00067     ,"max_real_runtime"
00068     ,"inequality_pick_policy"
00069     ,"bounds_tol"
00070     ,"inequality_tol"
00071     ,"equality_tol"
00072     ,"loose_feas_tol"
00073     ,"dual_infeas_tol"
00074     ,"huge_primal_step"
00075     ,"huge_dual_step"
00076     ,"bigM"
00077     ,"warning_tol"
00078     ,"error_tol"
00079     ,"iter_refine_min_iter"
00080     ,"iter_refine_max_iter"
00081     ,"iter_refine_opt_tol"
00082     ,"iter_refine_feas_tol"
00083     ,"iter_refine_at_solution"
00084     ,"pivot_warning_tol"
00085     ,"pivot_singular_tol"
00086     ,"pivot_wrong_inertia_tol"
00087     ,"print_level"
00088   };
00089 
00090 }
00091 
00092 namespace ConstrainedOptPack {
00093 
00094 QPSolverRelaxedQPSchurSetOptions::QPSolverRelaxedQPSchurSetOptions(
00095         QPSolverRelaxedQPSchur* target
00096       , const char opt_grp_name[] )
00097   : OptionsFromStreamPack::SetOptionsFromStreamNode(
00098         opt_grp_name, local_num_options, local_SOptions )
00099     , OptionsFromStreamPack::SetOptionsToTargetBase<
00100       QPSolverRelaxedQPSchur >( target )
00101 {}
00102 
00103 void QPSolverRelaxedQPSchurSetOptions::setOption(
00104   int option_num, const std::string& option_value )
00105 {
00106   using OptionsFromStreamPack::StringToBool;
00107   typedef QPSolverRelaxedQPSchur target_t;
00108   typedef QPSchurPack::ConstraintsRelaxedStd constr_t;
00109   switch( (local_EOptions)option_num ) {
00110     case MAX_QP_ITER_FRAC:
00111       target().max_qp_iter_frac(std::fabs(std::atof(option_value.c_str())));
00112       break;
00113     case MAX_REAL_RUNTIME:
00114       target().max_real_runtime(std::fabs(std::atof(option_value.c_str())));
00115       break;
00116     case INEQUALITY_PICK_POLICY:
00117       if(     option_value == "ADD_BOUNDS_THEN_MOST_VIOLATED_INEQUALITY" )
00118         target().inequality_pick_policy( constr_t::ADD_BOUNDS_THEN_MOST_VIOLATED_INEQUALITY );
00119       else if(  option_value == "ADD_BOUNDS_THEN_FIRST_VIOLATED_INEQUALITY" )
00120         target().inequality_pick_policy( constr_t::ADD_BOUNDS_THEN_FIRST_VIOLATED_INEQUALITY );
00121       else if(  option_value == "ADD_MOST_VIOLATED_BOUNDS_AND_INEQUALITY" )
00122         target().inequality_pick_policy( constr_t::ADD_MOST_VIOLATED_BOUNDS_AND_INEQUALITY );
00123       else
00124         throw std::invalid_argument( "QPSolverRelaxedQPSchurSetOptions::"
00125           "setOption(...) : Error, only the values of\n"
00126           " ADD_BOUNDS_THEN_MOST_VIOLATED_INEQUALITY\n"
00127           ", ADD_BOUNDS_THEN_FIRST_VIOLATED_INEQUALITY and"
00128           " ADD_MOST_VIOLATED_BOUNDS_AND_INEQUALITY \nare valid for the option"
00129           " \"QPSolverRelaxedQPSchur::inequality_pick_policy\"" );
00130       break;
00131     case BOUND_TOL:
00132       target().bounds_tol(std::fabs(std::atof(option_value.c_str())));
00133       break;
00134     case INEQUALITY_TOL:
00135       target().inequality_tol(std::fabs(std::atof(option_value.c_str())));
00136       break;
00137     case EQUALITY_TOL:
00138       target().equality_tol(std::fabs(std::atof(option_value.c_str())));
00139       break;
00140     case LOOSE_FEAS_TOL:
00141       target().loose_feas_tol(std::fabs(std::atof(option_value.c_str())));
00142       break;
00143     case DUAL_INFEAS_TOL:
00144       target().dual_infeas_tol(std::fabs(std::atof(option_value.c_str())));
00145       break;
00146     case HUGE_PRIMAL_STEP:
00147       target().huge_primal_step(std::fabs(std::atof(option_value.c_str())));
00148       break;
00149     case HUGE_DUAL_STEP:
00150       target().huge_dual_step(std::fabs(std::atof(option_value.c_str())));
00151       break;
00152     case BIGM:
00153       target().bigM(std::fabs(std::atof(option_value.c_str())));
00154       break;
00155     case WARNING_TOL:
00156       target().warning_tol(std::fabs(std::atof(option_value.c_str())));
00157       break;
00158     case ERROR_TOL:
00159       target().error_tol(std::fabs(std::atof(option_value.c_str())));
00160       break;
00161 
00162     case ITER_REFINE_MIN_ITER:
00163       target().iter_refine_min_iter(std::abs(std::atoi(option_value.c_str())));
00164       break;
00165     case ITER_REFINE_MAX_ITER:
00166       target().iter_refine_max_iter(std::abs(std::atoi(option_value.c_str())));
00167       break;
00168     case ITER_REFINE_OPT_TOL:
00169       target().iter_refine_opt_tol(std::fabs(std::atof(option_value.c_str())));
00170       break;
00171     case ITER_REFINE_FEAS_TOL:
00172       target().iter_refine_feas_tol(std::fabs(std::atof(option_value.c_str())));
00173       break;
00174     case ITER_REFINE_AT_SOLUTION:
00175       target().iter_refine_at_solution(StringToBool( "iter_refine_at_solution", option_value.c_str() ));
00176       break;
00177     case PIVOT_WARNING_TOL:
00178       target().pivot_warning_tol(std::fabs(std::atof(option_value.c_str())));
00179       break;
00180     case PIVOT_SINGULAR_TOL:
00181       target().pivot_singular_tol(std::fabs(std::atof(option_value.c_str())));
00182       break;
00183       case PIVOT_WRONG_INERTIA_TOL:
00184       target().pivot_wrong_inertia_tol(std::fabs(std::atof(option_value.c_str())));
00185       break;
00186     case PRINT_LEVEL:
00187       if(     option_value == "USE_INPUT_ARG" )
00188         target().print_level( target_t::USE_INPUT_ARG );
00189       else if(  option_value == "NO_OUTPUT" )
00190         target().print_level( target_t::NO_OUTPUT );
00191       else if(  option_value == "OUTPUT_BASIC_INFO" )
00192         target().print_level( target_t::OUTPUT_BASIC_INFO );
00193       else if(  option_value == "OUTPUT_ITER_SUMMARY" )
00194         target().print_level( target_t::OUTPUT_ITER_SUMMARY );
00195       else if(  option_value == "OUTPUT_ITER_STEPS" )
00196         target().print_level( target_t::OUTPUT_ITER_STEPS );
00197       else if(  option_value == "OUTPUT_ACT_SET" )
00198         target().print_level( target_t::OUTPUT_ACT_SET );
00199       else if(  option_value == "OUTPUT_ITER_QUANTITIES" )
00200         target().print_level( target_t::OUTPUT_ITER_QUANTITIES );
00201       else
00202         throw std::invalid_argument( "QPSolverRelaxedQPSchurSetOptions::"
00203           "setOption(...) : Error, only the values of USE_INPUT_ARG, NO_OUTPUT"
00204           ", OUTPUT_BASIC_INFO, OUTPUT_ITER_SUMMARY\n"
00205           ", OUTPUT_ITER_STEPS, OUTPUT_ACT_SET and"
00206           " OUTPUT_ITER_QUANTITIES \nare valid for the option"
00207           " \"QPSolverRelaxedQPSchur::print_level\"" );
00208       break;
00209     default:
00210       TEST_FOR_EXCEPT(true);  // Local error only?
00211   }
00212 }
00213 
00214 } // end namespace ConstrainedOptPack

Generated on Tue Jul 13 09:30:52 2010 for MOOCHO (Single Doxygen Collection) by  doxygen 1.4.7