In this paper, the distributed resource allocation problem over undirected networks, considering box constraints and demand–supply constraints, is studied. Furthermore, each agent has one private cost function that is only known by itself. The aim is to minimize the sum of all local cost functions in a distributed manner while meeting the constraints. To solve the dispatch problem, a continuous‐time distributed algorithm with fixed step‐size is proposed. After that, a modified distributed algorithm of discrete‐time multi‐agent system is provided. Moreover, the proposed algorithms obtain the global optimal solution with an exponential convergence speed by the conventional Lyapunov methods. Finally, several simulations of IEEE‐14 bus are presented to validate and illustrate the proposed designed algorithm.