AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
AbstractLinAlgPack_DirectSparseSolverMA28SetOptions.cpp
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 "Moocho_ConfigDefs.hpp"
00032 
00033 #ifdef HAVE_MOOCHO_MA28
00034 
00035 #include "AbstractLinAlgPack_DirectSparseSolverMA28SetOptions.hpp"
00036 #include "OptionsFromStreamPack_StringToBool.hpp"
00037 
00038 // Define the options
00039 namespace {
00040 
00041   const int local_num_options = 8;
00042 
00043   enum local_EOptions {
00044     ESTIMATED_FILLIN_RATIO
00045       ,U
00046     ,GROW
00047     ,TOL
00048     ,NSRCH
00049     ,LBIG
00050     ,PRINT_MA28_OUTPUTS
00051     ,OUTPUT_FILE_NAME
00052   };
00053 
00054   const char* local_SOptions[local_num_options] = {
00055     "estimated_fillin_ratio"
00056       ,"u"
00057     ,"grow"
00058     ,"tol"
00059     ,"nsrch"
00060     ,"lbig"
00061     ,"print_ma28_outputs"
00062     ,"output_file_name"
00063   };
00064 
00065 }
00066 
00067 namespace AbstractLinAlgPack {
00068 
00069 DirectSparseSolverMA28SetOptions::DirectSparseSolverMA28SetOptions(
00070       DirectSparseSolverMA28* qp_solver )
00071   : OptionsFromStreamPack::SetOptionsFromStreamNode(
00072         "DirectSparseSolverMA28", local_num_options, local_SOptions )
00073     , OptionsFromStreamPack::SetOptionsToTargetBase<
00074       DirectSparseSolverMA28 >( qp_solver )
00075 {}
00076 
00077 void DirectSparseSolverMA28SetOptions::setOption(
00078   int option_num, const std::string& option_value )
00079 {
00080   using OptionsFromStreamPack::StringToBool;
00081 
00082   switch( (local_EOptions)option_num ) {
00083     case ESTIMATED_FILLIN_RATIO: {
00084       target().estimated_fillin_ratio( ::atof( option_value.c_str() ) );
00085       break;
00086     }
00087     case U: {
00088       target().u( ::atof( option_value.c_str() ) );
00089       break;
00090     }
00091     case GROW: {
00092       target().grow( StringToBool( "grow", option_value.c_str() ) );
00093       break;
00094     }
00095     case TOL: {
00096       target().tol( ::atof( option_value.c_str() ) );
00097       break;
00098     }
00099     case NSRCH: {
00100       target().nsrch( ::atoi( option_value.c_str() ) );
00101       break;
00102     }
00103     case LBIG: {
00104       target().lbig( StringToBool( "lbig", option_value.c_str() ) );
00105       break;
00106     }
00107     case PRINT_MA28_OUTPUTS: {
00108       target().print_ma28_outputs( StringToBool( "grow", option_value.c_str() ) );
00109       break;
00110     }
00111     case OUTPUT_FILE_NAME: {
00112       if( option_value == "NONE" )
00113         target().output_file_name( "" );
00114       else
00115         target().output_file_name( option_value );
00116       break;
00117     }
00118     default:
00119       TEST_FOR_EXCEPT(true);  // Local error only?
00120   }
00121 }
00122 
00123 } // end namespace AbstractLinAlgPack 
00124 
00125 #endif // HAVE_MOOCHO_MA28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends