The RSModel class provides an abstraction for the RangeSearch class, abstracting away the TreeType parameter and allowing it to be specified at runtime. More...
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 (util::Timers &timers, 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... | |
void | InitializeModel (const bool naive, const bool singleMode) |
Allocate the memory for the range search model. 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... | |
RSModel & | operator= (const RSModel &other) |
Copy the given RSModel. More... | |
RSModel & | operator= (RSModel &&other) |
Take ownership of the given RSModel's data. 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 (util::Timers &timers, 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 (util::Timers &timers, 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 uint32_t) |
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... | |
TreeTypes & | TreeType () |
Modify the type of tree (don't do this after the model has been built). More... | |
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.
Definition at line 214 of file rs_model.hpp.
enum TreeTypes |
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 217 of file rs_model.hpp.
Initialize the RSModel with the given type and whether or not a random basis should be used.
treeType | Type of tree to use. |
randomBasis | Whether or not to use a random basis. |
~RSModel | ( | ) |
Clean memory, if necessary.
void BuildModel | ( | util::Timers & | timers, |
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.
referenceSet | Set of reference points. |
leafSize | Leaf size of tree (ignored for the cover tree). |
naive | Whether naive search should be used. |
singleMode | Whether single-tree search should be used. |
|
inline |
Expose the dataset.
Definition at line 283 of file rs_model.hpp.
void InitializeModel | ( | const bool | naive, |
const bool | singleMode | ||
) |
Allocate the memory for the range search model.
|
inline |
Get the leaf size (applicable to everything but the cover tree).
Definition at line 296 of file rs_model.hpp.
|
inline |
Modify the leaf size (applicable to everything but the cover tree).
Definition at line 298 of file rs_model.hpp.
|
inline |
Get whether the model is in naive search mode.
Definition at line 291 of file rs_model.hpp.
|
inline |
Modify whether the model is in naive search mode.
Definition at line 293 of file rs_model.hpp.
|
inline |
Get whether a random basis is used.
Definition at line 306 of file rs_model.hpp.
|
inline |
Modify whether a random basis is used (don't do this after the model has been built).
Definition at line 309 of file rs_model.hpp.
References mlpack::bindings::tests::CleanMemory(), and RSWrapperBase::Search().
void Search | ( | util::Timers & | timers, |
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().
querySet | Set of query points. |
range | Range to search for. |
neighbors | Output: neighbors falling within the desired range. |
distances | Output: distances of neighbors. |
void Search | ( | util::Timers & | timers, |
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().
range | Range to search for. |
neighbors | Output: neighbors falling within the desired range. |
distances | Output: distances of neighbors. |
void serialize | ( | Archive & | ar, |
const uint32_t | |||
) |
Serialize the range search model.
|
inline |
Get whether the model is in single-tree search mode.
Definition at line 286 of file rs_model.hpp.
|
inline |
Modify whether the model is in single-tree search mode.
Definition at line 288 of file rs_model.hpp.
|
inline |
Get the type of tree.
Definition at line 301 of file rs_model.hpp.
|
inline |
Modify the type of tree (don't do this after the model has been built).
Definition at line 303 of file rs_model.hpp.