Given a generic time-dependent many-body quantum state, we determine the associated parent Hamiltonian. This procedure may require, in general, interactions of any sort. Enforcing the requirement of a fixed set of engineerable Hamiltonians, we find the optimal Hamiltonian once a set of realistic elementary interactions is defined. We provide three examples of this approach. We first apply the optimization protocol to the ground states of the one-dimensional Ising model and a ferromagnetic p-spin model but with time-dependent coefficients. We also consider a time-dependent state that interpolates between a product state and the ground state of a p-spin model. We determine the time-dependent optimal parent Hamiltonian for these states and analyze the capability of this Hamiltonian of generating the state evolution. Finally, we discuss the connections of our approach to shortcuts to adiabaticity.