Algorithms for solving optimization problems in answer set programming