Providing an algorithm for solving general optimization problems based on Domino theory