LCOV - code coverage report
Current view: top level - bnmin1/src - mcmonitor.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 4 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /**
       2             :    Bojan Nikolic <bojan@bnikolic.co.uk> 
       3             :    Initial version 2009
       4             : 
       5             :    This file is part of BNMin1 and is licensed under GNU General
       6             :    Public License version 2
       7             : 
       8             :    \file mcmonitor.hxx
       9             :    Renamed to mcmonitor.h 2023
      10             : 
      11             :    Interface for monitoring Markov Chain type sampling
      12             : */
      13             : 
      14             : #ifndef _BNMIN1_MCMONITOR_HXX__
      15             : #define _BNMIN1_MCMONITOR_HXX__
      16             : 
      17             : #include <cstddef>
      18             : #include <iosfwd>
      19             : 
      20             : namespace Minim 
      21             : {
      22             :   // Forward declarations
      23             :   struct MCPoint;
      24             : 
      25             :   /** \brief Base class defining the interface for monitoring
      26             :       
      27             :    */
      28             :   class MCMonitorBase
      29             :   {
      30             : 
      31             :   public:
      32             :     // -------------- Construction/Destruction ---------------------
      33             :     
      34             :     virtual ~MCMonitorBase();
      35             :     
      36             :     // -------------- Public Interface ----------------------
      37             : 
      38             :     /** Called when point p has been accepted into the chain
      39             :      */
      40           0 :     virtual void accept(const MCPoint& /*p*/)
      41           0 :     {};
      42             :     
      43             :     /** Called when point p has been proposed for the chain
      44             :      */
      45           0 :     virtual void propose(const MCPoint& /*p*/)
      46           0 :     {};
      47             : 
      48             :   };
      49             : 
      50             :   /** Simple monitoring by printing every na-th accepted and np-th
      51             :       propsed point
      52             :    */
      53             :   class SOutMCMon :
      54             :     public MCMonitorBase
      55             :   {
      56             :     
      57             :     /// Counter for the accepted points
      58             :     size_t ia;
      59             :     
      60             :     /// Counter for the proposed points
      61             :     size_t ip;
      62             : 
      63             :   public:
      64             : 
      65             :     // -------------- Public Data -----------------------------
      66             :     
      67             :     /** Every na-th accepted point will be shown
      68             :      */
      69             :     size_t na;
      70             : 
      71             :     /** Every np-th propsed point will be shown
      72             :      */
      73             :     size_t np;
      74             : 
      75             :     /** Stream to output to 
      76             :      */
      77             :     std::ostream &os;
      78             : 
      79             :     // -------------- Construction/Destruction ---------------------
      80             :     
      81             :     SOutMCMon(void);
      82             : 
      83             :     // -------------- Public Interface -----------------------------
      84             : 
      85             :     // --------- Inherited from MCMonitorBase --------------
      86             :     virtual void accept(const MCPoint& p);
      87             :     virtual void propose(const MCPoint& p);
      88             :     
      89             :     
      90             : 
      91             :   };
      92             : 
      93             : }
      94             : 
      95             : #endif

Generated by: LCOV version 1.16