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_QPSolverRelaxed.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 #ifndef QP_SOLVER_RELAXED_H
43 #define QP_SOLVER_RELAXED_H
44 
45 #include "ConstrainedOptPack_QPSolverStats.hpp"
47 
48 namespace ConstrainedOptPack {
49 
133 public:
134 
137 
139  class Unbounded : public std::logic_error
140  {public: Unbounded(const std::string& what_arg) : std::logic_error(what_arg) {}};
141 
143  class Infeasible : public std::logic_error
144  {public: Infeasible(const std::string& what_arg) : std::logic_error(what_arg) {}};
145 
147  class InvalidInput : public std::logic_error
148  {public: InvalidInput(const std::string& what_arg) : std::logic_error(what_arg) {}};
149 
151  class TestFailed : public std::logic_error
152  {public: TestFailed(const std::string& what_arg) : std::logic_error(what_arg) {}};
153 
156  PRINT_NONE = 0,
157  PRINT_BASIC_INFO = 1,
158  PRINT_ITER_SUMMARY = 2,
159  PRINT_ITER_STEPS = 3,
160  PRINT_ITER_ACT_SET = 4,
161  PRINT_ITER_VECTORS = 5,
162  PRINT_EVERY_THING = 6
163  };
164 
166  enum ERunTests { RUN_TESTS, NO_TESTS };
167 
169 
172 
174  STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, infinite_bound );
175 
177  QPSolverRelaxed();
178 
180  virtual ~QPSolverRelaxed() {}
181 
183 
186 
312  std::ostream* out, EOutputLevel olevel, ERunTests test_what
313  ,const Vector& g, const MatrixSymOp& G
314  ,value_type etaL
315  ,const Vector& dL, const Vector& dU
316  ,const MatrixOp& E, BLAS_Cpp::Transp trans_E, const Vector& b
317  ,const Vector& eL, const Vector& eU
318  ,const MatrixOp& F, BLAS_Cpp::Transp trans_F, const Vector& f
319  ,value_type* obj_d
320  ,value_type* eta, VectorMutable* d
321  ,VectorMutable* nu
322  ,VectorMutable* mu, VectorMutable* Ed
323  ,VectorMutable* lambda, VectorMutable* Fd
324  );
325 
332  std::ostream* out, EOutputLevel olevel, ERunTests test_what
333  ,const Vector& g, const MatrixSymOp& G
334  ,value_type etaL
335  ,const Vector& dL, const Vector& dU
336  ,const MatrixOp& E, BLAS_Cpp::Transp trans_E, const Vector& b
337  ,const Vector& eL, const Vector& eU
338  ,value_type* obj_d
339  ,value_type* eta, VectorMutable* d
340  ,VectorMutable* nu
341  ,VectorMutable* mu, VectorMutable* Ed
342  );
343 
350  std::ostream* out, EOutputLevel olevel, ERunTests test_what
351  ,const Vector& g, const MatrixSymOp& G
352  ,value_type etaL
353  ,const Vector& dL, const Vector& dU
354  ,const MatrixOp& F, BLAS_Cpp::Transp trans_F, const Vector& f
355  ,value_type* obj_d
356  ,value_type* eta, VectorMutable* d
357  ,VectorMutable* nu
358  ,VectorMutable* lambda, VectorMutable* Fd
359  );
360 
361 
369  std::ostream* out, EOutputLevel olevel, ERunTests test_what
370  ,const Vector& g, const MatrixSymOp& G
371  ,const Vector& dL, const Vector& dU
372  ,value_type* obj_d
373  ,VectorMutable* d
374  ,VectorMutable* nu
375  );
376 
389  std::ostream* out, EOutputLevel olevel, ERunTests test_what
390  ,const Vector& g, const MatrixSymOp& G
391  ,value_type etaL
392  ,const Vector* dL, const Vector* dU
393  ,const MatrixOp* E, BLAS_Cpp::Transp trans_E, const Vector* b
394  ,const Vector* eL, const Vector* eU
395  ,const MatrixOp* F, BLAS_Cpp::Transp trans_F, const Vector* f
396  ,value_type* obj_d
397  ,value_type* eta, VectorMutable* d
398  ,VectorMutable* nu
399  ,VectorMutable* mu, VectorMutable* Ed
400  ,VectorMutable* lambda, VectorMutable* Fd
401  );
402 
416  virtual QPSolverStats get_qp_stats() const = 0;
417 
420  virtual void release_memory() = 0;
421 
423 
426 
449  static void validate_input(
450  const value_type infinite_bound
451  ,const Vector& g, const MatrixSymOp& G
452  ,value_type etaL
453  ,const Vector* dL, const Vector* dU
454  ,const MatrixOp* E, BLAS_Cpp::Transp trans_E, const Vector* b
455  ,const Vector* eL, const Vector* eU
456  ,const MatrixOp* F, BLAS_Cpp::Transp trans_F, const Vector* f
457  ,const value_type* obj_d
458  ,const value_type* eta, const Vector* d
459  ,const Vector* nu
460  ,const Vector* mu, const Vector* Ed
461  ,const Vector* lambda, const Vector* Fd
462  );
463 
479  static void print_qp_input(
480  const value_type infinite_bound
481  ,std::ostream* out, EOutputLevel olevel
482  ,const Vector& g, const MatrixSymOp& G
483  ,value_type etaL
484  ,const Vector* dL, const Vector* dU
485  ,const MatrixOp* E, BLAS_Cpp::Transp trans_E, const Vector* b
486  ,const Vector* eL, const Vector* eU
487  ,const MatrixOp* F, BLAS_Cpp::Transp trans_F, const Vector* f
488  ,value_type* eta, VectorMutable* d
489  ,VectorMutable* nu
490  ,VectorMutable* mu
491  ,VectorMutable* lambda
492  );
493 
509  static void print_qp_output(
510  const value_type infinite_bound
511  ,std::ostream* out, EOutputLevel olevel
512  ,const value_type* obj_d
513  ,const value_type* eta, const Vector* d
514  ,const Vector* nu
515  ,const Vector* mu, const Vector* Ed
516  ,const Vector* lambda, const Vector* Fd
517  );
518 
520 
521 protected:
522 
525 
531  std::ostream* out, EOutputLevel olevel, ERunTests test_what
532  ,const Vector& g, const MatrixSymOp& G
533  ,value_type etaL
534  ,const Vector* dL, const Vector* dU
535  ,const MatrixOp* E, BLAS_Cpp::Transp trans_E, const Vector* b
536  ,const Vector* eL, const Vector* eU
537  ,const MatrixOp* F, BLAS_Cpp::Transp trans_F, const Vector* f
538  ,value_type* obj_d
539  ,value_type* eta, VectorMutable* d
540  ,VectorMutable* nu
541  ,VectorMutable* mu, VectorMutable* Ed
542  ,VectorMutable* lambda, VectorMutable* Fd
543  ) = 0;
544 
546 
547 }; // end class QPSovlerRelaxed
548 
549 } // end namespace ConstrainedOptPack
550 
551 #endif // QP_SOLVER_RELAXED_H
ERunTests
Enumeration for if to run internal tests or not.
Solves Quadratic Programs (QPs) of several different forms while allowing a relaxation of the constra...
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.
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...
Class for storing statistics about a run of a (active set?) QP solver.
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()...
EOutputLevel
Enumeration for the amount of output to create from solve_qp().
STANDARD_MEMBER_COMPOSITION_MEMBERS(value_type, infinite_bound)
Set the scalar that will be used to identigy infinite bounds.
Transp
virtual QPSolverStats get_qp_stats() const =0
Get the statistics of the last QP solved.
ESolutionType
Enumeration for the type of point returned from solve_qp(...).
virtual void release_memory()=0
Release any memory that is being used.