Algorithm for campaign optimization (Digital Advertising) Suppose i am running an Ad thru an Ad exchange A, and i have a set of campaigns running on it. I have 


The spend of the campaign.
The budget allocated to it.
The number of hours it took to exhaust it's budget.
Total installs.
Total Revenue.


I want to write an algorithm to divide the total budget x to n campaigns, allocating higher budgets to a campaign delivering higher revenue.
sounds like a great place for a weighted average and a little algebra.

budget_n = (revenue_n / total_revenue) * total_budget

This is a simple solution you may have already tried, but in principle, the revenue fraction can be as complex as you need it to be as all the fractions across all campaigns add up to 1.