This paper formulates an optimal control problem for a system of rigid bodies
that are connected by ball joints and immersed in an irrotational and
incompressible fluid. The rigid bodies can translate and rotate in
three-dimensional space, and each joint has three rotational degrees of
freedom. We assume that internal control moments are applied at each joint. We
present a computational procedure for numerically solving this optimal control
problem, based on a geometric numerical integrator referred to as a Lie group
variational integrator. This computational approach preserves the Hamiltonian
structure of the controlled system and the Lie group configuration manifold of
the connected rigid bodies, thereby finding complex optimal maneuvers of
connected rigid bodies accurately and efficiently. This is illustrated by
numerical computations.