Constrained Optimal Control of a Flap-Type Wave Energy Converter with a Hydraulic Power Take-Off and Realistic Loss Model