ROOT  6.06/09
Reference Guide
TQpVar.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_TQpVar
44 #define ROOT_TQpVar
45 
46 #ifndef ROOT_TError
47 #include "TError.h"
48 #endif
49 
50 #ifndef ROOT_TMatrixD
51 #include "TMatrixD.h"
52 #endif
53 #ifndef ROOT_TVectorD
54 #include "TVectorD.h"
55 #endif
56 
57 ///////////////////////////////////////////////////////////////////////////
58 // //
59 // Class containing the variables for the general QP formulation //
60 // In terms of in our abstract problem formulation, these variables are //
61 // the vectors x, y, z and s. //
62 // //
63 ///////////////////////////////////////////////////////////////////////////
64 
65 class TQpVar : public TObject
66 {
67 
68 protected:
76 
77  // these variables will be "Used" not copied
82 
83  static Double_t StepBound (TVectorD &v,TVectorD &dir,Double_t maxStep);
84  static Double_t FindBlocking (TVectorD &w,TVectorD &wstep,TVectorD &u,TVectorD &ustep,
85  Double_t maxStep,Double_t &w_elt,Double_t &wstep_elt,Double_t &u_elt,
86  Double_t &ustep_elt,int& first_or_second);
87  static Double_t FindBlockingSub(Int_t n,Double_t *w,Int_t incw,Double_t *wstep,Int_t incwstep,
88  Double_t *u,Int_t incu,Double_t *ustep,Int_t incustep,
89  Double_t maxStep,Double_t &w_elt,Double_t &wstep_elt,
90  Double_t &u_elt,Double_t &ustep_elt,Int_t &first_or_second);
91 
92 public:
93 
94  Int_t fNComplementaryVariables; // number of complementary primal-dual variables.
95 
96  // these variables will be "Used" not copied
101 
104 
107 
110 
113 
114  TQpVar();
115  // constructor in which the data and variable pointers are set to point to the given arguments
116  TQpVar(TVectorD &x_in,TVectorD &s_in,TVectorD &y_in,TVectorD &z_in,
117  TVectorD &v_in,TVectorD &gamma_in,TVectorD &w_in,TVectorD &phi_in,
118  TVectorD &t_in,TVectorD &lambda_in,TVectorD &u_in,TVectorD &pi_in,
119  TVectorD &ixlow_in,TVectorD &ixupp_in,TVectorD &iclow_in,TVectorD &icupp_in);
120 
121  // constructor that creates variables objects of specified dimensions.
122  TQpVar(Int_t nx,Int_t my,Int_t mz,
123  TVectorD &ixlow,TVectorD &ixupp,TVectorD &iclow,TVectorD &icupp);
124  TQpVar(const TQpVar &another);
125 
126  virtual ~TQpVar() {}
127 
128  // Indicates what type is the blocking variable in the step length determination. If kt_block,
129  // then the blocking variable is one of the slack variables t for a general lower bound,
130  // and so on. Special value kno_block is for the case in which a step length of 1 can be
131  // taken without hitting the bound.
132 
135 
136  virtual Double_t GetMu (); // compute complementarity gap, obtained by taking the
137  // inner product of the complementary vectors and dividing
138  // by the total number of components
139  // computes mu = (t'lambda +u'pi + v'gamma + w'phi)/
140  // (mclow+mcupp+nxlow+nxupp)
141  virtual Double_t MuStep (TQpVar *step,Double_t alpha);
142  // compute the complementarity gap resulting from a step
143  // of length "alpha" along direction "step"
144  virtual void Saxpy (TQpVar *b,Double_t alpha);
145  // given variables b, compute a <- a + alpha b,
146  // where a are the variables in this class
147 
148  virtual void Negate (); // negate the value of all the variables in this structure
149 
150  virtual Double_t StepBound (TQpVar *b); // calculate the largest alpha in (0,1] such that the
151  // nonnegative variables stay nonnegative in the given
152  // search direction. In the general QP problem formulation
153  // this is the largest value of alpha such that
154  // (t,u,v,w,lambda,pi,phi,gamma) + alpha * (b->t,b->u,
155  // b->v,b->w,b->lambda,b->pi,b->phi,b->gamma) >= 0.
156 
157  virtual Double_t FindBlocking(TQpVar *step,Double_t &primalValue,Double_t &primalStep,Double_t &dualValue,
158  Double_t &dualStep,Int_t &firstOrSecond);
159  // Performs the same function as StepBound, and supplies
160  // additional information about which component of the
161  // nonnegative variables is responsible for restricting
162  // alpha. In terms of the abstract formulation, the
163  // components have the following meanings.
164  //
165  // primalValue: the value of the blocking component of the
166  // primal variables (u,t,v,w).
167  // primalStep: the corresponding value of the blocking
168  // component of the primal step variables (b->u,b->t,
169  // b->v,b->w)
170  // dualValue: the value of the blocking component of the
171  // dual variables (lambda,pi,phi,gamma).
172  // dualStep: the corresponding value of the blocking
173  // component of the dual step variables (b->lambda,b->pi,
174  // b->phi,b->gamma)
175  // firstOrSecond: 1 if the primal step is blocking, 2
176  // if the dual step is block, 0 if no step is blocking.
177 
178  virtual void InteriorPoint(Double_t alpha,Double_t beta);
179  // sets components of (u,t,v,w) to alpha and of
180  // (lambda,pi,phi,gamma) to beta
181  virtual void ShiftBoundVariables
182  (Double_t alpha,Double_t beta);
183  // add alpha to components of (u,t,v,w) and beta to
184  // components of (lambda,pi,phi,gamma)
185  virtual Bool_t IsInteriorPoint(); // check whether this is an interior point. Useful as a
186  // sanity check.
187  virtual Double_t Violation (); // The amount by which the current variables violate the
188  // non-negativity constraints.
189  virtual void Print (Option_t *option="") const;
190  virtual Double_t Norm1 (); // compute the 1-norm of the variables
191  virtual Double_t NormInf (); // compute the inf-norm of the variables
192  virtual Bool_t ValidNonZeroPattern();
193 
194  TQpVar &operator= (const TQpVar &source);
195 
196  ClassDef(TQpVar,1) // Qp Variables class
197 };
198 #endif
const int nx
Definition: kalman.C:16
static Double_t FindBlockingSub(Int_t n, Double_t *w, Int_t incw, Double_t *wstep, Int_t incwstep, Double_t *u, Int_t incu, Double_t *ustep, Int_t incustep, Double_t maxStep, Double_t &w_elt, Double_t &wstep_elt, Double_t &u_elt, Double_t &ustep_elt, Int_t &first_or_second)
See FindBlocking function.
Definition: TQpVar.cxx:464
TVectorD fCloIndex
Definition: TQpVar.h:81
const char Option_t
Definition: RtypesCore.h:62
TVectorD fCupIndex
Definition: TQpVar.h:80
virtual ~TQpVar()
Definition: TQpVar.h:126
virtual Double_t MuStep(TQpVar *step, Double_t alpha)
Compute the complementarity gap resulting from a step of length "alpha" along direction "step"...
Definition: TQpVar.cxx:210
Int_t fMclo
Definition: TQpVar.h:75
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Print(Option_t *option="") const
Print class members.
Definition: TQpVar.cxx:638
TVectorD fX
Definition: TQpVar.h:97
Int_t fNxup
Definition: TQpVar.h:72
double beta(double x, double y)
Calculates the beta function.
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual Double_t Violation()
The amount by which the current variables violate the non-negativity constraints. ...
Definition: TQpVar.cxx:573
virtual Double_t GetMu()
compute complementarity gap, obtained by taking the inner product of the complementary vectors and di...
Definition: TQpVar.cxx:191
static Double_t StepBound(TVectorD &v, TVectorD &dir, Double_t maxStep)
Find the maximum stepsize of v in direction dir before violating the nonnegativity constraints...
Definition: TQpVar.cxx:347
TVectorD fXupIndex
Definition: TQpVar.h:79
TVectorD fW
Definition: TQpVar.h:105
Int_t fMy
Definition: TQpVar.h:70
virtual void ShiftBoundVariables(Double_t alpha, Double_t beta)
Add alpha to components of (u,t,v,w) and beta to components of (lambda,pi,phi,gamma) ...
Definition: TQpVar.cxx:614
virtual Bool_t ValidNonZeroPattern()
Check that the variables conform to the non-zero indices.
Definition: TQpVar.cxx:739
EVarBlock
Definition: TQpVar.h:133
SVector< double, 2 > v
Definition: Dict.h:5
TVectorD fV
Definition: TQpVar.h:102
Int_t fMz
Definition: TQpVar.h:71
virtual void Negate()
Perform a "negate" operation on all data vectors : x = -x.
Definition: TQpVar.cxx:271
virtual Bool_t IsInteriorPoint()
Is the current position an interior point ?
Definition: TQpVar.cxx:374
Int_t fNxlo
Definition: TQpVar.h:73
Int_t fMcup
Definition: TQpVar.h:74
double Double_t
Definition: RtypesCore.h:55
static Double_t FindBlocking(TVectorD &w, TVectorD &wstep, TVectorD &u, TVectorD &ustep, Double_t maxStep, Double_t &w_elt, Double_t &wstep_elt, Double_t &u_elt, Double_t &ustep_elt, int &first_or_second)
See other FindBlocking function.
Definition: TQpVar.cxx:445
virtual void Saxpy(TQpVar *b, Double_t alpha)
Perform a "saxpy" operation on all data vectors : x += alpha*y.
Definition: TQpVar.cxx:231
TVectorD fY
Definition: TQpVar.h:99
TVectorD fLambda
Definition: TQpVar.h:109
TVectorD fU
Definition: TQpVar.h:111
TVectorD fPhi
Definition: TQpVar.h:103
TVectorD fGamma
Definition: TQpVar.h:106
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void InteriorPoint(Double_t alpha, Double_t beta)
Sets components of (u,t,v,w) to alpha and of (lambda,pi,phi,gamma) to beta.
Definition: TQpVar.cxx:533
virtual Double_t Norm1()
Return the sum of the vector-norm1's.
Definition: TQpVar.cxx:675
Definition: TQpVar.h:65
TVectorD fS
Definition: TQpVar.h:98
TVectorD fPi
Definition: TQpVar.h:112
TVectorD fT
Definition: TQpVar.h:108
virtual Double_t NormInf()
Return the sum of the vector-normInf's.
Definition: TQpVar.cxx:699
TQpVar & operator=(const TQpVar &source)
Assignment operator.
Definition: TQpVar.cxx:771
Int_t fNComplementaryVariables
Definition: TQpVar.h:94
Int_t fNx
Definition: TQpVar.h:69
const Int_t n
Definition: legend1.C:16
TVectorD fXloIndex
Definition: TQpVar.h:78
TVectorD fZ
Definition: TQpVar.h:100