Logo ROOT  
Reference Guide
TQpLinSolverSparse.cxx
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////////////////////////////////////////////////////////////////////////////////
44///
45/// \class TQpLinSolverSparse
46///
47/// Implements the aspects of the solvers for dense general QP
48/// formulation that are specific to the dense case.
49///
50////////////////////////////////////////////////////////////////////////////////
51
52#include "Riostream.h"
53#include "TQpLinSolverSparse.h"
54
56
57////////////////////////////////////////////////////////////////////////////////
58/// Constructor
59
61 TQpLinSolverBase(factory,data)
62{
63 const Int_t n = factory->fNx+factory->fMy+factory->fMz;
65
66 if (fMy > 0) data->PutAIntoAt(fKkt,fNx, 0);
67 if (fMz > 0) data->PutCIntoAt(fKkt,fNx+fMy,0);
68
69 // trick to make sure that A and C are inserted symmetrically
70 if (fMy > 0 || fMz > 0) {
72 fKkt += tmp;
73 }
74
75 data->PutQIntoAt(fKkt,0,0);
76}
77
78
79////////////////////////////////////////////////////////////////////////////////
80/// Copy constructor
81
83TQpLinSolverBase(another)
84{
85 *this = another;
86}
87
88
89////////////////////////////////////////////////////////////////////////////////
90/// Sets up the matrix for the main linear system in "augmented system" form.
91
93{
94 TQpLinSolverBase::Factor(prob,vars);
96}
97
98
99////////////////////////////////////////////////////////////////////////////////
100/// Places the diagonal resulting from the bounds on x into the augmented system matrix
101
103{
105 for (Int_t i = 0; i < xdiag.GetNrows(); i++)
106 diag[i] = xdiag[i];
107}
108
109
110////////////////////////////////////////////////////////////////////////////////
111/// Places the diagonal resulting from the bounds on Cx into the augmented system matrix
112
114{
116 for (Int_t i = 0; i < zdiag.GetNrows(); i++)
117 diag[i+fNx+fMy] = zdiag[i];
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// Perform the actual solve using the factors produced in factor.
123/// rhs on input contains the aggregated right-hand side of the augmented system;
124/// on output contains the solution in aggregated form .
125
127{
128 fSolveSparse.Solve(compressedRhs);
129}
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Assignment operator
134
136{
137 if (this != &source) {
139 fKkt.ResizeTo(source.fKkt); fKkt = source.fKkt;
140 fSolveSparse = source.fSolveSparse;
141 }
142 return *this;
143}
#define ClassImp(name)
Definition: Rtypes.h:361
virtual void SetMatrix(const TMatrixDSparse &a)
Set matrix to be decomposed .
static void Solve(const Int_t n, TArrayD &Aa, TArrayI &Aiw, TArrayD &Aw, const Int_t maxfrt, TVectorD &b, TArrayI &Aiw1, const Int_t nsteps, Int_t *icntl, Int_t *info)
Main routine for solving Ax=b.
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)
Set size of the matrix to nrows x ncols with nr_nonzeros non-zero entries if nr_nonzeros > 0 .
Data for the general QP formulation.
Definition: TQpDataBase.h:61
Data for the sparse QP formulation.
Definition: TQpDataSparse.h:60
virtual void PutCIntoAt(TMatrixDBase &M, Int_t row, Int_t col)
Insert the constraint matrix C into the matrix M at index (row,col) for the fundamental linear system...
virtual void PutAIntoAt(TMatrixDBase &M, Int_t row, Int_t col)
Insert the constraint matrix A into the matrix M at index (row,col) for the fundamental linear system...
virtual void PutQIntoAt(TMatrixDBase &M, Int_t row, Int_t col)
Insert the Hessian Q into the matrix M at index (row,col) for the fundamental linear system.
Implementation of main solver for linear systems.
TQpLinSolverBase & operator=(const TQpLinSolverBase &source)
Assignment opeartor.
virtual void Factor(TQpDataBase *prob, TQpVar *vars)
Sets up the matrix for the main linear system in "augmented system" form.
Implements the aspects of the solvers for dense general QP formulation that are specific to the dense...
TDecompSparse fSolveSparse
virtual void Factor(TQpDataBase *prob, TQpVar *vars)
Sets up the matrix for the main linear system in "augmented system" form.
TQpLinSolverSparse & operator=(const TQpLinSolverSparse &source)
Assignment operator.
virtual void PutZDiagonal(TVectorD &zdiag)
Places the diagonal resulting from the bounds on Cx into the augmented system matrix.
virtual void SolveCompressed(TVectorD &rhs)
Perform the actual solve using the factors produced in factor.
virtual void PutXDiagonal(TVectorD &xdiag)
Places the diagonal resulting from the bounds on x into the augmented system matrix.
dense matrix problem formulation
Definition: TQpProbSparse.h:59
Class containing the variables for the general QP formulation.
Definition: TQpVar.h:60
Int_t GetNrows() const
Definition: TVectorT.h:75
const Int_t n
Definition: legend1.C:16