source: src/FunctionApproximation/Extractors.hpp@ 63e786

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 Candidate_v1.7.0 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 63e786 was 63e786, checked in by Frederik Heber <heber@…>, 13 years ago

Refactored realignElementTargets() out of gatherDistancesOfTuples().

  • Property mode set to 100644
File size: 4.3 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 "Fragmentation/SetValues/Fragment.hpp"
17#include "FunctionApproximation/FunctionModel.hpp"
18
19class Fragment;
20
21/** Namespace containing all simple extractor functions.
22 *
23 */
24namespace Extractors {
25 typedef Fragment::charges_t::const_iterator chargeiter_t;
26 typedef std::vector<chargeiter_t> chargeiters_t;
27
28 typedef size_t count_t;
29 typedef Fragment::charge_t element_t;
30 typedef std::map< element_t, count_t> elementcounts_t;
31 typedef std::map< element_t, chargeiters_t > elementtargets_t;
32
33 /** Namespace for some internal helper functions.
34 *
35 */
36 namespace _detail {
37 /** Gather all distances from a given set of positions.
38 *
39 * \param positins vector of positions
40 * \param globalid index to associated in argument_t with
41 * \return vector of argument_ , each with a distance
42 */
43 FunctionModel::arguments_t
44 gatherAllDistanceArguments(
45 const Fragment::positions_t &positions,
46 const size_t globalid);
47
48 /** Gather all positions from the same aligned vector of charges.
49 *
50 * Basically, we filter the positions indicated by the targets but
51 * from a different vector that has the same layout.
52 *
53 * \param positions positions to search
54 * \param charges charges to match with \targets
55 * \param targets iterators on charges
56 * \return filtered positions
57 */
58 Fragment::positions_t gatherPositionsFromCharges(
59 const Fragment::positions_t &positions,
60 const Fragment::charges_t &charges,
61 const chargeiters_t targets
62 );
63
64 /** Counts all same elements in the vector and places into map of elements.
65 *
66 * \param elements vector of elements
67 * \return count of same element in vector
68 */
69 elementcounts_t getElementCounts(
70 const Fragment::charges_t elements
71 );
72
73 /** Gather iterators to the elements related to the desired elementcounts.
74 *
75 * \param charges charges wherein to search for the elements
76 * \param elementcounts number of desired hits per element
77 * \return iterators equal to the initial vector of elements
78 */
79 elementtargets_t convertElementcountsToTargets(
80 const Fragment::charges_t &charges,
81 const elementcounts_t &elementcounts
82 );
83
84 /** Convert the alignment back to as it was in the original vector.
85 *
86 * We lost the information by storing it in a map. Hence, we need this
87 * final step.
88 *
89 * \param elementtargets targets as they are in the map \a elementcounts
90 * \param elements the original order of the elements
91 * \param elementcounts the count per element for debugging checks
92 * \return vector of targets in the order as they are in \a element
93 */
94 chargeiters_t realignElementtargets(
95 const elementtargets_t &elementtargets,
96 const Fragment::charges_t elements,
97 const elementcounts_t &elementcounts
98 );
99 }
100
101 /** Simple extractor of all unique pair distances of a given \a fragment.
102 *
103 * \param fragment fragment with all nuclei positions
104 * \param index index refers to the index within the global set of configurations
105 * \return vector of of argument_t containing all found distances
106 */
107 inline FunctionModel::arguments_t gatherAllDistances(
108 const Fragment& fragment,
109 const size_t index
110 ) {
111 // get distance out of Fragment
112 return _detail::gatherAllDistanceArguments(fragment.getPositions(), index);
113 }
114
115 /** Gather all positions associated to the matching \a elements.
116 *
117 * \param fragment fragment with all nuclei positions
118 * \param elements tuple of desired elements
119 * \return vector of positions_t containing
120 */
121 Fragment::positions_t gatherDistanceOfTuples(
122 const Fragment& fragment,
123 const Fragment::charges_t elements
124 );
125
126 /** Reorder arguments by increasing distance.
127 *
128 * \param args arguments to reorder
129 * \return reordered args
130 */
131 FunctionModel::arguments_t reorderArgumentsByIncreasingDistance(
132 const FunctionModel::arguments_t &args
133 );
134
135}; /* namespace Extractors */
136
137
138#endif /* TRAININGDATA_EXTRACTORS_HPP_ */
Note: See TracBrowser for help on using the repository browser.