29 #ifndef CDPL_SHAPE_FASTGAUSSIANSHAPEALIGNMENT_HPP
30 #define CDPL_SHAPE_FASTGAUSSIANSHAPEALIGNMENT_HPP
35 #include <unordered_map>
39 #include <boost/functional/hash.hpp>
40 #include <boost/random/mersenne_twister.hpp>
62 typedef std::vector<AlignmentResult> ResultList;
65 static constexpr
double DEF_OPTIMIZATION_STOP_GRADIENT = 1.0;
66 static constexpr std::size_t DEF_MAX_OPTIMIZATION_ITERATIONS = 20;
68 static constexpr
double DEF_SYMMETRY_THRESHOLD = 0.15;
69 static constexpr std::size_t DEF_NUM_RANDOM_STARTS = 4;
70 static constexpr
double DEF_MAX_RANDOM_TRANSLATION = 2.0;
215 typedef std::vector<Element> ElementArray;
217 ElementArray elements;
218 std::size_t colElemOffs;
219 std::size_t setIndex;
221 unsigned int symClass;
224 double colSelfOverlap;
225 bool equalNonColDelta;
228 typedef std::pair<std::size_t, std::size_t> ResultID;
230 void alignAndProcessResults(std::size_t ref_idx, std::size_t al_idx);
231 void processResult(
AlignmentResult& res, std::size_t ref_idx, std::size_t al_idx);
233 void setupShapeData(
const GaussianShape& shape, ShapeData& data,
bool ref);
236 void prepareForAlignment();
238 bool generateStartTransforms(
const ShapeData& ref_data);
240 void generateTransformsForElementCenters(
const ShapeData& data,
unsigned int axes_swap_flags,
bool ref_shape);
241 void generateTransforms(
const Math::Vector3D& ctr_trans,
unsigned int axes_swap_flags);
243 template <
typename QE>
246 void transformAlignedShape();
251 double calcOverlap(
const ShapeData& ref_data,
const ShapeData& ovl_data,
bool color)
const;
254 bool getResultIndex(
const ResultID& res_id, std::size_t& res_idx);
256 typedef std::vector<ShapeData> ShapeDataArray;
257 typedef std::unordered_map<ResultID, std::size_t, boost::hash<ResultID> > ResultIndexMap;
258 typedef std::vector<QuaternionTransformation> StartTransformList;
259 typedef boost::random::mt11213b RandomEngine;
265 std::size_t maxNumOptIters;
267 unsigned int resultSelMode;
270 ShapeDataArray refShapeData;
271 ShapeData algdShapeData;
272 ResultIndexMap resIndexMap;
274 std::size_t currSetIndex;
275 std::size_t currShapeIndex;
278 bool nonColCtrStarts;
280 bool genForAlgdShape;
282 bool genForLargerShape;
284 double maxRandomTrans;
285 std::size_t numRandomStarts;
286 std::size_t numSubTransforms;
287 RandomEngine randomEngine;
288 StartTransformList startTransforms;
294 std::size_t currRefShapeIdx;
Definition of constants in namespace CDPL::Shape::AlignmentResultSelectionMode.
Definition of the class CDPL::Shape::AlignmentResult.
Implementation of the BFGS optimization algorithm.
Definition of the class CDPL::Shape::GaussianShapeSet.
Definition of matrix data types.
Definition of various quaternion expression types and operations.
Definition of the preprocessor macro CDPL_SHAPE_API.
#define CDPL_SHAPE_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Math::VectorArray.
Definition: Vector.hpp:1053
Definition: Expression.hpp:98
Definition: AlignmentResult.hpp:45
Definition: FastGaussianShapeAlignment.hpp:60
ResultList::const_iterator ConstResultIterator
Definition: FastGaussianShapeAlignment.hpp:74
void setSymmetryThreshold(double thresh)
bool genColorCenterStarts() const
AlignmentResult & getResult(std::size_t idx)
void genForAlignedShapeCenters(bool generate)
std::size_t getNumRandomStarts() const
void setNumRandomStarts(std::size_t num_starts)
const ResultCompareFunction & getResultCompareFunction() const
void setMaxRandomTranslation(double max_trans)
std::shared_ptr< FastGaussianShapeAlignment > SharedPointer
Definition: FastGaussianShapeAlignment.hpp:72
void setMaxNumOptimizationIterations(std::size_t max_iter)
std::size_t getNumResults() const
void optimizeOverlap(bool optimize)
ResultIterator getResultsBegin()
FastGaussianShapeAlignment(const GaussianShapeSet &ref_shapes)
std::function< bool(const AlignmentResult &, const AlignmentResult &)> ResultCompareFunction
Definition: FastGaussianShapeAlignment.hpp:78
void clearReferenceShapes()
void genColorCenterStarts(bool generate)
void setResultCompareFunction(const ResultCompareFunction &func)
bool genForLargerShapeCenters() const
ResultIterator getResultsEnd()
void genForReferenceShapeCenters(bool generate)
double getSymmetryThreshold()
void setRandomSeed(unsigned int seed)
void setOptimizationStopGradient(double grad_norm)
unsigned int getResultSelectionMode() const
ConstResultIterator begin() const
ConstResultIterator getResultsBegin() const
void setResultSelectionMode(unsigned int mode)
bool genShapeCenterStarts() const
bool greedyOptimization() const
std::size_t getMaxNumOptimizationIterations() const
void genNonColorCenterStarts(bool generate)
~FastGaussianShapeAlignment()
void genRandomStarts(bool generate)
bool genRandomStarts() const
void setScoringFunction(const ScoringFunction &func)
void greedyOptimization(bool greedy)
const AlignmentResult & getResult(std::size_t idx) const
bool performAlignment() const
bool genForReferenceShapeCenters() const
std::size_t getNumReferenceShapes() const
const ScoringFunction & getScoringFunction() const
bool align(const GaussianShape &shape)
void performAlignment(bool perf_align)
ResultList::iterator ResultIterator
Definition: FastGaussianShapeAlignment.hpp:75
double getOptimizationStopGradient() const
bool optimizeOverlap() const
FastGaussianShapeAlignment(const GaussianShape &ref_shape)
void genForLargerShapeCenters(bool generate)
ConstResultIterator end() const
void genShapeCenterStarts(bool generate)
bool genNonColorCenterStarts() const
std::function< double(const AlignmentResult &)> ScoringFunction
Definition: FastGaussianShapeAlignment.hpp:77
FastGaussianShapeAlignment(const FastGaussianShapeAlignment &alignment)=delete
void addReferenceShapes(const GaussianShapeSet &shapes, bool new_set=true)
double getMaxRandomTranslation() const
FastGaussianShapeAlignment & operator=(const FastGaussianShapeAlignment &alignment)=delete
bool genForAlignedShapeCenters() const
FastGaussianShapeAlignment()
bool align(const GaussianShapeSet &shapes)
ConstResultIterator getResultsEnd() const
void addReferenceShape(const GaussianShape &shape, bool new_set=true)
Definition: GaussianShapeSet.hpp:46
Definition: GaussianShape.hpp:55
A data type for the descripton of arbitrary shapes composed of spheres approximated by gaussian funct...
Definition: GaussianShape.hpp:51
VectorArray< Vector3D > Vector3DArray
An array of Math::Vector3D objects.
Definition: VectorArray.hpp:84
CVector< double, 3 > Vector3D
A bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:1637
constexpr unsigned int BEST_PER_REFERENCE_SET
Definition: AlignmentResultSelectionMode.hpp:45
CDPL_SHAPE_API void transform(GaussianShape &shape, const Math::Matrix4D &xform)
The namespace of the Chemical Data Processing Library.
Definition: FastGaussianShapeAlignment.hpp:205
Math::Vector3D center
Definition: FastGaussianShapeAlignment.hpp:208
double radius
Definition: FastGaussianShapeAlignment.hpp:209
std::size_t color
Definition: FastGaussianShapeAlignment.hpp:207
double volume
Definition: FastGaussianShapeAlignment.hpp:212
double weightFactor
Definition: FastGaussianShapeAlignment.hpp:211
double delta
Definition: FastGaussianShapeAlignment.hpp:210