refactor libdai wrappers for the new visitors