Solving a Hamilton–Jacobi–Bellman equation with constraints