A mathematical framework for optimal bilinear control of nonlinear Schrödinger equations of Gross--Pitaevskii type arising in the description of Bose--Einstein condensates is presented. The obtained results generalize earlier efforts found in the literature in several aspects. In particular, the cost induced by the physical workload over the control process is taken into account rather than the often used L^2- or H^1-norms for the cost of the control action. Well-posedness of the problem and existence of an optimal control are proved. In addition, the first order optimality system is rigorously derived. Also a numerical solution method is proposed, which is based on a Newton-type iteration, and used to solve several coherent quantum control problems.