The tactical planning to determine the frequency of trains and the routing of freight cars is modeled as an integer piecewise linear programming. The optimization model takes into account the interaction between trains and cars. An algorithm based on simulated annealing has been implemented to solve the model. Computational experience for small and medium networks is presented.