26 auto it =
global.find(_name);
28 return it !=
global.end() &&
29 ((it->second).rows() == 1 && (it->second).cols() == 1);
33 auto it =
global.find(_name);
35 throw std::invalid_argument(
"Invalid scalar property '" + _name +
"'");
37 assert((it->second).rows() == 1 && (it->second).cols() == 1);
38 return (it->second)(0, 0);
42 auto it =
global.find(_name);
45 .emplace(std::make_pair(_name, Eigen::MatrixXd::Zero(1, 1).eval()))
48 assert((it->second).rows() == 1 && (it->second).cols() == 1);
49 return (it->second)(0, 0);
53 json[
"origin"] = obj.
origin;
60 json[
"global"] = obj.
global;
61 json[
"site"] = obj.
site;
74 json[
"timestamp"].get<std::time_t>());
79 double _lattice_weight)
80 : method(_m),
name(
std::move(_name)), lattice_weight(_lattice_weight) {
83 throw std::invalid_argument(
85 "' requires additional string field \"property\".");
88 throw std::invalid_argument(
90 "' requires additional string field \"name\".");
92 if (lattice_weight < 0. || lattice_weight > 1.)
93 throw std::invalid_argument(
"Scoring method '" +
method_name(_m) +
94 "' requires numerical parameter "
95 "\"lattice_weight\" between 0.0 and 1.0.");
114 obj.
scalar(
"atomic_deformation_cost") *
136 return obj.
has_scalar(
"lattice_deformation_cost") &&
150 return !(*
this == B);
154 switch (
score.option().method) {
156 json[
"method"] =
"minimum";
157 json[
"property"] =
score.option().name;
160 json[
"method"] =
"maximum";
161 json[
"property"] =
score.option().name;
164 json[
"method"] =
"deformation_cost";
167 json[
"method"] =
"direct_selection";
168 json[
"name"] =
score.option().name;
179 std::string method = json[
"method"].
get<std::string>();
180 if (method ==
"minimum") {
182 opt.
name = json[
"property"].
get<std::string>();
183 }
else if (method ==
"maximum") {
185 opt.
name = json[
"property"].
get<std::string>();
186 }
else if (method ==
"deformation_cost") {
189 }
else if (method ==
"direct_selection") {
191 opt.
name = json[
"name"].
get<std::string>();
Interface class to check and/or store path and last_write_time of file on disk. Used to determine if ...
std::time_t timestamp() const
return stored timestamp. Timestamp corresponds to last_write_time of file timestamp defaults to 0 if ...
bool empty() const
Returns true if path is empty.
std::string const & path() const
return stored path
bool operator==(const ScoreMappedProperties &B) const
bool operator!=(const ScoreMappedProperties &B) const
bool validate(const MappedProperties &obj) const
ScoreMappedProperties(Option _opt=Option(Method::minimum, "energy"))
Default uses minimum energy.
static std::string method_name(Method m)
double operator()(const MappedProperties &obj) const
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
jsonParser & put_obj()
Puts new empty JSON object.
T get(Args &&... args) const
Get data from json, using one of several alternatives.
GenericDatumFormatter< double, Result > score()
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
GenericDatumFormatter< std::string, DataObject > name()
void from_json(ClexDescription &desc, const jsonParser &json)
T max(const T &A, const T &B)
double const & scalar(std::string const &_name) const
std::map< std::string, Eigen::MatrixXd > site
bool has_scalar(std::string const &_name) const
std::map< std::string, Eigen::MatrixXd > global
Option(Method _method=Method::minimum, std::string _name="energy")
Method method
Method for scoring.
std::string name
Property name or configname used for scoring.