Class ThreeSieves

Inheritance Relationships

Base Type

Class Documentation

class ThreeSieves : public SubmodularOptimizer

The ThreeSieves algorithm for submodular function maximization. This optimizer tries to estimate the probability that a given item is not out-valued in the future. To do so, it compares the marginal gain of each item against a pre-computed threshold. If this threshold is too large and the algorithm therefore rejects most items, it reduces the threshold after \( T \) tries. The confidence interval of not finding an element in the stream which would out-value the current threshold is given by the Rule Of Three, hence the name:

  • Stream: Yes

  • Solution: \( (1-\varepsilon)(1-1/\exp(1)) with probability (1-\alpha)^K \)

  • Runtime: \( O(N) \)

  • Memory: \( O(K) \)

  • Function Queries per Element: \( O(1) \)

  • Function Types: nonnegative submodular functions

Example usage in C++:

//read some data 
std::vector<std::vector<data_t>> = read_some_data(); 
auto K = 50;
// Define the function to be maximized and select the summary
FastIVM fastIVM(K, RBFKernel( std::sqrt(data[0].size()), 1.0) , 1.0);
ThreeSieves opt(K, fastIVM, 1.0, 0.1, THRESHOLD_STRATEGY::SIEVE, 1000);
opt.fit(data);
std::cout << "fval:" << opt.get_fval() << "num_elements: " << opt.get_num_elements_stored() << "num_candidates: " << opt.get_num_candidate_solutions() << std::endl;
// Process summary
auto summary = opt.get_solution();

Example usage in Python:

X = read_some_data(); 
K = 50
# Create function to be maximized
kernel = RBFKernel(sigma=sigma,scale=scale)
fastLogDet = FastIVM(K, kernel, 1.0)
opt = ThreeSieves(K, fastLogDet, 1.0, 0.1, "sieve", 1000)
opt.fit(X, K)
print("fval: {} num_elements: {} num_candidates: {}".format(opt.get_fval(), opt.get_num_elements_stored(), opt.get_num_candidate_solutions()))
# process summary
summary = opt.get_solution()

Internally this algorithm also uses a novelty threshold similar to SieveStreaming, but only maintains a single sieve. After \( T \) unsuccessful tries of adding an element to the summary, it reduces the threshold. This can either be a constant value (CONSTANT strategy) or by using the next smallest threshold from \( \{(1+\varepsilon)^i | i \in Z, lower \le (1+\varepsilon)^i \le upper\} \) similar to SieveStreaming (SIEVE strategy).

References

  • Buschjäger, Sebastian, Honysz, Philipp-Jan, Pfahler, Lukas & Morik, Katharina Very Fast Submodular Function Maximization. European Conference on Machine Learning and Knowledge Discovery in Databases (ECML/PKDD) 2021 (accepted)

  • Buschjäger, Sebastian, Honysz, Philipp-Jan, Pfahler, Lukas & Morik, Katharina (2021) Very Fast Submodular Function Maximization. https://arxiv.org/abs/2010.10059

Public Types

enum THRESHOLD_STRATEGY

The different strategies to reduce the threshold after \( T \) unsuccessful tries.

Values:

enumerator SIEVE

Start with the largest threshold in \( \{(1+\varepsilon)^i | i \in Z, lower \le (1+\varepsilon)^i \le upper\} \) and always use the next largest as the new threshold

enumerator CONSTANT

Reduce the threshold by a constant \( \varepsilon \)

Public Functions

inline ThreeSieves(unsigned int K, SubmodularFunction &f, data_t m, data_t epsilon, std::string const &strategy, unsigned int T)

Construct a new ThreeSieves 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.

  • m – The maximum singleton value

  • epsilon – The epsilon parameter used in the thresholding strategy

  • strategy – The thresholding strategy. Uses SIEVE if “sieve” (or any lower/upper-case variation) is supplied. Otherwise uses CONSTANT

  • T – The maximum number of tries until the threshold is reduced

inline ThreeSieves(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t m, data_t epsilon, std::string const &strategy, unsigned int T)

Construct a new ThreeSieves 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.

  • m – The maximum singleton value

  • epsilon – The epsilon parameter used in the thresholding strategy

  • strategy – The thresholding strategy. Uses SIEVE if “sieve” (or any lower/upper-case variation) is supplied. Otherwise uses CONSTANT

  • T – The maximum number of tries until the threshold is reduced

inline ThreeSieves(unsigned int K, SubmodularFunction &f, data_t m, data_t epsilon, THRESHOLD_STRATEGY strategy, unsigned int T)

Construct a new ThreeSieves 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.

  • m – The maximum singleton value

  • epsilon – The epsilon parameter used in the thresholding strategy

  • strategy – The thresholding strategy.

  • T – The maximum number of tries until the threshold is reduced

inline ThreeSieves(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t m, data_t epsilon, THRESHOLD_STRATEGY strategy, unsigned int T)

Construct a new ThreeSieves 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.

  • m – The maximum singleton value

  • epsilon – The epsilon parameter used in the thresholding strategy

  • strategy – The thresholding strategy.

  • T – The maximum number of tries until the threshold is reduced

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. If more than T tries have already been performed, then the threshold is lower according to the threshold strategy. In any case, the current item’s marginal gain is compared to the current / changed threshold and the item is added if the gain exceeds it. If so, the summary is updated accordingly.

Parameters
  • &x – A constant reference to the next object on the stream.

  • id – The id of the given object. If this is a std::nullopt this 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.

Public Members

data_t threshold
data_t epsilon
THRESHOLD_STRATEGY strategy
unsigned int T
unsigned int t