Modeling and optimal control of flexible wave energy converters