  We optimize finite-time stochastic heat engines with a periodically scaled
Hamiltonian under experimentally motivated constraints on the bath temperature
$T$ and the scaling parameter $\lambda$. We present a general geometric proof
that maximum-efficiency protocols for $T$ and $\lambda$ are piecewise constant,
alternating between the maximum and minimum allowed values. When $\lambda$ is
restricted to a small range and the system is close to equilibrium at the ends
of the isotherms, a similar argument shows that this protocol also maximizes
output power. These results are valid for arbitrary dynamics. We illustrate
them for an overdamped Brownian heat engine, which can experimentally be
realized using optical tweezers with stiffness $\lambda$.
