code: public static int libDaiIxToConfigId(int libDaiIx, int[] dims, Var[] varArray, VarSet vs) {
          int[] config = Tensor.unravelIndexMatlab(libDaiIx, dims);
          VarConfig vc = new VarConfig(varArray, config);
          return vc.getConfigIndexOfSubset(vs);
      }
docs: converts the index to the index used in pacaya the difference is that the
  vars in vs may be reordered compared to varArray and that pacaya
  representation has the leftmost v in vs be the slowest changing while
  libdai has the rightmost in varArray be the slowest changing; dims and
  varArray are assumed to both correspond to the order of the variables
  that is left to right (slowest changing last); the resulting index will
  respect the order of var in vs which is vs.get(0) as the slowest
  changing.