source: src/FunctionApproximation/Extractors.hpp@ 6d08032

Fix_FitPotential_needs_atomicnumbers
Last change on this file since 6d08032 was 6d08032, checked in by Frederik Heber <heber@…>, 9 years ago

tempcommit: Replaced boost::adjacency_list by PotentialSubgraph.

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/*
2 * Extractors.hpp
3 *
4 * Created on: 15.10.2012
5 * Author: heber
6 */
7
8#ifndef TRAININGDATA_EXTRACTORS_HPP_
9#define TRAININGDATA_EXTRACTORS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <boost/function.hpp>
17
18#include "Fragmentation/Summation/SetValues/Fragment.hpp"
19#include "FunctionApproximation/FunctionModel.hpp"
20
21class Fragment;
22
23/** Namespace containing all simple extractor functions.
24 *
25 * Extractor functions extract distances from a given fragment matching with
26 * a given set of particle types (i.e. elements, e.h. H2O).
27 * Filter functions extract a subset of distances from a given set of distances
28 * to be used with a specific model.
29 *
30 * To this end, each FunctionModel has both a filter and an extractor function.
31 *
32 * The functions in this namespace act as helpers or basic building blocks in
33 * constructing such filters and extractors.
34 *
35 */
36namespace Extractors {
37 typedef Fragment::charges_t::const_iterator chargeiter_t;
38 typedef std::vector<chargeiter_t> chargeiters_t;
39
40 typedef size_t count_t;
41 typedef Fragment::atomicNumber_t element_t;
42 typedef std::map< element_t, count_t> elementcounts_t;
43 typedef std::map< element_t, chargeiters_t > elementtargets_t;
44 typedef std::vector< chargeiters_t > targets_per_combination_t;
45 //!> typedef for particle designation
46 typedef unsigned int ParticleType_t;
47 //!> typedef for a vector of particle designations
48 typedef std::vector<ParticleType_t> ParticleTypes_t;
49
50 /** Namespace for some internal helper functions.
51 *
52 */
53 namespace _detail {
54
55 /** Counts all same elements in the vector and places into map of elements.
56 *
57 * \param elements vector of elements
58 * \return count of same element in vector
59 */
60 elementcounts_t getElementCounts(
61 const Fragment::atomicnumbers_t elements
62 );
63
64 }
65
66 /** Gather all distances from a given set of positions.
67 *
68 * Here, we only return one of the two equal distances.
69 *
70 * \param positions all nuclei positions
71 * \param atomicNumber all nuclei atomic numbers
72 * \param globalid index to associated in argument_t with
73 * \return vector of argument_ , each with a distance
74 */
75 FunctionModel::arguments_t
76 gatherAllSymmetricDistanceArguments(
77 const Fragment::positions_t& positions,
78 const Fragment::atomicnumbers_t& atomicnumbers,
79 const size_t globalid);
80
81 /** Simple extractor of all unique pair distances of a given \a fragment, where
82 * the first index is less than the second one.
83 *
84 * \param positions all nuclei positions
85 * \param atomicNumber all nuclei atomic numbers
86 * \param index index refers to the index within the global set of configurations
87 * \return vector of of argument_t containing all found distances
88 */
89 inline FunctionModel::arguments_t gatherAllSymmetricDistances(
90 const Fragment::positions_t& positions,
91 const Fragment::atomicnumbers_t& atomicnumbers,
92 const size_t index
93 ) {
94 // get distance out of Fragment
95 return gatherAllSymmetricDistanceArguments(positions, atomicnumbers, index);
96 }
97
98 /** Reorder the arguments to bring adjacent ones together.
99 *
100 * After filtering via particle types arguments related via same indices
101 * must not necessarily be contained in the same bunch. This reordering
102 * is done here, preserving the alignment given in
103 * \sa filterArgumentsByParticleTypes()
104 *
105 * \param listargs list of arguments to reorder each
106 * \param _types particle type vector which gives the order of the distance arguments
107 * \param _subgraph specifies the subgraph which we need to find in the arguments
108 * \return reordered args
109 */
110 FunctionModel::list_of_arguments_t reorderArgumentsByParticleTypes(
111 const FunctionModel::list_of_arguments_t &eachargs,
112 const ParticleTypes_t &_types,
113 const PotentialSubgraph &_subgraph
114 );
115
116 /** Filter arguments according to types, allowing multiples.
117 *
118 * If particle types is (0,1,2) and three arguments, each with a pair of types,
119 * are given, then the alignment will be: (0,1), (0,2), and (1,2).
120 *
121 * \param args arguments to reorder
122 * \param _types particle type vector which gives the order of the distance arguments
123 * \param _subgraph specifies the subgraph which we need to find in the arguments
124 * \return filtered list of args
125 */
126 FunctionModel::list_of_arguments_t filterArgumentsByParticleTypes(
127 const FunctionModel::arguments_t &args,
128 const ParticleTypes_t &_types,
129 const PotentialSubgraph &_subgraph
130 );
131
132 /** Combines two argument lists by sorting and making unique.
133 *
134 * @param firstargs first list of arguments
135 * @param secondargs second list of arguments
136 * @return concatenated lists
137 */
138 FunctionModel::arguments_t combineArguments(
139 const FunctionModel::arguments_t &firstargs,
140 const FunctionModel::arguments_t &secondargs);
141
142 /** Combines two argument lists by concatenation.
143 *
144 * @param firstargs first list of arguments
145 * @param secondargs second list of arguments
146 * @return concatenated lists
147 */
148 FunctionModel::arguments_t concatenateArguments(
149 const FunctionModel::arguments_t &firstargs,
150 const FunctionModel::arguments_t &secondargs);
151
152 /** Combines two argument lists by concatenation.
153 *
154 * @param firstlistargs first list of argument tuples
155 * @param secondlistargs second list of argument tuples
156 * @return concatenated lists
157 */
158 FunctionModel::list_of_arguments_t concatenateListOfArguments(
159 const FunctionModel::list_of_arguments_t &firstlistargs,
160 const FunctionModel::list_of_arguments_t &secondlistargs);
161
162}; /* namespace Extractors */
163
164
165#endif /* TRAININGDATA_EXTRACTORS_HPP_ */
Note: See TracBrowser for help on using the repository browser.