1 /* Copyright (C) 2006-2008 Joris Mooij [j dot mooij at science dot ru dot nl]
2 Radboud University Nijmegen, The Netherlands
4 This file is part of libDAI.
6 libDAI is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libDAI is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libDAI; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "../factorgraph.h"
30 int main( int argc
, char *argv
[] ) {
32 cout
<< "Usage: " << argv
[0] << " <in.fg>" << endl
<< endl
;
33 cout
<< "Reports some characteristics of the .fg network." << endl
;
38 char *infile
= argv
[1];
40 if( fg
.ReadFromFile( infile
) ) {
41 cerr
<< "Error reading file " << infile
<< endl
;
44 cout
<< "Number of variables: " << fg
.nrVars() << endl
;
45 cout
<< "Number of factors: " << fg
.nrFactors() << endl
;
46 cout
<< "Connected: " << fg
.isConnected() << endl
;
47 // cout << "Treewidth: " << endl;
49 double cavsum_lcbp
= 0.0;
50 double cavsum_lcbp2
= 0.0;
51 size_t max_Delta_size
= 0;
52 for( size_t i
= 0; i
< fg
.nrVars(); i
++ ) {
53 VarSet di
= fg
.delta(fg
.var(i
));
54 size_t Ds
= fg
.Delta(fg
.var(i
)).stateSpace();
55 if( Ds
> max_Delta_size
)
57 cavsum_lcbp
+= di
.stateSpace();
58 for( VarSet::const_iterator j
= di
.begin(); j
!= di
.end(); j
++ )
59 cavsum_lcbp2
+= j
->states();
61 cout
<< "Maximum pancake has " << max_Delta_size
<< " states" << endl
;
62 cout
<< "LCBP with full cavities needs " << cavsum_lcbp
<< " BP runs" << endl
;
63 cout
<< "LCBP with only pairinteractions needs " << cavsum_lcbp2
<< " BP runs" << endl
;