|
ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 // 00042 // C declarations for QPSOL functions. These declarations should not have to change 00043 // for different platforms. As long as the fortran object code uses capitalized 00044 // names for its identifers then the declarations in Teuchos_F77_wrappers.h should be 00045 // sufficent for portability. 00046 00047 #ifndef QPOPT_CPP_DECL_H 00048 #define QPOPT_CPP_DECL_H 00049 00050 #include "Teuchos_F77_wrappers.h" 00051 00052 namespace QPOPT_CppDecl { 00053 00054 // Declarations that will link to the fortran object file. 00055 // These may change for different platforms 00056 00057 using FortranTypes::f_int; // INTEGER 00058 using FortranTypes::f_real; // REAL 00059 using FortranTypes::f_dbl_prec; // DOUBLE PRECISION 00060 using FortranTypes::f_logical; // LOGICAL 00061 00062 // ///////////////////////////////////////////////////////////////////////// 00067 00068 typedef FORTRAN_FUNC_PTR_DECL_UL_(void,QPHESS_FUNC,qphess_func) ( const f_int& N, const f_int& LDH 00069 , const f_int& JTHCOL, const f_dbl_prec* HESS, const f_dbl_prec* X, f_dbl_prec* HX 00070 , f_int* IW, const f_int& LENIW, f_dbl_prec* W, const f_int& LENW ); 00071 00073 void qpopt( 00074 const f_int& N, const f_int& NCLIN 00075 ,const f_int& LDA, const f_int& LDH, const f_dbl_prec* A 00076 ,const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC 00077 ,const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X 00078 ,f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX 00079 ,f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W 00080 ,const f_int& LENW 00081 ); 00082 00083 // ////////////////////////////////////////////////////////// 00084 // Enumerations for QPOPT options 00085 00087 enum EQPOPT_problem_type { 00088 FP = 1, 00089 LP = 2, 00090 QP1 = 3, 00091 QP2 = 4, 00092 QP3 = 5, 00093 QP4 = 6 00094 }; 00095 00097 enum EQPOPT_int_option { 00098 CHECK_FREQUENCY = 1, 00099 EXPAND_FREQUENCY = 2, 00100 FEASIBILITY_PHASE_ITER_LIMIT = 3, 00101 OPTIMALITY_PHASE_ITER_LIMIT = 4, 00102 HESSIAN_ROWS = 5, 00103 ITERATION_LIMIT = 6, 00104 MAXIMUM_DEGREES_OF_FREEDOM = 7, 00105 PRINT_FILE = 8, 00106 PRINT_LEVEL = 9, 00107 PROBLEM_TYPE = 10, // Use EQPOPT_problem_type 00108 SUMMARY_FILE = 11 00109 }; 00110 00111 00113 enum EQPOPT_logical_option { 00114 WARM_START = 1, 00115 LIST = 2, 00116 MIN_SUM = 3 00117 }; 00118 00120 enum EQPOPT_real_option { 00121 CRASH_TOLERANCE = 1, 00122 FEASIBILITY_TOLERANCE = 2, 00123 INFINITE_BOUND_SIZE = 3, 00124 INFINITE_STEP_SIZE = 4, 00125 OPTIMALITY_TOLERANCE = 5, 00126 RANK_TOLERANCE = 6 00127 }; 00128 00129 // /////////////////////////////////////////////////////////// 00130 // C++ functions for setting QPOPT options. 00131 00133 void reset_defaults(); 00134 00136 void set_int_option(EQPOPT_int_option option, const f_int&); 00137 00139 void set_logical_option(EQPOPT_logical_option option, const f_logical&); 00140 00142 void set_real_option(EQPOPT_real_option option, const f_dbl_prec&); 00143 00144 // //////////////////////////////////////////////////// 00145 // Declarations to link with Fortran QPSOL procedures 00146 00147 namespace Fortran { 00148 extern "C" { 00149 00150 FORTRAN_FUNC_DECL_UL(void,QPOPT,qpopt) ( const f_int& N, const f_int& NCLIN 00151 , const f_int& LDA, const f_int& LDH, const f_dbl_prec* A 00152 , const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC 00153 , const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X 00154 , f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX 00155 , f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W 00156 , const f_int& LENW ); 00157 00158 FORTRAN_FUNC_DECL_UL(void,QPHESS,qphess) ( const f_int& N, const f_int& LDH 00159 , const f_int& JTHCOL, const f_dbl_prec* H, const f_dbl_prec* X, f_dbl_prec* HX 00160 , f_int* IW, const f_int& LENIW, f_dbl_prec* W, const f_int& LENW ); 00161 00162 FORTRAN_FUNC_DECL_UL_(void,QPOPT_SET_DEFAULTS,qpopt_set_defaults) (); 00163 00164 FORTRAN_FUNC_DECL_UL_(void,QPOPT_INT_OPT,qpopt_int_opt) (const f_int& option, const f_int& ); 00165 00166 FORTRAN_FUNC_DECL_UL_(void,QPOPT_LOG_OPT,qpopt_log_opt) (const f_int& option, const f_logical& ); 00167 00168 FORTRAN_FUNC_DECL_UL_(void,QPOPT_REAL_OPT,qpopt_real_opt) (const f_int& option, const f_dbl_prec& ); 00169 00170 } // end extern "C" 00171 } // end namespace Fortran 00172 00173 // /////////////////////////////////////////////////////////////////////////////// 00174 // Inline definitions. 00175 00176 inline 00177 void qpopt( const f_int& N, const f_int& NCLIN 00178 , const f_int& LDA, const f_int& LDH, const f_dbl_prec* A 00179 , const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC 00180 , const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X 00181 , f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX 00182 , f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W 00183 , const f_int& LENW ) 00184 { 00185 Fortran::FORTRAN_FUNC_CALL_UL(QPOPT,qpopt) ( N, NCLIN, LDA, LDH, A, BL, BU, CVEC, H, QPHESS 00186 , ISTATE, X, INFORM, ITER, OBJ, AX, CLAMDA, IW, LENIW, W, LENW ); 00187 } 00188 00189 inline 00190 void reset_defaults() 00191 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_SET_DEFAULTS,qpopt_set_defaults) (); } 00192 00193 inline 00194 void set_int_option(EQPOPT_int_option option, const f_int& val) 00195 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_INT_OPT,qpopt_int_opt) ( option, val ); } 00196 00197 inline 00198 void set_logical_option(EQPOPT_logical_option option, const f_logical& val) 00199 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_LOG_OPT,qpopt_log_opt) ( option, val ); } 00200 00201 inline 00202 void set_real_option(EQPOPT_real_option option, const f_dbl_prec& val) 00203 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_REAL_OPT,qpopt_real_opt) ( option, val ); } 00204 00206 00207 } // end namespace QPOPT_CppDecl 00208 00209 #endif // QPOPT_CPP_DECL_H
1.7.6.1