Class IndependentSetImprovement

Nested Relationships

Inheritance Relationships

Base Type

Class Documentation

class IndependentSetImprovement : public SubmodularOptimizer

Independent Set Improvement for submodular functions. This optimizer stores the marginal gain (“weight”) of each element upon arrival and replaces an element if its gain is at-least twice as large as the smallest gain currently stored in the summary. The gains are not recomputed if the summary changes and thus are somewhat independent from the current solution and hence the name:

  • Stream: No

  • Solution: \( 1/4 \)

  • 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);
IndependentSetImprovement opt(K, fastIVM);
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 = IndependentSetImprovement(K, fastLogDet)
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()

Parts of this algorithms are proposed in the appendix of the following paper, but this might not be enough to fully replicate the algorithm. Many thanks to Sagar Kale who helped with the implementation by answering my many questions via email.

References

  • Chakrabarti, Amit, and Sagar Kale. “Submodular maximization meets streaming: Matchings, matroids, and more.” Mathematical Programming 154.1 (2015): 225-247.

Note

This implementation uses a priority queue for managing the weights of each item. Thus, there is a \( O(log K) \) overhead when inserting new elements.

Public Functions

inline IndependentSetImprovement(unsigned int K, SubmodularFunction &f)

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

inline IndependentSetImprovement(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f)

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

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 there are fewer than K elements in the summary: Unconditionally accept the current, compute the function value and weight and update the priority queue of weights. Runtime is \( O(log K) + 1 \) function query If there are more than K elements in the summary: Compute the current function value and check if the weight is at-least twice as large as the smallest weight in the summary. If so, replace it. Runtime is \( O(1) \) (no update) or \( O(log K) \) (insert new element) + 1 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::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.

Returns None

Protected Attributes

std::priority_queue<Pair> weights
struct Pair

We use a priority queue to efficiently find / manage the smallest weights. Each item is identified by its weight and index in the summary.

Public Functions

inline Pair(data_t _weight, unsigned int _idx)

Creates a new Pair object with the given weight and index.

Parameters
  • _weight – The weight of the element

  • _idx – The position / index in the summary

inline bool operator<(const Pair &other) const

Implementation of the comparison operator for sorting into the priority queue. Sorting is done on the basis of the objects weight: this->weight > other.weight.

Parameters

&other – The other object this object is compared against.

Public Members

data_t weight
unsigned int idx