00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "TQpDataBase.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 ClassImp(TQpDataBase)
00062
00063
00064 TQpDataBase::TQpDataBase()
00065 {
00066
00067
00068 fNx = 0;
00069 fMy = 0;
00070 fMz = 0;
00071 }
00072
00073
00074
00075 TQpDataBase::TQpDataBase(Int_t nx,Int_t my,Int_t mz)
00076 {
00077
00078
00079 fNx = nx;
00080 fMy = my;
00081 fMz = mz;
00082
00083 fG .ResizeTo(fNx);
00084
00085 fBa .ResizeTo(fMy);
00086
00087 fXupBound.ResizeTo(fNx);
00088 fXupIndex.ResizeTo(fNx);
00089 fXloBound.ResizeTo(fNx);
00090 fXloIndex.ResizeTo(fNx);
00091
00092 fCupBound.ResizeTo(fMz);
00093 fCupIndex.ResizeTo(fMz);
00094 fCloBound.ResizeTo(fMz);
00095 fCloIndex.ResizeTo(fMz);
00096 }
00097
00098
00099
00100 TQpDataBase::TQpDataBase(const TQpDataBase &another) : TObject(another)
00101 {
00102
00103
00104 *this = another;
00105 }
00106
00107
00108
00109 void TQpDataBase::RandomlyChooseBoundedVariables(
00110 TVectorD &x,TVectorD &dualx,TVectorD &xlow,TVectorD &ixlow,
00111 TVectorD &xupp,TVectorD &ixupp,Double_t &ix,Double_t percentLowerOnly,
00112 Double_t percentUpperOnly,Double_t percentBound)
00113 {
00114
00115
00116 const Int_t n = x.GetNrows();
00117
00118
00119
00120 Int_t i;
00121 for (i = 0; i < n; i++) {
00122 const Double_t r = Drand(ix);
00123
00124 if (r < percentLowerOnly) {
00125 ixlow[i] = 1.0;
00126 xlow [i] = (Drand(ix)-0.5)*3.0;
00127 ixupp[i] = 0.0;
00128 xupp [i] = 0.0;
00129 }
00130 else if (r < percentLowerOnly+percentUpperOnly) {
00131 ixlow[i] = 0.0;
00132 xlow [i] = 0.0;
00133 ixupp[i] = 1.0;
00134 xupp [i] = (Drand(ix)-0.5)*3.0;
00135 }
00136 else if (r < percentLowerOnly+percentUpperOnly+percentBound) {
00137 ixlow[i] = 1.0;
00138 xlow [i] = (Drand(ix)-0.5)*3.0;
00139 ixupp[i] = 1.0;
00140 xupp [i] = xlow[i]+Drand(ix)*10.0;
00141 }
00142 else {
00143
00144 ixlow[i] = 0.0;
00145 xlow [i] = 0.0;
00146 ixupp[i] = 0.0;
00147 xupp [i] = 0.0;
00148 }
00149 }
00150
00151 for (i = 0; i < n; i++) {
00152 if (ixlow[i] == 0.0 && ixupp[i] == 0.0 ) {
00153
00154 x [i] = 20.0*Drand(ix)-10.0;
00155 dualx[i] = 0.0;
00156 }
00157 else if (ixlow[i] != 0.0 && ixupp[i] != 0.0) {
00158
00159 const Double_t r = Drand(ix);
00160 if (r < 0.33 ) {
00161
00162 x [i] = xlow[i];
00163 dualx[i] = 10.0*Drand(ix);
00164 }
00165 else if ( r > .66 ) {
00166
00167 x [i] = xupp[i];
00168 dualx[i] = -10.0*Drand(ix);
00169 }
00170 else {
00171
00172 const Double_t theta = .99*Drand(ix)+.005;
00173 x [i] = (1-theta)*xlow[i]+theta*xupp[i];
00174 dualx[i] = 0.0;
00175 }
00176 }
00177 else if (ixlow[i] != 0.0) {
00178
00179 if (Drand(ix) < .33 ) {
00180
00181 x [i] = xlow[i];
00182 dualx[i] = 10.0*Drand(ix);
00183 }
00184 else {
00185
00186 x [i] = xlow[i]+0.005+10.0*Drand(ix);
00187 dualx[i] = 0.0;
00188 }
00189 }
00190 else {
00191 if (Drand(ix) > .66 ) {
00192
00193 x [i] = xupp[i];
00194 dualx[i] = -10.0*Drand(ix);
00195 }
00196 else {
00197
00198 x [i] = xupp[i]-0.005-10.0*Drand(ix);
00199 dualx[i] = 0.0;
00200 }
00201 }
00202 }
00203 }
00204
00205
00206
00207 TQpDataBase &TQpDataBase::operator=(const TQpDataBase &source)
00208 {
00209
00210
00211 if (this != &source) {
00212 TObject::operator=(source);
00213 fNx = source.fNx;
00214 fMy = source.fMy;
00215 fMz = source.fMz;
00216
00217 fG .ResizeTo(source.fG) ; fG = source.fG ;
00218 fBa .ResizeTo(source.fBa) ; fBa = source.fBa ;
00219 fXupBound.ResizeTo(source.fXupBound); fXupBound = source.fXupBound;
00220 fXupIndex.ResizeTo(source.fXupIndex); fXupIndex = source.fXupIndex;
00221 fXloBound.ResizeTo(source.fXloBound); fXloBound = source.fXloBound;
00222 fXloIndex.ResizeTo(source.fXloIndex); fXloIndex = source.fXloIndex;
00223 fCupBound.ResizeTo(source.fCupBound); fCupBound = source.fCupBound;
00224 fCupIndex.ResizeTo(source.fCupIndex); fCupIndex = source.fCupIndex;
00225 fCloBound.ResizeTo(source.fCloBound); fCloBound = source.fCloBound;
00226 fCloIndex.ResizeTo(source.fCloIndex); fCloIndex = source.fCloIndex;
00227 }
00228 return *this;
00229 }