3 #include <boost/filesystem.hpp>
24 fs::path _calc_properties_path(
const Configuration &
config) {
36 "Evaluates the mapping of a configuration onto an arbitrary "
37 "primitive structure, specified by its path. Allowed options are [ "
38 "'basis_score' (mean-square site displacement) | 'lattice_score' "
39 "(lattice deformation metric having units Angstr.^2) | 'total_score' "
40 "(w*lattice_score+(1.0-w)*basis_score) ]. The struc_score weighting "
41 "parameter 'w' can be provided as an optional decimal parameter from "
42 "0.0 to 1.0 (default 0.5). Ex: struc_score(path/to/PRIM, "
50 m_altprim((RHS.m_altprim == nullptr)
53 m_strain_weight(RHS.m_strain_weight),
54 m_prim_path(RHS.m_prim_path),
55 m_prop_names(RHS.m_prop_names) {
61 std::vector<std::string> splt_vec;
62 double _strain_weight = 0.5;
65 boost::split(splt_vec, args, boost::is_any_of(
", "),
66 boost::token_compress_on);
67 if (splt_vec.size() < 2 || splt_vec.size() > 4) {
68 throw std::runtime_error(
69 "Attempted to initialize format tag " +
name() +
" with " +
71 "). You must provide at least 2 arguments, but no more than 4.\n");
79 throw std::runtime_error(
"Attempted to initialize format tag " +
name() +
80 " invalid file path '" +
82 "'. File does not exist.\n");
85 for (
Index i = 1; i < splt_vec.size(); ++i) {
86 if (splt_vec[i] !=
"basis_score" && splt_vec[i] !=
"lattice_score" &&
87 splt_vec[i] !=
"total_score") {
89 _strain_weight = std::stod(splt_vec[i]);
91 throw std::runtime_error(
"Attempted to initialize format tag " +
92 name() +
" with invalid argument '" +
94 "'. Valid arguments are [ basis_score | "
95 "lattice_score | total_score ]\n");
97 if (already_initialized &&
99 for (; pushed_args > 0; pushed_args--)
m_prop_names.pop_back();
114 PrimClex const &pclex(_tmplt.primclex());
126 return fs::exists(_calc_properties_path(_config));
133 std::vector<std::string> col;
135 std::stringstream t_ss;
138 col.push_back(t_ss.str());
146 std::stringstream t_ss;
160 auto result =
m_strucmapper->map_deformed_struc(relaxed_struc);
162 if (result.empty()) {
163 result_vec.setConstant(1e9);
175 result_vec[i] = mapping.
cost;
Evaluates the mapping of a configuration onto an arbitrary primitive structure.
Eigen::VectorXd evaluate(Configuration const &_config) const override
bool validate(Configuration const &_config) const override
std::unique_ptr< StrucMapper > m_strucmapper
std::string short_header(Configuration const &_config) const override
bool init(Configuration const &tmplt) const override
If not yet initialized, use the default clexulator from the PrimClex.
std::vector< std::string > m_prop_names
std::vector< std::string > col_header(Configuration const &_config) const override
bool parse_args(std::string const &args) override
Default implementation calls _parse_index_expression.
std::unique_ptr< BasicStructure > m_altprim
fs::path calculated_properties(std::string configname, std::string calctype) const
Return properties.calc.json file path.
PrimClex is the top-level data structure for a CASM project.
ClexDescription const & default_clex() const
Get default ClexDescription.
BasicStructure specifies the lattice and atomic basis of a crystal.
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
std::string to_string(ENUM val)
Return string representation of enum class.
ProjectSettings & settings()
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
ConfigIO::GenericConfigFormatter< jsonParser > config()
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
xtal::BasicStructure read_prim(fs::path filename, double xtal_tol, ParsingDictionary< AnisoValTraits > const *_aniso_val_dict=nullptr)
void from_json(ClexDescription &desc, const jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
double cost
Total cost of best solution to the constrained assignment problem having some forced_on assignments.
double cost
strain_cost of the LatticeNode
AssignmentNode atomic_node
double cost
total, finalized cost, populated by a StrucMapCalculator. Not guaranteed to be a linear function of l...