Limbo 3.5.4
Loading...
Searching...
No Matches
Limbo.Algorithms

Introduction

This package provides various algorithms that are often used in optimization.

Graph Partition

Partitioning algorithms are included such as FM partitioning [PAR_DAC1982_FM] and its multiway extensions.

Graph Coloring

Various graph coloring algorithms are included such as integer linear programming (ILP) based coloring [TPL_TCAD2015_Yu], semidefinite programming (SDP) based coloring [TPL_TCAD2015_Yu], iterative linear programming (LP) based coloring [TPL_SPIE2016_Lin] , greedy approach [MPL_CACM1979_Brelaz], etc. It also provides graph simplification algorithms for the coloring problem, which can also be applied to other graph algorithms.

Graph Misc

Implementation of graph utilities and some other graph algorithms such as maximum clique and maximum independent set.

Placement

Useful VLSI placement strategies.

Examples

FM Partition

See documented version: test/algorithms/test_FM.cpp

#include <iostream>
using std::cout;
using std::endl;
class Node
{
public:
typedef char tie_id_type;
typedef int weight_type;
Node(weight_type const& w, tie_id_type const& id)
{
m_weight = w;
m_id = id;
}
tie_id_type tie_id() const {return m_id;}
weight_type weight() const {return m_weight;}
protected:
tie_id_type m_id;
weight_type m_weight;
};
int main()
{
array<Node*, 8> vNode;
vNode[0] = new Node (1, 'a');
vNode[1] = new Node (1, 'b');
vNode[2] = new Node (1, 'c');
vNode[3] = new Node (1, 'd');
vNode[4] = new Node (1, 'e');
vNode[5] = new Node (1, 'f');
vNode[6] = new Node (1, 'g');
vNode[7] = new Node (1, 'h');
for (unsigned int i = 0; i < vNode.size(); ++i)
{
#if 1
if (i < 4)
fm.add_node(vNode[i], 0);
else
fm.add_node(vNode[i], 1);
#else
if (i < 4)
fm.add_node(vNode[i], i%2);
else
fm.add_node(vNode[i], i%2);
#endif
}
// net n1
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[0]);
vNodeNet.push_back(vNode[1]);
vNodeNet.push_back(vNode[2]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
// net n2
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[1]);
vNodeNet.push_back(vNode[3]);
vNodeNet.push_back(vNode[4]);
vNodeNet.push_back(vNode[5]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
// net n3
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[2]);
vNodeNet.push_back(vNode[5]);
vNodeNet.push_back(vNode[6]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
// net n4
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[0]);
vNodeNet.push_back(vNode[6]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
// net n5
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[3]);
vNodeNet.push_back(vNode[4]);
vNodeNet.push_back(vNode[7]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
// net n6
{
vector<Node*> vNodeNet;
vNodeNet.push_back(vNode[5]);
vNodeNet.push_back(vNode[7]);
fm.add_net(1, vNodeNet.begin(), vNodeNet.end());
//fm.add_net(1.0/(vNodeNet.size()-1), vNodeNet.begin(), vNodeNet.end());
}
fm.print();
fm(3.0/5, 5.0/3);
fm.print();
return 0;
}
Implementation of the FM partitioning algorithm.
a class to describe graph vertex
Definition test_FM.cpp:16
Node(weight_type const &w, tie_id_type const &id)
Definition test_FM.cpp:26
weight_type m_weight
node weight
Definition test_FM.cpp:39
tie_id_type m_id
node label
Definition test_FM.cpp:38
weight_type weight() const
Definition test_FM.cpp:35
tie_id_type tie_id() const
Definition test_FM.cpp:33
Implementation of FM partitioning algorithm.
Definition FM.h:73
void print_connection() const
print connection
Definition FM.h:420
bool add_net(net_weight_type const &weight, Iterator first, Iterator last)
add nets
Definition FM.h:354
bool add_node(node_type *pNode, int initialPartition)
add node
Definition FM.h:334
void print() const
print function
Definition FM.h:397
int main()

Compiling and running commands (assuming LIMBO_DIR and BOOST_DIR are well defined).

g++ -o test_FM test_FM.cpp -I $LIMBO_DIR/include -I $BOOST_DIR/include -L $BOOST_DIR/lib -lboost_regex
# test FM algorithm with a simple graph
./test_FM

Output

------- partitions -------
{d c b a | h g f e }
------- connections -------
a - b - c
b - d - e - f
c - f - g
a - g
d - e - h
f - h
######### iteration #0 #########
======= trial phase =======
======= actual phase w. target_cnt = 2 =======
######### iteration #1 #########
======= trial phase =======
======= actual phase w. target_cnt = 0 =======
------- partitions -------
{g c b a | h f e d }
------- connections -------
a - b - c
b - d - e - f
c - f - g
a - g
d - e - h
f - h

All Examples

Possible dependencies: Boost, Gurobi, Cbc, Lemon, Csdp, OpenBLAS.

References

Graph Partition

Graph Coloring

Graph Misc

Placement