Limbo 3.5.4
Loading...
Searching...
No Matches
limbo::algorithms::partition::FMMultiWay< GainCalcType > Class Template Reference

#include <FMMultiWay.h>

Classes

class  VertexMove
 a class denotes movement of vertex More...

Public Types

typedef GainCalcType gain_calc_type
typedef gain_calc_type::value_type gain_value_type

Public Member Functions

 FMMultiWay (gain_calc_type const &gc, int tn, signed char tp)
 constructor
void set_partition (int v, signed char p)
 set vertex v to partition p
template<typename Iterator>
void set_partitions (Iterator first, Iterator last)
 set partitions
signed char partition (int v) const
 get partition of a vertex
void operator() ()
 API to run the algorithm.

Protected Member Functions

void run ()
 kernel function to run the algorithm
void find_candidate (int &cv, signed char &cp, gain_value_type &max_gain) const
void best_kth_move (int &k, gain_value_type &improve) const
void revert_to_kth_move (int k)
void reset ()
 reset movements and fixed flags

Protected Attributes

gain_calc_type const & m_gain_calc
 function object to calculate gains
int m_num_vertice
 total number of vertices
int m_num_partitions
 total number of partitions
std::vector< signed char > m_vPartition
 an array storing partition of each vertex
std::vector< bool > m_vFixed
 whehter fixed during current iteration
std::vector< VertexMovem_vVertexMove
 record vertex movement during each iteration

Detailed Description

template<typename GainCalcType>
class limbo::algorithms::partition::FMMultiWay< GainCalcType >

Assume vertices are represented by 0, 1, ... N array.
Partitions are 0, 1, ... P array. Negative partition id denotes no partition assigned.

Template Parameters
GainCalcTypea function object that calculate gains, refer to limbo::algorithms::coloring::SDPColoringCsdp::FMGainCalcType for example.

Definition at line 31 of file FMMultiWay.h.

Member Typedef Documentation

◆ gain_calc_type

template<typename GainCalcType>
typedef GainCalcType limbo::algorithms::partition::FMMultiWay< GainCalcType >::gain_calc_type

Definition at line 35 of file FMMultiWay.h.

◆ gain_value_type

template<typename GainCalcType>
typedef gain_calc_type::value_type limbo::algorithms::partition::FMMultiWay< GainCalcType >::gain_value_type

Definition at line 36 of file FMMultiWay.h.

Constructor & Destructor Documentation

◆ FMMultiWay()

template<typename GainCalcType>
limbo::algorithms::partition::FMMultiWay< GainCalcType >::FMMultiWay ( gain_calc_type const & gc,
int tn,
signed char tp )
inline

constructor

Parameters
gcfunction object of gain calculator
tnnumber of vertices
tpnumber of partitions

Definition at line 57 of file FMMultiWay.h.

Member Function Documentation

◆ best_kth_move()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::best_kth_move ( int & k,
gain_value_type & improve ) const
protected

find best kth movement

Parameters
kindex of movement
improvecumulative improvement at kth movement

Definition at line 133 of file FMMultiWay.h.

◆ find_candidate()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::find_candidate ( int & cv,
signed char & cp,
gain_value_type & max_gain ) const
protected

traverse all vertices and partitions for the candidate with best gain

Parameters
cvfind vertex to move
cptarget partition
max_gainbest gain of the movement

Definition at line 109 of file FMMultiWay.h.

◆ operator()()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::operator() ( )
inline

API to run the algorithm.

Definition at line 81 of file FMMultiWay.h.

◆ partition()

template<typename GainCalcType>
signed char limbo::algorithms::partition::FMMultiWay< GainCalcType >::partition ( int v) const
inline

get partition of a vertex

Parameters
vvertex
Returns
partition

Definition at line 78 of file FMMultiWay.h.

◆ reset()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::reset ( )
protected

reset movements and fixed flags

Definition at line 157 of file FMMultiWay.h.

◆ revert_to_kth_move()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::revert_to_kth_move ( int k)
protected

revert to kth movement

Parameters
kindex of movement

Definition at line 150 of file FMMultiWay.h.

◆ run()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::run ( )
protected

kernel function to run the algorithm

Definition at line 164 of file FMMultiWay.h.

◆ set_partition()

template<typename GainCalcType>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::set_partition ( int v,
signed char p )
inline

set vertex v to partition p

Parameters
vvertex
ppartition

Definition at line 69 of file FMMultiWay.h.

◆ set_partitions()

template<typename GainCalcType>
template<typename Iterator>
void limbo::algorithms::partition::FMMultiWay< GainCalcType >::set_partitions ( Iterator first,
Iterator last )
inline

set partitions

Template Parameters
Iteratoriterator to the array of partitions
Parameters
first,lastbegin and end iterator to the array of partitions

Definition at line 74 of file FMMultiWay.h.

Member Data Documentation

◆ m_gain_calc

template<typename GainCalcType>
gain_calc_type const& limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_gain_calc
protected

function object to calculate gains

Definition at line 100 of file FMMultiWay.h.

◆ m_num_partitions

template<typename GainCalcType>
int limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_num_partitions
protected

total number of partitions

Definition at line 102 of file FMMultiWay.h.

◆ m_num_vertice

template<typename GainCalcType>
int limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_num_vertice
protected

total number of vertices

Definition at line 101 of file FMMultiWay.h.

◆ m_vFixed

template<typename GainCalcType>
std::vector<bool> limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_vFixed
protected

whehter fixed during current iteration

Definition at line 104 of file FMMultiWay.h.

◆ m_vPartition

template<typename GainCalcType>
std::vector<signed char> limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_vPartition
protected

an array storing partition of each vertex

Definition at line 103 of file FMMultiWay.h.

◆ m_vVertexMove

template<typename GainCalcType>
std::vector<VertexMove> limbo::algorithms::partition::FMMultiWay< GainCalcType >::m_vVertexMove
protected

record vertex movement during each iteration

Definition at line 105 of file FMMultiWay.h.


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