Class PySubmodularFunction

Inheritance Relationships

Base Type

Class Documentation

class PySubmodularFunction : public SubmodularFunction

This is a wrapper / trampoline class to pass the SubmodularFunction interface to the Python-side of things.

Public Functions

inline virtual data_t operator()(std::vector<std::vector<data_t>> const &solution) const override
inline virtual data_t peek(std::vector<std::vector<data_t>> const &cur_solution, std::vector<data_t> const &x, unsigned int pos) override

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

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

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

inline ~PySubmodularFunction()
inline virtual std::shared_ptr<SubmodularFunction> clone() const override

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