Optimization of functions on certain subsets of Banach spaces