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

Implements Branch and Bound with Partial Prediction (BBPP) method, i.e., with predicted node ordering. More...

#include <search_branch_and_bound_partial_prediction.hpp>

Inheritance diagram for FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >:
FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >

Public Types

typedef Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > parent
 base class alias
typedef parent::PCriterion PCriterion
 shared pointer to the criterion the search optimizes
typedef parent::PSubset PSubset
 shared pointer to a feature subset
typedef parent::PNode PNode
 pointer to a search-tree Node, see Search_Branch_And_Bound
typedef parent::Node Node
 search-tree node record (feature, value, type, valid), see Search_Branch_And_Bound
typedef parent::NodeType NodeType
 UNKNOWN/RANDOM/PREDICTED/COMPUTED node-value provenance, see Search_Branch_And_Bound.
typedef parent::PEvaluatorEngine PEvaluatorEngine
 shared pointer to the injected evaluation-strategy engine
Public Types inherited from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >
typedef Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > parent
 base class: the abstract Search interface (search(), progress reporting, result tracker)
typedef std::shared_ptr< CRITERION > PCriterion
 shared pointer to the criterion under optimization
typedef std::shared_ptr< SUBSET > PSubset
 shared pointer to a feature subset
typedef Candidate_Evaluator< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > EVALUATORENGINE
 the injected candidate-evaluation strategy type (sequential-inline or thread-pooled); process_leafs(), and descendants' pre_evaluate_availables()/post_process_tree_level() overrides, batch candidate evaluations through it
typedef std::shared_ptr< EVALUATORENGINE > PEvaluatorEngine
 shared pointer to an EVALUATORENGINE, as accepted by the constructor and returned by get_engine()

Public Member Functions

 Search_Branch_And_Bound_Partial_Prediction (PEvaluatorEngine engine=PEvaluatorEngine())
 engine forwarded to Search_Branch_And_Bound; defaults to sequential in-line evaluation if not supplied
virtual std::ostream & print (std::ostream &os) const override
 Writes the algorithm's name together with the prediction mechanism in use, and the thread count when a threaded evaluation engine is injected.
Public Member Functions inherited from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >
 Search_Branch_And_Bound (PEvaluatorEngine engine=PEvaluatorEngine())
 Constructs the search, optionally injecting a candidate-evaluation engine.
virtual bool search (const DIMTYPE target_d, RETURNTYPE &result, const PSubset sub, const PCriterion crit, std::ostream &os=std::cout) override
 returns the found subset of exactly target_d features + its criterion value; target_d must be nonzero (Branch & Bound searches one fixed cardinality, it does not optimize it)

Protected Member Functions

virtual void initialize (const DIMTYPE d, const DIMTYPE n, const PCriterion crit) override
 resets the prediction mechanism for a feature space of n features; nothing else needs setting up for BBPP
virtual void leaf_result (const DIMTYPE feature, const RETURNTYPE value) override
virtual void pre_evaluate_availables () override
 Assigns an ordering value to every available feature: predicted (parent value minus the predicted contrast) where the predictor already has evidence for that feature, otherwise the exact criterion value, obtained in one batch through the evaluation engine and fed back to the predictor.
virtual void post_process_tree_level () override
 Replaces the merely PREDICTED values of the nodes that made it into the new tree level by exact criterion values (again in one engine batch). This is what makes the method PARTIAL prediction: predictions decide the ORDER of the level only, while every node on the tree path carries a true value, so a cut is never based on an estimate and optimality is preserved.
virtual bool cut_possible () override
 Returns true when the current node's value does not exceed the current bound, so the whole sub-branch below it can be cut. The value is always exact here (post_process_tree_level() has made it COMPUTED), so no lazy evaluation is needed; returns false while no bound is valid yet.
Protected Member Functions inherited from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >
PCriterion const & get_criterion () const
 accessor for _criterion, for use by descendant B&B variants' hooks
PEvaluatorEngine const & get_engine () const
 accessor for the injected evaluation strategy (sequential-inline or thread-pooled), for use by descendant B&B variants' hooks
RETURNTYPE get_bound_value () const
 the current best (bound) criterion value; meaningful only once is_bound_valid()
bool is_bound_valid () const
 true once a valid bound has been established, see _boundvalid
int get_k () const
 the tree depth/level currently being processed (root is 0; the deepest stored level is n-d-1, and level n-d is the leaf level, evaluated but never stored). The return type is int, while the member k is DIMTYPE
DIMTYPE get_n () const
 total number of features, see n
DIMTYPE get_d () const
 target subset cardinality, see d
bool getFirstNode (PNode &nod)
 begins forward iteration (ascending by value, from _tree[k].begin()) over the current level's not-yet-decided nodes into nod; returns false if the level is empty
bool getNextNode (PNode &nod)
 advances the getFirstNode() iteration; returns false once the level's end is reached
bool getFirstAvailable (PNode &avail)
 begins iteration over _available in feature-index order, skipping withdrawn (invalid) entries, into avail; returns false if none are available
bool getNextAvailable (PNode &avail)
 advances the getFirstAvailable() iteration, again skipping invalid entries; returns false once exhausted
bool getAvailable (DIMTYPE idx, PNode &avail)
 direct lookup of _available[idx] by feature index, regardless of its valid flag; returns false if idx is out of range
PSubset & get_currentset ()
 mutable accessor for _currentset, for use by descendant B&B variants' hooks
Node & get_parent_node ()
 the node one level up (_tree[k-1].back()) whose feature removal defines the branch currently being followed; valid at the leaf level too (k==n-d==_tree.size(), the unstored leaf level whose parent is the last stored one), which is where FBB/BBPP's leaf hooks call it
Node & get_current_node ()
 the node at the current level k presently being visited (_tree[k].back()), i.e. about to be tested for cutting or descended into
void setup_default_structures (const DIMTYPE d, const DIMTYPE n)
 Allocates and resets everything one search() run needs: the n-d stored tree levels (all emptied), the _available pool (all n features valid), _currentset (all features selected, i.e. the root), the _tempset scratch subset and the _boundset holder (bound marked invalid).
void update_bound (const RETURNTYPE val, const PSubset &sub)
 Registers one fully-evaluated candidate subset of target cardinality d against the running bound. Updates _boundset/_boundvalue/_boundvalid whenever val improves on (or is the first) bound and, at NORMAL output or above, reports the improvement as a new solution; unconditionally feeds (val,sub) to the result tracker if one is active. Called from process_rightmost_path() and from process_leafs()'s per-leaf engine callback.
void make_tree_level ()
 Builds the k-th tree level (_tree[k]), keeping exactly n-d-k+1 candidates in reserve for the levels still to come. Calls pre_evaluate_availables() to obtain each still-available feature's ordering value, sorts the best (levelsize = get_available_size()-(n-d-k+1)) of them ascending by value into _tree[k] (withdrawing the chosen features from _available via available_remove()), then calls post_process_tree_level() so a descendant can substitute exact values for any node whose ordering value was only an estimate.
void process_rightmost_path ()
 Evaluates and registers the "rightmost" leaf reachable from the current branch by removing every feature still in _available at once. Copies _currentset into _tempset, deselects every remaining available feature, evaluates the criterion on the result and passes it to update_bound() - this seeds/tightens the bound as soon as each new tree level is built, before further descent, so later cuts can trigger sooner.
virtual void process_leafs ()
 engine-routed leaf evaluation; descendants hook per-leaf work via leaf_result() instead of overriding this

Protected Attributes

PREDICTOR _predictor
 the prediction mechanism instance (PREDICTOR type parameter, e.g. Branch_And_Bound_Predictor_Averaging); used only to ORDER each tree level's nodes (unlike FBB, BBPP always computes the true value along the tree path before deciding to cut, so optimality never relies on the prediction being accurate)
Protected Attributes inherited from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >
std::ostream * shared_os
 to enable sharing the same stream across the methods below
std::shared_ptr< StopWatch > swatch
 stopwatch for the running search, (re)created at the start of search() and reported alongside progress/solution messages

Additional Inherited Members

Protected Types inherited from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >
enum  NodeType { UNKNOWN , RANDOM , PREDICTED , COMPUTED }
 Marks how a Node's value was obtained: UNKNOWN = not yet assigned; RANDOM = reserved but currently unused by any B&B variant in this file; PREDICTED = filled from a PREDICTOR estimate pending confirmation (FBB/BBPP node ordering); COMPUTED = an exact criterion value.
typedef Node * PNode
 pointer to a Node, as used by the getFirst.../getNext... accessors below
typedef std::list< Node > ListNode
 one tree level's not-yet-decided candidate nodes, kept sorted ascending by value; the main search loop visits/pops from the back (highest value = most promising) via get_current_node()
typedef std::vector< ListNode > VectorListNode
 the search tree: one ListNode per level, indexed by tree depth k (see _tree)
typedef ListNode::iterator ListNodeIter
 iterator into a single tree level's ListNode, as used by _nodeiter/getFirstNode()/getNextNode()
typedef std::vector< ListNode >::iterator TreeLevelIter
 iterator over tree levels (used only to clear _tree in setup_default_structures())
typedef std::vector< Node > VectorNode
 type of _available: one Node per original feature, indexed by feature id

Detailed Description

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
class FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >

Implements Branch and Bound with Partial Prediction (BBPP) method, i.e., with predicted node ordering.

BBPP is generally slower than FBB but faster than IBB. Its principle is identical to that of Improved Branch & Bound (IBB), but it replaces large amount of criterion evaluations needed for ordering nodes in tree levels by quickly predicted values. The optimality of final result is not jeopardized but considerable amount of time is saved. See FBB for a more radical but still optimality preserving use of value prediction.

Warning
All Branch & Bound feature selection algorithms require the used CRITERION to be monotonic with respect to cardinality. More precisely, it must hold that removing a feature from a set MUST NOT increase criterion value. Otherwise there is no guarantee as of the optimality of obtained results with respect to the used criterion.
Note
All Branch & Bound algorithms by definition yield the solution with the same maximum criterion value, therefore the main concern regarding particular Branch & Bound algorithm is only its search speed.
Due to possibly high number of subsets to be tested expect excessive computational time.
Result tracking in case of Branch & Bound algorithms records only results of target cardinality.

Member Function Documentation

◆ cut_possible()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
bool FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >::cut_possible ( )
overrideprotectedvirtual

Returns true when the current node's value does not exceed the current bound, so the whole sub-branch below it can be cut. The value is always exact here (post_process_tree_level() has made it COMPUTED), so no lazy evaluation is needed; returns false while no bound is valid yet.

Implements FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ initialize()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
virtual void FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >::initialize ( const DIMTYPE d,
const DIMTYPE n,
const PCriterion crit )
inlineoverrideprotectedvirtual

resets the prediction mechanism for a feature space of n features; nothing else needs setting up for BBPP

Implements FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ leaf_result()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
void FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >::leaf_result ( const DIMTYPE feature,
const RETURNTYPE value )
overrideprotectedvirtual

feeds one leaf's contrast (parent value minus leaf value) to the predictor, so the leaf level - the cheapest and most numerous evidence in the tree - also trains the ordering predictions

Reimplemented from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ post_process_tree_level()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
void FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >::post_process_tree_level ( )
overrideprotectedvirtual

Replaces the merely PREDICTED values of the nodes that made it into the new tree level by exact criterion values (again in one engine batch). This is what makes the method PARTIAL prediction: predictions decide the ORDER of the level only, while every node on the tree path carries a true value, so a cut is never based on an estimate and optimality is preserved.

Implements FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ pre_evaluate_availables()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class CRITERION, class PREDICTOR>
void FST::Search_Branch_And_Bound_Partial_Prediction< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, PREDICTOR >::pre_evaluate_availables ( )
overrideprotectedvirtual

Assigns an ordering value to every available feature: predicted (parent value minus the predicted contrast) where the predictor already has evidence for that feature, otherwise the exact criterion value, obtained in one batch through the evaluation engine and fed back to the predictor.

Implements FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.

◆ print()

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

Writes the algorithm's name together with the prediction mechanism in use, and the thread count when a threaded evaluation engine is injected.

Reimplemented from FST::Search_Branch_And_Bound< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.


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.