code: public static int getConfigIndex(VarSet vars, VarConfig config) {
          int configIndex = 0;
          int numStatesProd = 1;
          for (int v=vars.size()-1; v >= 0; v--) {
              Var var = vars.get(v);
              int state = config.getState(var, 0);
              configIndex += state * numStatesProd;
              numStatesProd *= var.getNumStates();
          }
          return configIndex;
      }
docs: Gets the index of the configuration of the variables where all those in config
  have the specified value, and all other variables in vars have the zero state.
  
  @param vars The variable set over which to iterate.
  @param config An assignment to a subset of vars.
  @return The configuration index.