Changeset bfda648 in tol
- Timestamp:
- Oct 21, 2008, 10:52:40 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- c51d000
- Parents:
- e965532
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/math/stat/models/bayesian/bysMcmc/_build.tol
re965532 rbfda648 89 89 //Ensures path is all right 90 90 Real OSDirMake(GetFilePath(_.path)); 91 91 Real numDec = 1+Ceil(Log(sampleLength)/Log(10)); 92 Text numIterFmt = "% "+IntText(numDec)+".0lf"; 92 93 //Resume or clean old simulations 93 94 Real savedSimulations = If(!resume_, … … 97 98 }, 98 99 { 99 If(!FileExist(_.path),0, 100 Real WriteLn(_MID+"Trying to resume MCMC from "<<_.path); 101 If(!FileExist(_.path), 102 { 103 Real WriteLn(_MID+"Cannot find MCMC at "<<_.path+" to resume","W"); 104 0 105 }, 100 106 { 101 107 Matrix old.mcmc = MatReadFile(_.path); … … 105 111 Not(m), 106 112 { 113 Real WriteLn(_MID+"Empty MCMC at "<<_.path+" to resume","W"); 107 114 Real OSFilRemove(_.path); 108 115 0 … … 110 117 n==_.n, 111 118 { 112 Real WriteLn(_MID+" resuming "<<m+" old simulations");119 Real WriteLn(_MID+"resuming "<<m+" old simulations"); 113 120 Matrix lastRow = Sub(old.mcmc,m,1,1,_.n); 114 //WriteLn("TRACE "+_MID+" lastRow="<<lastRow);121 //WriteLn("TRACE "+_MID+"lastRow="<<lastRow); 115 122 Real _.sampler::setStore(lastRow); 116 123 m … … 118 125 1==1, 119 126 { 120 Real WriteLn(_MID+" Cannot resume due to old MCMC saved on "+127 Real WriteLn(_MID+"Cannot resume due to old MCMC saved on "+ 121 128 _.path+" has "+IntText(n)+" columns instead " 122 129 "of current nummber of parameters "+IntText(_.n)+".\n" … … 136 143 Real numErr0 = Copy(NError); 137 144 Real numSim = savedSimulations+1; 138 //WriteLn("TRACE "+_MID+" savedSimulations="<<savedSimulations);139 //WriteLn("TRACE "+_MID+" numSim="<<numSim);145 //WriteLn("TRACE "+_MID+"savedSimulations="<<savedSimulations); 146 //WriteLn("TRACE "+_MID+"numSim="<<numSim); 140 147 Real okMls = Case(Or(numSim>1, 141 148 config::mls.method==BysMcmc::Options::Mls.Method::None), … … 162 169 While(!end, 163 170 { 164 //WriteLn("TRACE "+_MID+" 2");171 //WriteLn("TRACE "+_MID+"2"); 165 172 Real doCache = Or(cacheLength_==1,numSim%cacheLength_==1); 166 //WriteLn("TRACE "+_MID+" 3");173 //WriteLn("TRACE "+_MID+"3"); 167 174 Real If(doCache, 168 175 { 169 176 If(cacheLength_>1, 170 177 { 171 Write(_MID+"Simulating iterations "+ 172 IntText(numSim)+"-"+IntText(numSim+cacheLength_-1)) 178 Write(" Simulating iterations "+ 179 FormatReal(numSim,numIterFmt)+"-"+ 180 FormatReal(numSim+cacheLength_-1,numIterFmt)) 173 181 }, 174 182 { 175 183 Write(_MID+"Simulating iteration "+ IntText(numSim)) 176 184 }); 177 If(!Rows(cache), WriteLn(" ... "), 178 { 185 If(And(cacheLength_>1,!Rows(cache)), WriteLn(" ... "), 186 { 187 Real donePercent = 100*numSim / sampleLength; 179 188 Real t2 = Copy(Time); 180 189 Real _.time := (t2-t1)/cacheLength_; 181 WriteLn(" [time by simulation:"<<_.time+"]"); 190 Real remain = _.time * (sampleLength-numSim); 191 WriteLn(" [done "+FormatReal(donePercent,"% 6.2lf")+"%]"+ 192 " [time/sim:"+FormatReal(_.time,"% 9.6lf")+" s]"+ 193 " [remaining "+FormatReal(remain,"% 6.0lf")+" s]"); 182 194 Real _.notifier::simulating(numSim-1, _.time); 183 195 Real t1 := t2 … … 185 197 1 186 198 }); 187 //WriteLn("TRACE "+_MID+" 4");199 //WriteLn("TRACE "+_MID+"4"); 188 200 VMatrix draw_ = _.sampler::draw(numSim); 189 //WriteLn("TRACE "+_MID+" 5");201 //WriteLn("TRACE "+_MID+"5"); 190 202 Matrix draw = VMat2Mat(draw_); 191 //WriteLn("TRACE "+_MID+" 6");203 //WriteLn("TRACE "+_MID+"6"); 192 204 Matrix cache := cache << Tra(draw); 193 205 //WriteLn("TRACE "+_MID+"7"); … … 220 232 Real end := True 221 233 }); 222 //WriteLn("TRACE "+_MID+" 8");234 //WriteLn("TRACE "+_MID+"8"); 223 235 Real numSim := numSim+1 224 236 }); 225 237 Matrix Do MatAppendFile(_.path, cache); 226 Real savedSimulations := sampleLength;227 Real _.time := (Time - t0)/ sampleLength;238 Real savedSimulations := numSim; 239 Real _.time := (Time - t0)/numSim; 228 240 WriteLn(" [time by simulation:"<<_.time+"]"); 229 Real _.notifier::simulating( sampleLength, _.time);230 //WriteLn("TRACE "+_MID+" 1");241 Real _.notifier::simulating(numSim, _.time); 242 //WriteLn("TRACE "+_MID+"1"); 231 243 1 232 244 };
Note: See TracChangeset
for help on using the changeset viewer.
