  We derive the fundamental equations of an optimal control theory for systems
containing both quantum electrons and classical ions. The system is modeled
with Ehrenfest dynamics, a non-adiabatic variant of molecular dynamics. The
general formulation, that needs the fully correlated many-electron wave
function, can be simplified by making use of time-dependent density-functional
theory. In this case, the optimal control equations require some modifications
that we will provide. The abstract general formulation is complemented with the
simple example of the H$_2^+$ molecule in the presence of a laser field.
