Optimization on a compact set