55 namespace ConstrainedOptPack {
66 ,
const Vector& g,
const MatrixSymOp& G
68 ,
const Vector& dL,
const Vector& dU
70 ,
const Vector& eL,
const Vector& eU
75 ,VectorMutable* mu, VectorMutable* Ed
76 ,VectorMutable* lambda, VectorMutable* Fd
79 return solve_qp(out,olevel,test_what,g,G,etaL,&dL,&dU
80 ,&E,trans_E,&b,&eL,&eU,&F,trans_F,&f
81 ,obj_d,eta,d,nu,mu,Ed,lambda,Fd);
87 ,
const Vector& g,
const MatrixSymOp& G
89 ,
const Vector& dL,
const Vector& dU
91 ,
const Vector& eL,
const Vector& eU
95 ,VectorMutable* mu, VectorMutable* Ed
98 return solve_qp(out,olevel,test_what,g,G,etaL,&dL,&dU
100 ,obj_d,eta,d,nu,mu,Ed,NULL,NULL);
106 ,
const Vector& g,
const MatrixSymOp& G
108 ,
const Vector& dL,
const Vector& dU
113 ,VectorMutable* lambda, VectorMutable* Fd
116 return solve_qp(out,olevel,test_what,g,G,etaL,&dL,&dU
118 ,obj_d,eta,d,nu,NULL,NULL,lambda,Fd);
125 ,
const Vector& g,
const MatrixSymOp& G
126 ,
const Vector& dL,
const Vector& dU
134 out,olevel,test_what,g,G,etaL,&dL,&dU
137 ,obj_d,&eta,d,nu,NULL,NULL,NULL,NULL);
143 ,
const Vector& g,
const MatrixSymOp& G
145 ,
const Vector* dL,
const Vector* dU
147 ,
const Vector* eL,
const Vector* eU
152 ,VectorMutable* mu, VectorMutable* Ed
153 ,VectorMutable* lambda, VectorMutable* Fd
156 #ifdef PROFILE_HACK_ENABLED
160 infinite_bound(),g,G,etaL,dL,dU
161 ,E,trans_E,b,eL,eU,F,trans_F,f
162 ,obj_d,eta,d,nu,mu,Ed,lambda,Fd);
164 infinite_bound(),out,olevel,g,G,etaL,dL,dU,E,trans_E,b,eL,eU
165 ,F,trans_F,f,eta,d,nu,mu,lambda );
168 out,olevel,test_what,g,G,etaL,dL,dU
169 ,E,trans_E,b,eL,eU,F,trans_F,f
170 ,obj_d,eta,d,nu,mu,Ed,lambda,Fd);
172 infinite_bound(),out,olevel,obj_d,eta,d,nu,mu,Ed,lambda,Fd);
178 ,
const Vector& g,
const MatrixSymOp& G
180 ,
const Vector* dL,
const Vector* dU
182 ,
const Vector* eL,
const Vector* eU
187 ,
const Vector* mu,
const Vector* Ed
188 ,
const Vector* lambda,
const Vector* Fd
193 !d, std::invalid_argument
194 ,
"QPSolverRelaxed::validate_input(...) : Error, "
195 "If d!=NULL is not allowed." );
197 ( E || F ) && !eta, std::invalid_argument
198 ,
"QPSolverRelaxed::validate_input(...) : Error, "
199 "If eta!=NULL is not allowed if E!=NULL or F!=NULL." );
203 dL && ( !dU || !nu ), std::invalid_argument
204 ,
"QPSolverRelaxed::validate_input(...) : Error, "
205 "If dL!=NULL then dU!=NULL and nu!=NULL must also be true." );
207 E && ( !b || !eL || !eU || !mu ), std::invalid_argument
208 ,
"QPSolverRelaxed::validate_input(...) : Error, "
209 "If E!=NULL then b!=NULL, eL!=NULL, eU!=NULL and mu!=NULL must also "
212 F && ( !f || !lambda ), std::invalid_argument
213 ,
"QPSolverRelaxed::validate_input(...) : Error, "
214 "If F!=NULL then f!=NULL and lambda!=NULL must also "
223 g.dim() != nd, std::invalid_argument
224 ,
"QPSolverRelaxed::validate_input(...) : Error, "
225 "g.dim() != d->dim()." );
227 G.rows() != nd || G.cols() != nd, std::invalid_argument
228 ,
"QPSolverRelaxed::validate_input(...) : Error, "
229 "G.rows() != d->dim() or G.cols() != d->dim()." );
231 dL && dL->dim() != nd, std::invalid_argument
232 ,
"QPSolverRelaxed::validate_input(...) : Error, "
233 "dL->dim() = " << dL->dim() <<
" != d->dim() = " << nd <<
"." );
235 dU && dU->dim() != nd, std::invalid_argument
236 ,
"QPSolverRelaxed::validate_input(...) : Error, "
237 "dU->dim() = " << dU->dim() <<
" != d->dim() = " << nd <<
"." );
242 BLAS_Cpp::cols( E->rows(), E->cols(), trans_E ) != nd, std::invalid_argument
243 ,
"QPSolverRelaxed::validate_input(...) : Error, op(E).cols() != d->dim()." );
244 TEUCHOS_TEST_FOR_EXCEPTION(
245 b->dim() != m_in, std::invalid_argument
246 ,
"QPSolverRelaxed::validate_input(...) : Error, b->dim() != op(E).rows()." );
247 TEUCHOS_TEST_FOR_EXCEPTION(
248 eL->dim() != m_in, std::invalid_argument
249 ,
"QPSolverRelaxed::validate_input(...) : Error, eL->dim() != op(E).rows()." );
250 TEUCHOS_TEST_FOR_EXCEPTION(
251 eU->dim() != m_in, std::invalid_argument
252 ,
"QPSolverRelaxed::validate_input(...) : Error, eU->dim() != op(E).rows()." );
253 TEUCHOS_TEST_FOR_EXCEPTION(
254 Ed && Ed->dim() != m_in, std::invalid_argument
255 ,
"QPSolverRelaxed::validate_input(...) : Error, Ed->dim() != op(E).rows()." );
261 BLAS_Cpp::cols( F->rows(), F->cols(), trans_F ) != nd, std::invalid_argument
262 ,
"QPSolverRelaxed::validate_input(...) : Error, op(F).cols() != d->dim()." );
263 TEUCHOS_TEST_FOR_EXCEPTION(
264 f->dim() != m_eq, std::invalid_argument
265 ,
"QPSolverRelaxed::validate_input(...) : Error, f->dim() != op(F).rows()." );
266 TEUCHOS_TEST_FOR_EXCEPTION(
267 lambda->dim() != m_eq, std::invalid_argument
268 ,
"QPSolverRelaxed::validate_input(...) : Error, lambda->dim() != op(F).rows()." );
269 TEUCHOS_TEST_FOR_EXCEPTION(
270 Fd && Fd->dim() != m_eq, std::invalid_argument
271 ,
"QPSolverRelaxed::validate_input(...) : Error, Fd->dim() != op(F).rows()." );
278 ,
const Vector& g,
const MatrixSymOp& G
280 ,
const Vector* dL,
const Vector* dU
282 ,
const Vector* eL,
const Vector* eU
287 ,VectorMutable* lambda
292 *out<<
"\n*** Printing input to QPSolverRelaxed::solve_qp(...) ...\n";
294 *out <<
"\n||g||inf = " << g.norm_inf() << std::endl;
299 *out<<
"\nG =\n" << G;
301 *out <<
"\netaL = " << etaL << std::endl;
303 *out <<
"\neta = " << *eta << std::endl;
306 *out <<
"\ndL.dim() = " << dL->dim();
307 *out <<
"\ndU.dim() = " << dU->dim();
308 *out <<
"\nnum_bounded(dL,dU) = " <<
num_bounded(*dL,*dU,infinite_bound) << std::endl;
309 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
310 *out <<
"dL =\n" << *dL;
311 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
312 *out <<
"dU =\n" << *dU;
315 *out <<
"\ndL = -inf";
316 *out <<
"\ndU = +inf";
319 *out <<
"\n||d||inf = " << d->norm_inf() << std::endl;
320 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
321 *out<<
"d =\n" << *d;
324 *out<<
"\nnu->nz() = " << nu->nz() << std::endl
325 <<
"||nu||inf = " << nu->norm_inf() << std::endl;
327 *out<<
"nu =\n" << *nu;
331 if( (
int)olevel >= (
int)PRINT_EVERY_THING )
332 *out<<
"\nE" << std::endl << *E
335 *out <<
"\n||b||inf = " << b->norm_inf() << std::endl;
336 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
337 *out<<
"b =\n" << *b;
339 *out<<
"\neL.dim() = " << eL->dim();
340 *out<<
"\neU.dim() = " << eU->dim();
341 *out <<
"\nnum_bounded(eL,eU) = " <<
num_bounded(*eL,*eU,infinite_bound) << std::endl;
342 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
343 *out<<
"eL =\n" << *eL;
344 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
345 *out<<
"eU =\n" << *eU;
347 *out<<
"\nmu.nz() = " << mu->nz() << std::endl
348 <<
"||mu||inf = " << mu->norm_inf() << std::endl;
350 *out<<
"mu =\n" << *mu;
354 if( (
int)olevel >= (
int)PRINT_EVERY_THING )
355 *out<<
"\nF" << std::endl << *F
358 *out<<
"\n||f||inf = " << f->norm_inf() << std::endl;
359 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
360 *out<<
"f =\n" << *f;
362 *out<<
"\n||lambda||inf = " << lambda->norm_inf() << std::endl;
364 *out<<
"lambda =\n" << *lambda;
366 *out<<
"\nEnd input to QPSolverRelaxed::solve_qp(...)\n";
376 ,
const Vector* mu,
const Vector* Ed
377 ,
const Vector* lambda,
const Vector* Fd
381 *out<<
"\n*** Printing output from QPSolverRelaxed::solve_qp(...) ...\n";
384 *out <<
"\nobj_d = " << *obj_d << std::endl;
386 *out <<
"\neta = " << *eta << std::endl;
388 *out <<
"\n||d||inf = " << d->norm_inf() << std::endl;
390 *out<<
"d =\n" << *d;
393 *out<<
"\nnu.nz() = " << nu->nz() << std::endl
394 <<
"||nu||inf = " << nu->norm_inf() << std::endl;
396 *out<<
"nu =\n" << *nu;
400 *out <<
"\n||Ed||inf = " << Ed->norm_inf() << std::endl;
401 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
402 *out<<
"Ed =\n" << *Ed;
406 *out<<
"\nmu.nz() = " << mu->nz() << std::endl
407 <<
"||mu||inf = " << mu->norm_inf() << std::endl;
409 *out<<
"mu =\n" << *mu;
413 *out<<
"\n||lambda||inf = " << lambda->norm_inf() << std::endl;
415 *out<<
"lambda =\n" << *lambda;
419 *out <<
"\n||Fd||inf = " << Fd->norm_inf() << std::endl;
420 if( (
int)olevel >= (
int)PRINT_ITER_VECTORS )
421 *out<<
"Fd =\n" << *Fd;
423 *out<<
"\nEnd output from QPSolverRelaxed::solve_qp(...)\n";
AbstractLinAlgPack::size_type size_type
ERunTests
Enumeration for if to run internal tests or not.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual QPSolverStats::ESolutionType imp_solve_qp(std::ostream *out, EOutputLevel olevel, ERunTests test_what, const Vector &g, const MatrixSymOp &G, value_type etaL, const Vector *dL, const Vector *dU, const MatrixOp *E, BLAS_Cpp::Transp trans_E, const Vector *b, const Vector *eL, const Vector *eU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const Vector *f, value_type *obj_d, value_type *eta, VectorMutable *d, VectorMutable *nu, VectorMutable *mu, VectorMutable *Ed, VectorMutable *lambda, VectorMutable *Fd)=0
Subclasses are to override this to implement the QP algorithm.
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
Helper class that takes care of timing.
static void print_qp_output(const value_type infinite_bound, std::ostream *out, EOutputLevel olevel, const value_type *obj_d, const value_type *eta, const Vector *d, const Vector *nu, const Vector *mu, const Vector *Ed, const Vector *lambda, const Vector *Fd)
Utility (static) function for printing the output input/output arguments after the QP solver is run...
static void print_qp_input(const value_type infinite_bound, std::ostream *out, EOutputLevel olevel, const Vector &g, const MatrixSymOp &G, value_type etaL, const Vector *dL, const Vector *dU, const MatrixOp *E, BLAS_Cpp::Transp trans_E, const Vector *b, const Vector *eL, const Vector *eU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const Vector *f, value_type *eta, VectorMutable *d, VectorMutable *nu, VectorMutable *mu, VectorMutable *lambda)
Utility (static) function for printing the input input/output arguments before the QP solver is run...
value_type max(value_type v1, value_type v2)
size_type num_bounded(const Vector &xl, const Vector &xu, value_type inf_bound)
Count the number of finitly bounded elements in xl <= x <= xu.
virtual QPSolverStats::ESolutionType solve_qp(std::ostream *out, EOutputLevel olevel, ERunTests test_what, const Vector &g, const MatrixSymOp &G, value_type etaL, const Vector &dL, const Vector &dU, const MatrixOp &E, BLAS_Cpp::Transp trans_E, const Vector &b, const Vector &eL, const Vector &eU, const MatrixOp &F, BLAS_Cpp::Transp trans_F, const Vector &f, value_type *obj_d, value_type *eta, VectorMutable *d, VectorMutable *nu, VectorMutable *mu, VectorMutable *Ed, VectorMutable *lambda, VectorMutable *Fd)
Solve the QP.
static void validate_input(const value_type infinite_bound, const Vector &g, const MatrixSymOp &G, value_type etaL, const Vector *dL, const Vector *dU, const MatrixOp *E, BLAS_Cpp::Transp trans_E, const Vector *b, const Vector *eL, const Vector *eU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const Vector *f, const value_type *obj_d, const value_type *eta, const Vector *d, const Vector *nu, const Vector *mu, const Vector *Ed, const Vector *lambda, const Vector *Fd)
This is a (static) function that is used as a utility to validate the input arguments to solve_qp()...
const char * trans_to_string(Transp _trans)
Give a string name to Transp value.
EOutputLevel
Enumeration for the amount of output to create from solve_qp().
AbstractLinAlgPack::value_type value_type
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
ESolutionType
Enumeration for the type of point returned from solve_qp(...).