Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ExplicitBoundsGraph.h
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_MOLASSEMBLER_DG_EXPLICIT_BOUNDS_GRAPH_H
13 #define INCLUDE_MOLASSEMBLER_DG_EXPLICIT_BOUNDS_GRAPH_H
14 
15 // #define MOLASSEMBLER_EXPLICIT_GRAPH_USE_SPECIALIZED_GOR1_ALGORITHM
16 
17 #include "boost/graph/adjacency_list.hpp"
18 #include "Eigen/Core"
20 
23 
24 namespace Scine {
25 namespace Molassembler {
26 
27 namespace Random {
28 class Engine;
29 } // namespace Random
30 
31 namespace outcome = OUTCOME_V2_NAMESPACE;
32 
33 // Forward-declare PrivateGraph
34 class PrivateGraph;
35 
36 namespace DistanceGeometry {
37 
38 // Forward-declarations
39 class DistanceBoundsMatrix;
40 
41 
60 public:
63  using EdgeWeightProperty = boost::property<boost::edge_weight_t, double>;
64  using GraphType = boost::adjacency_list<
65  boost::vecS,
66  boost::vecS,
67  boost::directedS,
68  boost::no_property,
69  EdgeWeightProperty
70  >;
71  using VertexDescriptor = GraphType::vertex_descriptor;
72  using EdgeDescriptor = GraphType::edge_descriptor;
73 
74  using BoundsMatrix = Eigen::MatrixXd;
76 
79 
84  const PrivateGraph& inner,
85  const DistanceBoundsMatrix& bounds
86  );
87 
93  const PrivateGraph& inner,
94  const BoundsMatrix& bounds
95  );
97 
100 
104  static void explainContradictionPaths(
105  VertexDescriptor a,
106  VertexDescriptor b,
107  const std::vector<VertexDescriptor>& predecessors,
108  const std::vector<double>& distances
109  );
110 
115  [[gnu::const]] static inline bool isLeft(const VertexDescriptor i) noexcept {
116  return i % 2 == 0;
117  }
118 
119  [[gnu::const]] static inline bool sameSide(const VertexDescriptor i, const VertexDescriptor j) noexcept {
120  return i % 2 == j % 2;
121  }
122 
127  [[gnu::const]] static inline VertexDescriptor left(const VertexDescriptor a) noexcept {
128  return 2 * a;
129  }
130 
135  [[gnu::const]] static inline VertexDescriptor right(const VertexDescriptor a) noexcept {
136  return 2 * a + 1;
137  }
139 
142 
154  void addBound(
155  VertexDescriptor a,
156  VertexDescriptor b,
157  const ValueBounds& bound
158  );
159 
164  double lowerBound(VertexDescriptor a, VertexDescriptor b) const;
165 
170  double upperBound(VertexDescriptor a, VertexDescriptor b) const;
171 
179  outcome::result<Eigen::MatrixXd> makeDistanceMatrix(Random::Engine& engine) noexcept;
180 
182  outcome::result<Eigen::MatrixXd> makeDistanceMatrix(Random::Engine& engine, Partiality partiality) noexcept;
184 
187 
191  double maximalImplicitLowerBound(VertexDescriptor i) const;
192 
197  const GraphType& graph() const;
198 
203  outcome::result<Eigen::MatrixXd> makeDistanceBounds() const noexcept;
205 
206 private:
207  GraphType graph_;
208  const PrivateGraph& inner_;
210  std::array<Utils::ElementType, 2> heaviestAtoms_;
211 
212  void updateOrAddEdge_(
213  VertexDescriptor i,
214  VertexDescriptor j,
215  double edgeWeight
216  );
217 
218  void updateGraphWithFixedDistance_(
219  VertexDescriptor a,
220  VertexDescriptor b,
221  double fixedDistance
222  );
223 };
224 
225 } // namespace DistanceGeometry
226 } // namespace Molassembler
227 } // namespace Scine
228 
229 #endif
static VertexDescriptor right(const VertexDescriptor a) noexcept
Get the right subgraph vertex descriptor corresponding to an outer index.
Definition: ExplicitBoundsGraph.h:135
outcome::result< Eigen::MatrixXd > makeDistanceMatrix(Random::Engine &engine) noexcept
Generate a distance matrix.
outcome::result< Eigen::MatrixXd > makeDistanceBounds() const noexcept
Make smooth distance bounds.
Drives a PRNG.
Definition: Prng.h:24
static bool sameSide(const VertexDescriptor i, const VertexDescriptor j) noexcept
Explain contradictions between distance bounds on a path.
Definition: ExplicitBoundsGraph.h:119
std::array< Utils::ElementType, 2 > heaviestAtoms_
Stores the two heaviest element types.
Definition: ExplicitBoundsGraph.h:210
static bool isLeft(const VertexDescriptor i) noexcept
Check whether a vertex is part of the left subgraph.
Definition: ExplicitBoundsGraph.h:115
ExplicitBoundsGraph(const PrivateGraph &inner, const DistanceBoundsMatrix &bounds)
Construct from distance bounds matrix.
Data struct for storing a numeric interval.
Library internal graph class wrapping BGL types.
Definition: PrivateGraph.h:24
void addBound(VertexDescriptor a, VertexDescriptor b, const ValueBounds &bound)
Adds a bound between outer vertex indices to the graph.
static void explainContradictionPaths(VertexDescriptor a, VertexDescriptor b, const std::vector< VertexDescriptor > &predecessors, const std::vector< double > &distances)
Explain contradictions between distance bounds on a path.
Data class for bounded values.
Definition: ValueBounds.h:23
double maximalImplicitLowerBound(VertexDescriptor i) const
Returns the length of the maximal implicit lower bound outgoing from a left vertex.
double lowerBound(VertexDescriptor a, VertexDescriptor b) const
Fetches the lower bound between outer vertex indices from the graph.
BGL wrapper to help with distance bounds smoothing.
Definition: ExplicitBoundsGraph.h:59
double upperBound(VertexDescriptor a, VertexDescriptor b) const
Fetches the upper bound between outer vertex indices from the graph.
static VertexDescriptor left(const VertexDescriptor a) noexcept
Get the left subgraph vertex descriptor corresponding to an outer index.
Definition: ExplicitBoundsGraph.h:127
Interface for the generation of new conformations of Molecules.
Partiality
Limit triangle inequality bounds smoothing to a subset of all atoms.
Definition: Conformers.h:44
const GraphType & graph() const
Nonmodifiable access to underlying graph.