CASM  1.1.0
A Clusters Approach to Statistical Mechanics
MonteCarloEnum_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_MonteCarloEnum_impl
2 #define CASM_MonteCarloEnum_impl
3 
6 #include "casm/clex/ConfigIO.hh"
7 #include "casm/clex/PrimClex.hh"
9 
10 namespace CASM {
11 namespace Monte {
12 
13 template <typename MonteTypeSettings, typename MonteCarloType>
15  const MonteTypeSettings &set, Log &log,
16  MonteCarloType &mc)
17  : m_primclex(primclex),
18  m_log(log),
19  m_sample_mode(set.enumeration_sample_mode()),
20  m_debug(set.debug()),
21  m_check_args(set.enumeration_check_args()),
22  m_metric_args(set.enumeration_metric_args()),
23  m_check_existence(set.enumeration_check_existence()),
24  m_insert_canonical(set.enumeration_insert_canonical()),
25  m_dict(primclex.settings().query_handler<Configuration>().dict()) {
27  "potential_energy", "potential_energy",
28  [&](const Configuration &config) { return mc.potential_energy(config); },
29  [&](const Configuration &config) { return true; }));
30 
32  "is_new", "is_new",
33  [&](const Configuration &config) { return m_data[config.name()].first; },
34  [&](const Configuration &config) {
35  return m_data.find(config.name()) != m_data.end();
36  }));
37 
39  "score", "score",
40  [&](const Configuration &config) { return m_data[config.name()].second; },
41  [&](const Configuration &config) {
42  return m_data.find(config.name()) != m_data.end();
43  }));
44 
45  m_halloffame.unique().reset(new HallOfFameType(
47  std::less<Configuration>(), set.enumeration_N_halloffame(),
48  set.enumeration_tol()));
49 
50  m_enum_check.unique().reset(
51  new MonteCarloEnumCheck(m_dict.parse(set.enumeration_check_args())));
52 
53  reset();
54 
55  _log().custom("Configuration enumeration");
56  _log() << " check: " << check_args() << "\n";
57  _log() << " metric: " << metric_args() << "\n";
58  _log() << " check_existence: " << std::boolalpha << m_check_existence
59  << "\n";
60  _log() << " insert_canonical: " << std::boolalpha << m_insert_canonical
61  << "\n";
62  _log() << " sample_mode: " << m_sample_mode << "\n";
63  _log() << std::endl;
64 }
65 
66 } // namespace Monte
67 } // namespace CASM
68 
69 #endif
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
Definition: Log.hh:48
void custom(const std::string &what)
Definition: Log.hh:139
std::map< std::string, std::pair< bool, double > > m_data
holds 'is_new, score' data
bool m_check_existence
If true, only keep configurations that are not enumerated already.
MonteCarloEnum(const PrimClex &primclex, const MonteTypeSettings &settings, Log &log, MonteCarloType &mc)
ENUM_SAMPLE_MODE m_sample_mode
when to attempt to insert configurations in the hall of fame
std::string metric_args() const
notstd::cloneable_ptr< HallOfFameType > m_halloffame
Use for enumerating configurations via Monte Carlo.
notstd::cloneable_ptr< MonteCarloEnumCheck > m_enum_check
Use for enumerating configurations via Monte Carlo.
void reset()
Clear hall of fame and reset excluded.
HallOfFame< Configuration, MonteCarloEnumMetric > HallOfFameType
DataFormatterDictionary< Configuration > m_dict
Used for various purposes.
std::string check_args() const
bool m_insert_canonical
If true, insert configurations in canonical form.
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
Main CASM namespace.
Definition: APICommand.hh:8
Log & log()
Definition: Log.hh:424
PrimClex * primclex
Definition: settings.cc:135
ProjectSettings & set
Definition: settings.cc:137