Molassembler  3.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 // Forward-declare PrivateGraph
32 class PrivateGraph;
33 
34 namespace DistanceGeometry {
35 
36 // Forward-declarations
37 class DistanceBoundsMatrix;
38 
39 
58 public:
61  using EdgeWeightProperty = boost::property<boost::edge_weight_t, double>;
62  using GraphType = boost::adjacency_list<
63  boost::vecS,
64  boost::vecS,
65  boost::directedS,
66  boost::no_property,
67  EdgeWeightProperty
68  >;
69  using VertexDescriptor = GraphType::vertex_descriptor;
70  using EdgeDescriptor = GraphType::edge_descriptor;
71 
72  using BoundsMatrix = Eigen::MatrixXd;
74 
77 
82  const PrivateGraph& inner,
83  const DistanceBoundsMatrix& bounds
84  );
85 
91  const PrivateGraph& inner,
92  const BoundsMatrix& bounds
93  );
95 
98 
102  static void explainContradictionPaths(
103  VertexDescriptor a,
104  VertexDescriptor b,
105  const std::vector<VertexDescriptor>& predecessors,
106  const std::vector<double>& distances
107  );
108 
113  [[gnu::const]] static inline bool isLeft(const VertexDescriptor i) noexcept {
114  return i % 2 == 0;
115  }
116 
117  [[gnu::const]] static inline bool sameSide(const VertexDescriptor i, const VertexDescriptor j) noexcept {
118  return i % 2 == j % 2;
119  }
120 
125  [[gnu::const]] static inline VertexDescriptor left(const VertexDescriptor a) noexcept {
126  return 2 * a;
127  }
128 
133  [[gnu::const]] static inline VertexDescriptor right(const VertexDescriptor a) noexcept {
134  return 2 * a + 1;
135  }
137 
140 
152  void addBound(
153  VertexDescriptor a,
154  VertexDescriptor b,
155  const ValueBounds& bound
156  );
157 
162  double lowerBound(VertexDescriptor a, VertexDescriptor b) const;
163 
168  double upperBound(VertexDescriptor a, VertexDescriptor b) const;
169 
177  Result<Eigen::MatrixXd> makeDistanceMatrix(Random::Engine& engine) noexcept;
178 
180  Result<Eigen::MatrixXd> makeDistanceMatrix(Random::Engine& engine, Partiality partiality) noexcept;
182 
185 
189  double maximalImplicitLowerBound(VertexDescriptor i) const;
190 
195  const GraphType& graph() const;
196 
201  Result<Eigen::MatrixXd> makeDistanceBounds() const noexcept;
203 
204 private:
205  GraphType graph_;
206  const PrivateGraph& inner_;
208  std::array<Utils::ElementType, 2> heaviestAtoms_;
209 
210  void updateOrAddEdge_(
211  VertexDescriptor i,
212  VertexDescriptor j,
213  double edgeWeight
214  );
215 
216  void updateGraphWithFixedDistance_(
217  VertexDescriptor a,
218  VertexDescriptor b,
219  double fixedDistance
220  );
221 };
222 
223 } // namespace DistanceGeometry
224 } // namespace Molassembler
225 } // namespace Scine
226 
227 #endif
static VertexDescriptor right(const VertexDescriptor a) noexcept
Get the right subgraph vertex descriptor corresponding to an outer index.
Definition: ExplicitBoundsGraph.h:133
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:117
std::array< Utils::ElementType, 2 > heaviestAtoms_
Stores the two heaviest element types.
Definition: ExplicitBoundsGraph.h:208
static bool isLeft(const VertexDescriptor i) noexcept
Check whether a vertex is part of the left subgraph.
Definition: ExplicitBoundsGraph.h:113
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:26
void addBound(VertexDescriptor a, VertexDescriptor b, const ValueBounds &bound)
Adds a bound between outer vertex indices to the graph.
Result< Eigen::MatrixXd > makeDistanceMatrix(Random::Engine &engine) noexcept
Generate a distance matrix.
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:57
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:125
Interface for the generation of new conformations of Molecules.
Partiality
Limit triangle inequality bounds smoothing to a subset of all atoms.
Definition: Conformers.h:42
const GraphType & graph() const
Nonmodifiable access to underlying graph.