Heuristics and optimization for knowledge discovery