Class SieveStreaming::Sieve¶
Defined in File SieveStreaming.h
Nested Relationships¶
This class is a nested type of Class SieveStreaming.
Inheritance Relationships¶
Base Type¶
public SubmodularOptimizer(Class SubmodularOptimizer)
Class Documentation¶
-
class SieveStreaming::Sieve : public SubmodularOptimizer¶
A single sieve with its own threshold and accompanying summary.
Note
This class is basically also implemented in SieveStreamingPP and - to some extend - in Salsa. I decided against a unified class for these Sieves, since the thresholding rules are often slightly different from paper to paper. I tried to stick as close as possible to the pseudocode in the papers.
Public Functions
-
inline Sieve(unsigned int K, SubmodularFunction &f, data_t threshold)¶
Construct a new Sieve object.
- Parameters
K – The cardinality constraint you of the optimization problem, that is the number of items selected.
f – The function which should be maximized. Note, that the `
clonefunction is used to construct a new SubmodularFunction which is owned by this object. If you implement a custom SubmodularFunction make sure that everything you need is actually cloned / copied.threshold – The threshold.
-
inline Sieve(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t threshold)¶
Construct a new Sieve object.
- Parameters
K – The cardinality constraint you of the optimization problem, that is the number of items selected.
f – The function which should be maximized. Note, that this parameter is likely moved and not copied. Thus, if you construct multiple optimizers with the same function they all reference the same function. This can be very efficient for state-less functions, but may lead to weird side effects if f keeps track of a state.
threshold – The threshold.
-
inline void fit(std::vector<std::vector<data_t>> const &X, unsigned int iterations = 1)¶
Throws an exception since fit() should not be used directly here. Sieves are not meant to be used on their own, but only through SieveStreaming.
- Parameters
X – A constant reference to the entire data set
-
inline void next(std::vector<data_t> const &x, std::optional<idx_t> const id = std::nullopt)¶
Consume the next object in the data stream. This call compares the marginal gain against the given threshold and add the current item to the current solution if it exceeds the given threshold.
- Parameters
&x – A constant reference to the next object on the stream.
id – The id of the given object. If this is a
std::nulloptthis parameter is ignored. Otherwise the id is inserted into the solution. Make sure, that either all or no object receives an id to keep track which id belongs to which object. This algorithm simply stores the objects and the ids in two separate lists and performs no safety checks.
-
inline Sieve(unsigned int K, SubmodularFunction &f, data_t threshold)¶