mc.h 1.17 KB
Newer Older
1
2
#pragma once

3
#include "evalable.h"
4
5
#include "measurements.h"
#include "parser.h"
6
7
8
9
#include "random.h"
#include <memory>
#include <string>
#include <vector>
Lukas Weber's avatar
Lukas Weber committed
10

11
12
13
namespace loadl {

class mc {
14
private:
15
	void random_init();
16

17
18
	int sweep_ = 0;
	int therm_ = 0;
19

20
21
protected:
	parser param;
22
23
	std::unique_ptr<randomnumbergenerator> rng;

24
	virtual void init() = 0;
25
26
	virtual void checkpoint_write(const iodump::group &out) = 0;
	virtual void checkpoint_read(const iodump::group &in) = 0;
27
	virtual void write_output(const std::string &filename);
28
	virtual void do_update() = 0;
29
	virtual void do_measurement() = 0;
30
31
32

public:
	double random01();
33
	int sweep() const;
34

35
	virtual void register_evalables(std::vector<evalable> &evalables) = 0;
36

37
38
39
	// these functions do a little more, like taking care of the
	// random number generator state, then call the child class versions.
	void _init();
40
41
	void _write(const std::string &dir);
	bool _read(const std::string &dir);
42

43
	void _write_output(const std::string &filename);
44

45
	void _do_update();
46
	void _do_measurement();
47

48
	bool is_thermalized();
49
50
	measurements measure;

Lukas Weber's avatar
wrong &    
Lukas Weber committed
51
	mc(const parser &p);
52
	virtual ~mc() = default;
53
};
Lukas Weber's avatar
Lukas Weber committed
54

Lukas Weber's avatar
wrong &    
Lukas Weber committed
55
typedef std::function<mc *(const parser &)> mc_factory;
56
}