Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TQpVar.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/quadp:$Id$
0002 // Author: Eddy Offermann   May 2004
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 /*************************************************************************
0013  * Parts of this file are copied from the OOQP distribution and          *
0014  * are subject to the following license:                                 *
0015  *                                                                       *
0016  * COPYRIGHT 2001 UNIVERSITY OF CHICAGO                                  *
0017  *                                                                       *
0018  * The copyright holder hereby grants you royalty-free rights to use,    *
0019  * reproduce, prepare derivative works, and to redistribute this software*
0020  * to others, provided that any changes are clearly documented. This     *
0021  * software was authored by:                                             *
0022  *                                                                       *
0023  *   E. MICHAEL GERTZ      gertz@mcs.anl.gov                             *
0024  *   Mathematics and Computer Science Division                           *
0025  *   Argonne National Laboratory                                         *
0026  *   9700 S. Cass Avenue                                                 *
0027  *   Argonne, IL 60439-4844                                              *
0028  *                                                                       *
0029  *   STEPHEN J. WRIGHT     swright@cs.wisc.edu                           *
0030  *   Computer Sciences Department                                        *
0031  *   University of Wisconsin                                             *
0032  *   1210 West Dayton Street                                             *
0033  *   Madison, WI 53706   FAX: (608)262-9777                              *
0034  *                                                                       *
0035  * Any questions or comments may be directed to one of the authors.      *
0036  *                                                                       *
0037  * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF   *
0038  * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND     *
0039  * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT   *
0040  * WITH THE DEPARTMENT OF ENERGY.                                        *
0041  *************************************************************************/
0042 
0043 #ifndef ROOT_TQpVar
0044 #define ROOT_TQpVar
0045 
0046 #include "TError.h"
0047 
0048 #include "TMatrixD.h"
0049 #include "TVectorD.h"
0050 
0051 ///////////////////////////////////////////////////////////////////////////
0052 //                                                                       //
0053 // Class containing the variables for the general QP formulation         //
0054 // In terms of in our abstract problem formulation, these variables are  //
0055 // the vectors x, y, z and s.                                            //
0056 //                                                                       //
0057 ///////////////////////////////////////////////////////////////////////////
0058 
0059 class TQpVar : public TObject
0060 {
0061 
0062 protected:
0063    Int_t fNx;
0064    Int_t fMy;
0065    Int_t fMz;
0066    Int_t fNxup;
0067    Int_t fNxlo;
0068    Int_t fMcup;
0069    Int_t fMclo;
0070 
0071    // these variables will be "Used" not copied
0072    TVectorD fXloIndex;
0073    TVectorD fXupIndex;
0074    TVectorD fCupIndex;
0075    TVectorD fCloIndex;
0076 
0077    static Double_t StepBound      (TVectorD &v,TVectorD &dir,Double_t maxStep);
0078    static Double_t FindBlocking   (TVectorD &w,TVectorD &wstep,TVectorD &u,TVectorD &ustep,
0079                                    Double_t maxStep,Double_t &w_elt,Double_t &wstep_elt,Double_t &u_elt,
0080                                    Double_t &ustep_elt,int& first_or_second);
0081    static Double_t FindBlockingSub(Int_t n,Double_t *w,Int_t incw,Double_t *wstep,Int_t incwstep,
0082                                    Double_t *u,Int_t incu,Double_t *ustep,Int_t incustep,
0083                                    Double_t maxStep,Double_t &w_elt,Double_t &wstep_elt,
0084                                    Double_t &u_elt,Double_t &ustep_elt,Int_t &first_or_second);
0085 
0086 public:
0087 
0088    Int_t fNComplementaryVariables;             // number of complementary primal-dual variables.
0089 
0090    // these variables will be "Used" not copied
0091    TVectorD fX;
0092    TVectorD fS;
0093    TVectorD fY;
0094    TVectorD fZ;
0095 
0096    TVectorD fV;
0097    TVectorD fPhi;
0098 
0099    TVectorD fW;
0100    TVectorD fGamma;
0101 
0102    TVectorD fT;
0103    TVectorD fLambda;
0104 
0105    TVectorD fU;
0106    TVectorD fPi;
0107 
0108    TQpVar();
0109    // constructor in which the data and variable pointers are set to point to the given arguments
0110    TQpVar(TVectorD &x_in,TVectorD &s_in,TVectorD &y_in,TVectorD &z_in,
0111           TVectorD &v_in,TVectorD &gamma_in,TVectorD &w_in,TVectorD &phi_in,
0112           TVectorD &t_in,TVectorD &lambda_in,TVectorD &u_in,TVectorD &pi_in,
0113           TVectorD &ixlow_in,TVectorD &ixupp_in,TVectorD &iclow_in,TVectorD &icupp_in);
0114 
0115    // constructor that creates variables objects of specified dimensions.
0116    TQpVar(Int_t nx,Int_t my,Int_t mz,
0117       TVectorD &ixlow,TVectorD &ixupp,TVectorD &iclow,TVectorD &icupp);
0118    TQpVar(const TQpVar &another);
0119 
0120    ~TQpVar() override {}
0121 
0122    // Indicates what type is the blocking variable in the step length determination. If kt_block,
0123    // then the blocking variable is one of the slack variables t for a general lower bound,
0124    // and so on. Special value kno_block is for the case in which a step length of 1 can be
0125    // taken without hitting the bound.
0126 
0127    enum EVarBlock { kno_block,kt_block,klambda_block,ku_block,kpi_block,
0128                     kv_block,kgamma_block,kw_block,kphi_block };
0129 
0130    virtual Double_t GetMu       ();            // compute complementarity gap, obtained by taking the
0131                                                // inner product of the complementary vectors and dividing
0132                                                // by the total number of components
0133                                                // computes mu = (t'lambda +u'pi + v'gamma + w'phi)/
0134                                                //                    (mclow+mcupp+nxlow+nxupp)
0135    virtual Double_t MuStep      (TQpVar *step,Double_t alpha);
0136                                                // compute the complementarity gap resulting from a step
0137                                                // of length "alpha" along direction "step"
0138    virtual void     Saxpy       (TQpVar *b,Double_t alpha);
0139                                                // given variables b, compute a <- a + alpha b,
0140                                                // where a are the variables in this class
0141 
0142    virtual void     Negate      ();            // negate the value of all the variables in this structure
0143 
0144    virtual Double_t StepBound   (TQpVar *b);   // calculate the largest alpha in (0,1] such that the
0145                                                // nonnegative variables stay nonnegative in the given
0146                                                // search direction. In the general QP problem formulation
0147                                                // this is the largest value of alpha such that
0148                                                // (t,u,v,w,lambda,pi,phi,gamma) + alpha * (b->t,b->u,
0149                                                //   b->v,b->w,b->lambda,b->pi,b->phi,b->gamma) >= 0.
0150 
0151    virtual Double_t FindBlocking(TQpVar *step,Double_t &primalValue,Double_t &primalStep,Double_t &dualValue,
0152                                  Double_t &dualStep,Int_t &firstOrSecond);
0153                                                // Performs the same function as StepBound, and supplies
0154                                                // additional information about which component of the
0155                                                // nonnegative variables is responsible for restricting
0156                                                // alpha. In terms of the abstract formulation, the
0157                                                // components have the following meanings.
0158                                                //
0159                                                // primalValue: the value of the blocking component of the
0160                                                // primal variables (u,t,v,w).
0161                                                // primalStep: the corresponding value of the blocking
0162                                                // component of the primal step variables (b->u,b->t,
0163                                                // b->v,b->w)
0164                                                // dualValue: the value of the blocking component of the
0165                                                // dual variables (lambda,pi,phi,gamma).
0166                                                // dualStep: the corresponding value of the blocking
0167                                                // component of the dual step variables (b->lambda,b->pi,
0168                                                // b->phi,b->gamma)
0169                                                // firstOrSecond:  1 if the primal step is blocking, 2
0170                                                // if the dual step is block, 0 if no step is blocking.
0171 
0172    virtual void     InteriorPoint(Double_t alpha,Double_t beta);
0173                                                // sets components of (u,t,v,w) to alpha and of
0174                                                // (lambda,pi,phi,gamma) to beta
0175    virtual void     ShiftBoundVariables
0176                                  (Double_t alpha,Double_t beta);
0177                                                // add alpha to components of (u,t,v,w) and beta to
0178                                                // components of (lambda,pi,phi,gamma)
0179    virtual Bool_t   IsInteriorPoint();         // check whether this is an interior point. Useful as a
0180                                                // sanity check.
0181    virtual Double_t Violation    ();           // The amount by which the current variables violate the
0182                                                //  non-negativity constraints.
0183    void     Print        (Option_t *option="") const override;
0184    virtual Double_t Norm1        ();           // compute the 1-norm of the variables
0185    virtual Double_t NormInf      ();           // compute the inf-norm of the variables
0186    virtual Bool_t   ValidNonZeroPattern();
0187 
0188    TQpVar &operator= (const TQpVar &source);
0189 
0190    ClassDefOverride(TQpVar,1)                          // Qp Variables class
0191 };
0192 #endif