Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TQpResidual.h
Go to the documentation of this file.
1 // @(#)root/quadp:$Id$
2 // Author: Eddy Offermann May 2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /*************************************************************************
13  * Parts of this file are copied from the OOQP distribution and *
14  * are subject to the following license: *
15  * *
16  * COPYRIGHT 2001 UNIVERSITY OF CHICAGO *
17  * *
18  * The copyright holder hereby grants you royalty-free rights to use, *
19  * reproduce, prepare derivative works, and to redistribute this software*
20  * to others, provided that any changes are clearly documented. This *
21  * software was authored by: *
22  * *
23  * E. MICHAEL GERTZ gertz@mcs.anl.gov *
24  * Mathematics and Computer Science Division *
25  * Argonne National Laboratory *
26  * 9700 S. Cass Avenue *
27  * Argonne, IL 60439-4844 *
28  * *
29  * STEPHEN J. WRIGHT swright@cs.wisc.edu *
30  * Computer Sciences Department *
31  * University of Wisconsin *
32  * 1210 West Dayton Street *
33  * Madison, WI 53706 FAX: (608)262-9777 *
34  * *
35  * Any questions or comments may be directed to one of the authors. *
36  * *
37  * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF *
38  * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND *
39  * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT *
40  * WITH THE DEPARTMENT OF ENERGY. *
41  *************************************************************************/
42 
43 #ifndef ROOT_TQpResidual
44 #define ROOT_TQpResidual
45 
46 #include "TError.h"
47 
48 #include "TQpVar.h"
49 #include "TQpDataDens.h"
50 
51 #include "TMatrixD.h"
52 
53 ///////////////////////////////////////////////////////////////////////////
54 // //
55 // Class containing the residuals of a QP when solved by an interior //
56 // point QP solver. In terms of our abstract QP formulation, these //
57 // residuals are rQ, rA, rC and r3. //
58 // //
59 ///////////////////////////////////////////////////////////////////////////
60 
61 class TQpResidual : public TObject
62 {
63 
64 protected:
65  Double_t fResidualNorm; // The norm of the residuals, ommiting the complementariy conditions
66  Double_t fDualityGap; // A quantity that measures progress toward feasibility. In terms
67  // of the abstract problem formulation, this quantity is defined as
68  // x' * Q * x - b' * y + c' * x - d' * z
69 
70  Int_t fNx;
71  Int_t fMy;
72  Int_t fMz;
73 
74  Double_t fNxup;
75  Double_t fNxlo;
76  Double_t fMcup;
77  Double_t fMclo;
78 
79  // these variables will be "Used" not copied
80  TVectorD fXupIndex;
81  TVectorD fXloIndex;
82  TVectorD fCupIndex;
83  TVectorD fCloIndex;
84 
85  static void GondzioProjection(TVectorD &v,Double_t rmin,Double_t rmax);
86 
87 public:
88  TVectorD fRQ;
89  TVectorD fRA;
90  TVectorD fRC;
91  TVectorD fRz;
92  TVectorD fRv;
93  TVectorD fRw;
94  TVectorD fRt;
95  TVectorD fRu;
96  TVectorD fRgamma;
97  TVectorD fRphi;
98  TVectorD fRlambda;
99  TVectorD fRpi;
100 
101  TQpResidual();
102  TQpResidual(Int_t nx,Int_t my,Int_t mz,
103  TVectorD &ixlow,TVectorD &ixupp,TVectorD &iclow,TVectorD &icupp);
104  TQpResidual(const TQpResidual &another);
105 
106  virtual ~TQpResidual() {}
107 
108  Double_t GetResidualNorm() { return fResidualNorm; }
109  Double_t GetDualityGap () { return fDualityGap; };
110 
111  void CalcResids (TQpDataBase *problem,TQpVar *vars);
112  // calculate residuals, their norms, and duality/
113  // complementarity gap, given a problem and variable set.
114  void Add_r3_xz_alpha (TQpVar *vars,Double_t alpha);
115  // Modify the "complementarity" component of the
116  // residuals, by adding the pairwise products of the
117  // complementary variables plus a constant alpha to this
118  // term.
119  void Set_r3_xz_alpha (TQpVar *vars,Double_t alpha);
120  // Set the "complementarity" component of the residuals
121  // to the pairwise products of the complementary variables
122  // plus a constant alpha
123  void Clear_r3 (); // set the complementarity component of the residuals
124  // to 0.
125  void Clear_r1r2 (); // set the noncomplementarity components of the residual
126  // (the terms arising from the linear equalities in the
127  // KKT conditions) to 0.
128  void Project_r3 (Double_t rmin,Double_t rmax);
129  // perform the projection operation required by Gondzio
130  // algorithm: replace each component r3_i of the
131  // complementarity component of the residuals by
132  // r3p_i-r3_i, where r3p_i is the projection of r3_i onto
133  // the box [rmin, rmax]. Then if the resulting value is
134  // less than -rmax, replace it by -rmax.
135  Bool_t ValidNonZeroPattern();
136 
137  TQpResidual &operator= (const TQpResidual &source);
138 
139  ClassDef(TQpResidual,1) // Qp Residual class
140 };
141 #endif