source: src/Fragmentation/Homology/HomologyContainer.hpp@ a2a2f7

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 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 a2a2f7 was a2a2f7, checked in by Frederik Heber <heber@…>, 11 years ago

Huge warning fix.

  • fixed unused variables.
  • fixed set but unused variables.
  • fixed signed vs. unsigned int comparison.
  • fixed static_warning_test<false, 98> (commented out _IMPLEMENT).
  • Property mode set to 100644
File size: 6.0 KB
Line 
1/*
2 * HomologyContainer.hpp
3 *
4 * Created on: Sep 22, 2012
5 * Author: heber
6 */
7
8#ifndef HOMOLOGYCONTAINER_HPP_
9#define HOMOLOGYCONTAINER_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <boost/serialization/export.hpp>
18#include <boost/serialization/map.hpp>
19#include <boost/serialization/split_member.hpp>
20#include <boost/serialization/vector.hpp>
21#include <boost/serialization/version.hpp>
22
23#include <iosfwd>
24#include <map>
25#include <vector>
26
27#include "CodePatterns/IteratorAdaptors.hpp"
28#include "CodePatterns/Observer/Observable.hpp"
29
30#include "Fragmentation/Homology/HomologyGraph.hpp"
31#include "Fragmentation/Summation/SetValues/Fragment.hpp"
32#include "Fragmentation/Summation/SetValues/SamplingGrid.hpp"
33
34class HomologyContainerTest;
35
36/** This class takes all KeySets in a Graph, checks for those that homologues
37 * of one another and places them together.
38 *
39 * This is meant as a storage for key, value pairs, where the key is the KeySet
40 * and the value is the energy associated to the fragment this keyset
41 * represents.
42 * Afterwards this can then be used as training data for a high-dimensional
43 * approximation to the Born-Oppenheimer-surface decomposed into lower-
44 * dimensional terms in an ANOVA-like fashion.
45 *
46 */
47class HomologyContainer : public Observable
48{
49 //!> grant access to output operator
50 friend std::ostream& operator<<(std::ostream &out, const HomologyContainer &container);
51 //!> grant unit test access
52 friend class HomologyContainerTest;
53
54public:
55 /** This structure represents all values associated to a specific homology
56 * that we wish to store in this container for later reference.
57 */
58 struct value_t {
59 Fragment fragment;
60 double energy;
61 bool containsGrids;
62 SamplingGrid charge_distribution;
63 SamplingGrid potential_distribution;
64
65 value_t() :
66 energy(0.),
67 containsGrids(false)
68 {}
69
70 bool operator==(const value_t &othervalue) const;
71
72 private:
73 friend class boost::serialization::access;
74 // serialization
75 template <typename Archive>
76 void serialize(Archive& ar, const unsigned int version)
77 {
78 ar & fragment;
79 ar & energy;
80 if (version > 0) {
81 ar & containsGrids;
82 if (containsGrids) {
83 ar & charge_distribution;
84 ar & potential_distribution;
85 }
86 }
87 }
88 };
89
90public:
91 typedef std::multimap< HomologyGraph, value_t> container_t;
92 typedef container_t::const_iterator const_iterator;
93 typedef MapKeyConstIterator<container_t::const_iterator> const_key_iterator;
94 typedef std::pair< const_iterator, const_iterator> range_t;
95
96public:
97 /** Default Constructor of class HomologyContainer.
98 *
99 */
100 HomologyContainer();
101
102 /** Constructor of class HomologyContainer.
103 *
104 * @param values values with with to initially fill the container
105 */
106 HomologyContainer(const container_t &values);
107
108 /** Destructor of class HomologyContainer.
109 *
110 */
111 ~HomologyContainer() {}
112
113 /** Equality comparator.
114 *
115 * Sadly, the insertion order of a std::multimap's values is not guaranteed
116 * by the standard and boost::serialization does not heed the ordering of
117 * the values associated to the same key. Hence, we implement a weaker
118 * comparator for this class in order for the unit test to pass as we don't
119 * actuallty care about the order of the homologous fragments.
120 *
121 * @param other instance to compare to
122 * @return true - each container contains all elements of the other
123 */
124 bool operator==(const HomologyContainer &other) const {
125 return ((*this >= other) && (other >= *this));
126 }
127 bool operator!=(const HomologyContainer& other) const {
128 return !(*this == other);
129 }
130
131 /** Greater equal comparator, i.e. subset comparator
132 *
133 * @param other container to check if it's subset
134 * @return true - \a other is a subset of this
135 */
136 bool operator>=(const HomologyContainer &other) const;
137
138 /** Inserter for more graphs along with values.
139 *
140 * @param values graph and values to insert
141 */
142 void insert(const container_t &values);
143
144 /** Returns iterator range with all contained graphs homologous to the given \a graph.
145 *
146 * @param graph graph to match
147 * @return iterator range with all matches
148 */
149 range_t getHomologousGraphs(const HomologyGraph &graph) const {
150 return container.equal_range(graph);
151 }
152
153 /** Getter for constant iterator to begin of homologous graph container.
154 *
155 * @return begin constant iterator
156 */
157 const_iterator begin() const {
158 return container.begin();
159 }
160
161 /** Getter for constant iterator to past end of homologous graph container.
162 *
163 * @return past end constant iterator
164 */
165 const_iterator end() const {
166 return container.end();
167 }
168
169 const_key_iterator key_begin() const
170 { return const_key_iterator(container.begin()); }
171
172 const_key_iterator key_end() const
173 { return const_key_iterator(container.end()); }
174
175 const_key_iterator getNextKey(const_key_iterator &iter) const
176 { return const_key_iterator(container.upper_bound(*iter)); }
177
178 /** Clears all homologies from container.
179 *
180 */
181 void clear();
182
183private:
184 //!> multimap containing all homologous graph under same key but each with its value
185 container_t container;
186
187private:
188 friend class boost::serialization::access;
189 // serialization
190 template <typename Archive>
191 void load(Archive& ar, const unsigned int version)
192 {
193 OBSERVE;
194 ar & container;
195 }
196 template <typename Archive>
197 void save(Archive& ar, const unsigned int version) const
198 {
199 ar & container;
200 }
201 BOOST_SERIALIZATION_SPLIT_MEMBER()
202};
203
204/** Output operator for HomologyContainer.
205 *
206 * \param out output stream
207 * \param container container to print
208 * \return output stream for concatenation
209 */
210std::ostream& operator<<(std::ostream &out, const HomologyContainer &container);
211
212// we need to give this class a unique key for serialization
213BOOST_CLASS_EXPORT_KEY(HomologyContainer)
214
215// version for serialized information associated to HomologyGraph
216BOOST_CLASS_VERSION(HomologyContainer::value_t, 1)
217
218#endif /* HOMOLOGYCONTAINER_HPP_ */
Note: See TracBrowser for help on using the repository browser.