Class SieveStreaming¶
Defined in File SieveStreaming.h
Inheritance Relationships¶
Base Type¶
public SubmodularOptimizer(Class SubmodularOptimizer)
Class Documentation¶
-
class SieveStreaming : public SubmodularOptimizer¶
The SieveStreaming optimizer for nonnegative, monotone submodular functions. It tries to estimate the potential gain of an element ahead of time by sampling different thresholds from \( \{(1+\varepsilon)^i | i \in Z, lower \le (1+\varepsilon)^i \le upper\} \) and maintaining a set of sieves in parallel. Each sieve uses a different threshold to sieve-out elements with too few of a gain.
lower = \( max_e f({e}) \) which is the largest function value of a singleton-set
upper = \( K \cdot max_e f({e}) \) which is \( K \) times the function value of a singleton-set
Note that this implementation requires that \( m = max_e f({e}) \) is known beforehand
Stream: Yes
Solution: \( 1/2 - \varepsilon \)
Runtime: \( O(1) \)
Memory: \( O(K \cdot log(K) / \varepsilon) \)
Function Queries per Element: \( O(log(K) / \varepsilon) \)
Function Types: nonnegative, monotone 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); SieveStreaming opt(K, fastIVM, 1.0, 0.1); 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 = SieveStreaming(K, fastLogDet, 1.0, 0.1) 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()
References
Badanidiyuru, A., Mirzasoleiman, B., Karbasi, A., & Krause, A. (2014). Streaming submodular maximization: Massive data summarization on the fly. In Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. https://doi.org/10.1145/2623330.2623637
Public Functions
-
inline SieveStreaming(unsigned int K, SubmodularFunction &f, data_t m, data_t epsilon)¶
Construct a new SieveStreaming 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.m – The maximum value of the singleton set, \( m = max_e f({e}) \)
epsilon – The sampling accuracy for threshold generation
-
inline SieveStreaming(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t m, data_t epsilon)¶
Construct a new SieveStreaming 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 value of the singleton set, \( m = max_e f({e}) \)
epsilon – The sampling accuracy for threshold generation
-
inline virtual unsigned int get_num_candidate_solutions() const¶
Returns the number of sieves.
-
inline virtual unsigned long get_num_elements_stored() const¶
Returns the total number of items stored across all sieves.
-
inline ~SieveStreaming()¶
Destroy the Sieve Streaming object.
-
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. This checks for each sieve if the given object exceeds the marginal gain thresholdhold and adds it to the corresponding solution.
- 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.