source: src/Fragmentation/Homology/HomologyGraph.hpp@ 7c1091

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

Extended CompoundPotential for multiple occurences of argument bunches.

  • added HomologyGraph::hasGreaterEqualTimesAtomicNumber() has model might have multiple matching arguments within a single fragment.
  • i.e. when there is more than one argument bunch for a given model. Hence, we check the stream whether upcoming arguments match current and next model. Note however that models are not necessarily sorted by particle_types' size. Hence, we must trick a little and need a specific map comparator.
  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * HomologyGraph.hpp
3 *
4 * Created on: Sep 24, 2012
5 * Author: heber
6 */
7
8#ifndef HOMOLOGYGRAPH_HPP_
9#define HOMOLOGYGRAPH_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
20#include <map>
21#include <iosfwd>
22
23#include "Fragmentation/Homology/FragmentEdge.hpp"
24#include "Fragmentation/Homology/FragmentNode.hpp"
25
26class IndexSet;
27class KeySet;
28
29/** This class contains the representation of a molecular fragment as a graph.
30 *
31 * Only, we do not store the full graph in here. We have to include symmetries
32 * such that two hydrogens may switch places. Eventually, we only look for the
33 * set of distances of a fragment. If two hydrogens switch places, then also in
34 * the set of distances some distances are interchanged but the whole fragment
35 * remains the same. Hence, we have to store the bond graph representation in
36 * such a way as to automatically include these symmetries.
37 *
38 * To this end, we use FragmentNode and FragmentEdge to store the vital
39 * information.
40 *
41 */
42class HomologyGraph
43{
44 //!> grant output operator access to internals
45 friend std::ostream& operator<<(std::ostream& ost, const HomologyGraph &graph);
46public:
47 //!> typedef for a set of nodes representing node information
48 typedef std::map<FragmentNode, size_t> nodes_t;
49 //!> typedef for a set of nodes representing edge information
50 typedef std::map<FragmentEdge, size_t> edges_t;
51public:
52 /** Default constructor for class HomologyGraph.
53 *
54 * This is required to allow placement in STL containers
55 *
56 */
57 HomologyGraph() {}
58
59 /** Constructor for class HomologyGraph.
60 *
61 * @param _nodes information on nodes of this graph
62 * @param _edges information on edges of this graph
63 */
64 HomologyGraph(const nodes_t &_nodes, const edges_t &_edges) :
65 nodes(_nodes),
66 edges(_edges)
67 {}
68
69 /** Constructor for class HomologyGraph from a keyset (i.e. from atoms in the World).
70 *
71 * @param keyset global ids of atoms to pick
72 */
73 HomologyGraph(const KeySet &keyset);
74
75 /** Constructor for class HomologyGraph from a IndexSet (i.e. from atoms in the World).
76 *
77 * @param index global ids of atoms to pick
78 */
79 HomologyGraph(const IndexSet &index);
80
81 /** Destructor for class HomologyGraph.
82 *
83 */
84 ~HomologyGraph() {}
85
86 // comparators (allows sorting and hence quicker finding in STL containers)
87 bool operator<(const HomologyGraph &graph) const;
88 bool operator>(const HomologyGraph &graph) const;
89 bool operator==(const HomologyGraph &graph) const;
90 bool operator!=(const HomologyGraph &graph) const {
91 return (!(*this == graph));
92 }
93
94 /** Checks whether this graph contains a specific \a node.
95 *
96 * @param node node to look for
97 * @param count how often this node must occur
98 * @return true - graph contains this node at least once, false - else
99 */
100 bool hasNode(const FragmentNode &node, const size_t count = 1) const {
101 nodes_t::const_iterator iter = nodes.find(node);
102 if (iter == nodes.end())
103 return count == 0;
104 else
105 return (iter->second == count);
106 }
107
108 /** Checks whether this graph contains a specific \a edge.
109 *
110 * @param edge edge to look for
111 * @param count how often this edge must occur
112 * @return true - graph contains this edge at least once, false - else
113 */
114 bool hasEdge(const FragmentEdge &edge, const size_t count = 1) const {
115 edges_t::const_iterator iter = edges.find(edge);
116 if (iter == edges.end())
117 return count == 0;
118 else
119 return (iter->second == count);
120 }
121
122 /** Checks whether this graph has \b exactly \a _times nodes with \a _number
123 * atomic number.
124 *
125 * @param _number desired atomic number
126 * @param _times number this must occur
127 * @return true - graph has exactly \a _times nodes with \a _number, false - else
128 */
129 bool hasTimesAtomicNumber(const size_t _number, const size_t _times) const;
130
131 /** Checks whether this graph has \b greater equal \a _times nodes with \a _number
132 * atomic number.
133 *
134 * @param _number desired atomic number
135 * @param _times number this must occur
136 * @return true - graph has greater equal \a _times nodes with \a _number, false - else
137 */
138 bool hasGreaterEqualTimesAtomicNumber(const size_t _number, const size_t _times) const;
139
140 /** Assignment operator for class HomologyGraph.
141 *
142 * This is required to allow placement in STL container as we need to
143 * const_cast override our const member variables.
144 *
145 */
146 HomologyGraph& operator=(const HomologyGraph &graph);
147
148private:
149 //!> information on the nodes of the graph
150 const nodes_t nodes;
151 //!> information on the edges of the graph
152 const edges_t edges;
153
154private:
155 friend class boost::serialization::access;
156 // serialization
157 template <typename Archive>
158 void serialize(Archive& ar, const unsigned int version)
159 {
160 ar & const_cast<nodes_t &>(nodes);
161 ar & const_cast<edges_t &>(edges);
162 }
163};
164
165std::ostream& operator<<(std::ostream& ost, const HomologyGraph &graph);
166
167// we need to give this class a unique key for serialization
168BOOST_CLASS_EXPORT_KEY(HomologyGraph)
169
170// define some helpers outside to allow for light-weight unit testing
171namespace detail {
172 const HomologyGraph::nodes_t getNodesFromKeySet(const KeySet &keyset);
173 const HomologyGraph::edges_t getEdgesFromKeySet(const KeySet &keyset);
174 const HomologyGraph::nodes_t getNodesFromIndexSet(const IndexSet &keyset);
175 const HomologyGraph::edges_t getEdgesFromIndexSet(const IndexSet &keyset);
176};
177
178
179#endif /* HOMOLOGYGRAPH_HPP_ */
Note: See TracBrowser for help on using the repository browser.