  The quantum approximate optimization algorithm/quantum alternating operator
ansatz (QAOA) is a heuristic to find approximate solutions of combinatorial
optimization problems. Most literature is limited to quadratic problems without
constraints. However, many practically relevant optimization problems do have
(hard) constraints that need to be fulfilled. In this article, we present a
framework for constructing mixing operators that restrict the evolution to a
subspace of the full Hilbert space given by these constraints; We generalize
the "XY"-mixer designed to preserve the subspace of "one-hot" states to the
general case of subspaces given by a number of computational basis states. We
expose the underlying mathematical structure which reveals more of how mixers
work and how one can minimize their cost in terms of number of CX gates,
particularly when Trotterization is taken into account. Our analysis also leads
to valid Trotterizations for "XY"-mixer with fewer CX gates than is known to
date. In view of practical implementations, we also describe algorithms for
efficient decomposition into basis gates. Several examples of more general
cases are presented and analyzed.
