Changeset bfda648 in tol


Ignore:
Timestamp:
Oct 21, 2008, 10:52:40 AM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c51d000
Parents:
e965532
Message:

Just traces

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@33 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/_build.tol

    re965532 rbfda648  
    8989  //Ensures path is all right
    9090    Real OSDirMake(GetFilePath(_.path));
    91 
     91    Real numDec = 1+Ceil(Log(sampleLength)/Log(10));
     92    Text numIterFmt = "% "+IntText(numDec)+".0lf";
    9293  //Resume or clean old simulations
    9394    Real savedSimulations = If(!resume_,
    … …  
    9798    },
    9899    {
    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      },
    100106      {
    101107        Matrix old.mcmc = MatReadFile(_.path);
    … …  
    105111        Not(m),
    106112        {
     113          Real WriteLn(_MID+"Empty MCMC at "<<_.path+" to resume","W");
    107114          Real OSFilRemove(_.path);
    108115          0
    … …  
    110117        n==_.n,
    111118        {
    112           Real WriteLn(_MID+" resuming "<<m+" old simulations");
     119          Real WriteLn(_MID+"resuming "<<m+" old simulations");
    113120          Matrix lastRow = Sub(old.mcmc,m,1,1,_.n);
    114         //WriteLn("TRACE "+_MID+" lastRow="<<lastRow);
     121        //WriteLn("TRACE "+_MID+"lastRow="<<lastRow);
    115122          Real _.sampler::setStore(lastRow);
    116123          m
    … …  
    118125        1==1,
    119126        {
    120           Real WriteLn(_MID+" Cannot resume due to old MCMC saved on "+
     127          Real WriteLn(_MID+"Cannot resume due to old MCMC saved on "+
    121128            _.path+" has "+IntText(n)+" columns instead "
    122129            "of current nummber of parameters "+IntText(_.n)+".\n"
    … …  
    136143    Real numErr0 = Copy(NError);
    137144    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);
    140147    Real okMls = Case(Or(numSim>1,
    141148       config::mls.method==BysMcmc::Options::Mls.Method::None),
    … …  
    162169    While(!end,
    163170    {
    164     //WriteLn("TRACE "+_MID+" 2");
     171    //WriteLn("TRACE "+_MID+"2");
    165172      Real doCache = Or(cacheLength_==1,numSim%cacheLength_==1);
    166     //WriteLn("TRACE "+_MID+" 3");
     173    //WriteLn("TRACE "+_MID+"3");
    167174      Real If(doCache,
    168175      {
    169176        If(cacheLength_>1,
    170177        {
    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))
    173181        },
    174182        {
    175183          Write(_MID+"Simulating iteration "+ IntText(numSim))
    176184        });
    177         If(!Rows(cache), WriteLn(" ... "),
    178         {
     185        If(And(cacheLength_>1,!Rows(cache)), WriteLn(" ... "),
     186        {
     187          Real donePercent = 100*numSim / sampleLength;
    179188          Real t2 = Copy(Time);
    180189          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]");
    182194          Real _.notifier::simulating(numSim-1, _.time);
    183195          Real t1 := t2
    … …  
    185197        1
    186198      });
    187     //WriteLn("TRACE "+_MID+" 4");
     199    //WriteLn("TRACE "+_MID+"4");
    188200      VMatrix draw_ = _.sampler::draw(numSim);
    189     //WriteLn("TRACE "+_MID+" 5");
     201    //WriteLn("TRACE "+_MID+"5");
    190202      Matrix  draw  = VMat2Mat(draw_);
    191     //WriteLn("TRACE "+_MID+" 6");
     203    //WriteLn("TRACE "+_MID+"6");
    192204      Matrix cache := cache << Tra(draw);
    193205    //WriteLn("TRACE "+_MID+"7");
    … …  
    220232        Real end := True
    221233      });
    222     //WriteLn("TRACE "+_MID+" 8");
     234    //WriteLn("TRACE "+_MID+"8");
    223235      Real numSim := numSim+1
    224236    });
    225237    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;
    228240    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");
    231243    1
    232244  };
Note: See TracChangeset for help on using the changeset viewer.