  The quantum approximate optimization algorithm (QAOA) is a hybrid
quantum-classical variational algorithm that offers the potential to handle
combinatorial optimization problems. Introducing constraints in such
combinatorial optimization problems poses a significant challenge in the
extensions of QAOA to support relevant larger-scale problems. This paper
introduces a quantum machine learning approach to learn the mixer Hamiltonian
required to hard constrain the search subspace. We show that this method can be
used for encoding any general form of constraints. One can directly plug the
learnt unitary into the QAOA framework using an adaptable ansatz. This
procedure gives the flexibility to control the depth of the circuit at the cost
of the accuracy of enforcing the constraint, thus having immediate application
in the Noisy Intermediate Scale Quantum (NISQ) era. We also develop an
intuitive metric that uses Wasserstein distance to assess the performance of
general approximate optimization algorithms with/without constraints. Finally,
using this metric, we evaluate the performance of the proposed algorithm.
