Repeatedly samples random subsets to eventually yield the one with highest criterion value. More...
#include <search_monte_carlo.hpp>
Public Types | |
| typedef Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | parent |
| base class alias | |
| typedef std::shared_ptr< CRITERION > | PCriterion |
| shared pointer to the criterion the search optimizes | |
| typedef std::shared_ptr< SUBSET > | PSubset |
| shared pointer to a feature subset | |
| typedef Candidate_Evaluator< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | EVALUATORENGINE |
| the injected evaluation-strategy interface (sequential in-line or thread-pooled) | |
| typedef std::shared_ptr< EVALUATORENGINE > | PEvaluatorEngine |
| Public Types inherited from FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | |
| typedef std::shared_ptr< CRITERION > | PCriterion |
| shared pointer to the criterion the search optimizes | |
| typedef std::shared_ptr< SUBSET > | PSubset |
| shared pointer to a feature subset | |
| typedef std::shared_ptr< Result_Tracker< RETURNTYPE, SUBSET > > | PResultTracker |
| shared pointer to the result tracker enabled via enable_result_tracking() | |
| typedef Search_Observer< RETURNTYPE, SUBSET > | OBSERVER |
| the observer interface type this search reports through (see Search_Observer) | |
| typedef std::shared_ptr< OBSERVER > | PObserver |
| shared pointer to an OBSERVER, as set via set_observer() | |
Public Member Functions | |
| Search_Monte_Carlo (const unsigned long long trials_limit=1000, const unsigned long time_limit=0, const unsigned int time_limit_check_freq=1, PEvaluatorEngine engine=PEvaluatorEngine()) | |
engine defaults to sequential in-line evaluation if not supplied; see set_stopping_condition() for trials_limit / time_limit / time_limit_check_freq | |
| virtual bool | search (const DIMTYPE target_d, RETURNTYPE &result, const PSubset sub, const PCriterion crit, std::ostream &os=std::cout) override |
samples random subsets of target_d features (of randomized size if target_d==0: from the configured range or inclusion probability, see set_cardinality_randomization(), or uniformly from [1,n] when neither is set) until the stopping condition is met, and returns the best one + its criterion value; false if no candidate was evaluated successfully. target_d must be smaller than the full feature count - drawing all n features at random is not a search (unlike Search_Exhaustive, which accepts target_d==n) | |
| void | set_stopping_condition (const unsigned long long trials_limit=1000, const unsigned long time_limit=0, const unsigned int time_limit_check_freq=100) |
set maximum number of random trials or maximum time in seconds or both; trials_limit and time_limit both 0 is replaced by a limit of 1000 trials, time_limit_check_freq 0 by 100 (the elapsed time is read once per that many trials; the constructor asks for 1, i.e. a check per trial) | |
| void | set_cardinality_randomization (const DIMTYPE d_from, const DIMTYPE d_to) |
| generate subset size first from [d_from,d_to], then randomly choose exactly that number of features | |
| void | set_cardinality_randomization (const float d_prob) |
| for each feature roll the dice and select it with probability d_prob | |
| void | reset_cardinality_randomization () |
| clears both ways of randomizing the subset size (the constructor calls this); with neither of them in effect a target_d==0 search draws each probe's size uniformly from [1,n] | |
| virtual std::ostream & | print (std::ostream &os) const override |
| writes a human-readable identification of the search and its configuration; base default writes nothing | |
| Public Member Functions inherited from FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | |
| void | enable_result_tracking (PResultTracker tracker) |
| assigns a result tracker to the search process, i.e., enables logging of all evaluated subsets for future reuse (re-evaluation, etc.) | |
| void | disable_result_tracking () |
| detaches any result tracker (result_tracker_active() then returns false) | |
| bool | result_tracker_active () const |
| true if a result tracker was assigned via enable_result_tracking() and not since disabled | |
| 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 | |
| void | set_observer (PObserver observer) |
redirects search progress reporting away from the default syncout text output to observer | |
Protected Attributes | |
| PEvaluatorEngine | _engine |
| injected evaluation strategy (sequential-inline or thread-pooled); defaulted in the constructor if not supplied | |
| unsigned long | _time_limit |
| max time allowed to be spent in seconds | |
| unsigned long long | _trials_limit |
| max no of candidates evaluated (64-bit: counts candidates, see the LLP64 note on Candidate_Evaluator::BestCallback) | |
| unsigned int | _time_limit_check_freq |
| number of trials before next time check | |
| DIMTYPE | _d_from |
| lower bound of the random subset size range; see set_cardinality_randomization(const DIMTYPE, const DIMTYPE) | |
| DIMTYPE | _d_to |
| upper bound of the random subset size range | |
| float | _d_prob |
| active d_prob must be from (0,1]; generates random subset of random size where the mean size over a series of calls is d_prob*no_of_all_features | |
| Protected Attributes inherited from FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | |
| PResultTracker | _tracker |
| the assigned result tracker, or null (see enable_result_tracking()/result_tracker_active()) | |
| OutputDetail | _detail |
| the output detail level set via set_output_detail(); read by output_normal()/output_detailed() | |
| PObserver | _observer |
| the attached progress observer, or null (see set_observer(), report(), report_solution()) | |
Additional Inherited Members | |
| Protected Member Functions inherited from FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | |
| void | report (std::ostream &os, const msgbuf &m) const |
| delivers one pre-formatted progress message: to the observer if attached, otherwise as syncout text to os | |
| void | report_solution (std::ostream &os, const RETURNTYPE value, const SUBSET &sub, const msgbuf &m) const |
| like report(), for sites announcing a new (sub-)solution; fires on_solution instead | |
Repeatedly samples random subsets to eventually yield the one with highest criterion value.
The search always runs under a terminating condition - a number of random trials, a time limit in seconds, or both; with neither requested it stops after 1000 trials (see set_stopping_condition()). Candidate evaluation goes through the injected engine (a Candidate_Evaluator implementation, sequential in-line by default); the random draws themselves always happen on the calling thread, so the same seed yields the same sequence of candidates at any thread count.
| typedef std::shared_ptr<EVALUATORENGINE> FST::Search_Monte_Carlo< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >::PEvaluatorEngine |
shared pointer to an EVALUATORENGINE
|
overridevirtual |
writes a human-readable identification of the search and its configuration; base default writes nothing
Reimplemented from FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.
|
overridevirtual |
samples random subsets of target_d features (of randomized size if target_d==0: from the configured range or inclusion probability, see set_cardinality_randomization(), or uniformly from [1,n] when neither is set) until the stopping condition is met, and returns the best one + its criterion value; false if no candidate was evaluated successfully. target_d must be smaller than the full feature count - drawing all n features at random is not a search (unlike Search_Exhaustive, which accepts target_d==n)
Implements FST::Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION >.