Appears to be working (both the comparison between replica and sampling and between replica and Lagrangian optimality. The error in the previous version was with using the wrong qThy