// @(#)root/quadp:$Id$
// Author: Eddy Offermann   May 2004

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

/*************************************************************************
 * Parts of this file are copied from the OOQP distribution and          *
 * are subject to the following license:                                 *
 *                                                                       *
 * COPYRIGHT 2001 UNIVERSITY OF CHICAGO                                  *
 *                                                                       *
 * The copyright holder hereby grants you royalty-free rights to use,    *
 * reproduce, prepare derivative works, and to redistribute this software*
 * to others, provided that any changes are clearly documented. This     *
 * software was authored by:                                             *
 *                                                                       *
 *   E. MICHAEL GERTZ      gertz@mcs.anl.gov                             *
 *   Mathematics and Computer Science Division                           *
 *   Argonne National Laboratory                                         *
 *   9700 S. Cass Avenue                                                 *
 *   Argonne, IL 60439-4844                                              *
 *                                                                       *
 *   STEPHEN J. WRIGHT     swright@cs.wisc.edu                           *
 *   Computer Sciences Department                                        *
 *   University of Wisconsin                                             *
 *   1210 West Dayton Street                                             *
 *   Madison, WI 53706   FAX: (608)262-9777                              *
 *                                                                       *
 * Any questions or comments may be directed to one of the authors.      *
 *                                                                       *
 * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF   *
 * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND     *
 * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT   *
 * WITH THE DEPARTMENT OF ENERGY.                                        *
 *************************************************************************/

#ifndef ROOT_TQpDataBase
#define ROOT_TQpDataBase

#ifndef ROOT_TError
#include "TError.h"
#endif

#ifndef ROOT_TQpVar
#include "TQpVar.h"
#endif

#ifndef ROOT_TMatrixD
#include "TMatrixD.h"
#endif

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TQpDataBase                                                          //
//                                                                      //
// Data for the general QP formulation                                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TQpDataBase : public TObject
{

protected:

   // as part of setting up a random test problem, generate a random
   //  set of upper, lower, and two-sided bounds
   static void RandomlyChooseBoundedVariables(TVectorD &x,TVectorD &dualx,TVectorD &blx,TVectorD &ixlow,
                                              TVectorD &bux,TVectorD &ixupp,Double_t &ix,Double_t percentLowerOnly,
                                              Double_t percentUpperOnly,Double_t percentBound);

public:

   Int_t    fNx;
   Int_t    fMy;
   Int_t    fMz;

   TVectorD fG;                                // linear part of Objective function
   TVectorD fBa;                               // vector of equality constraint
   TVectorD fXupBound;                         // Bounds on variables
   TVectorD fXupIndex;
   TVectorD fXloBound;
   TVectorD fXloIndex;
   TVectorD fCupBound;                         // Inequality constraints
   TVectorD fCupIndex;
   TVectorD fCloBound;
   TVectorD fCloIndex;

   TQpDataBase();
   TQpDataBase(Int_t nx,Int_t my,Int_t mz);
   TQpDataBase(const TQpDataBase &another);
   virtual ~TQpDataBase() {}

   virtual void PutQIntoAt(TMatrixDBase &M,Int_t row,Int_t col) = 0;
   virtual void PutAIntoAt(TMatrixDBase &M,Int_t row,Int_t col) = 0;
   virtual void PutCIntoAt(TMatrixDBase &M,Int_t row,Int_t col) = 0;

   virtual void Qmult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x) = 0;
   virtual void Amult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x) = 0;
   virtual void Cmult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x) = 0;
   virtual void ATransmult(Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x) = 0;
   virtual void CTransmult(Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x) = 0;

   virtual void GetDiagonalOfQ(TVectorD &dQ) = 0;

   virtual TVectorD &GetG           () { return fG; }
   virtual TVectorD &GetBa          () { return fBa; }

   virtual TVectorD &GetXupperBound () { return fXupBound; }
   virtual TVectorD &GetiXupperBound() { return fXupIndex; }
   virtual TVectorD &GetXlowerBound () { return fXloBound; }
   virtual TVectorD &GetiXlowerBound() { return fXloIndex; }
   virtual TVectorD &GetSupperBound () { return fCupBound;  }
   virtual TVectorD &GetiSupperBound() { return fCupIndex; }
   virtual TVectorD &GetSlowerBound () { return fCloBound;  }
   virtual TVectorD &GetiSlowerBound() { return fCloIndex; }

   virtual Double_t  DataNorm      () = 0;
   virtual void      DataRandom    (TVectorD &x,TVectorD &y,TVectorD &z,TVectorD &s) = 0;
   virtual Double_t  ObjectiveValue(TQpVar *vars) = 0;

   TQpDataBase &operator= (const TQpDataBase &source);

   ClassDef(TQpDataBase,1)                     // Qp Base Data class
};
#endif
 TQpDataBase.h:1
 TQpDataBase.h:2
 TQpDataBase.h:3
 TQpDataBase.h:4
 TQpDataBase.h:5
 TQpDataBase.h:6
 TQpDataBase.h:7
 TQpDataBase.h:8
 TQpDataBase.h:9
 TQpDataBase.h:10
 TQpDataBase.h:11
 TQpDataBase.h:12
 TQpDataBase.h:13
 TQpDataBase.h:14
 TQpDataBase.h:15
 TQpDataBase.h:16
 TQpDataBase.h:17
 TQpDataBase.h:18
 TQpDataBase.h:19
 TQpDataBase.h:20
 TQpDataBase.h:21
 TQpDataBase.h:22
 TQpDataBase.h:23
 TQpDataBase.h:24
 TQpDataBase.h:25
 TQpDataBase.h:26
 TQpDataBase.h:27
 TQpDataBase.h:28
 TQpDataBase.h:29
 TQpDataBase.h:30
 TQpDataBase.h:31
 TQpDataBase.h:32
 TQpDataBase.h:33
 TQpDataBase.h:34
 TQpDataBase.h:35
 TQpDataBase.h:36
 TQpDataBase.h:37
 TQpDataBase.h:38
 TQpDataBase.h:39
 TQpDataBase.h:40
 TQpDataBase.h:41
 TQpDataBase.h:42
 TQpDataBase.h:43
 TQpDataBase.h:44
 TQpDataBase.h:45
 TQpDataBase.h:46
 TQpDataBase.h:47
 TQpDataBase.h:48
 TQpDataBase.h:49
 TQpDataBase.h:50
 TQpDataBase.h:51
 TQpDataBase.h:52
 TQpDataBase.h:53
 TQpDataBase.h:54
 TQpDataBase.h:55
 TQpDataBase.h:56
 TQpDataBase.h:57
 TQpDataBase.h:58
 TQpDataBase.h:59
 TQpDataBase.h:60
 TQpDataBase.h:61
 TQpDataBase.h:62
 TQpDataBase.h:63
 TQpDataBase.h:64
 TQpDataBase.h:65
 TQpDataBase.h:66
 TQpDataBase.h:67
 TQpDataBase.h:68
 TQpDataBase.h:69
 TQpDataBase.h:70
 TQpDataBase.h:71
 TQpDataBase.h:72
 TQpDataBase.h:73
 TQpDataBase.h:74
 TQpDataBase.h:75
 TQpDataBase.h:76
 TQpDataBase.h:77
 TQpDataBase.h:78
 TQpDataBase.h:79
 TQpDataBase.h:80
 TQpDataBase.h:81
 TQpDataBase.h:82
 TQpDataBase.h:83
 TQpDataBase.h:84
 TQpDataBase.h:85
 TQpDataBase.h:86
 TQpDataBase.h:87
 TQpDataBase.h:88
 TQpDataBase.h:89
 TQpDataBase.h:90
 TQpDataBase.h:91
 TQpDataBase.h:92
 TQpDataBase.h:93
 TQpDataBase.h:94
 TQpDataBase.h:95
 TQpDataBase.h:96
 TQpDataBase.h:97
 TQpDataBase.h:98
 TQpDataBase.h:99
 TQpDataBase.h:100
 TQpDataBase.h:101
 TQpDataBase.h:102
 TQpDataBase.h:103
 TQpDataBase.h:104
 TQpDataBase.h:105
 TQpDataBase.h:106
 TQpDataBase.h:107
 TQpDataBase.h:108
 TQpDataBase.h:109
 TQpDataBase.h:110
 TQpDataBase.h:111
 TQpDataBase.h:112
 TQpDataBase.h:113
 TQpDataBase.h:114
 TQpDataBase.h:115
 TQpDataBase.h:116
 TQpDataBase.h:117
 TQpDataBase.h:118
 TQpDataBase.h:119
 TQpDataBase.h:120
 TQpDataBase.h:121
 TQpDataBase.h:122
 TQpDataBase.h:123
 TQpDataBase.h:124
 TQpDataBase.h:125
 TQpDataBase.h:126
 TQpDataBase.h:127
 TQpDataBase.h:128
 TQpDataBase.h:129
 TQpDataBase.h:130
 TQpDataBase.h:131