Class SubmodularFunction

Inheritance Relationships

Derived Types

Class Documentation

class SubmodularFunction

Interface class which every submodular function should implement. Is is expected by all optimizers. This interface offers a convenient way to implement stateful submodular functions. Each submodular function must offer four functions:

  • operator()

  • peek

  • update

  • clone as detailed below. The SubmodularOptimizer class are expected to use peek whenever they ask for a function value and to use update whenever a new element is added to the solution. The clone function should implement a deep copy of the object. For state-less functions there is also a SubmodlarFunctonWrapper available which expects a lambda / std::function.

    Note

    returns None

Subclassed by IVM, PySubmodularFunction, SubmodularFunctionWrapper

Public Functions

virtual data_t operator()(std::vector<std::vector<data_t>> const &cur_solution) const = 0
virtual data_t peek(std::vector<std::vector<data_t>> const &cur_solution, std::vector<data_t> const &x, unsigned int pos) = 0

Returns the function value if x would be added at position “pos” in the current solution. If pos is greater than the number of elements in the current solution we would add x the current solution. Otherwise, we would replace the object at position “pos” with x.

Note

Parameters
  • cur_solution – The current solution.

  • x – The item which we would hypothetically add to the solution.

  • pos – The position at which we would add x. Note that it holds: \( 0 \le pos < K \)

Returns The

function value if we would add x to cur_solution at position pos

virtual void update(std::vector<std::vector<data_t>> const &cur_solution, std::vector<data_t> const &x, unsigned int pos) = 0

Update the function if we add x at position “pos” to the current solution. If pos is greater than the number of elements in the current solution we add x the current solution. Otherwise, we replace the object at position “pos” with x.

Note

Parameters
  • cur_solution – The current solution.

  • x – The item which we add to the solution.

  • pos – The position at which we would add x. Note that it holds: \( 0 \le pos < K \)

Returns None

virtual std::shared_ptr<SubmodularFunction> clone() const = 0

This function returns a clone of this Submodular function. Make sure, that the new objet is a valid clone which behaves like a new object and does not reference any members of this object. Some algorithms like SieveStreaming(++) or Salsa utilize multiple optimizers in parallel each with their own unique SubmodularFunction. Moreover, to make for efficient PyBind bindings, we use clone() to give the C++ side more control over the memory.

Note

Returns

inline virtual ~SubmodularFunction()

Destroys this object.

Note

Returns None