42 #ifdef CONSTRAINED_OPTIMIZATION_PACK_USE_QPOPT
50 #include "ConstrainedOptPack_QPSolverRelaxedQPOPT.hpp"
51 #include "ConstrainedOptPack_QPOPT_CppDecl.hpp"
52 #include "AbstractLinAlgPack_MatrixOp.hpp"
53 #include "AbstractLinAlgPack_SpVectorClass.hpp"
54 #include "AbstractLinAlgPack_EtaVector.hpp"
55 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
56 #include "AbstractLinAlgPack_VectorMutableDense.hpp"
57 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
58 #include "DenseLinAlgPack_DMatrixOut.hpp"
59 #include "DenseLinAlgPack_DVectorOut.hpp"
66 typedef FortranTypes::f_int f_int;
67 typedef FortranTypes::f_dbl_prec f_dbl_prec;
68 typedef FortranTypes::f_logical f_logical;
78 void qphess_server_relax(
const f_int& N,
const f_int& LDH
79 ,
const f_int& JTHCOL,
const f_dbl_prec* H,
const f_dbl_prec* X, f_dbl_prec* HX
80 , f_int* IW,
const f_int& LENIW, f_dbl_prec* W,
const f_int& LENW )
82 using DenseLinAlgPack::DVectorSlice;
83 using AbstractLinAlgPack::SpVector;
84 using LinAlgOpPack::V_MtV;
85 using ConstrainedOptPack::QPSolverRelaxedQPOPT;
89 const QPSolverRelaxedQPOPT* qp_solver =
reinterpret_cast<const QPSolverRelaxedQPOPT*
>(H);
92 const DVectorSlice x(const_cast<f_dbl_prec*>(X),N);
93 DVectorSlice hx(HX,N);
102 hx(N) = qp_solver->use_as_bigM() * x(N);
110 hx(N) = qp_solver->use_as_bigM();
136 FORTRAN_FUNC_DECL_UL_(
void, QPHESS_SERVER_RELAX2, qphess_server_relax2 ) (
const f_int& N,
const f_int& LDH
137 ,
const f_int& JTHCOL,
const f_dbl_prec* H,
const f_dbl_prec* X, f_dbl_prec* HX
138 , f_int* IW,
const f_int& LENIW, f_dbl_prec* W,
const f_int& LENW )
140 qphess_server_relax( N, LDH, JTHCOL, H, X, HX, IW, LENIW, W, LENW );
145 namespace LinAlgOpPack {
153 namespace ConstrainedOptPack {
155 QPSolverRelaxedQPOPT::QPSolverRelaxedQPOPT(
156 value_type max_qp_iter_frac
158 :max_qp_iter_frac_(max_qp_iter_frac)
164 QPSolverRelaxedQPOPT::~QPSolverRelaxedQPOPT()
171 void QPSolverRelaxedQPOPT::release_memory()
179 QPSolverRelaxedQPOPT::f_int QPSolverRelaxedQPOPT::liwork(f_int N, f_int NCLIN)
const
182 QPSolverRelaxedQPOPT::f_int QPSolverRelaxedQPOPT::lrwork(f_int N, f_int NCLIN)
const
183 {
return NCLIN > 0 ? 2*N*N + 8*N + 5*NCLIN : N*N + 8 *N; }
190 BIGBND_ = this->infinite_bound();
191 ITMAX_ = max_qp_iter_frac() * N_;
192 LDA_ = ( A_.rows() > 0 ? A_.rows() : 1 );
193 H_ =
reinterpret_cast<f_dbl_prec*
>(
this);
194 AX_.resize( NCLIN_ > 0 ? NCLIN_ : 1 );
198 namespace ns = QPOPT_CppDecl;
199 namespace ft = FortranTypes;
200 ns::reset_defaults();
201 ns::set_logical_option( ns::WARM_START , warm_start ? ft::F_FALSE : ft::F_TRUE );
202 ns::set_real_option( ns::FEASIBILITY_TOLERANCE , FEATOL_ );
203 ns::set_real_option( ns::INFINITE_BOUND_SIZE , BIGBND_ );
204 ns::set_int_option( ns::ITERATION_LIMIT , ITMAX_ );
205 ns::set_int_option( ns::PRINT_FILE , 0 );
206 ns::set_int_option( ns::SUMMARY_FILE , 0 );
207 ns::set_int_option( ns::PRINT_LEVEL , 0 );
208 ns::set_int_option( ns::PROBLEM_TYPE , ns::QP2 );
211 QPOPT_CppDecl::qpopt(
212 N_, NCLIN_, LDA_, LDH_, NCLIN_ ? &A_(1,1) : NULL, &BL_(1), &BU_(1)
214 , FORTRAN_NAME_UL_(QPHESS_SERVER_RELAX2,qphess_server_relax2)
215 , &ISTATE_[0], &X_(1), INFORM_, ITER_, OBJ_, &AX_(1)
216 , &CLAMDA_(1), &IWORK_[0], LIWORK_, &WORK_[0], LWORK_ );
218 EInform return_inform;
219 typedef QPSolverRelaxedQPOPTSOL bc;
221 case STRONG_LOCAL_MIN:
222 return_inform = bc::STRONG_LOCAL_MIN;
225 return_inform = bc::WEAK_LOCAL_MIN;
230 ,
"QPSolverRelaxedQPOPT::call_qp_solver() : Error,"
231 " QPOPT returned that the QP is unbounded!" );
235 ,
"QPSolverRelaxedQPOPT::call_qp_solver() : Error,"
236 " QPOPT returned that the QP is infeasible!" );
238 return_inform = bc::MAX_ITER_EXCEEDED;
240 case MAX_DOF_TOO_SMALL:
242 true, std::runtime_error,
243 "QPSolverRelaxedQPOPT::call_qp_solver() : Error,"
244 " QPOPT says that the max dof is too small" );
248 "QPSolverRelaxedQPOPT::call_qp_solver() : Error,"
249 " QPOPT returned that the input is invalid" );
250 case PROB_TYPE_NOT_REGOG:
252 true, std::logic_error,
253 "QPSolverRelaxedQPOPT::call_qp_solver() : Error,"
254 " QPOPT says that the problem type is not recognized" );
260 return return_inform;
265 #endif // CONSTRAINED_OPTIMIZATION_PACK_USE_QPOPT
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)