Attacker Protection Build Banks/Armories
We assume the following buildings:
10% homes
10% farms
15% guilds
5% towers
and would like to determine the most efficient way to split the remaining 60% of buildings between banks and armories to maximize the number of troops you end up with OOP.
Banks increase income, so you can measure benefit by total income / natural income (the income you would have without banks), which measures the proportion of extra troops you can train. Armories decrease unit costs so you can measure benefit by the inverse of the amount by which they reduce to also measure the proportion of extra troops you can train. For 400 acres, and 240 to be split between the 2, let x denote your number of banks and 240-x denote your number of armories.
Income I(x)=(1+1.25x(1-x/400)/400)(20250+25x)
=-1.953125e-4x^3-0.080078125x^2+88.28125x+20250
Benefit1=I(x)/20250
Training Cost Reduction R(240-x)=1-1.5(240-x)(1-(240-x)/400)/400
=9.375e-6x^2-7.5e-4x+0.64
Benefit2=1/R(240-x)
Total Benefit B(x)=Benefit1*Benefit2=I(x)/(20250*R(240-x))
Then all you have to to is maximize total benefit or take dB/dx=0 and check that d^2B/dx^2<0. I've solved this equation to find x=116.67539. This means you can maximize the number of troops you can train if you get 29% banks and 31% armories. This is close enough to 30% banks and 30% armories for easier calculations.
Assumptions: 400 acres, 240 disposable acres, no unfilled jobs (This last assumption won't hold all the way, but it won't effect calculations by much because the majority of effects of both buildings vary together with the number of workers. The only thing that does not is the flat rate the banks give you, which is a function of the building efficiency, which is a different function of the number of workers. However, the changes are so small that we can simplify the model to what I have.