Presentation is loading. Please wait.

Presentation is loading. Please wait.

Searching for maximum cliques (implementation details) WORKSHOP ON CLUSTERING AND SEARCH TECHNIQUES IN LARGE SCALE NETWORKS This work is partially funded.

Similar presentations


Presentation on theme: "Searching for maximum cliques (implementation details) WORKSHOP ON CLUSTERING AND SEARCH TECHNIQUES IN LARGE SCALE NETWORKS This work is partially funded."— Presentation transcript:

1 Searching for maximum cliques (implementation details) WORKSHOP ON CLUSTERING AND SEARCH TECHNIQUES IN LARGE SCALE NETWORKS This work is partially funded by the Spanish National Government (DPI C02) and CAR (UPM-CSIC) Pablo San Segundo Carrillo (Associate professor in UPM)

2 Overview 2  Simple case studies  BITSCAN  Brief description of main features  Comparison with state of the art  Application to maximum clique in large scale networks (BBMCS)  Graph encoding  Coloring  Computation of a new subproblem (a child subgraph)  Summary

3 Case study (I): multi-properties 3 enum mode_t{ MODE_A = 0x01, MODE_B = 0x02, MODE_C = 0x04, MODE_D = 0x08 }; class Foo{ public: void set_modes(int modes){current_modes=modes;} bool clear_modes(int modes){ return current_modes &= ~modes; } bool test_mode(mode_t mode) const{ return current_modes & mode; } private: int current_modes; }; void main(){ Foo myfoo; myfoo.set_modes(MODE_A | MODE_B | MODE_D); myfoo.clear_modes(MODE_D); if(myfoo.test_mode(MODE_D)) cout<<"MODE_D is active"<

4 Case study (II.1): Set representation 4  Membership to a set  1-bit : member  0-bit: not a member  Storage of a subset of natural numbers Masks (C-C++) A U BA b | B b A ∩ BA b & B b A – BA b &~ B b (A B)?{A b &~ B b } ≠

5 Case study (II.2): An example 5 #define NUMBER_OF_STUDENTS 100 void main(){ set s_ids;// student ids set e_ids;// exam ids for(int i=1; i<=NUMBER_OF_STUDENTS; i++){ s_ids.insert(i); } //… determine exam ids //students which did not take the exam set s_not_assist; set_difference(s_ids.begin(), s_ids.end(), e_ids.begin(), e_ids.end(), insert_iterator >( s_not_assist, s_not_assist.begin()) ); } #define NUMBER_OF_STUDENTS 100 void main(){ bitarray s_ids(NUMBER_OF_STUDENTS);// student ids bitarray e_ids(NUMBER_OF_STUDENTS);// exam ids s_ids.init_bit(0,NUMBER_OF_STUDENTS-1); //… determine exam ids //students which passed the exam bitarray s_not_assist(s_ids); s_not_assist.erase_bit(e_ids); } O(n/W size )

6 BITSCAN: a C++ library for bitstrings 6  Inspired by optimization requirements found during 10 years of research in combinatorial optimization problems.  Implementation of exact algorithms for NP-hard problems related to graphs (maximum clique, vertex coloring etc.)  Some of these requirements  Fast bitscanning loops  Forward and reverse directions  Destructive and non-destructive  Sparsity  Semi-sparsity

7 7 Data types  Main data types  bitblock  bitarray  sparse_bitarray  watched_bitarray simple_bitarraysimple_sparse_bitarray bitarray bbo watched_bitarray bitblock sparse_bitarray

8 bitblock type: 64bit bit-twiddling 8 #include "pablodev/bitscan/bitscan.h“ void main(){ BITBOARD bb=0xFFF; cout<<"number of 1-bits:"<

9 bitarray type: bitscanning loops 9 #include "pablodev/bitscan/bitscan.h" #define POPULATION_SIZE 100 void main(){ bitarray bba(POPULATION_SIZE); bba.init_bit(0, 9);//first 10 bits to 1 //typical bit scanning loop int nBit=EMPTY_ELEM; bba.init_scan(bbo::NON_DESTRUCTIVE); while(true){ nBit=bba.next_bit(); if(nBit==EMPTY_ELEM) break; cout<

10 sparse_bitarray type 10 S S b = ··· 111 S sb = ··· 100 class sparse_bitarray: public bbo{ struct elem_t{ int index; BITBOARD bb; }; protected: vector m_aBB; int m_MAXBB;//max num. of bitblocks }; Sorted array by index always Complexity of setting bits? Complexity of deleting bits? Complexity of bit masking with other sparse bitarrays? Complexity of setting bits? Complexity of deleting bits? Complexity of bit masking with other sparse bitarrays?

11 sparse_bitarray : example 11 #include "pablodev/bitscan/bitscan.h“ #define POPULATION_SIZE void main(){ sparse_bitarray bba(POPULATION_SIZE); bba.set_bit(1216, 1230); cout<<"number of bitblocks:"<

12 watched_bitarray type 12  Conceived for semi-sparse sets  Addresses the following issues  Fast empty-set detection  Avoids spurious operations between empty bitblocks LC UC Mask S

13 Current state of BITSCAN 13  Alpha  Lacking proper doc, standardization of names and namespaces…   Easy to use  Active development  Applied in cutting edge research on efficient algorithms  Source code available in Biicode repository  #include “pablodev/bitscan/bitscan.h”  https://www.biicode.com/  Tested on Windows and Linux WE NEED YOUR FEEDBACK!

14 State of the Art : functionality 14  std::vector  std::bitset  boost::dynamic_bitset  find y find_next NONE OF THEM ADDRESS ANY OF THE PREVIOUS ISSUES DIRECTLY

15 State of the Art: efficiency (I) 15 Results over repetitions

16 State of the Art: efficiency (II) 16  BITSCAN is in the core of a number of algorithms for NP- hard problems widely accepted as state of the art by the scientific community:  PASS: An exact vertex coloring algorithm  BBMC: An exact maximum clique algorithm  These algorithms are known since 2010 and literature does not report superior performance with other state of the art bitstring implementations.

17 APPLICATION TO COMBINATORIAL OPTIMIZATION

18 Graph bitarray encoding : GRAPH Vertices x x x x x Adjacency Matrix bitarray 0 bitarray 2 bitarray 3 bitarray 4 bitarray 1 #include "pablodev/graph/graph.h“ #define NUMBER_OF_VERTICES 5 void main(){ //undirected graph ugraph ug(NUMBER_OF_VERTICES); ug.add_edge(0, 1); ug.add_edge(0, 2); ug.add_edge(1, 2); ug.add_edge(1, 3); ug.add_edge(3, 4); //… } #include "pablodev/graph/graph.h“ #define NUMBER_OF_VERTICES void main(){ //undirected graph sparse_ugraph ug(NUMBER_OF_VERTICES); ug.add_edge(0, 1); ug.add_edge(0, 2); ug.add_edge(1, 2); ug.add_edge(1, 3); ug.add_edge(3, 4); //… }

19 Greedy sequential vertex coloring C1C1 C2C2 C3C SEQ: GREEDY COLORING PROCEDURE 1.Define a vertex ordering 2.Color vertices sequentially with the least possible color

20 Implementation of SEQ with BITSCAN/GRAPH (I) 20 #include "pablodev/copt/init_color.h“ #include "pablodev/graph/graph.h“ #define GRAPH_SIZE 5 void main(){ //Ugraph ugraph ug(GRAPH_SIZE); ug.add_edge(0, 1); ug.add_edge(0, 3); ug.add_edge(1, 2); ug.add_edge(1, 4); ug.add_edge(2, 3); ug.add_edge(2, 4); ug.add_edge(3, 4); ug.add_edge(0, 5); InitColor c(ug); bitarray subgraph(GRAPH_SIZE); subgraph.init_bit(0, GRAPH_SIZE-1) cout<<"col_size:"<

21 Implementation of SEQ with BITSCAN/GRAPH (II) 21 template<> int InitColor ::greedyIndependentSetColoring(bitarray & bb){ int pc=bb.popcn64(), col=1, v=EMPTY_ELEM, from=EMPTY_ELEM; bitarray sel(g.number_of_vertices()); bitarray unsel(bb); while(true){ sel=unsel; sel.init_scan(bbo::DESTRUCTIVE); while(true){ if( (v=sel.next_bit_del(from, unsel))==EMPTY_ELEM ) break; //exit condition: all vertices colored if((--pc)==0)return col; //implicitly computes next vertex in the same color class sel.erase_block(from, g.get_neighbors(v)); } col++; //next color class } return col; }

22 Computing child subgraph in maximum clique 22 //P is the current subproblem, P new the new child subproblem //v is the current vertex to expand //Node generation by masking AND(g.get_neighbors(v), P, P new ); inline BitBoardS& AND (const BitBoardS& lhs, const BitBoardS& rhs, BitBoardS& res){ res.erase_bit(); int i1=0, i2=0; while(i1!=lhs.m_aBB.size() && i2!=rhs.m_aBB.size() ){ if(lhs.m_aBB[i1].index

23 Summary 23  A number of important issues related to bitstrings and their application to combinatorial optimization have been described  BITSCAN and GRAPH C++ libraries have been presented  A number of implementation details behind BBMCS have been discussed.


Download ppt "Searching for maximum cliques (implementation details) WORKSHOP ON CLUSTERING AND SEARCH TECHNIQUES IN LARGE SCALE NETWORKS This work is partially funded."

Similar presentations


Ads by Google