Application of linear and dynamic programming to the optimization of the production of hydroelectric power