Implements threaded version of randomized search that repeatedly samples random subsets to eventually yield the one with highest criterion value. More...
#include <search_monte_carlo_threaded.hpp>
Classes | |
struct | ThreadLocal |
thread-local storage of current subset candidate, criterion clone, and tracker clone More... | |
Public Types | |
typedef Search< RETURNTYPE, DIMTYPE, SUBSET, CRITERION > | parent |
typedef boost::shared_ptr < CRITERION > | PCriterion |
typedef boost::shared_ptr< SUBSET > | PSubset |
Public Member Functions | |
Search_Monte_Carlo_Threaded (const unsigned long trials_limit=1000, const unsigned long time_limit=0, const unsigned int time_limit_check_freq=10) | |
virtual bool | search (const DIMTYPE target_d, RETURNTYPE &result, const PSubset sub, const PCriterion crit, std::ostream &os=std::cout) |
returns found subset of target_d features (optimizes cardinality if target_d==0) + criterion value | |
void | set_stopping_condition (const unsigned 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 | |
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 () |
equivalent to set_cardinality_randomization(1,no_of_all_features) | |
virtual std::ostream & | print (std::ostream &os) const |
Protected Member Functions | |
void | evaluator_thread (unsigned int idx) |
unsigned long | next_trial () |
Protected Attributes | |
PCriterion | template_crit |
ThreadLocal | tlocal [max_threads] |
boost::mutex | mutex_trials_out |
boost::mutex | mutex_random_sub |
boost::shared_ptr< StopWatch > | swatch |
unsigned long | _trials |
to be updated concurrently from threads | |
volatile DIMTYPE | _target_d |
unsigned long | _time_limit |
max time allowed to be spent in seconds | |
unsigned long | _trials_limit |
max no of candidates evaluated | |
unsigned int | _time_limit_check_freq |
number of trials before next time check | |
DIMTYPE | _d_from |
DIMTYPE | _d_to |
generate random subsets of size within these limits | |
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 |
Implements threaded version of randomized search that repeatedly samples random subsets to eventually yield the one with highest criterion value.
Concurrently evaluates each subset candidate using clones of the supplied criterion and returns the one subset that yielded highest criterion value
demo24t.cpp, and demo35t.cpp.
unsigned long FST::Search_Monte_Carlo_Threaded< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, max_threads >::next_trial | ( | ) | [inline, protected] |
< (synchronized) _trials increase + test whether _trials_limit has been reached
References FST::Search_Monte_Carlo_Threaded< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, max_threads >::_trials.
PCriterion FST::Search_Monte_Carlo_Threaded< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, max_threads >::template_crit [protected] |
to detect change of criterion inbetween search() calls
Referenced by FST::Search_Monte_Carlo_Threaded< RETURNTYPE, DIMTYPE, SUBSET, CRITERION, max_threads >::search().