CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
MonteCarloEnum_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_MonteCarloEnum_impl
2 #define CASM_MonteCarloEnum_impl
3 
7 #include "casm/clex/PrimClex.hh"
8 
9 namespace CASM {
10 
11  template<typename MonteTypeSettings, typename MonteCarloType>
12  MonteCarloEnum::MonteCarloEnum(PrimClex &primclex, const MonteTypeSettings &set, Log &log, MonteCarloType &mc) :
13  m_primclex(primclex),
14  m_log(log),
15  m_sample_mode(set.enumeration_sample_mode()),
16  m_debug(set.debug()),
17  m_check_args(set.enumeration_check_args()),
18  m_metric_args(set.enumeration_metric_args()),
19  m_check_existence(set.enumeration_check_existence()),
20  m_insert_canonical(set.enumeration_insert_canonical()),
21  m_dict(primclex.settings().query_handler<Configuration>().dict()) {
22 
23  m_dict.insert(
25  "potential_energy",
26  "potential_energy",
27  [&](const Configuration & config) {
28  return mc.potential_energy(config);
29  },
30  [&](const Configuration & config) {
31  return true;
32  }));
33 
34  m_dict.insert(
36  "is_new",
37  "is_new",
38  [&](const Configuration & config) {
39  return m_data[config.name()].first;
40  },
41  [&](const Configuration & config) {
42  return m_data.find(config.name()) != m_data.end();
43  }
44  ));
45 
46  m_dict.insert(
48  "score",
49  "score",
50  [&](const Configuration & config) {
51  return m_data[config.name()].second;
52  },
53  [&](const Configuration & config) {
54  return m_data.find(config.name()) != m_data.end();
55  }
56  ));
57 
58  m_halloffame.unique().reset(
59  new HallOfFameType(
61  std::less<Configuration>(),
62  set.enumeration_N_halloffame(),
63  set.enumeration_tol()));
64 
65  m_enum_check.unique().reset(new MonteCarloEnumCheck(m_dict.parse(set.enumeration_check_args())));
66 
67  reset();
68 
69  _log().custom("Configuration enumeration");
70  _log() << " check: " << check_args() << "\n";
71  _log() << " metric: " << metric_args() << "\n";
72  _log() << " check_existence: " << std::boolalpha << m_check_existence << "\n";
73  _log() << " insert_canonical: " << std::boolalpha << m_insert_canonical << "\n";
74  _log() << " sample_mode: " << m_sample_mode << "\n";
75  _log() << std::endl;
76 
77  }
78 
79 }
80 
81 #endif
82 
MonteCarloEnum(PrimClex &primclex, const MonteTypeSettings &settings, Log &log, MonteCarloType &mc)
HallOfFame< Configuration, MonteCarloEnumMetric > HallOfFameType
Monte::ENUM_SAMPLE_MODE m_sample_mode
when to attempt to insert configurations in the hall of fame
void reset()
Clear hall of fame and reset excluded.
notstd::cloneable_ptr< HallOfFameType > m_halloffame
Use for enumerating configurations via Monte Carlo.
std::string metric_args() const
std::map< std::string, std::pair< bool, double > > m_data
holds 'is_new, score' data
PrimClex * primclex
Definition: settings.cc:101
bool m_check_existence
If true, only keep configurations that are not enumerated already.
Main CASM namespace.
Definition: complete.cpp:8
Log & log
Definition: settings.cc:105
ProjectSettings & set
Definition: settings.cc:103
std::string check_args() const
void custom(const std::string &what)
Definition: Log.hh:96
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
std::string name() const
SCELV_A_B_C_D_E_F/i.
notstd::cloneable_ptr< MonteCarloEnumCheck > m_enum_check
Use for enumerating configurations via Monte Carlo.
DataFormatterDictionary< Configuration > m_dict
Used for various purposes.
Definition: Log.hh:9
bool m_insert_canonical
If true, insert configurations in canonical form.
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
A Configuration represents the values of all degrees of freedom in a Supercell.