/***************************************************************************** ** banzhaf.h = header file for Banzhaf power index computations ** ** Original version: Mark A. Livingston, 24 Dec 95 ** Dept. of Computer Science, Univ. of North Carolina ** ** Modification: 05 May 2000 (Added qualified majority switch) ** Hewlett-Packard Laboratories, Palo Alto, California ** ** Copyright (C) 1995--2000, Mark A. Livingston, The University of North ** Carolina at Chapel Hill, Hewlett-Packard Company ** ** Type declarations needed for computation of Banzhaf power index for a ** voting block. *****************************************************************************/ /* Boolean type and constants */ #ifndef False #define False 0 #endif #ifndef True #define True !False #endif typedef int Boolean; /* some simple constants */ #define BUFLEN 256 #define NAMELEN 81 /* Main structure for organizing data */ typedef struct { /* static data, read from file */ char *name; /* of block */ int pop; /* ulation */ int weight; /* number of votes for this block */ /* first group used for counting of coalitions */ Boolean member; /* are we in the current 'yea' coalition? */ unsigned long power; /* current number of 'critical' coalition memberships */ double Pb_chng; /* probability of block changing election result */ /* second group used for computations done with Stirling's approximation */ double Pp_chng; /* probability of changing block's decision */ /* putting it all together */ double ppc; /* power per capita, computed by either method */ double pr; /* power ratio, eventually normalized to be relative to power of citizens with the weakest voting strength */ } Block; /* Function declarations */ int banzhafReadBlocks( char *fname, Block **bl ); void banzhafSetMajority( int value ); Boolean banzhafNextCoalition( Block *bl, int ct, Boolean verbose ); Boolean banzhafHasCritical( Block *bl, int ct ); void banzhafCountCritical( Block *bl, int ct ); void banzhafComputeRatios( Block *bl, int ct ); void banzhafPrintTable( Block *bl, int ct ); #define Swap( a, b, t ) { t = b; b = a; a = t; }