|
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 00043 #include "Moocho_ConfigDefs.hpp" 00044 00045 00046 #ifdef CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK 00047 00048 00049 #include "ConstrainedOptPack_QPKWIK_Output.hpp" 00050 #include "Teuchos_F77_wrappers.h" 00051 00052 namespace QPKWIK_Output { 00053 std::ostream* out = 0; 00054 00055 set_output::set_output(std::ostream* _out) 00056 { out = _out; } 00057 set_output::~set_output() 00058 { out = 0; } 00059 00060 } // end namespace QPKWIK_Output 00061 00062 // implementations. 00063 namespace { 00064 00065 // scalar 00066 template<class T> 00067 inline 00068 void output(const char name[], const T& val) { 00069 *QPKWIK_Output::out << name << " = " << val << "\n"; 00070 } 00071 00072 // array 00073 template<class T> 00074 inline 00075 void output(const char name[], const int n, const T array[]) { 00076 *QPKWIK_Output::out << name << " =\n"; 00077 for(const T* itr = array; itr != array + n; ) 00078 *QPKWIK_Output::out << "\t" << *itr++; 00079 *QPKWIK_Output::out << "\n"; 00080 } 00081 00082 // matrix 00083 template<class T> 00084 inline 00085 void output(const char name[], const int m, const int n, const T matrix[]) { 00086 *QPKWIK_Output::out << name << " =\n"; 00087 for(int i = 0; i < m; ++i) { 00088 for(int j = 0; j < n; ++j) { 00089 *QPKWIK_Output::out << "\t" << matrix[ i + j * m ]; 00090 } 00091 *QPKWIK_Output::out << "\n"; 00092 } 00093 } 00094 00095 } // end namespace 00096 00097 namespace QPKWIK_Print_Decl { 00098 00099 using FortranTypes::f_int; 00100 using FortranTypes::f_dbl_prec; 00101 00102 // Functions that are called by Fortran QPKWIK 00103 00104 extern "C" { 00105 00107 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_INPUT,qpkwik_print_input) ( const f_int& N, const f_int& M1 00108 , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D 00109 , const f_int& M3D, const f_dbl_prec GRAD[], const f_dbl_prec Z[] 00110 , const f_int& LDZ, const f_int IBND[] 00111 , const f_dbl_prec BL[], const f_dbl_prec BU[], const f_dbl_prec A[], const f_int& LDA 00112 , const f_dbl_prec YPY[], const f_int& INF, const f_dbl_prec& SMALL 00113 , const f_dbl_prec& VSMALL, const f_dbl_prec& VLARGE, const f_int& N1 00114 , const f_int& M12, const f_int& M23, const f_int& M123 ) 00115 { 00116 using QPKWIK_Output::out; 00117 if(!out) return; 00118 00119 *out << "\n*** Printing QPKWIK input\n"; 00120 output("N",N); 00121 output("M1",M1); 00122 output("M2",M2); 00123 output("M3",M3); 00124 output("M1D",M1D); 00125 output("M2D",M2D); 00126 output("M3D",M3D); 00127 output("GRAD",N,GRAD); 00128 output("Z",LDZ,N1,Z); 00129 output("IBND",M1D,IBND); 00130 output("BL",M1D,BL); 00131 output("BU",M3D,BU); 00132 output("A",LDA,N,A); 00133 // output("YPY",M1D,YPY); 00134 output("INF",INF); 00135 output("SMALL",SMALL); 00136 output("VSMALL",VSMALL); 00137 output("VLARGE",VLARGE); 00138 output("N1",N1); 00139 output("M12",M12); 00140 output("M23",M23); 00141 output("M123",M123); 00142 } 00143 00145 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_SPARSITY,qpkwik_print_sparsity) ( const f_int& N, const f_int& M2D 00146 , const f_int& ISPARSE, const f_int ISTART[], const f_int IPOINT[] ) 00147 { 00148 using QPKWIK_Output::out; 00149 if(!out) return; 00150 00151 *out << "\n*** Printing QPKWIK sparsity data\n"; 00152 // output("ISPARSE",ISPARSE); 00153 output("ISTART",M2D+1,ISTART); 00154 output("IPOINT",M2D*N,IPOINT); 00155 } 00156 00158 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_ITERATION_INFO,qpkwik_print_iteration_info) ( 00159 const f_int& CALLING_LABLE, const f_int& N, const f_int& M1 00160 , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D 00161 , const f_int& M3D, const f_dbl_prec X[] 00162 , const f_int& NACT, const f_int IACT[], const f_dbl_prec UR[] 00163 , const f_int IACTSTORE[], const f_dbl_prec Z[], const f_int& LDZ, const f_dbl_prec AINV[] 00164 , const f_dbl_prec T1[], const f_dbl_prec T2[], const f_dbl_prec R[] 00165 , const f_dbl_prec XX[], const f_int& IYPY, const f_dbl_prec& EXTRA 00166 , const f_int& WARM, const f_int& NACTSTORE, const f_dbl_prec& SUMY 00167 , const f_int& ICHECK, const f_int& I, const f_int& J, const f_int& II 00168 , const f_dbl_prec& SUM, const f_int& KDROP, const f_int& IFLAG 00169 , const f_int& KSTART, const f_dbl_prec& SUMNORM, const f_dbl_prec& CVMAX 00170 , const f_dbl_prec& RES, const f_int& KNEXT, const f_int& IFINISH 00171 , const f_int& IBEGIN, const f_dbl_prec& TEMP, const f_int& INDEX 00172 , const f_dbl_prec& PARNEW, const f_int& LFLAG, const f_dbl_prec& SUMA 00173 , const f_dbl_prec& SUMB, const f_dbl_prec& SUMC, const f_dbl_prec& TEMPA 00174 , const f_dbl_prec& TEMPB, const f_int& IKNEXT, const f_int& JJ, const f_int& JN 00175 , const f_dbl_prec& PARINC, const f_dbl_prec& STEP 00176 , const f_dbl_prec& RATIO, const f_int& ICOUNT, const f_dbl_prec& XMIN 00177 , const f_dbl_prec& BOTTOM, const f_int& IWARM, const f_int& ITEMP 00178 , const f_int& ITEMPP ) 00179 { 00180 using QPKWIK_Output::out; 00181 if(!out) return; 00182 00183 *out << "\n*** QPKWIK Iteration info, CALLING_LABLE = " << CALLING_LABLE << "\n"; 00184 output("X",N,X); 00185 output("NACT",NACT); 00186 output("IACT",NACT,IACT); 00187 output("UR",NACT,UR); 00188 output("IACTSTORE",NACTSTORE,IACTSTORE); 00189 output("Z",LDZ,N+1,Z); 00190 output("AINV",M3D+1,AINV); 00191 output("T1",N+1,T1); 00192 output("T2",N+1,T2); 00193 output("R",(3*(N+1)+(N+1)*(N+1))/2,R); 00194 output("XX",N,XX); 00195 output("IYPY",IYPY); 00196 output("EXTRA",EXTRA); 00197 output("WARM",WARM); 00198 output("NACTSTORE",NACTSTORE); 00199 output("SUMY",SUMY); 00200 output("ICHECK",ICHECK); 00201 output("I",I); 00202 output("J",J); 00203 output("II",II); 00204 output("SUM",SUM); 00205 output("KDROP",KDROP); 00206 output("IFLAG",IFLAG); 00207 output("KSTART",KSTART); 00208 output("SUMNORM",SUMNORM); 00209 output("CVMAX",CVMAX); 00210 output("RES",RES); 00211 output("KNEXT",KNEXT); 00212 output("IFINISH",IFINISH); 00213 output("IBEGIN",IBEGIN); 00214 output("TEMP",TEMP); 00215 output("INDEX",INDEX); 00216 output("PARNEW",PARNEW); 00217 output("LFLAG",LFLAG); 00218 output("SUMA",SUMA); 00219 output("SUMB",SUMB); 00220 output("SUMC",SUMC); 00221 output("TEMPA",TEMPA); 00222 output("TEMPB",TEMPB); 00223 output("IKNEXT",IKNEXT); 00224 output("JJ",JJ); 00225 output("JN",JN); 00226 output("PARINC",PARINC); 00227 output("STEP",STEP); 00228 output("RATIO",RATIO); 00229 output("ICOUNT",ICOUNT); 00230 output("XMIN",XMIN); 00231 output("BOTTOM",BOTTOM); 00232 output("IWARM",IWARM); 00233 output("ITEMP",ITEMP); 00234 output("ITEMPP",ITEMPP); 00235 } 00236 00237 00238 } // end extern "C" 00239 00240 00241 } // end namespace QPKWIK_Print_Decl 00242 00243 00244 #endif // CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK
1.7.6.1