Class Salsa::FixedThreshold¶
Defined in File Salsa.h
Nested Relationships¶
This class is a nested type of Class Salsa.
Inheritance Relationships¶
Base Type¶
public SubmodularOptimizer(Class SubmodularOptimizer)
Class Documentation¶
-
class Salsa::FixedThreshold : public SubmodularOptimizer
Fixed thresholding strategy (Algorithm 2 in the ICML paper). This basically simulates the thresholding strategy of SieveStreaming with a slightly different sampling strategy for the thresholds. In the original version OPT is known and different epsilon are used to “sample” different thresholds. As detailed in the longer version arxiv of the paper, we can estimate OPT via \(O = \{(1+\varepsilon)^i \mid i \in \mathbb{Z}, m \le (1+\varepsilon)^i \le K \cdot m\}\) where \( m = \max f({m}) \) is the maximum singleton function value.
Note
This class is basically also implemented in SieveStreaming and SieveStreamingPP. 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 FixedThreshold(unsigned int K, SubmodularFunction &f, data_t epsilon, data_t threshold)
Construct a new FixedThreshold 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 clone function 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.
epsilon – The epsilon parameter for this algorithm
threshold – The (sampled) OPT threshold
-
inline FixedThreshold(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t epsilon, data_t threshold)
Construct a new FixedThreshold 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.
epsilon – The epsilon parameter for this algorithm
threshold – The (sampled) OPT threshold
-
inline virtual void fit(std::vector<std::vector<data_t>> const &X, unsigned int iterations = 1)
Throws an exception when called. FixedThreshold should not be used outside Salsa.
- Parameters
X – A constant reference to the entire data set
iterations – Number of iterations over the entire dataset
-
inline virtual void next(std::vector<data_t> const &x, std::optional<idx_t> const id = std::nullopt)
Consume the next object in the data stream. Add the current item to the summary if there are fewer than K element in it and if the items gain exceeds the current thresholding rule. Performs one function query.
- 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 FixedThreshold(unsigned int K, SubmodularFunction &f, data_t epsilon, data_t threshold)