15#ifndef MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP
16#define MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP
22#include <boost/variant.hpp>
31template<
template<
typename TreeMetricType,
32 typename TreeStatType,
33 typename TreeMatType>
class TreeType>
46 std::vector<std::vector<size_t>>& neighbors;
48 std::vector<std::vector<double>>& distances;
52 template<
typename RSType>
57 std::vector<std::vector<size_t>>& neighbors,
58 std::vector<std::vector<double>>& distances):
75 const arma::mat& querySet;
79 std::vector<std::vector<size_t>>& neighbors;
81 std::vector<std::vector<double>>& distances;
83 const size_t leafSize;
86 template<
typename RSType>
87 void SearchLeaf(
RSType* rs)
const;
91 template<
template<
typename TreeMetricType,
92 typename TreeStatType,
93 typename TreeMatType>
class TreeType>
97 template<
template<
typename TreeMetricType,
98 typename TreeStatType,
99 typename TreeMatType>
class TreeType>
114 std::vector<std::vector<size_t>>& neighbors,
115 std::vector<std::vector<double>>& distances,
116 const size_t leafSize);
129 arma::mat&& referenceSet;
133 template<
typename RSType>
134 void TrainLeaf(
RSType* rs)
const;
138 template<
template<
typename TreeMetricType,
139 typename TreeStatType,
140 typename TreeMatType>
class TreeType>
144 template<
template<
typename TreeMetricType,
145 typename TreeStatType,
146 typename TreeMatType>
class TreeType>
160 const size_t leafSize);
170 template<
typename RSType>
181 template<
typename RSType>
195 template<
typename RSType>
208 template<
typename RSType>
247 boost::variant<RSType<tree::KDTree>*,
271 const bool randomBasis =
false);
302 template<
typename Archive>
344 const size_t leafSize,
346 const bool singleMode);
360 std::vector<std::vector<size_t>>& neighbors,
361 std::vector<std::vector<double>>& distances);
373 std::vector<std::vector<size_t>>& neighbors,
374 std::vector<std::vector<double>>& distances);
381 std::string TreeName()
const;
393#include "rs_model_impl.hpp"
Simple real-valued range.
BiSearchVisitor executes a bichromatic range search on the given RSType.
void operator()(RSTypeT< tree::BallTree > *rs) const
Bichromatic range search on the given RSType specialized for BallTrees.
void operator()(RSTypeT< tree::Octree > *rs) const
Bichromatic range search specialized for octrees.
void operator()(RSTypeT< tree::KDTree > *rs) const
Bichromatic range search on the given RSType specialized for KDTrees.
BiSearchVisitor(const arma::mat &querySet, const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances, const size_t leafSize)
Construct the BiSearchVisitor.
DeleteVisitor deletes the given RSType instance.
void operator()(RSType *rs) const
Delete the RSType object.
MonoSearchVisitor executes a monochromatic range search on the given RSType.
void operator()(RSType *rs) const
Perform monochromatic search with the given RangeSearch object.
MonoSearchVisitor(const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances)
Construct the MonoSearchVisitor with the given parameters.
NaiveVisitor exposes the Naive() method of the given RSType.
bool & operator()(RSType *rs) const
Get a reference to the naive parameter of the given RangeSearch object.
RSModel(RSModel &&other)
Take ownership of the given RSModel.
const arma::mat & Dataset() const
Expose the dataset.
bool & RandomBasis()
Modify whether a random basis is used (don't do this after the model has been built).
size_t & LeafSize()
Modify the leaf size (applicable to everything but the cover tree).
bool Naive() const
Get whether the model is in naive search mode.
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
Build the reference tree on the given dataset with the given parameters.
RSModel(const TreeTypes treeType=TreeTypes::KD_TREE, const bool randomBasis=false)
Initialize the RSModel with the given type and whether or not a random basis should be used.
RSModel & operator=(RSModel other)
Copy the given RSModel.
void Search(const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances)
Perform monochromatic range search, with the reference set as the query set.
~RSModel()
Clean memory, if necessary.
void Search(arma::mat &&querySet, const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances)
Perform range search.
TreeTypes & TreeType()
Modify the type of tree (don't do this after the model has been built).
bool SingleMode() const
Get whether the model is in single-tree search mode.
RSModel(const RSModel &other)
Copy the given RSModel.
bool & Naive()
Modify whether the model is in naive search mode.
size_t LeafSize() const
Get the leaf size (applicable to everything but the cover tree).
bool & SingleMode()
Modify whether the model is in single-tree search mode.
TreeTypes TreeType() const
Get the type of tree.
bool RandomBasis() const
Get whether a random basis is used.
void serialize(Archive &ar, const unsigned int)
Serialize the range search model.
The RangeSearch class is a template class for performing range searches.
ReferenceSetVisitor exposes the referenceSet of the given RSType.
const arma::mat & operator()(RSType *rs) const
Return the reference set.
SingleModeVisitor exposes the SingleMode() method of the given RSType.
bool & operator()(RSType *rs) const
Get a reference to the singleMode parameter of the given RangeSeach object.
TrainVisitor sets the reference set to a new reference set on the given RSType.
void operator()(RSTypeT< tree::BallTree > *rs) const
Train on the given RSType specialized for BallTrees.
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize)
Construct the TrainVisitor object with the given reference set, leafSize.
void operator()(RSTypeT< tree::Octree > *rs) const
Train specialized for octrees.
void operator()(RSTypeT< tree::KDTree > *rs) const
Train on the given RSType specialized for KDTrees.
Linear algebra utility functions, generally performed on matrices or vectors.