Trajectory optimization for a two-link flexible manipulator