An algorithm for optimal control of a gas network with any configuration based upon hierarchical control and decomposition of the network is described. Local problems are solved using a gradient technique. The subsystems are coordinated using „good coordination” method to find the overall optimum. Discrete state equation for the case in which output pressures are treated as elements of the control vector has been formulated. Results of investigations are included.