heuristic function fixed