A non-convex variational problem with constraints