Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TQpDataBase.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 "TQpDataBase.h"
44
45////////////////////////////////////////////////////////////////////////////////
46///
47/// \class TQpDataBase
48///
49/// Data for the general QP formulation
50///
51/// The Data class stores the data defining the problem and provides
52/// methods for performing the operations with this data required by
53/// the interior-point algorithms. These operations include assembling
54/// the linear systems (5) or (7), performing matrix-vector operations
55/// with the data, calculating norms of the data, reading input into the
56/// data structure from various sources, generating random problem
57/// instances, and printing the data.
58///
59////////////////////////////////////////////////////////////////////////////////
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Default constructor
64
66{
67 fNx = 0;
68 fMy = 0;
69 fMz = 0;
70}
71
72
73////////////////////////////////////////////////////////////////////////////////
74/// Constructor
75
96
97
98////////////////////////////////////////////////////////////////////////////////
99/// Copy constructor
100
105
106
107////////////////////////////////////////////////////////////////////////////////
108/// Randomly choose x and its boundaries
109
114{
115 const Int_t n = x.GetNrows();
116
117 // Initialize the upper and lower bounds on x
118
119 Int_t i;
120 for (i = 0; i < n; i++) {
121 const Double_t r = Drand(ix);
122
123 if (r < percentLowerOnly) {
124 ixlow[i] = 1.0;
125 xlow [i] = (Drand(ix)-0.5)*3.0;
126 ixupp[i] = 0.0;
127 xupp [i] = 0.0;
128 }
130 ixlow[i] = 0.0;
131 xlow [i] = 0.0;
132 ixupp[i] = 1.0;
133 xupp [i] = (Drand(ix)-0.5)*3.0;
134 }
136 ixlow[i] = 1.0;
137 xlow [i] = (Drand(ix)-0.5)*3.0;
138 ixupp[i] = 1.0;
139 xupp [i] = xlow[i]+Drand(ix)*10.0;
140 }
141 else {
142 // it is free
143 ixlow[i] = 0.0;
144 xlow [i] = 0.0;
145 ixupp[i] = 0.0;
146 xupp [i] = 0.0;
147 }
148 }
149
150 for (i = 0; i < n; i++) {
151 if (ixlow[i] == 0.0 && ixupp[i] == 0.0 ) {
152 // x[i] not bounded
153 x [i] = 20.0*Drand(ix)-10.0;
154 dualx[i] = 0.0;
155 }
156 else if (ixlow[i] != 0.0 && ixupp[i] != 0.0) {
157 // x[i] is bounded above and below
158 const Double_t r = Drand(ix);
159 if (r < 0.33 ) {
160 // x[i] is on its lower bound
161 x [i] = xlow[i];
162 dualx[i] = 10.0*Drand(ix);
163 }
164 else if ( r > .66 ) {
165 // x[i] is on its upper bound
166 x [i] = xupp[i];
167 dualx[i] = -10.0*Drand(ix);
168 }
169 else {
170 // x[i] is somewhere in between
171 const Double_t theta = .99*Drand(ix)+.005;
172 x [i] = (1-theta)*xlow[i]+theta*xupp[i];
173 dualx[i] = 0.0;
174 }
175 }
176 else if (ixlow[i] != 0.0) {
177 // x[i] is only bounded below
178 if (Drand(ix) < .33 ) {
179 // x[i] is on its lower bound
180 x [i] = xlow[i];
181 dualx[i] = 10.0*Drand(ix);
182 }
183 else {
184 // x[i] is somewhere above its lower bound
185 x [i] = xlow[i]+0.005+10.0*Drand(ix);
186 dualx[i] = 0.0;
187 }
188 } // x[i] only has an upper bound
189 else {
190 if (Drand(ix) > .66 ) {
191 // x[i] is on its upper bound
192 x [i] = xupp[i];
193 dualx[i] = -10.0*Drand(ix);
194 }
195 else {
196 // x[i] is somewhere below its upper bound
197 x [i] = xupp[i]-0.005-10.0*Drand(ix);
198 dualx[i] = 0.0;
199 }
200 }
201 }
202}
203
204
205////////////////////////////////////////////////////////////////////////////////
206/// Assignment operator
207
209{
210 if (this != &source) {
212 fNx = source.fNx;
213 fMy = source.fMy;
214 fMz = source.fMz;
215
216 fG .ResizeTo(source.fG) ; fG = source.fG ;
217 fBa .ResizeTo(source.fBa) ; fBa = source.fBa ;
218 fXupBound.ResizeTo(source.fXupBound); fXupBound = source.fXupBound;
219 fXupIndex.ResizeTo(source.fXupIndex); fXupIndex = source.fXupIndex;
220 fXloBound.ResizeTo(source.fXloBound); fXloBound = source.fXloBound;
221 fXloIndex.ResizeTo(source.fXloIndex); fXloIndex = source.fXloIndex;
222 fCupBound.ResizeTo(source.fCupBound); fCupBound = source.fCupBound;
223 fCupIndex.ResizeTo(source.fCupIndex); fCupIndex = source.fCupIndex;
224 fCloBound.ResizeTo(source.fCloBound); fCloBound = source.fCloBound;
225 fCloIndex.ResizeTo(source.fCloIndex); fCloIndex = source.fCloIndex;
226 }
227 return *this;
228}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Double_t Drand(Double_t &ix)
Random number generator [0....1] with seed ix.
Mother of all ROOT objects.
Definition TObject.h:41
TObject & operator=(const TObject &rhs) noexcept
TObject assignment operator.
Definition TObject.h:299
Data for the general QP formulation.
Definition TQpDataBase.h:61
TQpDataBase & operator=(const TQpDataBase &source)
Assignment operator.
TVectorD fXupIndex
Definition TQpDataBase.h:80
TVectorD fXloBound
Definition TQpDataBase.h:81
TVectorD fCloIndex
Definition TQpDataBase.h:86
TVectorD fCupIndex
Definition TQpDataBase.h:84
TVectorD fG
Definition TQpDataBase.h:77
TVectorD fXupBound
Definition TQpDataBase.h:79
TQpDataBase()
Default constructor.
TVectorD fXloIndex
Definition TQpDataBase.h:82
TVectorD fCupBound
Definition TQpDataBase.h:83
TVectorD fCloBound
Definition TQpDataBase.h:85
TVectorD fBa
Definition TQpDataBase.h:78
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)
Randomly choose x and its boundaries.
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
Definition TVectorT.cxx:293
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16