Parasol Planning Library (PPL)
NeighborhoodFinderMethod Class Referenceabstract

#include <NeighborhoodFinderMethod.h>

Inheritance diagram for NeighborhoodFinderMethod:
Inheritance graph
[legend]
Collaboration diagram for NeighborhoodFinderMethod:
Collaboration graph
[legend]

Public Types

Local Types
enum class  Type { K , RADIUS , APPROX , OTHER }
 The type of neighbors found. More...
 
typedef std::back_insert_iterator< std::vector< Neighbor > > OutputIterator
 Output iterator for writing discovered neighbors to a container. More...
 
Motion Planning Types
typedef MPBaseObject::RoadmapType RoadmapType
 
typedef RoadmapType::VID VID
 
typedef RoadmapType::VertexSet VertexSet
 
typedef MPBaseObject::GroupRoadmapType GroupRoadmapType
 
typedef MPBaseObject::GroupCfgType GroupCfgType
 
- Public Types inherited from MPBaseObject
typedef DefaultWeight< CfgWeightType
 
typedef GenericStateGraph< Cfg, WeightTypeRoadmapType
 
typedef GroupCfg< RoadmapTypeGroupCfgType
 
typedef GroupLocalPlan< RoadmapTypeGroupWeightType
 
typedef GroupRoadmap< GroupCfgType, GroupWeightTypeGroupRoadmapType
 

Public Member Functions

Construction
 NeighborhoodFinderMethod (const Type _type=Type::OTHER)
 
 NeighborhoodFinderMethod (XMLNode &_node, const Type _type=Type::OTHER, const bool _requireDM=true)
 
virtual ~NeighborhoodFinderMethod ()=default
 
MPBaseObject Overrides
virtual void Print (std::ostream &_os) const override
 
Accessors
Type GetType () const noexcept
 
virtual size_t & GetK () noexcept
 
virtual double & GetRadius () noexcept
 
virtual void SetDMLabel (const std::string &_label) noexcept
 
virtual const std::string & GetDMLabel () const noexcept
 
Nearest-Neighbor Queries
virtual void FindNeighbors (RoadmapType *const _r, const Cfg &_cfg, const VertexSet &_candidates, OutputIterator _out)=0
 
virtual void FindNeighbors (GroupRoadmapType *const _r, const GroupCfgType &_cfg, const VertexSet &_candidates, OutputIterator _out)=0
 
template<typename AbstractRoadmapType >
void FindNeighbors (AbstractRoadmapType *const _r, const typename AbstractRoadmapType::CfgType &_cfg, OutputIterator _out)
 
- Public Member Functions inherited from MPBaseObject
 MPBaseObject (const std::string &_label="", const std::string &_name="", bool _debug=false)
 
 MPBaseObject (XMLNode &_node)
 
virtual ~MPBaseObject ()
 
virtual void Initialize ()
 
const std::string & GetName () const
 Get the class name for this object. More...
 
const std::string & GetLabel () const
 Get the unique label for this object. More...
 
std::string GetNameAndLabel () const
 Get the unique string identifier for this object "m_name::m_label". More...
 
void SetLabel (const std::string &)
 Set the unique label for this object. More...
 
void SetMPLibrary (MPLibrary *) noexcept
 Set the owning MPLibrary. More...
 
MPLibraryGetMPLibrary () const noexcept
 Get the owning MPLibrary. More...
 
bool IsRunning () const noexcept
 Check the library's running flag. More...
 
MPProblemGetMPProblem () const noexcept
 Get the library's current MPProblem. More...
 
EnvironmentGetEnvironment () const noexcept
 Get the current environment. More...
 
MPTaskGetTask () const noexcept
 Get the current task. More...
 
GroupTaskGetGroupTask () const noexcept
 Get the current group task. More...
 
MPSolutionTypeGetMPSolution () const noexcept
 
RoadmapTypeGetRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current free-space roadmap. More...
 
GroupRoadmapTypeGetGroupRoadmap (RobotGroup *const _g=nullptr) const noexcept
 Get the current free-space group roadmap. More...
 
RoadmapTypeGetBlockRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current obstacle-space roadmap. More...
 
PathGetPath (Robot *const _r=nullptr) const noexcept
 
GroupPathGetGroupPath (RobotGroup *const _g=nullptr) const noexcept
 Get the current best group path. More...
 
StatClassGetStatClass () const noexcept
 Get the current StatClass. More...
 
LocalObstacleMapGetLocalObstacleMap () const noexcept
 Get the local obstacle map. More...
 

Protected Member Functions

Helpers
template<typename AbstractRoadmapType >
bool DirectEdge (const AbstractRoadmapType *_g, const typename AbstractRoadmapType::CfgType &_c, const typename AbstractRoadmapType::VID _v) const noexcept
 
- Protected Member Functions inherited from MPBaseObject
void SetName (const std::string &_s)
 
const std::string & GetBaseFilename () const
 

Protected Attributes

Internal State
Todo:
Remove m_k and m_radius - these don't apply to all NFs so it doesn't make sense to have them here. Fix design errors in SRT method which require this.
Type m_nfType {Type::OTHER}
 Type of neighborhood finder. More...
 
size_t m_k {0}
 How many closest neighbors to find? More...
 
double m_radius {0}
 Maximum distance of closest neighbors. More...
 
std::string m_dmLabel
 The distance metric to use. More...
 
bool m_unconnected {false}
 Require neighbors with no direct edge. More...
 
- Protected Attributes inherited from MPBaseObject
bool m_debug
 Print debug info? More...
 

Detailed Description

Base algorithm abstraction for NeighborhoodFinders, which are methods that solve nearest-neighbor queries against configurations in a roadmap.

The primary function 'FindNeighbors' takes an input configuration and optionally a set of candidate neighbors. It returns the computed set of "nearest" neighbors and their distances (through the 'Neighbor' structure). @usage

NeighborhoodFinderPointer nf = this->GetNeighborhoodFinder(m_nfLabel);
Cfg queryCfg;
VertexSet candidates;
std::vector<Neighbor> neighbors;
nf->FindNeighbors(this->GetRoadmap(), queryCfg, candidates,
std::back_inserter(neighbors));
Definition: Cfg.h:38
RoadmapType * GetRoadmap(Robot *const _r=nullptr) const noexcept
Get the current free-space roadmap.
Definition: MPBaseObject.cpp:123
RoadmapType::VertexSet VertexSet
Definition: NeighborhoodFinderMethod.h:41

Member Typedef Documentation

◆ GroupCfgType

◆ GroupRoadmapType

◆ OutputIterator

typedef std::back_insert_iterator<std::vector<Neighbor> > NeighborhoodFinderMethod::OutputIterator

Output iterator for writing discovered neighbors to a container.

◆ RoadmapType

◆ VertexSet

◆ VID

Member Enumeration Documentation

◆ Type

The type of neighbors found.

Enumerator

k-closest neighbors

RADIUS 

All neighbors within a radius.

APPROX 

Approximate nearest neighbors.

OTHER 

Something else.

Constructor & Destructor Documentation

◆ NeighborhoodFinderMethod() [1/2]

NeighborhoodFinderMethod::NeighborhoodFinderMethod ( const Type  _type = Type::OTHER)

◆ NeighborhoodFinderMethod() [2/2]

NeighborhoodFinderMethod::NeighborhoodFinderMethod ( XMLNode _node,
const Type  _type = Type::OTHER,
const bool  _requireDM = true 
)

◆ ~NeighborhoodFinderMethod()

virtual NeighborhoodFinderMethod::~NeighborhoodFinderMethod ( )
virtualdefault

Member Function Documentation

◆ DirectEdge()

template<typename AbstractRoadmapType >
bool NeighborhoodFinderMethod::DirectEdge ( const AbstractRoadmapType *  _g,
const typename AbstractRoadmapType::CfgType &  _c,
const typename AbstractRoadmapType::VID  _v 
) const
inlineprotectednoexcept

Checks if there is a direct edge to potential neighbor.

Parameters
_gThe roadmap graph we are searching.
_cThe query configuration.
_vA potential neighbor for _c.
Returns
True if there is already a direct edge from _c to _v.
Note
Takes linear time in |g|.

◆ FindNeighbors() [1/3]

template<typename AbstractRoadmapType >
void NeighborhoodFinderMethod::FindNeighbors ( AbstractRoadmapType *const  _r,
const typename AbstractRoadmapType::CfgType &  _cfg,
OutputIterator  _out 
)

◆ FindNeighbors() [2/3]

virtual void NeighborhoodFinderMethod::FindNeighbors ( GroupRoadmapType *const  _r,
const GroupCfgType _cfg,
const VertexSet _candidates,
OutputIterator  _out 
)
pure virtual

Implemented in RandomNF, RadiusNF, KdTreeNF, and BruteForceNF.

◆ FindNeighbors() [3/3]

virtual void NeighborhoodFinderMethod::FindNeighbors ( RoadmapType *const  _r,
const Cfg _cfg,
const VertexSet _candidates,
OutputIterator  _out 
)
pure virtual

Some methods can be implemented more efficiently if the candidates are provided in a hash set. This function is to support that; the default implementation forwards to the iterator version.

Parameters
_rThe roadmap.
_cfgThe query configuration.
_candidatesThe set of candidate VIDs.
_outOutput iterator.

Implemented in RandomNF, RadiusNF, KdTreeNF, and BruteForceNF.

◆ GetDMLabel()

const std::string & NeighborhoodFinderMethod::GetDMLabel ( ) const
inlinevirtualnoexcept

Get the distance metric label.

Returns
The label for the current DM.

◆ GetK()

size_t & NeighborhoodFinderMethod::GetK ( )
inlinevirtualnoexcept
Returns
Number of closest neighbors to find

◆ GetRadius()

double & NeighborhoodFinderMethod::GetRadius ( )
inlinevirtualnoexcept
Returns
Distance of farthest potential neighbor

◆ GetType()

NeighborhoodFinderMethod::Type NeighborhoodFinderMethod::GetType ( ) const
inlinenoexcept
Returns
Type of neighborhood finder

◆ Print()

void NeighborhoodFinderMethod::Print ( std::ostream &  _os) const
overridevirtual

Print internal state of this object.

Parameters
_osThe std::ostream to print to.

Reimplemented from MPBaseObject.

Reimplemented in RandomNF, RadiusNF, KdTreeNF, and BruteForceNF.

◆ SetDMLabel()

void NeighborhoodFinderMethod::SetDMLabel ( const std::string &  _label)
inlinevirtualnoexcept

Set the distance metric label.

Parameters
_labelThe new DM label to use.

Field Documentation

◆ m_dmLabel

std::string NeighborhoodFinderMethod::m_dmLabel
protected

The distance metric to use.

◆ m_k

size_t NeighborhoodFinderMethod::m_k {0}
protected

How many closest neighbors to find?

◆ m_nfType

Type NeighborhoodFinderMethod::m_nfType {Type::OTHER}
protected

Type of neighborhood finder.

◆ m_radius

double NeighborhoodFinderMethod::m_radius {0}
protected

Maximum distance of closest neighbors.

◆ m_unconnected

bool NeighborhoodFinderMethod::m_unconnected {false}
protected

Require neighbors with no direct edge.


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