ALPSCore reference
mcbase.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
7 #pragma once
8 
9 #include <boost/function.hpp>
10 
11 #include <alps/accumulators.hpp>
12 #include <alps/params.hpp>
13 #include "random01.hpp"
14 
15 #include <vector>
16 #include <string>
17 
18 // move to alps::mcbase root scope
19 namespace alps {
20 
21  class mcbase {
22 
23  protected:
24 
26 
27  public:
28 
30  typedef std::vector<std::string> result_names_type;
31 
33 
34  mcbase(parameters_type const & parms, std::size_t seed_offset = 0);
35 
36  static parameters_type& define_parameters(parameters_type & parameters);
37 
38  virtual void update() = 0;
39  virtual void measure() = 0;
40  virtual double fraction_completed() const = 0;
41  bool run(boost::function<bool ()> const & stop_callback);
42 
43  result_names_type result_names() const;
44  result_names_type unsaved_result_names() const;
45  results_type collect_results() const;
46  results_type collect_results(result_names_type const & names) const;
47 
48  void save(std::string const & filename) const;
49  void load(std::string const & filename);
50  virtual void save(alps::hdf5::archive & ar) const;
51  virtual void load(alps::hdf5::archive & ar);
52 
53  protected:
54 
55  parameters_type parameters;
56  // parameters_type & params; // TODO: deprecated, remove!
58  observable_collection_type measurements;
59  };
60 
61 
62 }
63 
virtual void measure()=0
observable_collection_type measurements
Definition: mcbase.hpp:58
Parse sectioned INI file or HDF5 or command line, provide the results as dictionary.
Definition: params.hpp:84
bool run(boost::function< bool()> const &stop_callback)
Definition: mcbase.cpp:33
void save(std::string const &filename) const
Definition: mcbase.cpp:23
result_names_type unsaved_result_names() const
Definition: mcbase.cpp:50
std::vector< std::string > result_names_type
Definition: mcbase.hpp:30
alps::random01 random
Definition: mcbase.hpp:57
virtual double fraction_completed() const =0
alps::accumulators::accumulator_set observable_collection_type
Definition: mcbase.hpp:25
void load(std::string const &filename)
Definition: mcbase.cpp:28
results_type collect_results() const
Definition: mcbase.cpp:54
static parameters_type & define_parameters(parameters_type &parameters)
Definition: mcbase.cpp:19
result_names_type result_names() const
Definition: mcbase.cpp:43
mcbase(parameters_type const &parms, std::size_t seed_offset=0)
Definition: mcbase.cpp:12
alps::accumulators::result_set results_type
Definition: mcbase.hpp:32
virtual void update()=0
Functor-predicate: is it time to stop?
alps::params parameters_type
Definition: mcbase.hpp:29
parameters_type parameters
Definition: mcbase.hpp:55