Large-scale hierarchical optimization for online advertising and wind farm planning