49 #include "ConstrainedOptPack_Types.hpp" 50 #include "ConstrainedOptPack_MatrixSymAddDelUpdateableWithOpNonsingular.hpp" 51 #include "AbstractLinAlgPack_GenPermMatrixSlice.hpp" 52 #include "AbstractLinAlgPack_SpVectorClass.hpp" 53 #include "AbstractLinAlgPack_MatrixSymOpNonsing.hpp" 54 #include "AbstractLinAlgPack_MatrixSymOp.hpp" 55 #include "AbstractLinAlgPack_MatrixOp.hpp" 56 #include "AbstractLinAlgPack_MatrixSymAddDelUpdateable.hpp" 57 #include "AbstractLinAlgPack_MatrixOpSerial.hpp" 58 #include "DenseLinAlgPack_DMatrixClass.hpp" 59 #include "Teuchos_StandardCompositionMacros.hpp" 60 #include "Teuchos_StandardMemberCompositionMacros.hpp" 61 #include "StopWatchPack_stopwatch.hpp" 65 namespace QPSchurPack {
76 #ifdef LINALGPACK_CHECK_RANGE 79 return this->operator[](i-1);
85 #ifdef LINALGPACK_CHECK_RANGE 88 return this->operator[](i-1);
197 virtual const DVectorSlice g()
const = 0;
199 virtual const MatrixSymOp& G()
const = 0;
201 virtual const MatrixOp& A()
const = 0;
219 virtual const x_init_t& x_init()
const = 0;
232 virtual const l_x_X_map_t& l_x_X_map()
const = 0;
243 virtual const i_x_X_map_t& i_x_X_map()
const = 0;
257 virtual const DVectorSlice b_X()
const = 0;
260 virtual const GenPermMatrixSlice& Q_R()
const = 0;
263 virtual const GenPermMatrixSlice& Q_X()
const = 0;
266 virtual const MatrixSymOpNonsing& Ko()
const = 0;
269 virtual const DVectorSlice fo()
const = 0;
275 virtual Constraints& constraints() = 0;
278 virtual const Constraints& constraints()
const = 0;
284 virtual void dump_qp( std::ostream& out );
344 virtual const MatrixOp& A_bar()
const = 0;
347 virtual void pick_violated_policy(
EPickPolicy pick_policy ) = 0;
349 virtual EPickPolicy pick_violated_policy()
const = 0;
363 virtual void pick_violated(
364 const DVectorSlice& x,
size_type* j_viol, value_type* constr_val
365 ,value_type* viol_bnd_val, value_type* norm_2_constr, EBounds* bnd,
bool* can_ignore
382 virtual value_type get_bnd(
size_type j, EBounds bnd )
const = 0;
404 typedef MatrixSymAddDelUpdateable
MSADU;
407 {
public:
TestFailed(
const std::string& what_arg) : std::logic_error(what_arg) {}};
424 ,MAX_RUNTIME_EXEEDED_FAIL
425 ,MAX_RUNTIME_EXEEDED_DUAL_FEAS
426 ,MAX_ALLOWED_STORAGE_EXCEEDED
427 ,INFEASIBLE_CONSTRAINTS
435 ,OUTPUT_BASIC_INFO = 1
436 ,OUTPUT_ITER_SUMMARY = 2
437 ,OUTPUT_ITER_STEPS = 3
439 ,OUTPUT_ITER_QUANTITIES = 5
454 STANDARD_MEMBER_COMPOSITION_MEMBERS(
size_type, max_iter );
458 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, max_real_runtime );
462 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, feas_tol );
466 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, loose_feas_tol );
471 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, dual_infeas_tol );
477 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, huge_primal_step );
483 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, huge_dual_step );
487 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, warning_tol );
491 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, error_tol );
496 STANDARD_MEMBER_COMPOSITION_MEMBERS(
size_type, iter_refine_min_iter );
501 STANDARD_MEMBER_COMPOSITION_MEMBERS(
size_type, iter_refine_max_iter );
506 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, iter_refine_opt_tol );
511 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, iter_refine_feas_tol );
516 STANDARD_MEMBER_COMPOSITION_MEMBERS(
bool, iter_refine_at_solution );
521 STANDARD_MEMBER_COMPOSITION_MEMBERS(
bool, salvage_init_schur_comp );
525 void pivot_tols( MSADU::PivotTolerances pivot_tols );
527 MSADU::PivotTolerances pivot_tols()
const;
534 const schur_comp_ptr_t& schur_comp = Teuchos::null
536 ,value_type max_real_runtime = 1e+20
537 ,value_type feas_tol = 1e-8
538 ,value_type loose_feas_tol = 1e-6
539 ,value_type dual_infeas_tol = 1e-12
540 ,value_type huge_primal_step = 1e+20
541 ,value_type huge_dual_step = 1e+20
542 ,value_type warning_tol = 1e-10
543 ,value_type error_tol = 1e-5
546 ,value_type iter_refine_opt_tol = 1e-12
547 ,value_type iter_refine_feas_tol = 1e-12
548 ,
bool iter_refine_at_solution =
true 549 ,
bool salvage_init_schur_comp =
true 550 ,MSADU::PivotTolerances pivot_tols = MSADU::PivotTolerances( 1e-8,1e-11,1e-11 )
613 ,
size_type num_act_change,
const int ij_act_change[],
const EBounds bnds[]
615 ,DVectorSlice* x, SpVector* mu, DVectorSlice* lambda, SpVector* lambda_breve
636 ,
const MatrixOp *A_bar
637 ,
const GenPermMatrixSlice *Q_R
638 ,
const GenPermMatrixSlice *P_XF_hat
639 ,
const GenPermMatrixSlice *P_plus_hat
642 const MatrixSymOp&
G()
const 645 const MatrixOp*
A()
const 651 const GenPermMatrixSlice&
Q_R()
const 655 {
return *P_XF_hat_; }
658 {
return *P_plus_hat_; }
676 ,
const DVectorSlice& vs_rhs2, value_type beta
681 ,
const SpVectorSlice& sv_rhs2, value_type beta
687 const MatrixSymOp *G_;
689 const MatrixOp *A_bar_;
690 const GenPermMatrixSlice *Q_R_;
691 const GenPermMatrixSlice *P_XF_hat_;
692 const GenPermMatrixSlice *P_plus_hat_;
736 typedef MatrixSymAddDelUpdateable
MSADU;
750 STANDARD_MEMBER_COMPOSITION_MEMBERS( MSADU::PivotTolerances, pivot_tols );
754 const schur_comp_ptr_t &schur_comp
755 ,MSADU::PivotTolerances pivot_tols = MSADU::PivotTolerances( 1e-6,1e-8,1e-8 )
769 QP& qp,
size_type num_act_change,
const int ij_act_change[]
770 ,
const EBounds bnds[],
bool test,
bool salvage_init_schur_comp
777 void refactorize_schur_comp();
796 size_type ja, EBounds bnd_ja,
bool update_steps
798 ,
bool force_refactorization =
true 799 ,
bool allow_any_cond =
false );
808 bool drop_constraint(
810 ,
bool force_refactorization =
true,
bool allow_any_cond =
false );
819 bool drop_add_constraints(
820 int jd,
size_type ja, EBounds bnd_ja,
bool update_steps
831 const QP& qp()
const;
899 value_type constr_norm(
size_type s )
const;
915 const MatrixSymOpNonsing& S_hat()
const;
917 const GenPermMatrixSlice& P_XF_hat()
const;
919 const GenPermMatrixSlice& P_FC_hat()
const;
921 const GenPermMatrixSlice& P_plus_hat()
const;
923 const GenPermMatrixSlice& Q_XD_hat()
const;
925 const DVectorSlice d_hat()
const;
927 DVectorSlice z_hat();
929 const DVectorSlice z_hat()
const;
931 DVectorSlice p_z_hat();
933 const DVectorSlice p_z_hat()
const;
935 DVectorSlice mu_D_hat();
937 const DVectorSlice mu_D_hat()
const;
939 DVectorSlice p_mu_D_hat();
941 const DVectorSlice p_mu_D_hat()
const;
955 bool all_dof_used_up()
const;
965 typedef std::vector<int> ij_map_t;
967 typedef std::map<int,size_type> s_map_t;
969 typedef std::vector<EBounds> bnds_t;
971 typedef std::vector<int> l_fxfx_t;
973 typedef std::vector<size_type> P_row_t;
975 typedef std::vector<size_type> P_col_t;
993 DVector constr_norm_;
1004 GenPermMatrixSlice P_XF_hat_;
1005 P_row_t P_XF_hat_row_;
1006 P_row_t P_XF_hat_col_;
1015 GenPermMatrixSlice P_FC_hat_;
1016 P_row_t P_FC_hat_row_;
1017 P_row_t P_FC_hat_col_;
1025 GenPermMatrixSlice P_plus_hat_;
1026 P_row_t P_plus_hat_row_;
1027 P_row_t P_plus_hat_col_;
1033 GenPermMatrixSlice Q_XD_hat_;
1034 P_row_t Q_XD_hat_row_;
1035 P_row_t Q_XD_hat_col_;
1041 DVector p_mu_D_hat_;
1047 void assert_initialized()
const;
1053 void reinitialize_matrices(
bool test);
1059 bool remove_augmented_element(
1060 size_type sd,
bool force_refactorization
1061 ,MatrixSymAddDelUpdateable::EEigenValType eigen_val_drop
1063 ,
bool allow_any_cond );
1074 static void dump_act_set_quantities(
const ActiveSet& act_set, std::ostream& out
1075 ,
bool print_S_hat =
true );
1083 enum EPDSteps { PICK_VIOLATED_CONSTRAINT, UPDATE_ACTIVE_SET, COMPUTE_SEARCH_DIRECTION
1084 , COMPUTE_STEP_LENGTHS, TAKE_STEP };
1099 ,
const DVectorSlice& vo,
ActiveSet* act_set, DVectorSlice* v
1107 virtual void set_x(
const ActiveSet& act_set,
const DVectorSlice& v, DVectorSlice* x );
1110 virtual void set_multipliers(
1111 const ActiveSet& act_set,
const DVectorSlice& v
1112 ,SpVector* mu, DVectorSlice* lambda, SpVector* lambda_breve );
1119 ITER_REFINE_NOT_PERFORMED
1120 ,ITER_REFINE_ONE_STEP
1121 ,ITER_REFINE_NOT_NEEDED
1122 ,ITER_REFINE_IMPROVED
1123 ,ITER_REFINE_NOT_IMPROVED
1124 ,ITER_REFINE_CONVERGED
1138 ,
const value_type ao
1139 ,
const DVectorSlice *bo
1140 ,
const value_type aa
1141 ,
const DVectorSlice *ba
MatrixSymAddDelUpdateable MSADU
static value_type DEGENERATE_MULT
Value for near degenerate lagrange multipliers.
const GenPermMatrixSlice & Q_R() const
MatrixSymAddDelUpdateable MSADU
Thrown if there is some numerical instability.
T & operator()(typename this_t::size_type i)
one based indexing
const MatrixSymOp & G() const
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Represents the matrix U_hat.
vector_one_based_checked< size_type > l_x_X_map_t
EOutputLevel
Output level.
const GenPermMatrixSlice & P_plus_hat() const
Represents and manages the active set for the QPSchur algorithm.
T operator()(typename this_t::size_type i) const
one based indexing
const GenPermMatrixSlice & P_XF_hat() const
const MatrixOp * A() const
Interface for updating a symmetric matrix and its factorization by adding and deleting rows and colum...
Represents the QP to be solved by QPSchur {abstract}.
const MatrixOp & A_bar() const
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)
ESolveReturn
solve_qp return values
Thrown if constraints are inconsistant (no feasible region)
QPSchurPack::Constraints Constraints
vector_one_based_checked< EBounds > x_init_t
Utility class for a ranged check vector.
ERunTests
Enumeration for if to run internal tests or not.
Represents the extra constraints in the QP to be satisfied by the schur complement QP solver QPSchur ...
vector_one_based_checked< size_type > i_x_X_map_t
Solves a Quadratic Program with a dual QP method using a schur complement factorization.
Thrown if during the course of the primal-dual iteration a non-dual feasible point if found...
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)