40 : _isSample(false), _team(0)
49 "This dueler is already a sample for id %llu",
id);
64 std::size_t team_size,
unsigned num_bits,
double low_threshold,
65 double high_threshold)
66 :
id(1 << numInstances), constituencySize(constituency_size),
67 teamSize(team_size), lowThreshold(low_threshold),
68 highThreshold(high_threshold),
selector(num_bits), regionCounter(0),
72 "There must be at least team size entries per team in a constituency");
75 "The low threshold must be within the range ]0.0, 1.0[");
77 "The high threshold must be within the range ]0.0, 1.0[");
79 "The low threshold must be below the high threshold");
A dueler is an entry that may or may not be accounted for sampling.
uint64_t _team
If entry is a sample, it belongs to one of two possible teams.
void setSample(uint64_t id, bool team)
Make this entry a sampling entry for a specific Dueling instance.
bool isSample(uint64_t id, bool &team) const
Check if entry is a sample for the given instance.
uint64_t _isSample
Whether this entry is a sample or a follower.
Dueler()
By default initializes entries as followers.
const std::size_t constituencySize
Given a table containing X entries, a constituency is a region of the table such that it contains X/c...
int regionCounter
Counts the number of entries have been initialized in the current constituency.
SatCounter32 selector
Counter that determines which dueler is winning.
const std::size_t teamSize
Number of entries that belong to each team within a constituency.
bool winner
The team that is currently winning.
bool getWinner() const
Get the team that is currently winning the duel.
bool isSample(const Dueler *dueler, bool &team) const
Check if the given dueler is a sample for this instance.
void sample(const Dueler *dueler)
If given dueler is a sampling entry, sample it and check if the winning team must be updated.
const double lowThreshold
If the winning team was "True", and the counter is decreased further than this threshold,...
static unsigned numInstances
Number of times this class has been instantiated.
DuelingMonitor(std::size_t constituency_size, std::size_t team_size=1, unsigned num_bits=10, double low_threshold=0.5, double high_threshold=0.5)
const double highThreshold
If the winning team was "False", and the counter is increased further than this threshold,...
void initEntry(Dueler *dueler)
Initialize a dueler entry, deciding wether it is a sample or not.
constexpr int popCount(uint64_t val)
Returns the number of set ones in the provided value.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
double calcSaturation() const
Calculate saturation percentile of the current counter's value with regard to its maximum possible va...
T saturate()
Saturate the counter.
Bitfield< 31, 16 > selector
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.