27int main(
int argc,
char* argv[])
32 if (!(argc == 3 || argc == 4))
34 cout <<
"USAGE: " << argv[0] <<
" <mode> <threshold> <<sensmode>>\n"
35 <<
" <mode> ........ Use scaling data \"range\" or "
36 "sensitivity analysis data \"sensitivity\".\n"
37 <<
" <threshold> ... Prune symmetry function lines in "
38 "settings file below this threshold.\n"
39 <<
" <sensmode> .... If <mode> is sensitivity, select mean "
40 "square average or maximum sensitivity (msa/max).\n"
41 <<
" Execute in directory with these NNP files present:\n"
42 <<
" - input.nn (NNP settings)\n"
43 <<
" - sensitivity.???.out (Data for sensitivity mode).\n";
48 if (! (pruneMode ==
"range" || pruneMode ==
"sensitivity"))
50 throw invalid_argument(
"ERROR: Unknown pruning mode.\n");
52 threshold = atof(argv[2]);
61 if (pruneMode ==
"range")
67 mode.
log <<
"*** PRUNE SYMMETRY FUNCTIONS ************"
68 "**************************************\n";
72 if (pruneMode ==
"range")
74 mode.
log <<
"Pruning symmetry functions according to their range.\n";
75 mode.
log <<
strpr(
"Symmetry function threshold for pruning |Gmax - "
76 "Gmin| < %10.2E\n", threshold);
78 mode.
log <<
strpr(
"Number of symmetry functions to be pruned: %zu\n",
81 mode.
log <<
"Pruned settings file written to: output-prune-range.nn\n";
83 else if (pruneMode ==
"sensitivity")
87 throw invalid_argument(
"ERROR: Please select sensitivity mode.\n");
89 string sensMode = argv[3];
91 if (sensMode ==
"msa")
94 mode.
log <<
strpr(
"Pruning symmetry functions below mean square "
95 "average sensitivity threshold: %10.2E.\n",
98 else if (sensMode ==
"max")
101 mode.
log <<
strpr(
"Pruning symmetry functions below maximum "
102 "sensitivity threshold: %10.2E.\n",
107 throw invalid_argument(
"ERROR: Unknown sensitivity mode.\n");
109 vector<vector<double> > sensitivity;
112 sensitivity.resize(numElements);
113 for (
size_t i = 0; i < numElements; ++i)
116 string sensFileName =
strpr(
"sensitivity.%03d.out",
118 sensFile.open(sensFileName.c_str());
120 vector<string> lines;
121 while (getline(sensFile, line))
123 if (line.at(0) !=
'#')
125 lines.push_back(line);
128 if (lines.size() != numSymmetryFunctions.at(i))
130 throw range_error(
strpr(
"ERROR: Inconsistent sensistivity"
131 " data file \"%s\".\n",
132 sensFileName.c_str()));
134 for (
size_t j = 0; j < numSymmetryFunctions.at(i); ++j)
137 double s = atof(
split.at(column).c_str());
138 sensitivity.at(i).push_back(s);
143 mode.
log <<
strpr(
"Number of symmetry functions to be pruned: %zu\n",
146 mode.
log <<
"Pruned settings file written to: "
147 "output-prune-sensitivity.nn\n";
150 mode.
log <<
"*****************************************"
151 "**************************************\n";
std::size_t atomicNumber(std::size_t index) const
Get atomic number from element index.
void registerStreamPointer(std::ofstream *const &streamPointer)
Register new C++ ofstream pointer.
Base class for all NNP applications.
ElementMap elementMap
Global element map, populated by setupElementMap().
void initialize()
Write welcome message with version information.
std::size_t getNumElements() const
Getter for Mode::numElements.
void setupGeneric(std::string const &nnpDir="", bool skipNormalize=false, bool initialHardness=false)
Combine multiple setup routines and provide a basic NNP setup.
std::vector< std::size_t > pruneSymmetryFunctionsRange(double threshold)
Prune symmetry functions according to their range and write settings file.
void writePrunedSettingsFile(std::vector< std::size_t > prune, std::string fileName="output.nn") const
Copy settings file but comment out lines provided.
virtual void setupSymmetryFunctionScaling(std::string const &fileName="scaling.data")
Set up symmetry function scaling from file.
std::vector< std::size_t > getNumSymmetryFunctions() const
Get number of symmetry functions per element.
void loadSettingsFile(std::string const &fileName="input.nn")
Open settings file and load all keywords into memory.
std::vector< std::size_t > pruneSymmetryFunctionsSensitivity(double threshold, std::vector< std::vector< double > > sensitivity)
Prune symmetry functions with sensitivity analysis data.
string strpr(const char *format,...)
String version of printf function.
vector< string > split(string const &input, char delimiter)
Split string at each delimiter.
string reduce(string const &line, string const &whitespace, string const &fill)
Replace multiple whitespaces with fill.
int main(int argc, char *argv[])