15 #ifndef MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP 16 #define MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP 22 #include <boost/variant.hpp> 31 template<
template<
typename TreeMetricType,
32 typename TreeStatType,
33 typename TreeMatType>
class TreeType>
38 static const std::string
Name() {
return "range_search_model"; }
51 std::vector<std::vector<size_t>>& neighbors;
53 std::vector<std::vector<double>>& distances;
57 template<
typename RSType>
62 std::vector<std::vector<size_t>>& neighbors,
63 std::vector<std::vector<double>>& distances):
80 const arma::mat& querySet;
84 std::vector<std::vector<size_t>>& neighbors;
86 std::vector<std::vector<double>>& distances;
88 const size_t leafSize;
91 template<
typename RSType>
92 void SearchLeaf(
RSType* rs)
const;
96 template<
template<
typename TreeMetricType,
97 typename TreeStatType,
98 typename TreeMatType>
class TreeType>
102 template<
template<
typename TreeMetricType,
103 typename TreeStatType,
104 typename TreeMatType>
class TreeType>
105 void operator()(
RSTypeT<TreeType>* rs)
const;
119 std::vector<std::vector<size_t>>& neighbors,
120 std::vector<std::vector<double>>& distances,
121 const size_t leafSize);
134 arma::mat&& referenceSet;
138 template<
typename RSType>
139 void TrainLeaf(
RSType* rs)
const;
143 template<
template<
typename TreeMetricType,
144 typename TreeStatType,
145 typename TreeMatType>
class TreeType>
149 template<
template<
typename TreeMetricType,
150 typename TreeStatType,
151 typename TreeMatType>
class TreeType>
152 void operator()(
RSTypeT<TreeType>* rs)
const;
165 const size_t leafSize);
175 template<
typename RSType>
186 template<
typename RSType>
193 template<
typename Archive>
200 const std::string& name;
204 template<
typename RSType>
221 template<
typename RSType>
234 template<
typename RSType>
273 boost::variant<RSType<tree::KDTree>*,
297 const bool randomBasis =
false);
314 template<
typename Archive>
315 void Serialize(Archive& ar,
const unsigned int );
318 const arma::mat&
Dataset()
const;
356 const size_t leafSize,
358 const bool singleMode);
370 void Search(arma::mat&& querySet,
372 std::vector<std::vector<size_t>>& neighbors,
373 std::vector<std::vector<double>>& distances);
385 std::vector<std::vector<size_t>>& neighbors,
386 std::vector<std::vector<double>>& distances);
393 std::string TreeName()
const;
405 #include "rs_model_impl.hpp" The RangeSearch class is a template class for performing range searches.
TreeTypes TreeType() const
Get the type of tree.
void operator()(RSType *rs) const
Perform monochromatic search with the given RangeSearch object.
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.
bool & operator()(RSType *rs) const
Get a reference to the naive parameter of the given RangeSearch object.
Exposes the seralize method of the given RSType.
Linear algebra utility functions, generally performed on matrices or vectors.
~RSModel()
Clean memory, if necessary.
SerializeVisitor(Archive &ar, const std::string &name)
Construct the SerializeVisitor with the given archive and name.
ReferenceSetVisitor exposes the referenceSet of the given RSType.
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.
static const std::string Name()
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize)
Construct the TrainVisitor object with the given reference set, leafSize.
void operator()(RSType *rs) const
Serialize the given model.
void operator()(RSTypeT< TreeType > *rs) const
Default Bichromatic range search on the given RSType instance.
size_t LeafSize() const
Get the leaf size (applicable to everything but the cover tree).
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.
void operator()(RSTypeT< TreeType > *rs) const
Default Train on the given RSType instance.
NaiveVisitor exposes the Naive() method of the given RSType.
bool SingleMode() const
Get whether the model is in single-tree search mode.
TrainVisitor sets the reference set to a new reference set on the given RSType.
const arma::mat & operator()(RSType *rs) const
Return the reference set.
bool & operator()(RSType *rs) const
Get a reference to the singleMode parameter of the given RangeSeach object.
TreeTypes & TreeType()
Modify the type of tree (don't do this after the model has been built).
size_t & LeafSize()
Modify the leaf size (applicable to everything but the cover tree).
MonoSearchVisitor executes a monochromatic range search on the given RSType.
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.
void operator()(RSType *rs) const
Delete the RSType object.
BiSearchVisitor executes a bichromatic range search on the given RSType.
bool Naive() const
Get whether the model is in naive search mode.
bool & RandomBasis()
Modify whether a random basis is used (don't do this after the model has been built).
SingleModeVisitor exposes the SingleMode() method of the given RSType.
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...
bool RandomBasis() const
Get whether a random basis is used.
const arma::mat & Dataset() const
Expose the dataset.
DeleteVisitor deletes the given RSType instance.
void Serialize(Archive &ar, const unsigned int)
Serialize the range search model.
RSModel & operator=(const RSModel &other)
Copy operator.