Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
rtflann::AutotunedIndex< Distance > Class Template Reference

#include <autotuned_index.h>

Inheritance diagram for rtflann::AutotunedIndex< Distance >:
Inheritance graph
[legend]

Classes

struct  CostData
 

Public Types

typedef NNIndex< Distance > BaseClass
 
typedef Distance::ResultType DistanceType
 
typedef Distance::ElementType ElementType
 
typedef AutotunedIndex< Distance > IndexType
 
typedef bool needs_kdtree_distance
 
- Public Types inherited from rtflann::NNIndex< Distance >
typedef Distance::ResultType DistanceType
 
typedef Distance::ElementType ElementType
 

Public Member Functions

void addPoints (const Matrix< ElementType > &points, float rebuild_threshold=2)
 Incrementally add points to the index. More...
 
 AutotunedIndex (const Matrix< ElementType > &inputData, const IndexParams &params=AutotunedIndexParams(), Distance d=Distance())
 
 AutotunedIndex (const IndexParams &params=AutotunedIndexParams(), Distance d=Distance())
 
 AutotunedIndex (const AutotunedIndex &other)
 
void buildIndex ()
 
void buildIndex (const Matrix< ElementType > &dataset)
 
BaseClassclone () const
 
void findNeighbors (ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams) const
 
IndexParams getParameters () const
 
FLANN_DEPRECATED SearchParams getSearchParameters () const
 
FLANN_DEPRECATED float getSpeedup () const
 
flann_algorithm_t getType () const
 
int knnSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
void loadIndex (FILE *stream)
 
AutotunedIndexoperator= (AutotunedIndex other)
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, DistanceType radius, const SearchParams &params) const
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, DistanceType radius, const SearchParams &params) const
 
void removePoint (size_t id)
 
void saveIndex (FILE *stream)
 
template<typename Archive >
void serialize (Archive &ar)
 
size_t size () const
 
int usedMemory () const
 
size_t veclen () const
 
virtual ~AutotunedIndex ()
 
- Public Member Functions inherited from rtflann::NNIndex< Distance >
IndexParams getParameters () const
 
virtual ElementTypegetPoint (size_t id)
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 
 NNIndex (Distance d)
 
 NNIndex (const IndexParams &params, Distance d)
 
 NNIndex (const NNIndex &other)
 
virtual int radiusSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 
virtual int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 
size_t removedCount () const
 
template<typename Archive >
void serialize (Archive &ar)
 
size_t size () const
 
size_t sizeAtBuild () const
 
size_t veclen () const
 
virtual ~NNIndex ()
 
- Public Member Functions inherited from rtflann::IndexBase
virtual ~IndexBase ()
 

Protected Member Functions

void buildIndexImpl ()
 
void freeIndex ()
 
- Protected Member Functions inherited from rtflann::NNIndex< Distance >
void cleanRemovedPoints ()
 
void extendDataset (const Matrix< ElementType > &new_points)
 
size_t id_to_index (size_t id)
 
void indices_to_ids (const size_t *in, size_t *out, size_t size) const
 
void setDataset (const Matrix< ElementType > &dataset)
 
void swap (NNIndex &other)
 

Private Member Functions

IndexParams estimateBuildParams ()
 
float estimateSearchParams (SearchParams &searchParams)
 
void evaluate_kdtree (CostData &cost)
 
void evaluate_kmeans (CostData &cost)
 
void optimizeKDTree (std::vector< CostData > &costs)
 
void optimizeKMeans (std::vector< CostData > &costs)
 
void swap (AutotunedIndex &other)
 

Private Attributes

NNIndex< Distance > * bestIndex_
 
IndexParams bestParams_
 
SearchParams bestSearchParams_
 
float build_weight_
 
Matrix< ElementTypedataset_
 
Matrix< size_t > gt_matches_
 
float memory_weight_
 
float sample_fraction_
 
Matrix< ElementTypesampledDataset_
 
float speedup_
 
float target_precision_
 
Matrix< ElementTypetestDataset_
 

Additional Inherited Members

- Protected Attributes inherited from rtflann::NNIndex< Distance >
ElementTypedata_ptr_
 
Distance distance_
 
std::vector< size_t > ids_
 
IndexParams index_params_
 
size_t last_id_
 
std::vector< ElementType * > points_
 
bool removed_
 
size_t removed_count_
 
DynamicBitset removed_points_
 
size_t size_
 
size_t size_at_build_
 
size_t veclen_
 

Detailed Description

template<typename Distance>
class rtflann::AutotunedIndex< Distance >

Definition at line 73 of file autotuned_index.h.

Member Typedef Documentation

◆ BaseClass

template<typename Distance >
typedef NNIndex<Distance> rtflann::AutotunedIndex< Distance >::BaseClass

Definition at line 79 of file autotuned_index.h.

◆ DistanceType

template<typename Distance >
typedef Distance::ResultType rtflann::AutotunedIndex< Distance >::DistanceType

Definition at line 77 of file autotuned_index.h.

◆ ElementType

template<typename Distance >
typedef Distance::ElementType rtflann::AutotunedIndex< Distance >::ElementType

Definition at line 76 of file autotuned_index.h.

◆ IndexType

template<typename Distance >
typedef AutotunedIndex<Distance> rtflann::AutotunedIndex< Distance >::IndexType

Definition at line 81 of file autotuned_index.h.

◆ needs_kdtree_distance

template<typename Distance >
typedef bool rtflann::AutotunedIndex< Distance >::needs_kdtree_distance

Definition at line 83 of file autotuned_index.h.

Constructor & Destructor Documentation

◆ AutotunedIndex() [1/3]

template<typename Distance >
rtflann::AutotunedIndex< Distance >::AutotunedIndex ( const Matrix< ElementType > &  inputData,
const IndexParams params = AutotunedIndexParams(),
Distance  d = Distance() 
)
inline

Definition at line 85 of file autotuned_index.h.

◆ AutotunedIndex() [2/3]

template<typename Distance >
rtflann::AutotunedIndex< Distance >::AutotunedIndex ( const IndexParams params = AutotunedIndexParams(),
Distance  d = Distance() 
)
inline

Definition at line 94 of file autotuned_index.h.

◆ AutotunedIndex() [3/3]

template<typename Distance >
rtflann::AutotunedIndex< Distance >::AutotunedIndex ( const AutotunedIndex< Distance > &  other)
inline

Definition at line 103 of file autotuned_index.h.

◆ ~AutotunedIndex()

template<typename Distance >
virtual rtflann::AutotunedIndex< Distance >::~AutotunedIndex ( )
inlinevirtual

Definition at line 122 of file autotuned_index.h.

Member Function Documentation

◆ addPoints()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::addPoints ( const Matrix< ElementType > &  points,
float  rebuild_threshold = 2 
)
inlinevirtual

Incrementally add points to the index.

Parameters
pointsMatrix with points to be added
rebuild_threshold

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 164 of file autotuned_index.h.

◆ buildIndex() [1/2]

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::buildIndex ( )
inlinevirtual

Method responsible with building the index.

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 135 of file autotuned_index.h.

◆ buildIndex() [2/2]

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::buildIndex ( const Matrix< ElementType > &  dataset)
inlinevirtual

Builds the index using the specified dataset

Parameters
datasetthe dataset to use

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 157 of file autotuned_index.h.

◆ buildIndexImpl()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::buildIndexImpl ( )
inlineprotectedvirtual

Implements rtflann::NNIndex< Distance >.

Definition at line 349 of file autotuned_index.h.

◆ clone()

template<typename Distance >
BaseClass* rtflann::AutotunedIndex< Distance >::clone ( ) const
inlinevirtual

Implements rtflann::NNIndex< Distance >.

Definition at line 127 of file autotuned_index.h.

◆ estimateBuildParams()

template<typename Distance >
IndexParams rtflann::AutotunedIndex< Distance >::estimateBuildParams ( )
inlineprivate

Chooses the best nearest-neighbor algorithm and estimates the optimal parameters to use when building the index (for a given precision). Returns a dictionary with the optimal parameters.

Definition at line 560 of file autotuned_index.h.

◆ estimateSearchParams()

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::estimateSearchParams ( SearchParams searchParams)
inlineprivate

Estimates the search time parameters needed to get the desired precision. Precondition: the index is built Postcondition: the searchParams will have the optimum params set, also the speedup obtained over linear search.

Definition at line 647 of file autotuned_index.h.

◆ evaluate_kdtree()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::evaluate_kdtree ( CostData cost)
inlineprivate

Definition at line 397 of file autotuned_index.h.

◆ evaluate_kmeans()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::evaluate_kmeans ( CostData cost)
inlineprivate

Definition at line 370 of file autotuned_index.h.

◆ findNeighbors()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::findNeighbors ( ResultSet< DistanceType > &  result,
const ElementType vec,
const SearchParams searchParams 
) const
inlinevirtual

Method that searches for nearest-neighbors

Implements rtflann::NNIndex< Distance >.

Definition at line 294 of file autotuned_index.h.

◆ freeIndex()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::freeIndex ( )
inlineprotectedvirtual

Implements rtflann::NNIndex< Distance >.

Definition at line 354 of file autotuned_index.h.

◆ getParameters()

template<typename Distance >
IndexParams rtflann::AutotunedIndex< Distance >::getParameters ( ) const
inlinevirtual

Implements rtflann::IndexBase.

Definition at line 300 of file autotuned_index.h.

◆ getSearchParameters()

template<typename Distance >
FLANN_DEPRECATED SearchParams rtflann::AutotunedIndex< Distance >::getSearchParameters ( ) const
inline

Definition at line 305 of file autotuned_index.h.

◆ getSpeedup()

template<typename Distance >
FLANN_DEPRECATED float rtflann::AutotunedIndex< Distance >::getSpeedup ( ) const
inline

Definition at line 310 of file autotuned_index.h.

◆ getType()

template<typename Distance >
flann_algorithm_t rtflann::AutotunedIndex< Distance >::getType ( ) const
inlinevirtual

Algorithm name

Implements rtflann::IndexBase.

Definition at line 343 of file autotuned_index.h.

◆ knnSearch() [1/2]

template<typename Distance >
int rtflann::AutotunedIndex< Distance >::knnSearch ( const Matrix< ElementType > &  queries,
Matrix< size_t > &  indices,
Matrix< DistanceType > &  dists,
size_t  knn,
const SearchParams params 
) const
inlinevirtual

Perform k-nearest neighbor search.

Parameters
[in]queriesThe query points for which to find the nearest neighbors
[out]indicesThe indices of the nearest neighbors found
[out]distsDistances to the nearest neighbors found
[in]knnNumber of nearest neighbors to return
[in]paramsSearch parameters

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 232 of file autotuned_index.h.

◆ knnSearch() [2/2]

template<typename Distance >
int rtflann::AutotunedIndex< Distance >::knnSearch ( const Matrix< ElementType > &  queries,
std::vector< std::vector< size_t > > &  indices,
std::vector< std::vector< DistanceType > > &  dists,
size_t  knn,
const SearchParams params 
) const
inlinevirtual

Perform k-nearest neighbor search.

Parameters
queries
indices
dists
knn
params
Returns
Parameters
[in]queriesThe query points for which to find the nearest neighbors
[out]indicesThe indices of the nearest neighbors found
[out]distsDistances to the nearest neighbors found
[in]knnNumber of nearest neighbors to return
[in]paramsSearch parameters

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 246 of file autotuned_index.h.

◆ loadIndex()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::loadIndex ( FILE *  stream)
inlinevirtual

Implements rtflann::IndexBase.

Definition at line 219 of file autotuned_index.h.

◆ operator=()

template<typename Distance >
AutotunedIndex& rtflann::AutotunedIndex< Distance >::operator= ( AutotunedIndex< Distance >  other)
inline

Definition at line 116 of file autotuned_index.h.

◆ optimizeKDTree()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::optimizeKDTree ( std::vector< CostData > &  costs)
inlineprivate

Definition at line 518 of file autotuned_index.h.

◆ optimizeKMeans()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::optimizeKMeans ( std::vector< CostData > &  costs)
inlineprivate

Definition at line 470 of file autotuned_index.h.

◆ radiusSearch() [1/2]

template<typename Distance >
int rtflann::AutotunedIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
Matrix< size_t > &  indices,
Matrix< DistanceType > &  dists,
DistanceType  radius,
const SearchParams params 
) const
inline

Definition at line 261 of file autotuned_index.h.

◆ radiusSearch() [2/2]

template<typename Distance >
int rtflann::AutotunedIndex< Distance >::radiusSearch ( const Matrix< ElementType > &  queries,
std::vector< std::vector< size_t > > &  indices,
std::vector< std::vector< DistanceType > > &  dists,
DistanceType  radius,
const SearchParams params 
) const
inline

Definition at line 275 of file autotuned_index.h.

◆ removePoint()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::removePoint ( size_t  id)
inlinevirtual

Remove point from the index

Parameters
indexIndex of point to be removed

Reimplemented from rtflann::NNIndex< Distance >.

Definition at line 171 of file autotuned_index.h.

◆ saveIndex()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::saveIndex ( FILE *  stream)
inlinevirtual

Implements rtflann::IndexBase.

Definition at line 209 of file autotuned_index.h.

◆ serialize()

template<typename Distance >
template<typename Archive >
void rtflann::AutotunedIndex< Distance >::serialize ( Archive &  ar)
inline

Definition at line 180 of file autotuned_index.h.

◆ size()

template<typename Distance >
size_t rtflann::AutotunedIndex< Distance >::size ( ) const
inlinevirtual

Number of features in this index.

Implements rtflann::IndexBase.

Definition at line 319 of file autotuned_index.h.

◆ swap()

template<typename Distance >
void rtflann::AutotunedIndex< Distance >::swap ( AutotunedIndex< Distance > &  other)
inlineprivate

Definition at line 720 of file autotuned_index.h.

◆ usedMemory()

template<typename Distance >
int rtflann::AutotunedIndex< Distance >::usedMemory ( ) const
inlinevirtual

The amount of memory (in bytes) this index uses.

Implements rtflann::IndexBase.

Definition at line 335 of file autotuned_index.h.

◆ veclen()

template<typename Distance >
size_t rtflann::AutotunedIndex< Distance >::veclen ( ) const
inlinevirtual

The length of each vector in this index.

Implements rtflann::IndexBase.

Definition at line 327 of file autotuned_index.h.

Member Data Documentation

◆ bestIndex_

template<typename Distance >
NNIndex<Distance>* rtflann::AutotunedIndex< Distance >::bestIndex_
private

Definition at line 735 of file autotuned_index.h.

◆ bestParams_

template<typename Distance >
IndexParams rtflann::AutotunedIndex< Distance >::bestParams_
private

Definition at line 737 of file autotuned_index.h.

◆ bestSearchParams_

template<typename Distance >
SearchParams rtflann::AutotunedIndex< Distance >::bestSearchParams_
private

Definition at line 738 of file autotuned_index.h.

◆ build_weight_

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::build_weight_
private

Definition at line 755 of file autotuned_index.h.

◆ dataset_

template<typename Distance >
Matrix<ElementType> rtflann::AutotunedIndex< Distance >::dataset_
private

The dataset used by this index

Definition at line 749 of file autotuned_index.h.

◆ gt_matches_

template<typename Distance >
Matrix<size_t> rtflann::AutotunedIndex< Distance >::gt_matches_
private

Definition at line 742 of file autotuned_index.h.

◆ memory_weight_

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::memory_weight_
private

Definition at line 756 of file autotuned_index.h.

◆ sample_fraction_

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::sample_fraction_
private

Definition at line 757 of file autotuned_index.h.

◆ sampledDataset_

template<typename Distance >
Matrix<ElementType> rtflann::AutotunedIndex< Distance >::sampledDataset_
private

Definition at line 740 of file autotuned_index.h.

◆ speedup_

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::speedup_
private

Definition at line 744 of file autotuned_index.h.

◆ target_precision_

template<typename Distance >
float rtflann::AutotunedIndex< Distance >::target_precision_
private

Index parameters

Definition at line 754 of file autotuned_index.h.

◆ testDataset_

template<typename Distance >
Matrix<ElementType> rtflann::AutotunedIndex< Distance >::testDataset_
private

Definition at line 741 of file autotuned_index.h.


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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:39:00