14 #ifndef MLPACK_METHODS_RANN_RA_MODEL_HPP
15 #define MLPACK_METHODS_RANN_RA_MODEL_HPP
21 #include <boost/variant.hpp>
30 template<
typename SortPolicy,
31 template<
typename TreeMetricType,
32 typename TreeStatType,
33 typename TreeMatType>
class TreeType>
34 using
RAType = RASearch<SortPolicy,
49 arma::Mat<size_t>& neighbors;
55 template<
typename RAType>
60 arma::Mat<size_t>& neighbors,
61 arma::mat& distances) :
74 template<
typename SortPolicy>
75 class BiSearchVisitor :
public boost::static_visitor<void>
79 const arma::mat& querySet;
83 arma::Mat<size_t>& neighbors;
87 const size_t leafSize;
90 template<
typename RAType>
91 void SearchLeaf(
RAType* ra)
const;
95 template<
template<
typename TreeMetricType,
96 typename TreeStatType,
97 typename TreeMatType>
class TreeType>
101 template<
template<
typename TreeMetricType,
102 typename TreeStatType,
103 typename TreeMatType>
class TreeType>
104 void operator()(
RATypeT<TreeType>* ra)
const;
115 arma::Mat<size_t>& neighbors,
116 arma::mat& distances,
117 const size_t leafSize);
126 template<
typename SortPolicy>
131 arma::mat&& referenceSet;
136 template<
typename RAType>
137 void TrainLeaf(
RAType* ra)
const;
141 template<
template<
typename TreeMetricType,
142 typename TreeStatType,
143 typename TreeMatType>
class TreeType>
147 template<
template<
typename TreeMetricType,
148 typename TreeStatType,
149 typename TreeMatType>
class TreeType>
150 void operator()(
RATypeT<TreeType>* ra)
const;
161 const size_t leafSize);
170 template<
typename RAType>
180 template<
typename RAType>
191 template<
typename RAType>
202 template<
typename RAType>
213 template<
typename RAType>
224 template<
typename RAType>
235 template<
typename RAType>
242 class DeleteVisitor :
public boost::static_visitor<void>
258 template<
typename RAType>
270 template<
typename SortPolicy>
304 boost::variant<RAType<SortPolicy, tree::KDTree>*,
354 template<
typename Archive>
355 void serialize(Archive& ar,
const unsigned int );
358 const arma::mat&
Dataset()
const;
376 double Alpha()
const;
413 const size_t leafSize,
415 const bool singleMode);
419 void Search(arma::mat&& querySet,
421 arma::Mat<size_t>& neighbors,
422 arma::mat& distances);
428 void Search(
const size_t k,
429 arma::Mat<size_t>& neighbors,
430 arma::mat& distances);
439 #include "ra_model_impl.hpp"
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
MonoSearchVisitor(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Construct the MonoSearchVisitor object with the given parameters.
NaiveVisitor exposes the Naive() method of the given RAType.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
Build the reference tree.
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize, const double tau, const double rho)
Construct the TrainVisitor object with the given reference set, leafSize for BinarySpaceTrees, and tau and rho for spill trees.
Exposes the FirstLeafExact() method of the given RAType.
void operator()(NSType *ns) const
Delete the NSType object.
ReferenceSetVisitor exposes the referenceSet of the given NSType.
void operator()(NSTypeT< TreeType > *ns) const
Default Train on the given NSType instance.
size_t LeafSize() const
Get the leaf size (only relevant when the kd-tree is used).
bool & operator()(RAType *ra) const
Exposes the SingleMode() method of the given RAType.
void operator()(NSType *ns) const
Perform monochromatic nearest neighbor search.
double & operator()(RAType *ra) const
Return Alpha parameter.
bool & operator()(RAType *) const
Return SampleAtLeaves (whether or not sampling is done at leaves).
RAModel(TreeTypes treeType=TreeTypes::KD_TREE, bool randomBasis=false)
Initialize the RAModel with the given type and whether or not a random basis should be used...
const arma::mat & operator()(NSType *ns) const
Return the reference set.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
bool Naive() const
Get whether or not naive search is being used.
double Alpha() const
Get the desired success probability.
Exposes the Tau() method of the given RAType.
const arma::mat & Dataset() const
Expose the dataset.
RAModel & operator=(const RAModel &other)
Copy the given RAModel.
double & operator()(RAType *ra) const
Get a reference to the Tau parameter.
void Search(arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Perform rank-approximate neighbor search, taking ownership of the query set.
std::string TreeName() const
Get the name of the tree type.
TrainVisitor sets the reference set to a new reference set on the given NSType.
void operator()(NSTypeT< TreeType > *ns) const
Default Bichromatic neighbor search on the given NSType instance.
BiSearchVisitor(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances, const size_t leafSize, const double tau, const double rho)
Construct the BiSearchVisitor.
bool SingleMode() const
Get whether or not single-tree search is being used.
RASearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType > RAType
Alias template for RASearch.
~RAModel()
Clean memory, if necessary.
bool & operator()(RAType *ra) const
Get a reference to the SingleMode parameter of the given RASearch object.
size_t & operator()(RAType *ra) const
MonoSearchVisitor executes a monochromatic neighbor search on the given NSType.
Exposes the Alpha() method of the given RAType.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
Exposes the SampleAtLeaves() method of the given RAType.
TreeTypes
The list of tree types we can use with RASearch.
double Tau() const
Get the rank-approximation in percentile of the data.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType param...
bool & operator()(RAType *ra) const
Get a reference to the naive parameter of the given RASearch object.
src mlpack core util version hpp VERSION_HPP_CONTENTS string(REGEX REPLACE".*#define MLPACK_VERSION_MAJOR ([0-9]+).*""\\1"MLPACK_VERSION_MAJOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* MLPACK_VERSION_MINOR "$
bool RandomBasis() const
Get whether or not a random basis is being used.
TreeTypes TreeType() const
Get the type of tree being used.
Exposes the SingleSampleLimit() method of the given RAType.