CASM  1.1.0
A Clusters Approach to Statistical Mechanics
MonteCounter.hh
Go to the documentation of this file.
1 #ifndef CASM_MonteCounter_HH
2 #define CASM_MonteCounter_HH
3 
6 
7 namespace CASM {
8 namespace Monte {
9 
10 class EquilibriumMonteSettings;
11 class MonteCarlo;
12 
23 class MonteCounter {
24  public:
25  typedef Index size_type;
26 
28  MonteCounter(const EquilibriumMonteSettings &settings,
29  size_type _steps_per_pass);
30 
32  size_type pass() const;
33 
35  size_type step() const;
36 
38  size_type steps_per_pass() const;
39 
41  size_type samples() const;
42 
45  void increment_samples();
46 
48  void reset();
49 
51  void set(size_type _pass, size_type _step, size_type _samples);
52 
55  bool sample_time() const;
56 
59 
62 
64  bool is_complete() const;
65 
67  bool minimums_met() const;
68 
70  bool maximums_met() const;
71 
72  void debugprint(std::ostream &sout) const;
73 
74  private:
78 
81 
84 
87 
88  // --- If not in 'must converge mode' -----
89 
91  bool m_is_N_step = false;
93 
95  bool m_is_N_pass = false;
97 
99  bool m_is_N_sample = false;
101 
102  // --- Imposed limits ------------
103 
105  bool m_is_max_step = false;
107 
109  bool m_is_min_step = false;
111 
113  bool m_is_max_pass = false;
115 
117  bool m_is_min_pass = false;
119 
121  bool m_is_max_sample = false;
123 
125  bool m_is_min_sample = false;
127 
128  // --- Periods at which certain things should happen --------
129 
132 
136 
140 };
141 
142 } // namespace Monte
143 } // namespace CASM
144 
145 #endif
Track the number of passes, steps and samples taken in a Monte Carlo calculation.
Definition: MonteCounter.hh:23
bool sample_time() const
Returns true if based on period and current number of steps it is time to take a sample.
bool m_is_max_step
Maximum allowed number of steps.
void reset()
Set all counter variables back to 0.
bool maximums_met() const
Check if maximum number of pass, step, and samples has been met.
size_type m_step
Number of steps taken during the current pass.
Definition: MonteCounter.hh:80
bool m_is_N_step
Requested number of steps.
Definition: MonteCounter.hh:91
size_type samples() const
Number of samples taken.
SAMPLE_MODE m_sample_mode
Whether sampling mode is by SAMPLE_MODE::PASS or SAMPLE_MODE::STEP.
bool m_is_min_pass
Minimum allowed number of passes.
MonteCounter & operator++()
Prefix increment step and updates pass.
bool is_complete() const
Check if requested number of pass, step, or samples has been met.
bool m_is_N_pass
Requested number of passes.
Definition: MonteCounter.hh:95
bool minimums_met() const
Check if minimum number of pass, step, and samples has been met.
size_type m_samples
Number of data samples taken.
Definition: MonteCounter.hh:83
bool m_is_max_sample
Maximum allowed number of samples to take.
size_type steps_per_pass() const
Number of steps per pass.
Definition: MonteCounter.cc:98
size_type step() const
Number of steps into the current pass.
Definition: MonteCounter.cc:95
size_type m_since_last_sample
Number of passes or steps since last sample.
Definition: MonteCounter.hh:86
void increment_samples()
Increments the number of samples taken and resets counter until the next sample should be taken.
void debugprint(std::ostream &sout) const
bool m_is_max_pass
Maximum allowed number of passes.
void set(size_type _pass, size_type _step, size_type _samples)
Set all counter variables for performing a restart.
bool m_is_min_step
Minimum allowed number of steps.
MonteCounter(const EquilibriumMonteSettings &settings, size_type _steps_per_pass)
Construct a MonteCounter and initialize to all counts to zero.
Definition: MonteCounter.cc:12
bool m_is_N_sample
Requested number of samples.
Definition: MonteCounter.hh:99
bool m_is_min_sample
Minimum allowed number of samples to take.
size_type pass() const
Number of complete passes performed.
Definition: MonteCounter.cc:93
SAMPLE_MODE
How often to sample runs.
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39