Implements concurrent evaluation of a criterion on a set of subset candidates. More...
#include <candidate_evaluator_threaded.hpp>
Classes | |
struct | CandidateResult |
temporary storage of subset candidate evaluation results More... | |
struct | ThreadLocal |
thread-local storage of current subset candidate, criterion clone, and tracker clone More... | |
Public Types | |
typedef boost::shared_ptr < CRITERION > | PCriterion |
typedef boost::shared_ptr< SUBSET > | PSubset |
typedef boost::shared_ptr < Result_Tracker< RETURNTYPE, SUBSET > > | PResultTracker |
Public Member Functions | |
void | initialize (const PCriterion &crit, const DIMTYPE max_candidates) |
to prevent race conditions due to vector resizing max_candidates must be set greater or equal than the maximum number of candidates that will be added | |
bool | add_candidate (const PSubset &sub, const DIMTYPE feature=0) |
adds candidate subset to the evaluation pool | |
bool | getBestResult (RETURNTYPE &result, PSubset &sub, DIMTYPE &feature) |
returns pointer to (does not copy sub contents) whichever candidate yielded the highest criterion value (first waits for all threads to finish) | |
bool | getFirstResult (RETURNTYPE &result, PSubset &sub, DIMTYPE &feature) |
iterator, returns pointer (does not copy sub contents) | |
bool | getNextResult (RETURNTYPE &result, PSubset &sub, DIMTYPE &feature) |
iterator | |
bool | results_to_tracker (const PResultTracker tracker) |
virtual std::ostream & | print (std::ostream &os) const |
Protected Member Functions | |
void | evaluator_thread (unsigned int tidx) |
bool | get_candidate (DIMTYPE &idx) |
points the calling thread to next candidate to be processed | |
Protected Attributes | |
PCriterion | template_crit |
to detect change of employed criterion inbetween search() calls | |
bool | initialized |
bool | working |
ThreadLocal | tlocal [max_threads] |
ThreadPool< max_threads > | tp |
DIMTYPE | _processed_candidates |
volatile DIMTYPE | _available_candidates |
to sychronize get_candidate() with adding new candidates to cres[] | |
boost::mutex | mutex_candidate_getter |
to sychronize threads when requesting new cres[] candidate through get_candidate() | |
boost::condition | condition_available |
to announce availability of new candidate for processing | |
volatile bool | stop_all_threads |
vector< CandidateResult > | cres |
DIMTYPE | _reading_result |
iterating index for get*Result readers |
Implements concurrent evaluation of a criterion on a set of subset candidates.
Concurrently evaluates each subset candidate using clones of the supplied criterion and at most max_threads worker threads. Returns the one subset that yiels highest criterion value, or iterates through all obtained results