In this paper, we consider the problem of minimising the cost of data transmission as a function of the capacity of telecommunication links. To solve this problem, we first formulated a mathematical model, and then we designed and developed a software that enables the optimisation of the given or randomly generated telecommunications network. Declarative programming is a good choice for optimisation problems because it is enough to specify only the relations that must be satisfied, without giving any effective procedure for finding the values for the decision variables. To test the application, we developed a software that randomly generates a telecommunications network that meets the given requirements. This enables us to test the application on an arbitrary number of different telecommunication networks with different numbers of nodes and links, and analyse the impact of changing network parameters on the flow and results of the optimisation. As telecommunications networks operate in conditions of uncertainty, the subject of special analysis was the potential failure of some of the network links. The paper presents and thoroughly analyses the optimisation results for several selected networks, as well as summary results for a number of telecommunications networks.