Optimum supply of freight to port stations together with questions of optimization of transport tasks are considered in many works. As the tool the graphic-analytical method, a method of dynamic programming and methods are applied for the decision of the given questions of theory of mass service. Considering creation of imitating model it is necessary to make the mathematical description of system in all conditions. Events occur stohastically, to some parameters determined beforehand. Creation of a matrix of gravitation together with the coefficient of gravitation enables to optimize rational use of resources of ports and port stations. Function of rearrangement is described by system of the equations and creates mathematical model which characterizes freight transportation to port stations.