00001 // @(#)root/quadp:$Id: TQpLinSolverBase.h 20882 2007-11-19 11:31:26Z rdm $ 00002 // Author: Eddy Offermann May 2004 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 /************************************************************************* 00013 * Parts of this file are copied from the OOQP distribution and * 00014 * are subject to the following license: * 00015 * * 00016 * COPYRIGHT 2001 UNIVERSITY OF CHICAGO * 00017 * * 00018 * The copyright holder hereby grants you royalty-free rights to use, * 00019 * reproduce, prepare derivative works, and to redistribute this software* 00020 * to others, provided that any changes are clearly documented. This * 00021 * software was authored by: * 00022 * * 00023 * E. MICHAEL GERTZ gertz@mcs.anl.gov * 00024 * Mathematics and Computer Science Division * 00025 * Argonne National Laboratory * 00026 * 9700 S. Cass Avenue * 00027 * Argonne, IL 60439-4844 * 00028 * * 00029 * STEPHEN J. WRIGHT swright@cs.wisc.edu * 00030 * Computer Sciences Department * 00031 * University of Wisconsin * 00032 * 1210 West Dayton Street * 00033 * Madison, WI 53706 FAX: (608)262-9777 * 00034 * * 00035 * Any questions or comments may be directed to one of the authors. * 00036 * * 00037 * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF * 00038 * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND * 00039 * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT * 00040 * WITH THE DEPARTMENT OF ENERGY. * 00041 *************************************************************************/ 00042 00043 #ifndef ROOT_TQpLinSolverBase 00044 #define ROOT_TQpLinSolverBase 00045 00046 #ifndef ROOT_TError 00047 #include "TError.h" 00048 #endif 00049 00050 #ifndef ROOT_TQpVar 00051 #include "TQpVar.h" 00052 #endif 00053 #ifndef ROOT_TQpDataBase 00054 #include "TQpDataBase.h" 00055 #endif 00056 #ifndef ROOT_TQpResidual 00057 #include "TQpResidual.h" 00058 #endif 00059 #ifndef ROOT_TQpProbBase 00060 #include "TQpProbBase.h" 00061 #endif 00062 00063 #ifndef ROOT_TMatrixD 00064 #include "TMatrixD.h" 00065 #endif 00066 00067 /////////////////////////////////////////////////////////////////////////// 00068 // // 00069 // Implements the main solver for linear systems that arise in // 00070 // primal-dual interior-point methods for QP . This class contains // 00071 // definitions of methods and data common to the sparse and dense // 00072 // special cases of the general formulation. The derived classes contain // 00073 // the aspects that are specific to the sparse and dense forms. // 00074 // // 00075 /////////////////////////////////////////////////////////////////////////// 00076 00077 class TQpProbBase; 00078 class TQpLinSolverBase : public TObject 00079 { 00080 00081 protected: 00082 00083 TVectorD fNomegaInv; // stores a critical diagonal matrix as a vector 00084 TVectorD fRhs; // right-hand side of the system 00085 00086 Int_t fNx; // dimensions of the vectors in the general QP formulation 00087 Int_t fMy; 00088 Int_t fMz; 00089 00090 TVectorD fDd; // temporary storage vectors 00091 TVectorD fDq; 00092 00093 TVectorD fXupIndex; // index matrices for the upper and lower bounds on x and Cx 00094 TVectorD fCupIndex; 00095 TVectorD fXloIndex; 00096 TVectorD fCloIndex; 00097 00098 Int_t fNxup; // dimensions of the upper and lower bound vectors 00099 Int_t fNxlo; 00100 Int_t fMcup; 00101 Int_t fMclo; 00102 00103 TQpProbBase *fFactory; 00104 00105 public: 00106 TQpLinSolverBase(); 00107 TQpLinSolverBase(TQpProbBase *factory,TQpDataBase *data); 00108 TQpLinSolverBase(const TQpLinSolverBase &another); 00109 00110 virtual ~TQpLinSolverBase() {} 00111 00112 virtual void Factor (TQpDataBase *prob,TQpVar *vars); 00113 // sets up the matrix for the main linear system in 00114 // "augmented system" form. The actual factorization is 00115 // performed by a routine specific to either the sparse 00116 // or dense case 00117 virtual void Solve (TQpDataBase *prob,TQpVar *vars,TQpResidual *resids,TQpVar *step); 00118 // solves the system for a given set of residuals. 00119 // Assembles the right-hand side appropriate to the 00120 // matrix factored in factor, solves the system using 00121 // the factorization produced there, partitions the 00122 // solution vector into step components, then recovers 00123 // the step components eliminated during the block 00124 // elimination that produced the augmented system form 00125 virtual void JoinRHS (TVectorD &rhs, TVectorD &rhs1,TVectorD &rhs2,TVectorD &rhs3); 00126 // assembles a single vector object from three given vectors 00127 // rhs (output) final joined vector 00128 // rhs1 (input) first part of rhs 00129 // rhs2 (input) middle part of rhs 00130 // rhs3 (input) last part of rhs 00131 virtual void SeparateVars (TVectorD &vars1,TVectorD &vars2,TVectorD &vars3,TVectorD &vars); 00132 // extracts three component vectors from a given aggregated 00133 // vector. 00134 // vars (input) aggregated vector 00135 // vars1 (output) first part of vars 00136 // vars2 (output) middle part of vars 00137 // vars3 (output) last part of vars 00138 00139 virtual void SolveXYZS (TVectorD &stepx,TVectorD &stepy,TVectorD &stepz,TVectorD &steps, 00140 TVectorD &ztemp,TQpDataBase *data); 00141 // assemble right-hand side of augmented system and call 00142 // SolveCompressed to solve it 00143 00144 virtual void SolveCompressed (TVectorD &rhs) = 0; 00145 // perform the actual solve using the factors produced in 00146 // factor. 00147 // rhs on input contains the aggregated right-hand side of 00148 // the augmented system; on output contains the solution in 00149 // aggregated form 00150 00151 virtual void PutXDiagonal (TVectorD &xdiag) = 0; 00152 // places the diagonal resulting from the bounds on x into 00153 // the augmented system matrix 00154 virtual void PutZDiagonal (TVectorD& zdiag) = 0; 00155 // places the diagonal resulting from the bounds on Cx into 00156 // the augmented system matrix 00157 virtual void ComputeDiagonals(TVectorD &dd,TVectorD &omega,TVectorD &t, TVectorD &lambda, 00158 TVectorD &u, TVectorD &pi,TVectorD &v, TVectorD &gamma, 00159 TVectorD &w, TVectorD &phi); 00160 // computes the diagonal matrices in the augmented system 00161 // from the current set of variables 00162 00163 TQpLinSolverBase &operator= (const TQpLinSolverBase &source); 00164 00165 ClassDef(TQpLinSolverBase,1) // Qp linear solver base class 00166 }; 00167 #endif