Towards the optimum by semidefinite and copositive programming