Skip to content

Commit

Permalink
Merge pull request #198 from glenco/nt/progress
Browse files Browse the repository at this point in the history
show maxloglike in progress
  • Loading branch information
Nicolas Tessore committed Aug 14, 2015
2 parents e828d25 + ce2a262 commit 18fbc33
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/nested.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <string.h>
#include <float.h>
#include <math.h>
#include <time.h>

#include "opencl.h"
#include "input.h"
Expand Down Expand Up @@ -139,8 +138,6 @@ void dumper(int* nsamples, int* nlive, int* npar, double** physlive,

cl_float* output[4] = {0};

double progress;

// copy parameters to results
for(size_t i = 0; i < lensed->npars; ++i)
lensed->mean[i] = constraints[0][MEAN*lensed->npars+i];
Expand Down Expand Up @@ -233,27 +230,22 @@ void dumper(int* nsamples, int* nlive, int* npar, double** physlive,
free(relerr);
}

// calculate progress
progress = fmax(0, fmin(1, 1.0*nsamples[0]/nlive[0]/(maxloglike[0] - logz[0] - log(lensed->tol))));

// status output
if(LOG_LEVEL <= LOG_INFO)
{
char ts[10];
time_t t = time(NULL);
// calculate progress
double progress = fmax(0, fmin(1, 1.0*nsamples[0]/nlive[0]/(maxloglike[0] - logz[0] - log(lensed->tol))));

int i = 0;
int n = round(20*progress) + 0.5;
int p = round(100*progress) + 0.5;

strftime(ts, 10, "%H:%M:%S", localtime(&t));
int n = floor(20*progress) + 0.5;
int p = fmin(99, floor(100*progress)) + 0.5;

fprintf(stdout, " %s [", ts);
fprintf(stdout, " [");
for(; i < n; ++i)
fputc('#', stdout);
for(; i < 20; ++i)
fputc(' ', stdout);
fprintf(stdout, "] %d%% | S: %d\r", p, nsamples[0]);
fprintf(stdout, "] %2d%% | L: %+10.3e | S: %d\r", p, maxloglike[0], nsamples[0]);
fflush(stdout);
}
}

0 comments on commit 18fbc33

Please sign in to comment.