public int getConfigIndexOfSubset ( VarSet vars ) { int configIndex = 0 ; int numStatesProd = 1 ; for ( int v = vars . size ( ) - 1 ; v >= 0 ; v -- ) { Var var = vars . get ( v ) ; int state = config . get ( var ) ; configIndex += state * numStatesProd ; numStatesProd *= var . getNumStates ( ) ; if ( numStatesProd <= 0 ) { throw new IllegalStateException ( "Integer overflow when computing config index -- this can occur if trying to compute the index of a high arity factor: " + numStatesProd ) ; } } return configIndex ; }
Gets the index of this configuration for the given variable set .