| 1 | /* | 
|---|
| 2 | * PotentialTrainer.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Sep 11, 2014 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef POTENTIALTRAINER_HPP_ | 
|---|
| 9 | #define POTENTIALTRAINER_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <boost/filesystem/path.hpp> | 
|---|
| 17 | #include <vector> | 
|---|
| 18 |  | 
|---|
| 19 | #include "Potentials/SerializablePotential.hpp" | 
|---|
| 20 |  | 
|---|
| 21 | class element; | 
|---|
| 22 | class HomologyContainer; | 
|---|
| 23 | class HomologyGraph; | 
|---|
| 24 |  | 
|---|
| 25 | /** This class is a functor for training a (compound) potential from homologies. | 
|---|
| 26 | * | 
|---|
| 27 | */ | 
|---|
| 28 | class PotentialTrainer | 
|---|
| 29 | { | 
|---|
| 30 | public: | 
|---|
| 31 | PotentialTrainer(); | 
|---|
| 32 | ~PotentialTrainer(); | 
|---|
| 33 |  | 
|---|
| 34 | bool operator()( | 
|---|
| 35 | const HomologyContainer &_homologies, | 
|---|
| 36 | const HomologyGraph &_graph, | 
|---|
| 37 | const boost::filesystem::path &_trainingfile, | 
|---|
| 38 | const unsigned int _maxiterations, | 
|---|
| 39 | const double _threshold, | 
|---|
| 40 | const unsigned int _best_of_howmany) const; | 
|---|
| 41 |  | 
|---|
| 42 | /** Get the first matching homologous graph based only on the number of nodes. | 
|---|
| 43 | * | 
|---|
| 44 | * We could directly access the equal_range in the HomologyContainer we if were | 
|---|
| 45 | * specified the full HomologyGraph. However, if we have only get "CH4", then | 
|---|
| 46 | * we lack the bonding structure, hence one half of the graph is missing. | 
|---|
| 47 | * | 
|---|
| 48 | * Therefore, we step through all graphs and get the first to match exactly | 
|---|
| 49 | * with the number of specified element.s | 
|---|
| 50 | * | 
|---|
| 51 | * \param homologies container sorted by homologous fragments/graphs | 
|---|
| 52 | * \param types fragment specification, e.g. "CH4" | 
|---|
| 53 | * \return the first matching HomologyGraph | 
|---|
| 54 | */ | 
|---|
| 55 | static | 
|---|
| 56 | HomologyGraph getFirstGraphwithSpecifiedElements( | 
|---|
| 57 | const HomologyContainer &homologies, | 
|---|
| 58 | const SerializablePotential::ParticleTypes_t &types); | 
|---|
| 59 |  | 
|---|
| 60 | static | 
|---|
| 61 | SerializablePotential::ParticleTypes_t getNumbersFromElements( | 
|---|
| 62 | const std::vector<const element *> &fragment); | 
|---|
| 63 | }; | 
|---|
| 64 |  | 
|---|
| 65 |  | 
|---|
| 66 | #endif /* POTENTIALTRAINER_HPP_ */ | 
|---|