ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ConstrainedOptPack_QPOPT_CppDecl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 //
42 // C declarations for QPSOL functions. These declarations should not have to change
43 // for different platforms. As long as the fortran object code uses capitalized
44 // names for its identifers then the declarations in Teuchos_F77_wrappers.h should be
45 // sufficent for portability.
46 
47 #ifndef QPOPT_CPP_DECL_H
48 #define QPOPT_CPP_DECL_H
49 
50 #include "Teuchos_F77_wrappers.h"
51 
52 namespace QPOPT_CppDecl {
53 
54 // Declarations that will link to the fortran object file.
55 // These may change for different platforms
56 
57 using FortranTypes::f_int; // INTEGER
58 using FortranTypes::f_real; // REAL
59 using FortranTypes::f_dbl_prec; // DOUBLE PRECISION
60 using FortranTypes::f_logical; // LOGICAL
61 
62 // /////////////////////////////////////////////////////////////////////////
67 
68 typedef FORTRAN_FUNC_PTR_DECL_UL_(void,QPHESS_FUNC,qphess_func) ( const f_int& N, const f_int& LDH
69  , const f_int& JTHCOL, const f_dbl_prec* HESS, const f_dbl_prec* X, f_dbl_prec* HX
70  , f_int* IW, const f_int& LENIW, f_dbl_prec* W, const f_int& LENW );
71 
73 void qpopt(
74  const f_int& N, const f_int& NCLIN
75  ,const f_int& LDA, const f_int& LDH, const f_dbl_prec* A
76  ,const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC
77  ,const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X
78  ,f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX
79  ,f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W
80  ,const f_int& LENW
81  );
82 
83 // //////////////////////////////////////////////////////////
84 // Enumerations for QPOPT options
85 
87 enum EQPOPT_problem_type {
88  FP = 1,
89  LP = 2,
90  QP1 = 3,
91  QP2 = 4,
92  QP3 = 5,
93  QP4 = 6
94 };
95 
97 enum EQPOPT_int_option {
98  CHECK_FREQUENCY = 1,
99  EXPAND_FREQUENCY = 2,
100  FEASIBILITY_PHASE_ITER_LIMIT = 3,
101  OPTIMALITY_PHASE_ITER_LIMIT = 4,
102  HESSIAN_ROWS = 5,
103  ITERATION_LIMIT = 6,
104  MAXIMUM_DEGREES_OF_FREEDOM = 7,
105  PRINT_FILE = 8,
106  PRINT_LEVEL = 9,
107  PROBLEM_TYPE = 10, // Use EQPOPT_problem_type
108  SUMMARY_FILE = 11
109 };
110 
111 
113 enum EQPOPT_logical_option {
114  WARM_START = 1,
115  LIST = 2,
116  MIN_SUM = 3
117 };
118 
120 enum EQPOPT_real_option {
121  CRASH_TOLERANCE = 1,
122  FEASIBILITY_TOLERANCE = 2,
123  INFINITE_BOUND_SIZE = 3,
124  INFINITE_STEP_SIZE = 4,
125  OPTIMALITY_TOLERANCE = 5,
126  RANK_TOLERANCE = 6
127 };
128 
129 // ///////////////////////////////////////////////////////////
130 // C++ functions for setting QPOPT options.
131 
133 void reset_defaults();
134 
136 void set_int_option(EQPOPT_int_option option, const f_int&);
137 
139 void set_logical_option(EQPOPT_logical_option option, const f_logical&);
140 
142 void set_real_option(EQPOPT_real_option option, const f_dbl_prec&);
143 
144 // ////////////////////////////////////////////////////
145 // Declarations to link with Fortran QPSOL procedures
146 
147 namespace Fortran {
148 extern "C" {
149 
150 FORTRAN_FUNC_DECL_UL(void,QPOPT,qpopt) ( const f_int& N, const f_int& NCLIN
151  , const f_int& LDA, const f_int& LDH, const f_dbl_prec* A
152  , const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC
153  , const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X
154  , f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX
155  , f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W
156  , const f_int& LENW );
157 
158 FORTRAN_FUNC_DECL_UL(void,QPHESS,qphess) ( const f_int& N, const f_int& LDH
159  , const f_int& JTHCOL, const f_dbl_prec* H, const f_dbl_prec* X, f_dbl_prec* HX
160  , f_int* IW, const f_int& LENIW, f_dbl_prec* W, const f_int& LENW );
161 
162 FORTRAN_FUNC_DECL_UL_(void,QPOPT_SET_DEFAULTS,qpopt_set_defaults) ();
163 
164 FORTRAN_FUNC_DECL_UL_(void,QPOPT_INT_OPT,qpopt_int_opt) (const f_int& option, const f_int& );
165 
166 FORTRAN_FUNC_DECL_UL_(void,QPOPT_LOG_OPT,qpopt_log_opt) (const f_int& option, const f_logical& );
167 
168 FORTRAN_FUNC_DECL_UL_(void,QPOPT_REAL_OPT,qpopt_real_opt) (const f_int& option, const f_dbl_prec& );
169 
170 } // end extern "C"
171 } // end namespace Fortran
172 
173 // ///////////////////////////////////////////////////////////////////////////////
174 // Inline definitions.
175 
176 inline
177 void qpopt( const f_int& N, const f_int& NCLIN
178  , const f_int& LDA, const f_int& LDH, const f_dbl_prec* A
179  , const f_dbl_prec* BL, const f_dbl_prec* BU, const f_dbl_prec* CVEC
180  , const f_dbl_prec* H, FORTRAN_NAME_UL_(QPHESS_FUNC,qphess_func) QPHESS, f_int* ISTATE, f_dbl_prec* X
181  , f_int& INFORM, f_int& ITER, f_dbl_prec& OBJ, f_dbl_prec* AX
182  , f_dbl_prec* CLAMDA, f_int* IW, const f_int& LENIW, f_dbl_prec* W
183  , const f_int& LENW )
184 {
185  Fortran::FORTRAN_FUNC_CALL_UL(QPOPT,qpopt) ( N, NCLIN, LDA, LDH, A, BL, BU, CVEC, H, QPHESS
186  , ISTATE, X, INFORM, ITER, OBJ, AX, CLAMDA, IW, LENIW, W, LENW );
187 }
188 
189 inline
190 void reset_defaults()
191 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_SET_DEFAULTS,qpopt_set_defaults) (); }
192 
193 inline
194 void set_int_option(EQPOPT_int_option option, const f_int& val)
195 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_INT_OPT,qpopt_int_opt) ( option, val ); }
196 
197 inline
198 void set_logical_option(EQPOPT_logical_option option, const f_logical& val)
199 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_LOG_OPT,qpopt_log_opt) ( option, val ); }
200 
201 inline
202 void set_real_option(EQPOPT_real_option option, const f_dbl_prec& val)
203 { Fortran::FORTRAN_FUNC_CALL_UL_(QPOPT_REAL_OPT,qpopt_real_opt) ( option, val ); }
204 
206 
207 } // end namespace QPOPT_CppDecl
208 
209 #endif // QPOPT_CPP_DECL_H