mlpack
Public Types | Public Member Functions | List of all members
mlpack::range::RSModel Class Reference

The RSModel class provides an abstraction for the RangeSearch class, abstracting away the TreeType parameter and allowing it to be specified at runtime. More...

#include <rs_model.hpp>

Public Types

enum  TreeTypes {
  KD_TREE, COVER_TREE, R_TREE, R_STAR_TREE,
  BALL_TREE, X_TREE, HILBERT_R_TREE, R_PLUS_TREE,
  R_PLUS_PLUS_TREE, VP_TREE, RP_TREE, MAX_RP_TREE,
  UB_TREE, OCTREE
}
 

Public Member Functions

 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. More...
 
 RSModel (const RSModel &other)
 Copy the given RSModel. More...
 
 RSModel (RSModel &&other)
 Take ownership of the given RSModel. More...
 
RSModeloperator= (const RSModel &other)
 Copy the given RSModel. More...
 
RSModeloperator= (RSModel &&other)
 Take ownership of the given RSModel's data. More...
 
 ~RSModel ()
 Clean memory, if necessary.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the range search model.
 
const arma::mat & Dataset () const
 Expose the dataset.
 
bool SingleMode () const
 Get whether the model is in single-tree search mode.
 
bool & SingleMode ()
 Modify whether the model is in single-tree search mode.
 
bool Naive () const
 Get whether the model is in naive search mode.
 
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).
 
size_t & LeafSize ()
 Modify the leaf size (applicable to everything but the cover tree).
 
TreeTypes TreeType () const
 Get the type of tree.
 
TreeTypes & TreeType ()
 Modify the type of tree (don't do this after the model has been built).
 
bool RandomBasis () const
 Get whether a random basis is used.
 
bool & RandomBasis ()
 Modify whether a random basis is used (don't do this after the model has been built). More...
 
void InitializeModel (const bool naive, const bool singleMode)
 Allocate the memory for the range search model.
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

The RSModel class provides an abstraction for the RangeSearch class, abstracting away the TreeType parameter and allowing it to be specified at runtime.

This class is written for the sake of the range_search binding, but is not necessarily restricted to that usage.

Constructor & Destructor Documentation

◆ RSModel() [1/3]

mlpack::range::RSModel::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.

Initialize the RSModel with the given tree type and whether or not a random basis should be used.

Parameters
treeTypeType of tree to use.
randomBasisWhether or not to use a random basis.

◆ RSModel() [2/3]

mlpack::range::RSModel::RSModel ( const RSModel other)

Copy the given RSModel.

Parameters
otherRSModel to copy.

◆ RSModel() [3/3]

mlpack::range::RSModel::RSModel ( RSModel &&  other)

Take ownership of the given RSModel.

Parameters
otherRSModel to take ownership of.

Member Function Documentation

◆ BuildModel()

void mlpack::range::RSModel::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.

This takes possession of the reference set to avoid a copy.

Parameters
referenceSetSet of reference points.
leafSizeLeaf size of tree (ignored for the cover tree).
naiveWhether naive search should be used.
singleModeWhether single-tree search should be used.

◆ operator=() [1/2]

RSModel & mlpack::range::RSModel::operator= ( const RSModel other)

Copy the given RSModel.

Parameters
otherRSModel to copy.

◆ operator=() [2/2]

RSModel & mlpack::range::RSModel::operator= ( RSModel &&  other)

Take ownership of the given RSModel's data.

Parameters
otherRSModel to copy.

◆ RandomBasis()

bool& mlpack::range::RSModel::RandomBasis ( )
inline

Modify whether a random basis is used (don't do this after the model has been built).

◆ Search() [1/2]

void mlpack::range::RSModel::Search ( arma::mat &&  querySet,
const math::Range range,
std::vector< std::vector< size_t >> &  neighbors,
std::vector< std::vector< double >> &  distances 
)

Perform range search.

This takes possession of the query set, so the query set will not be usable after the search. For more information on the output format, see RangeSearch<>::Search().

Parameters
querySetSet of query points.
rangeRange to search for.
neighborsOutput: neighbors falling within the desired range.
distancesOutput: distances of neighbors.

◆ Search() [2/2]

void mlpack::range::RSModel::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.

For more information on the output format, see RangeSearch<>::Search().

Parameters
rangeRange to search for.
neighborsOutput: neighbors falling within the desired range.
distancesOutput: distances of neighbors.

The documentation for this class was generated from the following files: