ROOT logo
// @(#)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_TQpDataSparse
#define ROOT_TQpDataSparse

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

#ifndef ROOT_TMatrixDSparse
#include "TMatrixDSparse.h"
#endif

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TQpDataSparse                                                        //
//                                                                      //
// Data for the dense QP formulation                                    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TQpDataSparse : public TQpDataBase
{

protected:

   // these variables will be "Used" not copied
   TMatrixDSparse fQ;                          // quadratic part of Objective function
   TMatrixDSparse fA;                          // Equality constraints
   TMatrixDSparse fC;                          // Inequality constraints

public:

   TQpDataSparse() {}
   // data objects of the specified dimensions
   TQpDataSparse(Int_t nx,Int_t my,Int_t mz);

   // sets up pointers to the data objects that are passed as arguments
   TQpDataSparse(TVectorD &c,TMatrixDSparse &Q,TVectorD &xlow,TVectorD &ixlow,TVectorD &xupp,
                 TVectorD &ixupp,TMatrixDSparse &A,TVectorD &bA,TMatrixDSparse &C,TVectorD &clow,
                 TVectorD &iclow,TVectorD &cupp,TVectorD &icupp);
   TQpDataSparse(const TQpDataSparse &another);

   virtual ~TQpDataSparse() {}

   void SetNonZeros(Int_t nnzQ,Int_t nnzA,Int_t nnzC);

   virtual void PutQIntoAt(TMatrixDBase &M,Int_t row,Int_t col);
                                               // insert the Hessian Q into the matrix M for the fundamental
                                               // linear system, where M is stored as a TMatrixDSparse
   virtual void PutAIntoAt(TMatrixDBase &M,Int_t row,Int_t col);
                                               // insert the constraint matrix A into the matrix M for the
                                               // fundamental linear system, where M is stored as a TMatrixDSparse
   virtual void PutCIntoAt(TMatrixDBase &M,Int_t row,Int_t col);
                                               // insert the constraint matrix C into the matrix M for the
                                               // fundamental linear system, where M is stored as a
                                               // TMatrixDSparse

   virtual void Qmult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x);
                                               // y = beta * y + alpha * Q * x
   virtual void Amult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x);
                                               // y = beta * y + alpha * A * x
   virtual void Cmult     (Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x);
                                               // y = beta * y + alpha * C * x
   virtual void ATransmult(Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x);
                                               // y = beta * y + alpha * A^T * x
   virtual void CTransmult(Double_t beta,TVectorD& y,Double_t alpha,const TVectorD& x);
                                               // y = beta * y + alpha * C^T * x

   virtual void GetDiagonalOfQ(TVectorD &dQ);  // extract the diagonal of Q and put it in the vector dQ

   virtual Double_t DataNorm();
   virtual void DataRandom(TVectorD &x,TVectorD &y,TVectorD &z,TVectorD &s);
                                               // Create a random problem (x,y,z,s)
                                               // the solution to the random problem
   virtual void Print(Option_t *opt="") const;

   virtual Double_t ObjectiveValue(TQpVar *vars);

   TQpDataSparse &operator= (const TQpDataSparse &source);

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