15 #ifndef MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP 16 #define MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP 49 virtual const arma::mat&
Dataset()
const = 0;
57 virtual bool Naive()
const = 0;
59 virtual bool&
Naive() = 0;
62 virtual void Train(arma::mat&& referenceSet,
63 const size_t leafSize) = 0;
67 virtual void Search(arma::mat&& querySet,
69 std::vector<std::vector<size_t>>& neighbors,
70 std::vector<std::vector<double>>& distances,
71 const size_t leafSize) = 0;
76 std::vector<std::vector<size_t>>& neighbors,
77 std::vector<std::vector<double>>& distances) = 0;
83 template<
template<
typename TreeMetricType,
84 typename TreeStatType,
85 typename TreeMatType>
class TreeType>
90 RSWrapper(
const bool singleMode,
const bool naive) :
104 const arma::mat&
Dataset()
const {
return rs.ReferenceSet(); }
112 bool Naive()
const {
return rs.Naive(); }
114 bool&
Naive() {
return rs.Naive(); }
118 virtual void Train(arma::mat&& referenceSet,
123 virtual void Search(arma::mat&& querySet,
125 std::vector<std::vector<size_t>>& neighbors,
126 std::vector<std::vector<double>>& distances,
132 std::vector<std::vector<size_t>>& neighbors,
133 std::vector<std::vector<double>>& distances);
136 template<
typename Archive>
154 template<
template<
typename TreeMetricType,
155 typename TreeStatType,
156 typename TreeMatType>
class TreeType>
178 virtual void Train(arma::mat&& referenceSet,
179 const size_t leafSize);
183 virtual void Search(arma::mat&& querySet,
185 std::vector<std::vector<size_t>>& neighbors,
186 std::vector<std::vector<double>>& distances,
187 const size_t leafSize);
190 template<
typename Archive>
234 RSModel(
const TreeTypes treeType = TreeTypes::KD_TREE,
235 const bool randomBasis =
false);
271 template<
typename Archive>
272 void serialize(Archive& ar,
const uint32_t );
275 const arma::mat&
Dataset()
const {
return rSearch->Dataset(); }
283 bool Naive()
const {
return rSearch->Naive(); }
285 bool&
Naive() {
return rSearch->Naive(); }
306 void InitializeModel(
const bool naive,
const bool singleMode);
317 void BuildModel(arma::mat&& referenceSet,
318 const size_t leafSize,
320 const bool singleMode);
332 void Search(arma::mat&& querySet,
334 std::vector<std::vector<size_t>>& neighbors,
335 std::vector<std::vector<double>>& distances);
347 std::vector<std::vector<size_t>>& neighbors,
348 std::vector<std::vector<double>>& distances);
372 std::string TreeName()
const;
RSWrapper is a wrapper class for most RangeSearch types.
Definition: rs_model.hpp:86
bool & Naive()
Modify whether naive search is being used.
Definition: rs_model.hpp:114
bool SingleMode() const
Get whether the model is in single-tree search mode.
Definition: rs_model.hpp:278
virtual const arma::mat & Dataset() const =0
Get the dataset.
const arma::mat & Dataset() const
Get the dataset.
Definition: rs_model.hpp:104
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
bool Naive() const
Get whether the model is in naive search mode.
Definition: rs_model.hpp:283
virtual void Train(arma::mat &&referenceSet, const size_t leafSize)=0
Train the model (build the reference tree if needed).
bool & RandomBasis()
Modify whether a random basis is used (don't do this after the model has been built).
Definition: rs_model.hpp:301
virtual RSWrapper * Clone() const
Create a new RSWrapper that is the same as this one.
Definition: rs_model.hpp:98
bool Naive() const
Get whether naive search is being used.
Definition: rs_model.hpp:112
void serialize(Archive &ar, const uint32_t)
Serialize the RangeSearch model.
Definition: rs_model.hpp:137
TreeTypes TreeType() const
Get the type of tree.
Definition: rs_model.hpp:293
Forward declaration.
Definition: range_search.hpp:28
bool SingleMode() const
Get whether single-tree search is being used.
Definition: rs_model.hpp:107
bool & Naive()
Modify whether the model is in naive search mode.
Definition: rs_model.hpp:285
virtual bool SingleMode() const =0
Get whether single-tree search is being used.
size_t LeafSize() const
Get the leaf size (applicable to everything but the cover tree).
Definition: rs_model.hpp:288
TreeTypes & TreeType()
Modify the type of tree (don't do this after the model has been built).
Definition: rs_model.hpp:295
RSType rs
The instantiated RangeSearch object that we are wrapping.
Definition: rs_model.hpp:146
virtual ~RSWrapperBase()
Destruct the RSWrapperBase (nothing to do).
Definition: rs_model.hpp:46
virtual void Search(arma::mat &&querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances, const size_t leafSize)=0
Perform bichromatic range search (i.e.
bool & SingleMode()
Modify whether single-tree search is being used.
Definition: rs_model.hpp:109
bool RandomBasis() const
Get whether a random basis is used.
Definition: rs_model.hpp:298
The RSModel class provides an abstraction for the RangeSearch class, abstracting away the TreeType pa...
Definition: rs_model.hpp:206
void serialize(Archive &ar, const uint32_t)
Serialize the RangeSearch model.
Definition: rs_model.hpp:191
bool & SingleMode()
Modify whether the model is in single-tree search mode.
Definition: rs_model.hpp:280
size_t & LeafSize()
Modify the leaf size (applicable to everything but the cover tree).
Definition: rs_model.hpp:290
virtual bool Naive() const =0
Get whether naive search is being used.
const arma::mat & Dataset() const
Expose the dataset.
Definition: rs_model.hpp:275
LeafSizeRSWrapper(const bool singleMode, const bool naive)
Construct the LeafSizeRSWrapper by delegating to the RSWrapper constructor.
Definition: rs_model.hpp:162
virtual RSWrapperBase * Clone() const =0
Create a new RSWrapperBase that is the same as this one.
virtual ~RSWrapper()
Destruct the RSWrapper (nothing to do).
Definition: rs_model.hpp:101
RSWrapperBase()
Create the RSWrapperBase object.
Definition: rs_model.hpp:39
virtual ~LeafSizeRSWrapper()
Delete the LeafSizeRSWrapper.
Definition: rs_model.hpp:169
RSWrapperBase is a base wrapper class for holding all RangeSearch types supported by RSModel...
Definition: rs_model.hpp:34
RSWrapper(const bool singleMode, const bool naive)
Create the RSWrapper object.
Definition: rs_model.hpp:90
virtual LeafSizeRSWrapper * Clone() const
Return a copy of the LeafSizeRSWrapper.
Definition: rs_model.hpp:172