Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TQpProbSparse.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#include "TQpProbSparse.h"
44#include "TMatrixD.h"
45#include "TQpLinSolverSparse.h"
46
47////////////////////////////////////////////////////////////////////////////////
48///
49/// \class TQpProbSparse
50///
51/// dense matrix problem formulation
52///
53////////////////////////////////////////////////////////////////////////////////
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Constructor
58
61{
62 // We do not want more constrains than variables
63 R__ASSERT(nx-my-mz > 0);
64}
65
66
67////////////////////////////////////////////////////////////////////////////////
68/// Copy constructor
69
74
75
76////////////////////////////////////////////////////////////////////////////////
77/// Setup the data
78
81 Double_t *xlo,Bool_t *ixlo,
82 Double_t *xup,Bool_t *ixup,
84 Double_t *bA,
88{
89 TVectorD vc ; vc .Use(fNx,c);
91 TVectorD vxlo; vxlo.Use(fNx,xlo);
92 TVectorD vxup; vxup.Use(fNx,xup);
95 if (fMy > 0) {
96 mA .Use(fMy,fNx,nnzA,irowA,icolA,A);
97 vbA .Use(fMy,bA);
98 }
102 if (fMz > 0) {
103 mC .Use(fMz,fNx,nnzC,irowC,icolC,C);
104 vclo.Use(fMz,clo);
105 vcup.Use(fMz,cup);
106 }
107
110 for (Int_t ix = 0; ix < fNx; ix++) {
111 vixlo[ix] = (ixlo[ix]) ? 1.0 : 0.0;
112 vixup[ix] = (ixup[ix]) ? 1.0 : 0.0;
113 }
114
117 for (Int_t ic = 0; ic < fMz; ic++) {
118 viclo[ic] = (iclo[ic]) ? 1.0 : 0.0;
119 vicup[ic] = (icup[ic]) ? 1.0 : 0.0;
120 }
121
124
125 return data;
126}
127
128
129////////////////////////////////////////////////////////////////////////////////
130/// Setup the data
131
134 TVectorD &xlo, TVectorD &ixlo,
135 TVectorD &xup, TVectorD &ixup,
140{
144
145 R__ASSERT(mQ.GetNrows() == fNx && mQ.GetNcols() == fNx);
146 if (fMy > 0) R__ASSERT(mA.GetNrows() == fMy && mA.GetNcols() == fNx);
147 else R__ASSERT(mA.GetNrows() == fMy);
148 if (fMz > 0) R__ASSERT(mC.GetNrows() == fMz && mC.GetNcols() == fNx);
149 else R__ASSERT(mC.GetNrows() == fMz);
150
151 R__ASSERT(c.GetNrows() == fNx);
152 R__ASSERT(xlo.GetNrows() == fNx);
153 R__ASSERT(ixlo.GetNrows() == fNx);
154 R__ASSERT(xup.GetNrows() == fNx);
155 R__ASSERT(ixup.GetNrows() == fNx);
156
157 R__ASSERT(bA.GetNrows() == fMy);
158 R__ASSERT(clo.GetNrows() == fMz);
159 R__ASSERT(iclo.GetNrows() == fMz);
160 R__ASSERT(cup.GetNrows() == fMz);
161 R__ASSERT(icup.GetNrows() == fMz);
162
164
165 return data;
166}
167
168
169////////////////////////////////////////////////////////////////////////////////
170/// Setup the residuals
171
173{
175 return new TQpResidual(fNx,fMy,fMz,data->fXloIndex,data->fXupIndex,data->fCloIndex,data->fCupIndex);
176}
177
178
179////////////////////////////////////////////////////////////////////////////////
180/// Setup the variables
181
183{
185
186 return new TQpVar(fNx,fMy,fMz,data->fXloIndex,data->fXupIndex,data->fCloIndex,data->fCupIndex);
187}
188
189
190////////////////////////////////////////////////////////////////////////////////
191/// Setup the linear solver
192
198
199
200////////////////////////////////////////////////////////////////////////////////
201/// Assembles a single vector object from three given vectors .
202/// rhs_out (output) final joined vector
203/// rhs1_in (input) first part of rhs
204/// rhs2_in (input) middle part of rhs
205/// rhs3_in (input) last part of rhs .
206
208{
209 rhs.SetSub(0,rhs1_in);
210 if (fMy > 0) rhs.SetSub(fNx, rhs2_in);
211 if (fMz > 0) rhs.SetSub(fNx+fMy,rhs3_in);
212}
213
214
215////////////////////////////////////////////////////////////////////////////////
216/// Extracts three component vectors from a given aggregated vector.
217/// vars_in (input) aggregated vector
218/// x_in (output) first part of vars
219/// y_in (output) middle part of vars
220/// z_in (output) last part of vars
221
223{
224 x_in = vars_in.GetSub(0,fNx-1);
225 if (fMy > 0) y_in = vars_in.GetSub(fNx, fNx+fMy-1);
226 if (fMz > 0) z_in = vars_in.GetSub(fNx+fMy,fNx+fMy+fMz-1);
227}
228
229
230////////////////////////////////////////////////////////////////////////////////
231/// Create a random QP problem
232
234{
236 soln = this->MakeVariables(data);
237 data->SetNonZeros(nnzQ,nnzA,nnzC);
238 data->DataRandom(soln->fX,soln->fY,soln->fZ,soln->fS);
239}
240
241
242////////////////////////////////////////////////////////////////////////////////
243/// Assignment operator
244
246{
247 if (this != &source) {
249 }
250 return *this;
251}
#define c(i)
Definition RSha256.hxx:101
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Data for the general QP formulation.
Definition TQpDataBase.h:61
Data for the sparse QP formulation.
Implementation of main solver for linear systems.
Implements the aspects of the solvers for dense general QP formulation that are specific to the dense...
default general problem formulation:
Definition TQpProbBase.h:89
TQpProbBase & operator=(const TQpProbBase &source)
Assignment operator.
dense matrix problem formulation
void JoinRHS(TVectorD &rhs_in, TVectorD &rhs1_in, TVectorD &rhs2_in, TVectorD &rhs3_in) override
Assembles a single vector object from three given vectors .
virtual TQpDataBase * MakeData(Double_t *c, Int_t nnzQ, Int_t *irowQ, Int_t *icolQ, Double_t *Q, Double_t *xlo, Bool_t *ixlo, Double_t *xup, Bool_t *ixup, Int_t nnzA, Int_t *irowA, Int_t *icolA, Double_t *A, Double_t *bA, Int_t nnzC, Int_t *irowC, Int_t *icolC, Double_t *C, Double_t *clo, Bool_t *iclo, Double_t *cup, Bool_t *icup)
Setup the data.
TQpProbSparse & operator=(const TQpProbSparse &source)
Assignment operator.
TQpVar * MakeVariables(const TQpDataBase *data) override
Setup the variables.
void MakeRandomData(TQpDataSparse *&data, TQpVar *&soln, Int_t nnzQ, Int_t nnzA, Int_t nnzC)
Create a random QP problem.
TQpResidual * MakeResiduals(const TQpDataBase *data) override
Setup the residuals.
void SeparateVars(TVectorD &x_in, TVectorD &y_in, TVectorD &z_in, TVectorD &vars_in) override
Extracts three component vectors from a given aggregated vector.
TQpLinSolverBase * MakeLinSys(const TQpDataBase *data) override
Setup the linear solver.
The Residuals class calculates and stores the quantities that appear on the right-hand side of the li...
Definition TQpResidual.h:62
Class containing the variables for the general QP formulation.
Definition TQpVar.h:60
Int_t GetNrows() const
Definition TVectorT.h:75