Optimizing the profit from a complex cascade of hydroelectric