Alpha Expansion Library
C++ library for the Alpha-Expansion graph-cut algorithm with Python bindings
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
MaxFlowSolver< T > Class Template Referenceabstract

Abstract interface for a binary max-flow / QPBO solver. More...

#include <MaxFlowSolver.hpp>

Inheritance diagram for MaxFlowSolver< T >:
[legend]

Public Types

typedef int Var
 Integer handle identifying a binary variable.
 

Public Member Functions

virtual ~MaxFlowSolver ()=default
 
virtual Var add_variable ()=0
 Introduces a new binary variable and returns its handle.
 
virtual void add_constant (T E)=0
 Adds a constant term to the energy function.
 
virtual void add_term1 (Var x, T E0, T E1)=0
 Adds a unary term E(x) where x ∈ {0, 1}.
 
virtual void add_term2 (Var x, Var y, T E00, T E01, T E10, T E11)=0
 Adds a pairwise term E(x, y) where x, y ∈ {0, 1}.
 
virtual T minimize ()=0
 Minimizes the energy and returns the minimum value.
 
virtual int get_var (Var x)=0
 Returns the optimal value of variable x (0 or 1) after minimize().
 

Detailed Description

template<typename T>
class MaxFlowSolver< T >

Abstract interface for a binary max-flow / QPBO solver.

Implementations build a binary energy function term by term using add_term1 and add_term2, then minimize it via max-flow.

Built-in implementations: BKSolver (Boykov–Kolmogorov), ORToolsSolver (Google OR-Tools). Implement this interface and add a factory lambda to AlphaExpansion to add a custom solver.

Template Parameters
TNumeric type for energy values (int32_t, float, or double).

Member Typedef Documentation

◆ Var

template<typename T >
typedef int MaxFlowSolver< T >::Var

Integer handle identifying a binary variable.

Constructor & Destructor Documentation

◆ ~MaxFlowSolver()

template<typename T >
virtual MaxFlowSolver< T >::~MaxFlowSolver ( )
virtualdefault

Member Function Documentation

◆ add_constant()

template<typename T >
virtual void MaxFlowSolver< T >::add_constant ( E)
pure virtual

Adds a constant term to the energy function.

Parameters
EConstant to add.

Implemented in BKSolver< T >, and ORToolsSolver< T >.

◆ add_term1()

template<typename T >
virtual void MaxFlowSolver< T >::add_term1 ( Var  x,
E0,
E1 
)
pure virtual

Adds a unary term E(x) where x ∈ {0, 1}.

Parameters
xVariable handle.
E0Energy contribution when x = 0.
E1Energy contribution when x = 1.

◆ add_term2()

template<typename T >
virtual void MaxFlowSolver< T >::add_term2 ( Var  x,
Var  y,
E00,
E01,
E10,
E11 
)
pure virtual

Adds a pairwise term E(x, y) where x, y ∈ {0, 1}.

The values must satisfy E00 + E11 ≤ E01 + E10 (submodularity requirement).

Parameters
xFirst variable handle.
ySecond variable handle.
E00Energy when x=0, y=0.
E01Energy when x=0, y=1.
E10Energy when x=1, y=0.
E11Energy when x=1, y=1.

◆ add_variable()

template<typename T >
virtual Var MaxFlowSolver< T >::add_variable ( )
pure virtual

Introduces a new binary variable and returns its handle.

Implemented in BKSolver< T >, and ORToolsSolver< T >.

◆ get_var()

template<typename T >
virtual int MaxFlowSolver< T >::get_var ( Var  x)
pure virtual

Returns the optimal value of variable x (0 or 1) after minimize().

◆ minimize()

template<typename T >
virtual T MaxFlowSolver< T >::minimize ( )
pure virtual

Minimizes the energy and returns the minimum value.

Implemented in BKSolver< T >, and ORToolsSolver< T >.


The documentation for this class was generated from the following file: