a partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

6
Computer Physics Communications 163 (2004) 79–84 www.elsevier.com/locate/cpc A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes Heng Liang, Fengshan Bai Department of Mathematical Sciences, Tsinghua University, Beijing, 100084, P.R. China Received 7 April 2004; accepted 2 August 2004 Abstract A partially structure-preserving method for sparse symmetric matrices is proposed. Computational results on the permanents of adjacency matrices arising from molecular chemistry are presented. The largest adjacency matrix of fullerenes computed before is that of C 60 with a cost of several hours on supercomputers, while only about 6 min on an Intel Pentium PC (1.8 GHz) with our method. Further numerical computations are given for larger fullerenes and other adjacency matrices with n = 60, 80. This shows that our method is promising for problems from molecular chemistry. 2004 Elsevier B.V. All rights reserved. PACS: 02.10.Eb; 02.10.Sp; 81.05.Tp Keywords: Permanent of matrix; Adjacency matrix; Structure-preserving algorithm; Fullerenes 1. Introduction The permanent of an n × n matrix A =[a ij ] is de- fined as (1) Per(A) = σ Λ n n i =1 a iσ(i) where Λ n denotes the set of all possible permutations of {1, 2,...,n}. The numerical computation of the Supported by National Science Foundation of China G10228101 and National Key Basic Research Special Fund G1998020306. * Corresponding author. E-mail address: [email protected] (F. Bai). permanent recently attracts more and more attentions from mathematicians and computer scientists [1–8], statistical physists [9–11] and chemists [12–17]. The definition of Per(A) looks similar to the determinant of matrix, however, it is much harder to be computed. Valiant [2] proves that computing the permanent of a (0, 1) matrix is a #P-complete problem in counting. Even for matrices with only three nonzero entries in each row and column, evaluating their permanents is still a #P-complete problem [3]. The best-known algorithm on precise evaluation of the permanent, due to Ryser [18] and later im- proved by Nijenhuis and Wilf [19], runs O(n2 n1 ) in complexity. For (0, 1) sparse matrices, there are sev- 0010-4655/$ – see front matter 2004 Elsevier B.V. All rights reserved. doi:10.1016/j.cpc.2004.08.003

Upload: heng-liang

Post on 26-Jun-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

c

rmanentsomputed

8 GHz)

Computer Physics Communications 163 (2004) 79–84

www.elsevier.com/locate/cp

A partially structure-preserving algorithm for the permanentsof adjacency matrices of fullerenes✩

Heng Liang, Fengshan Bai∗

Department of Mathematical Sciences, Tsinghua University, Beijing, 100084, P.R. China

Received 7 April 2004; accepted 2 August 2004

Abstract

A partially structure-preserving method for sparse symmetric matrices is proposed. Computational results on the peof adjacency matrices arising from molecular chemistry are presented. The largest adjacency matrix of fullerenes cbefore is that ofC60 with a cost of several hours on supercomputers, while only about 6 min on an Intel Pentium PC (1.with our method. Further numerical computations are given for larger fullerenes and other adjacency matrices withn = 60,80.This shows that our method is promising for problems from molecular chemistry. 2004 Elsevier B.V. All rights reserved.

PACS: 02.10.Eb; 02.10.Sp; 81.05.Tp

Keywords: Permanent of matrix; Adjacency matrix; Structure-preserving algorithm; Fullerenes

nse

inaund

s

ted.f ag.in

s

ion

v-

1. Introduction

The permanent of ann × n matrix A = [aij ] is de-fined as

(1)Per(A) =∑

σ∈Λn

n∏i=1

aiσ(i)

whereΛn denotes the set of all possible permutatioof {1,2, . . . , n}. The numerical computation of th

✩ Supported by National Science Foundation of ChG10228101 and National Key Basic Research Special FG1998020306.

* Corresponding author.E-mail address: [email protected](F. Bai).

0010-4655/$ – see front matter 2004 Elsevier B.V. All rights reserveddoi:10.1016/j.cpc.2004.08.003

permanent recently attracts more and more attentionfrom mathematicians and computer scientists[1–8],statistical physists[9–11] and chemists[12–17]. Thedefinition of Per(A) looks similar to the determinanof matrix, however, it is much harder to be computValiant [2] proves that computing the permanent o(0,1) matrix is a #P-complete problem in countinEven for matrices with only three nonzero entrieseach row and column, evaluating their permanents istill a #P-complete problem[3].

The best-known algorithm on precise evaluatof the permanent, due to Ryser[18] and later im-proved by Nijenhuis and Wilf[19], runs O(n2n−1) incomplexity. For(0,1) sparse matrices, there are se

.

Page 2: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

80 H. Liang, F. Bai / Computer Physics Communications 163 (2004) 79–84

sion

o-as

l-ws

ith

iona-ill

-of

rop-

;

ting

ch

-a-

nalblyre-ing

ces.nll-elllym-

ma-ru-

f-

e

st

.

d.

ate

two

eral other precise algorithms, such as direct expanmethod[12] and Kallman’s method[20]. Delic andCash[15] intensively review and compare those algrithms. They are tested on different platforms, suchCray T3D, SGI as well as Intel PC’s. Kallman’s agorithm performs the best over all others, and shothe lowest growth rate with respect ton in computa-tional costs. Thus we always make comparison wKallman’s algorithm in this paper.

It is only possible to make the precise calculatmethod faster if the special structural properties of mtrices can be used intensively. In this paper, we wfocus mostly on adjacency matrices arising from molecular chemistry[21] so that the structure propertiesmatrices are explored accordingly. They are all(0,1)

sparse matrices and have the following structure perties in common:

(1) symmetric;(2) degree (i.e. row or column sum) of either 3 or 2(3) all 0 entries along the main diagonal.

Among the adjacency matrices, the most interesones are those of fullerenes[12,13,22]which satisfy astronger structure property instead of (2):

(2)′ degree always 3.

Hence the computation for fullerenes is muharder.

A partially structure-preserving method, which improves a hybrid algorithm for sparse symmetric mtrices, is proposed. Adjacency matrices used in[15]are calculated with our methods. The computatioresults show that the hybrid algorithm is remarkafaster than Kallman’s method. The partially structupreserving method can speed up further by makuse of the structure properties of adjacency matriThe computation forC60 takes more than 6 hours oSGI Onyx2 (1 processor) with Fortran 77 using Kaman’s algorithm, while only about 6 min on an IntPentium PC (1.8 GHz) with Matlab using the partiastructure-preserving method. Further numerical coputations are presented for other fullerenes andtrices with even largern. The results show that ounew method is promising for problems from moleclar chemistry.

2. Algorithms

2.1. Ryser–Nijenhuis and Wilf method (R-NW)

Let S be any set, and|S| denote the number oelements of the setS. Ryser[18] shows that the permanent of matrixA can be given by

(2)Per(A) = (−1)n∑S

(−1)|S|n∏

i=1

(∑j∈S

aij

).

Here A is the n × n matrix andS runs over all thesubsets of{1,2, . . . , n}. This method is based on thinclusion and exclusion principle.

The computational cost of Ryser formula is O(n2 ·2n−1). Nijenhuis and Wilf[19] improve Ryser methodthrough the following considerations.

(1) It is enough to process only the subsets of{1,2,

. . . , n − 1}. This reduces the computational coof Ryser method by a factor of 2.

(2) A Hamiltonian walk on an(n − 1)-cube (Chap-ter 1 of [19]) is used in the implementationA slight change in the calculation for a setS

yields the result for the successor ofS. This ac-complishes a reduction of a factorn/2 in thecomputational cost.

So the total computational cost becomes O(n ·2n−1). We call the improved version R-NW methowhich is very efficient for small and dense matrices

2.2. A hybrid method

Consider an expansion

Per

(a b xT

y1 y2 Z

)

= Per

(0 0 xT

y1 y2 Z

)+ Per(ay2 + by1 Z)

(3)= Per(A1) + Per(A2),

wherea andb are scalars,xT is an(n−2)-dimensionalrow vector,y1 and y2 are both(n − 1)-dimensionalcolumn vectors, andZ is an(n − 1) × (n − 2) matrix.This expansion is used to establishing an approximalgorithm for permanent by[11]. Combining the ex-pansion (3) with R-NW algorithm, a hybrid algorithmis constructed. Essentially, the method eliminates

Page 3: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

H. Liang, F. Bai / Computer Physics Communications 163 (2004) 79–84 81

han

ne

he-

,,

a-m

ive

S

a-yill

ne

telted(1),the

n-

theted

en-

allThe

entries each time. Hence it is exponentially faster tthe direct expansion method.

Algorithm H (Hybrid).

P = H(A)

n ← the order ofAs ← the minimal number of nonzero entries in o

row or column ofAif n > 2 ands < 5, then divideA into A1,A2 as (3),

andP = H(A1) + H(A2)

else return by R-NW(A).

The algorithm above is recursive. Here R-NW(A)

means that the permanent ofA is evaluated with R-NW method.

2.3. A partially structure-preserving method

The following expansion can partially preserve tstructure properties (1)–(3) so as to improve the efficiency in computation further.

Per

0 a b xT

a 0 c yT1

b c 0 yT2

x y1 y2 Z

= Per

0 0 0 xT

0 0 c yT1

0 c 0 yT2

x y1 y2 Z

+ 2abc · Per(Z)

+ Per

(0 ayT

2 + byT1

ay2 + by1 Z

)

+2 · Per

( 0 0 xT

ac bc ayT2 + byT

1y1 y2 Z

)

(4)= Per(A1) + αPer(A2) + Per(A3) + 2Per(B),

wherea, b andc are scalar,α = 2abc is a constantxT, yT

1 andyT2 are all(n − 3)-dimensional row vector

Z is an (n − 3) × (n − 3) symmetric matrix with alldiagonal entries 0.

Notice that matricesA1,A2 andA3 are symmetricand still have all 0 along diagonal. Hence the permnent of the matrixA can be computed by the suof permanents of matricesA1,A2 and A3, togetherwith the permanent of a nonsymmetric matrixB. Al-gorithm S, a partially structure-preserving recurs

Table 1Comparison between computational times of Algorithms H and

n Per(A) H (s) S (s) Speedup ratio

30 33317 0.421 0.263 1.6040 1260673 4.08 2.41 1.6950 12237781 57.9 33.5 1.7360 294614944 689 383 1.80

method, is given as follows. The nonsymmetric mtrix B is computed with Algorithm H. As long as anof the matrix becomes small and/or dense, R-NW wbe used.

Algorithm S (Partially structure-preserving).

P = S(A)

n ← the order ofAs ← the minimal number of nonzero entries in o

row or column ofAif n > 4 ands < 5, then divide A into symmetric

matricesA1,A2,A3 and a nonsymmetric matrixB as (2),andP = S(A1) + αS(A2) + S(A3) + 2H(B)

else return by R-NW(A).

Table 1shows our computational results on an InPentium PC (1.8 GHz). The matrices are construcrandomly such that satisfy the structure properties(2)′ and (3) in the last section. One can see thatspeedup ratio of Algorithm S versus Algorithm H icreases asn grows.

3. Numerical results

Computational results on some fullerenes withnumber of carbon atoms from 30 to 82 are reporfirst. Results by Delic and Cash[15] are comparedwith our computations. Then permanents of some geral matrices with structure properties (1)–(3) are cal-culated.

3.1. The permanents of the adjacency matrices offullerenes

In this subsection, five test matrices which areadjacency matrices of fullerenes are computed.

Page 4: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

82 H. Liang, F. Bai / Computer Physics Communications 163 (2004) 79–84

e-

-ac-Ino-out

z),hen-hanbeC.nd

er-

at

. Soleis

nd

ander

forl-

ast

y

s

ofn-.336e

-

de-ity

r-

c-fwsare

udeare

Table 2Computational results of Algorithm S for fullerenes

Fullerene n Per(A) S (s)

C30(C2ν) 30 29621 0.328C44(T ) 44 2478744 8.22C60(Ih) 60 395974320 355.2C70(D5h) 70 9193937544 3606C82(C2) 82 418912566060 60730

data are taken from fullerenes gallery by Yoshida[23].The computational results are shown inTable 2.

Note thatC60 is the largest fullerenes computed bfore on supercomputers. We can computeC70 andC82with Algorithm S simply using PC.

3.2. Comparison with results before

Delic and Cash[15] show that type of CPU, platform, compiler and programming language are all ftors to the efficiency of algorithm implementation.their tests, Kallman’s method on SGI Onyx2 (1 prcessor) with Fortran 77 runs fastest, and it takes ab6.12 hrs for the case ofC60. Algorithm S takes onlyabout 6 min for the same problem on PC (1.8 GHas shown inTable 2. We use Matlab 5.3/6.1 here as tprogramming language for simplicity. Matlab is an iterpreted programming language. It runs slower tFortran and C in general. So our algorithms shouldable to run even faster by porting them to Fortran or

The comparison between Kallman’s method aAlgorithm S is shown inTable 3. Results of Kallman’smethod are all taken from[15]. That the Intel 133 MHzruns faster than the Intel 166 MHz is due to the diffence in compiler. It indicates that WATCOM compileris about ten times faster than Microsoft compilerthat time. Note that test matrices withn = 30,44,60are all degree 3, whereas those withn = 48,52,56have row sums either 3 or 2 (and hence sparser)they are divided into two subgroups. In order to ruout the factor of hardware, our Matlab 5.3 programrun on an Intel Pentium (133 MHz). That is also a kiof computer used by[15].

Regardless factors of programming languagecompiler, Algorithm S is still about 50 times fastthan Kallman’s method for the casen = 60.

Computational costs increase about 25 timesAlgorithm S and at least 145 times for Kallman’s agorithm, asn grows fromn = 30 ton = 44. And they

Fig. 1. The relations between log2(T ) andn.

increase about 40 times for Algorithm S and at le250 times for Kallman’s algorithm, asn grows fromn = 44 ton = 60. This indicates that Algorithm S mastill be promising asn goes larger.

We further find that the logarithm of running timeare almost linearly increase with respect ton for bothAlgorithm S and Kallman’s method. The logarithmrunning time of Algorithm S (we take the case of Itel PC 1.8 GHz) has the increase scope about 0with n and that of Kallman’s method (we take thcase of SGI Onyx2, which is the best in[15]) hasthe increase scope 0.506 withn. The relations between log2(T ) andn of Algorithm S and Kallman’smethod are shown inFig. 1, where theT denotes therunning time, K denotes Kallman’s method and Snotes Algorithm S. For fullerenes, the time complexof Algorithm S method is roughly O(2n/3) and that ofKallman’s method is roughly O(2n/2). Note that thetime complexity of R-NW is O(n2n). As n is littlelarger, such differences are crucial.

3.3. Further numerical computation

In order to show the efficiency of our methods futher, we construct two sets of matrices withn = 60and n = 80, respectively. They all have the struture properties (1)–(3). Let m denote the number orows (columns) with degree 2, and the rest of ro(columns) all have degree 3. Numerical resultsgiven inTables 4and5.

From the computational results one can conclthat Algorithms H and S are high speed. Theypromising for large scale very sparse problems.

Page 5: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

H. Liang, F. Bai / Computer Physics Communications 163 (2004) 79–84 83

Table 3Computational costs of Kallman’s method and Algorithm S (s)

n Kallman[15] S

Cray C90 SGI Onyx2 Intel (133 MHz) Intel (166 MHz) Intel (133 MHz)

48 27.0 17.0 155 1469.7 13.352 95.4 60.6 555 5386.7 24.056 832.3 464 4745 46045.5 126.6

30 0.957 0.60 4.5 41.1 5.3844 179.2 88.4 1089 8754.7 133.060 55834 22032 304564 – 5620.5

Table 4Computational results forn = 60

m 0 2 4 6 8 10

Per(A) 305772432 116492924 43714385 25301405 12394933 9861700H (s) 541 355 188 61.4 14.6 9.28S (s) 276 183 106 36.7 10.9 5.59Speedup 1.96 1.94 1.77 1.68 1.34 1.66

Table 5Computational results forn = 80

m 0 4 8 12 16

Per(A) 135613902348 21867490933 3047801633 1157835140 149329201H (s) 147531 13759 4299 880 120S (s) 86529 8885 2281 568 102Speedup 1.71 1.55 1.88 1.55 1.18

ro-tri-up

ilere.is

o-enem

thisson-

Ap-bean

-

asd to

ing

,

,

.

4. Discussions and conclusions

In this paper, a structure-preserving method is pposed for finding the permanents of adjacency maces arising from molecular chemistry. Fullerenesto C82 are computed with our new method, whC60 is the largest fullerenes ever computed befoThis shows that the structure-preserving methodpromising for larger fullerenes. Approximate algrithm may essentially be the unique way for evlarger fullerenes, since it is a #P-complete problin computation[3].

Compare with the precise methods discussed inpaper, approximate algorithms can produce a reaable estimation forPer(A) within a relatively shortCPU time. Results obtained are no longer exact.proximate algorithms on permanent can roughlydivided into the following classes: random Laplaciexpansion method[6], reduction to determinants[5],Markov chain Monte Carlo[4,8] and importance sam

pling method[10]. Abundant theoretical analysis hbeen developed for those methods. Works still neebe done for solid applications.

Acknowledgments

The authors thank referees for their careful readand helpful suggestions and comments.

References

[1] H. Minc, Permanents, Addison-Wesley, 1978.[2] L. Valliant, Theoret. Comput. Sci. 8 (1979) 189.[3] P. Dagum, M. Luby, M. Mihail,U. Vazirani, in: 29th FOCS

1988, p. 412.[4] M. Jerrum, A. Sinclair, SIAM J. Comput. 18 (1989) 1149.[5] N. Karmarkar, R.M. Karp, R. Lipton, L. Lovasz, M. Luby

SIAM J. Comput. 22 (1993) 284.[6] L.E. Rasmussen, Random Struct. Algorithms 5 (1994) 349

Page 6: A partially structure-preserving algorithm for the permanents of adjacency matrices of fullerenes

84 H. Liang, F. Bai / Computer Physics Communications 163 (2004) 79–84

.6)

67.

.15.)

cal

978,

ess,

r.

[7] A.I. Barvinok, Random Struct. Algorithms 14 (1999) 29.[8] M. Jerrum, A. Sinclair, E. Vigoda, in: 33th STOC, 2001, p. 712[9] C. Kenyon, D. Randall, A. Sinclair, J. Stat. Phys. 83 (199

637.[10] I. Beichl, F. Sullivan, J. Comput. Phys. 149 (1999) 128.[11] H. Forbert, D. Mark, Comput. Phys. Commun. 150 (2003) 2[12] G.G. Cash, J. Math. Chem. 18 (1995) 115.[13] G.G. Cash, Polycyclic Aromatic Compounds 12 (1997) 61.[14] I. Gutman, Polycyclic Aromatic Compounds 12 (1998) 281[15] G. Delic, G.G. Cash, Comput. Phys. Commun. 124 (2000) 3[16] F. Torrens, Internet Electronic J. Molecular Design 1 (2002

352.[17] F. Torrens, J. Chem. Inf. Comput. Sci. 44 (2004) 60.

[18] H.J. Ryser, Combinatorial Mathematics, Wiley, MathematiAssociation of America, 1963.

[19] A. Nijenhuis, H.S. Wilf, Combinatorial Algorithms for Com-puters and Calculators, second ed., Academic Press, 1Chapter 23.

[20] R. Kallman, Math. Comput. 38 (1982) 167.[21] N. Trinajstic, Chemical Graph Theory, second ed., CRC Pr

1992.[22] H.W. Kroto, Nature 329 (1987) 529.[23] M. Yoshida,http://www.cochem2.tutkie.tut.ac.jp/Fuller/Fulle

html, 1998.