Changeset - 5617f4d9a868
[Not reviewed]
0 1 0
Tom Bannink - 8 years ago 2017-09-17 12:01:40
tom.bannink@cwi.nl
Update resampler output format
1 file changed with 19 insertions and 12 deletions:
0 comments (0 inline, 0 general)
montecarlo/resampler_segment.cpp
Show inline comments
 
@@ -24,13 +24,13 @@ class SegmentResampler : public ResamplerBase<SegmentResampler, std::mt19937> {
 
void doRun(float p, size_t n) {
 
    std::cerr << "Running p = " << p << " and n = " << n << std::endl;
 

	
 
    constexpr int samples = 500;
 
    constexpr int samples = 1000;
 

	
 
    int terminateCount = 0;
 
    int hitnCount = 0;
 
    for (int j = 0; j < samples; ++j) {
 
        SegmentResampler sampler(p, n);
 
        for (int t = 0; t != 500000; t++) {
 
        for (auto t = 0u; t != 1000 * n; t++) {
 
            sampler.doMove();
 
            if (sampler.numBads() == 0) {
 
                terminateCount++;
 
@@ -47,8 +47,11 @@ void doRun(float p, size_t n) {
 
                  << " runs with timelimit!\n";
 
    }
 

	
 
    std::cout << '{' << p << ',' << n << ',';
 
    std::cout << hitnCount << '/' << hitnCount + terminateCount << '}';
 
    std::cout << '{' << p << ',' << n;
 
    std::cout << ',' << hitnCount << '/' << hitnCount + terminateCount;
 
    std::cout << ',' << hitnCount + terminateCount;
 
    std::cout << ',' << samples;
 
    std::cout << '}';
 
    std::cout << std::flush;
 
}
 

	
 
@@ -57,29 +60,33 @@ int main() {
 
    // Interesting range is p in [0.60,0.75]
 
    std::cout << "(* Probability of hitting site n when starting from single "
 
                 "BAD at 0 on segment [0,n].\n";
 
    std::cout << "Data-format: {p, n, probability} *)\n";
 
    std::cout << "Data-format: {p, n, probability, runs within timelimit, "
 
                 "total run attempts} *)\n";
 
    std::cout << "{\n";
 
    for (size_t n = 600; ; n += 200) {
 
    for (size_t n = 600;; n += 200) {
 
        doRun(0.10f, n);
 
        std::cout << ',';
 
        std::cout << ',' << std::endl;
 

	
 
        for (int i = 0; i <= 100; ++i) {
 
            float p = 0.60f + 0.001f * i;
 
            doRun(p, n);
 
            std::cout << ',';
 
            std::cout << ',' << std::endl;
 
        }
 
        doRun(0.75f, n);
 
        std::cout << ',';
 
        std::cout << ',' << std::endl;
 
        ;
 
        doRun(0.80f, n);
 
        std::cout << ',';
 
        std::cout << ',' << std::endl;
 
        ;
 
        doRun(0.90f, n);
 

	
 
        if (n == 1000)
 
            break;
 
        else
 
            std::cout << ',';
 
            std::cout << ',' << std::endl;
 
        ;
 
    }
 
    std::cout << '}' << std::endl;
 
    std::cout << '\n' << '}' << std::endl;
 

	
 
    return 0;
 
}
0 comments (0 inline, 0 general)