Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET > Class Template Reference

Collects multiple results, avoiding duplicates. More...

#include <result_tracker_dupless.hpp>

Inheritance diagram for FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >:
FST::Clonable_Impl< Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker< RETURNTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP > FST::Result_Tracker< RETURNTYPE, SUBSET > FST::Clonable FST::Clonable_Impl< Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP > FST::Clonable_Impl< Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP > FST::Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET > FST::Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >

Public Types

typedef Result_Tracker< RETURNTYPE, SUBSET > parent
 the abstract Result_Tracker interface this class implements
typedef Clonable_Impl< Result_Tracker_Dupless, parent, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP > parent_impl
 implements stateless_clone() via the copy-constructor (CLONE_DEEP); clone()/sharing_clone() are inherited from Result_Tracker, which throws for both
typedef parent::ResultRec ResultRec
 see Result_Tracker::ResultRec
typedef parent::PResultRec PResultRec
 see Result_Tracker::PResultRec
typedef std::shared_ptr< SUBSET > PSubset
typedef std::list< ResultRec >::const_iterator CONSTRESULTSITER
 read-only iterator over results, for use by subclasses/friends inspecting the collected results
typedef std::list< ResultRec >::iterator RESULTSITER
 mutable iterator over results, as returned by begin()/end()
Public Types inherited from FST::Result_Tracker< RETURNTYPE, SUBSET >
typedef std::shared_ptr< SUBSET > PSubset
 shared pointer to a tracked feature subset
typedef ResultRec * PResultRec
 raw pointer to a ResultRec, as used by get_first()/get_next() iteration

Public Member Functions

 Result_Tracker_Dupless (const IDXTYPE capacity_limit=0)
 Result_Tracker_Dupless (const Result_Tracker_Dupless &rtd)
 copies the configuration (margin, cardinality restriction, capacity limit) only; the results list is NOT copied (starts empty) – this constructor backs stateless_clone() (CLONE_DEEP), which by contract does not replicate exact object state
virtual bool add (const RETURNTYPE value, const PSubset sub) override
 Offers one (value, subset) result for inclusion; sub is copied, the caller keeps ownership of its own object.
virtual void clear () override
 discards all recorded results
virtual std::size_t size () const override
 number of results currently held (std::size_t rather than 'long': on LLP64 platforms 'long' is 32 bits and would narrow the container's own size type)
virtual std::size_t size (const RETURNTYPE margin) const
 number of currently held results whose value is within margin of the best (first, highest-value) held result
virtual bool get_first (PResultRec &r) override
 starts iteration at the best held result; false if nothing is held. The returned pointer refers into this tracker's own storage and is invalidated by add(), join() and clear()
virtual bool get_next (PResultRec &r) override
 hands out the next result in descending-value order; false when the iteration is exhausted. There is one shared cursor per tracker, so nested or concurrent iterations of the same tracker interfere
virtual void join (Result_Tracker< RETURNTYPE, SUBSET > &src) override
 merges the results held by src into this tracker, keeping the ordering and skipping duplicates exactly as add() does, then re-applies the capacity limit and the margin to the merged list. Consumes src's iteration cursor; src itself is left unchanged
void set_inclusion_margin (const RETURNTYPE margin=0)
 restrict adding to only subsets with criterion value within given distance (margin) from best known
void set_inclusion_cardinality_restriction (const DIMTYPE d)
 for d>0 restricts adding only to subsets of size d, for d=0 subset size restriction is removed
virtual std::ostream & print (std::ostream &os) const override
 writes a human-readable identification of the object; base default writes nothing
RESULTSITER begin ()
 iterator to the best (first) held result
RESULTSITER end ()
 iterator past the last held result
Public Member Functions inherited from FST::Clonable_Impl< Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker< RETURNTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >
Result_Tracker< RETURNTYPE, SUBSET > * clone () const override
 dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor)
Result_Tracker< RETURNTYPE, SUBSET > * sharing_clone () const override
 dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Result_Tracker< RETURNTYPE, SUBSET > * stateless_clone () const override
 dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Public Member Functions inherited from FST::Result_Tracker< RETURNTYPE, SUBSET >
 Result_Tracker (const Result_Tracker &rt)
 copies the output-detail setting only – concrete trackers copy their own collected results separately
Result_Tracker * clone () const override
Result_Tracker * sharing_clone () const override
void set_output_detail (OutputDetail detail)
 sets the amount of information that is logged to output stream throughout the course of search
OutputDetail get_output_detail () const
 the currently configured output detail level
bool output_normal () const
 true unless output detail is SILENT
bool output_detailed () const
 true only at the DETAILED output level
Public Member Functions inherited from FST::Clonable
bool is_clone () const
bool is_sharing () const
 true if this instance is a sharing_clone() result (referencing, not owning, the source's structures)
bool is_sharing_clone () const
 true if this instance is BOTH a clone and sharing – i.e. specifically a sharing_clone() result, not a clone()/stateless_clone() one

Protected Attributes

std::list< ResultRec > results
 held results, sorted descending by value (ties broken toward the smaller subset); see add() for the exact insertion/dedup/trim rule
RETURNTYPE _margin
 set via set_inclusion_margin(); 0 = no margin restriction
DIMTYPE _restrict_to_d
 set via set_inclusion_cardinality_restriction(); 0 = no subset-size restriction
const IDXTYPE _capacity_limit
 set by the constructor; 0 = unlimited
Protected Attributes inherited from FST::Result_Tracker< RETURNTYPE, SUBSET >
OutputDetail _detail
 the output detail level set via set_output_detail(); read by output_normal()/output_detailed()

Private Attributes

RESULTSITER getiter
 iteration cursor for get_first()/get_next() (single shared cursor, not reentrant)

Additional Inherited Members

Protected Member Functions inherited from FST::Clonable
void set_cloned (const bool cloned=true)
 marks/unmarks this instance as a clone; call from clone()/stateless_clone() overrides (Clonable_Impl does this automatically)
void set_sharing (const bool sharing=true)
 marks/unmarks this instance as sharing (see is_sharing())
void set_sharing_cloned (const bool cloned=true, const bool sharing=true)
 sets both flags at once; call from sharing_clone() overrides (Clonable_Impl does this automatically)

Detailed Description

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
class FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >

Collects multiple results, avoiding duplicates.

See Result_Tracker description why this is needed. Upon adding, sorts results descending according to value, in case of ties smaller subset is considered better.

Member Typedef Documentation

◆ PSubset

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
typedef std::shared_ptr<SUBSET> FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::PSubset

shared pointer to a tracked feature subset

Constructor & Destructor Documentation

◆ Result_Tracker_Dupless()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::Result_Tracker_Dupless ( const IDXTYPE capacity_limit = 0)
inline
Parameters
capacity_limitif nonzero, caps the number of retained results (the tail, i.e. the worst-valued results, is trimmed as new results are inserted); 0 = unlimited

Member Function Documentation

◆ add()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
bool FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::add ( const RETURNTYPE value,
const PSubset sub )
overridevirtual

Offers one (value, subset) result for inclusion; sub is copied, the caller keeps ownership of its own object.

The result is declined (false is returned) when

  • a cardinality restriction is in effect and sub->get_d() differs from it (see set_inclusion_cardinality_restriction()),
  • a margin is in effect and value falls more than the margin below the best value held so far (see set_inclusion_margin()),
  • an equivalent subset of the same value and the same cardinality is already held (duplicates are looked for only among results with exactly that value and cardinality - results differing in value are never compared feature-wise).

Otherwise the result is sorted into the list, which stays ordered by descending value, and among equal values by ascending cardinality (the smaller subset counts as the better one). A result that becomes the new best additionally trims the tail of results that thereby fell outside the margin. Finally, a nonzero capacity limit trims the worst-valued results away - which may discard the just inserted result itself if it ended up at the tail; true only reports that the result was accepted for insertion.

Implements FST::Result_Tracker< RETURNTYPE, SUBSET >.

◆ clear()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
virtual void FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::clear ( )
inlineoverridevirtual

discards all recorded results

Implements FST::Result_Tracker< RETURNTYPE, SUBSET >.

◆ get_first()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
bool FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::get_first ( PResultRec & r)
overridevirtual

starts iteration at the best held result; false if nothing is held. The returned pointer refers into this tracker's own storage and is invalidated by add(), join() and clear()

Implements FST::Result_Tracker< RETURNTYPE, SUBSET >.

◆ get_next()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
bool FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::get_next ( PResultRec & r)
overridevirtual

hands out the next result in descending-value order; false when the iteration is exhausted. There is one shared cursor per tracker, so nested or concurrent iterations of the same tracker interfere

Implements FST::Result_Tracker< RETURNTYPE, SUBSET >.

◆ join()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
void FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::join ( Result_Tracker< RETURNTYPE, SUBSET > & src)
overridevirtual

merges the results held by src into this tracker, keeping the ordering and skipping duplicates exactly as add() does, then re-applies the capacity limit and the margin to the merged list. Consumes src's iteration cursor; src itself is left unchanged

Reimplemented from FST::Result_Tracker< RETURNTYPE, SUBSET >.

◆ print()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
virtual std::ostream & FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::print ( std::ostream & os) const
inlineoverridevirtual

writes a human-readable identification of the object; base default writes nothing

Reimplemented from FST::Clonable.

Reimplemented in FST::Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, and FST::Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ size()

template<class RETURNTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET>
virtual std::size_t FST::Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >::size ( ) const
inlineoverridevirtual

number of results currently held (std::size_t rather than 'long': on LLP64 platforms 'long' is 32 bits and would narrow the container's own size type)

Implements FST::Result_Tracker< RETURNTYPE, SUBSET >.


The documentation for this class was generated from the following file:
Copyright © 2000–present ÚTIA, Institute of Information Theory and Automation of the Czech Academy of Sciences · Contacts · This site sets no cookies and uses no analytics.