This paper focuses on solving the problem of how to assign locomotives to assembled trains optimally. To solve the problem, linear programming is applied. The situation we model in the paper occurs in the conditions of a transport operator that provides rail transport in the Czech Republic. In the paper, an extended locomotive assignment problem is modeled; the transport operator can use different classes of the locomotives to serve individual connections, some connections must be served by a predefined locomotive class, and the locomotives can be allocated to several depots at the beginning. The proposed model also takes into consideration the fact that some connections can be served by the locomotives of external transport companies or operators. The presented model is applied to a real example in order to test its functionality.