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

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

Private Member Functions

void CleanMemory ()
 Clean up memory. More...
 
std::string TreeName () const
 Return a string representing the name of the tree. More...
 

Private Attributes

size_t leafSize
 
arma::mat q
 Random projection matrix. More...
 
bool randomBasis
 If true, we randomly project the data into a new basis before search. More...
 
boost::variant< RSType< tree::KDTree > *, RSType< tree::StandardCoverTree > *, RSType< tree::RTree > *, RSType< tree::RStarTree > *, RSType< tree::BallTree > *, RSType< tree::XTree > *, RSType< tree::HilbertRTree > *, RSType< tree::RPlusTree > *, RSType< tree::RPlusPlusTree > *, RSType< tree::VPTree > *, RSType< tree::RPTree > *, RSType< tree::MaxRPTree > *, RSType< tree::UBTree > *, RSType< tree::Octree > * > rSearch
 rSearch holds an instance of the RangeSearch class for the current treeType. More...
 
TreeTypes treeType
 

Detailed Description

Definition at line 238 of file rs_model.hpp.

Member Enumeration Documentation

Enumerator
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 

Definition at line 241 of file rs_model.hpp.

Constructor & Destructor Documentation

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.

Parameters
treeTypeType of tree to use.
randomBasisWhether or not to use a random basis.
mlpack::range::RSModel::RSModel ( const RSModel other)

Copy the given RSModel.

Parameters
otherRSModel to copy.
mlpack::range::RSModel::RSModel ( RSModel &&  other)

Take ownership of the given RSModel.

Parameters
otherRSModel to take ownership of.
mlpack::range::RSModel::~RSModel ( )

Clean memory, if necessary.

Member Function Documentation

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.
void mlpack::range::RSModel::CleanMemory ( )
private

Clean up memory.

const arma::mat& mlpack::range::RSModel::Dataset ( ) const

Expose the dataset.

size_t mlpack::range::RSModel::LeafSize ( ) const
inline

Get the leaf size (applicable to everything but the cover tree).

Definition at line 350 of file rs_model.hpp.

size_t& mlpack::range::RSModel::LeafSize ( )
inline

Modify the leaf size (applicable to everything but the cover tree).

Definition at line 352 of file rs_model.hpp.

bool mlpack::range::RSModel::Naive ( ) const

Get whether the model is in naive search mode.

bool& mlpack::range::RSModel::Naive ( )

Modify whether the model is in naive search mode.

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

Copy the given RSModel.

Parameters
otherRSModel to copy.
RSModel& mlpack::range::RSModel::operator= ( RSModel &&  other)

Take ownership of the given RSModel.

Parameters
otherRSModel to take ownership of.
bool mlpack::range::RSModel::RandomBasis ( ) const
inline

Get whether a random basis is used.

Definition at line 360 of file rs_model.hpp.

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

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

Definition at line 363 of file rs_model.hpp.

References string().

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.
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.
template<typename Archive >
void mlpack::range::RSModel::Serialize ( Archive &  ar,
const unsigned  int 
)

Serialize the range search model.

bool mlpack::range::RSModel::SingleMode ( ) const

Get whether the model is in single-tree search mode.

bool& mlpack::range::RSModel::SingleMode ( )

Modify whether the model is in single-tree search mode.

std::string mlpack::range::RSModel::TreeName ( ) const
private

Return a string representing the name of the tree.

This is used for logging output.

TreeTypes mlpack::range::RSModel::TreeType ( ) const
inline

Get the type of tree.

Definition at line 355 of file rs_model.hpp.

TreeTypes& mlpack::range::RSModel::TreeType ( )
inline

Modify the type of tree (don't do this after the model has been built).

Definition at line 357 of file rs_model.hpp.

Member Data Documentation

size_t mlpack::range::RSModel::leafSize
private

Definition at line 261 of file rs_model.hpp.

arma::mat mlpack::range::RSModel::q
private

Random projection matrix.

Definition at line 266 of file rs_model.hpp.

bool mlpack::range::RSModel::randomBasis
private

If true, we randomly project the data into a new basis before search.

Definition at line 264 of file rs_model.hpp.

rSearch holds an instance of the RangeSearch class for the current treeType.

It is initialized every time BuildModel is executed. We access to the contained value through the visitor classes defined above.

Definition at line 286 of file rs_model.hpp.

TreeTypes mlpack::range::RSModel::treeType
private

Definition at line 260 of file rs_model.hpp.


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