again no disagreement. however arriving at such an optimum is not always possible:

1) you need a few factories to build up the planet, otherwise it takes ages or a lot of credits. destroying those few factories might be unwise because you probably need to upgrade buildings as you progress through the research tree.

2) you may not have that many tiles to get to the optimum

in short: on most smaller and middle sized planets you will end up with a mix where the optimum (for that planet) is between manufacturing and research/credits.

I was maximizing O with respect to w, the fraction of production set to the desired output type, not with respect to the multipliers you have or can achieve on the planet.

O = (w*P + W + 0.25*((1 - w)*P + M)*(1 + Bm))*(1 + Bw)

This is linear with respect to w. Proof:

O = (w*P + W + 0.25*(P + M)*(1 + Bm) - 0.25*(1 + Bm)*w*P)*(1 + Bw)

O = (W + 0.25*(P + M)*(1 + Bm) + (0.75 - 0.25*Bm)*P*w)*(1 + Bw)

O = (W + 0.25*(P + M)*(1 + Bm))*(1 + Bw) + (0.75 - 0.25*Bm)*(1 + Bw)*P*w

The production fractions can vary between 0 and 1, so we want to maximize O with respect to w on the interval [0, 1]. If you do not know how to maximize a linear function over a closed interval, you need to review basic algebra, because this is trivially easy math. All you need to do is check the sign of the slope of the funciton; in this case, the slope is (0.75 - 0.25*Bm)*(1 + Bw)*P. P is strictly positive unless there's something very, very weird going on. 1 + Bw is positive as long as Bw > -1; as Bw is the bonus to wealth expressed as a decimal, (1 + Bw) will be positive for any planet which has a wealth bonus greater than -100%. Since it's rather unlikely that we'd have a planet with a wealth bonus less than -100%, this leaves us with only (0.75 - 0.25*Bm) governing the sign of the slope. This is positive for Bm < 3 and negative for Bm > 3, where Bm is the bonus to manufacturing expressed as a decimal (i.e., you're checking to see if you have a manufacturing bonus greater than +300%).

Since it's very, very unlikely that Bw will be less than -1, this gives us three cases to consider:

- Bm = 3. O is constant with respect to w. Therefore, all valid values of w are optimal points.
- Bm < 3. O is strictly increasing in w. A function which is strictly increasing in x over a closed interval [xmin, xmax] has one and only one maximum on the interval; this maximum occurs at x = x' s.t. x' >= y for all y in [xmin, xmax]. Our variable ranges from 0 to 1, so therefore when Bm < 3, the optimum value of w is w = 1.
- Bm > 3. O is strictly decreasing in w. A function which is strictly decreasing in x over a closed interval [xmin, xmax] has one and only one maximum on the interval; this maximum occurs at x = x' s.t. x' <= y for all y in [xmin, xmax]. Our variable ranges from 0 to 1, so therefore when Bm > 3, the optimum value of w is w = 0.

This has almost nothing to do with the number of tiles on the planet. It has nothing to do with maximizing the planet's potential output. It has everything to do with what the planet's bonuses currently are, and with what the slider settings are. There is no question of whether or not you are able to "arrive" at these optimum values, as there is nothing that you can do that will change them. This is a question of slider settings, not of what you build on the planet.

If I were looking to maximize a planet's potential output under the assumption that I'm producing only one type of output (i.e. the manufacturing fraction and the desired output fraction sum to 1), then the maximization problem would look more like:

Maximize O with respect to Nfactories, Nother, and Nfarms:

O = (w*P + 0.25*((1 - w)*P*(1 + Bm))*(1 + Bw)

Subject to the constraint:

Nfactories + Nother + Nfarms = PlanetQuality - Notherimprovements

Defining P, Bm, and Bw in terms of Nfarms, Nother, and Nfactories:

P = (1 + ProductionBonus)*(FlatProdution + ((1 + FoodBonus)*(BasePop + Nfarms*Bfarms))^0.7)

Bm = Nfactories*Bfactories + B_manu_planet + B_manu_SB

Bw = Nother*Bother + B_other_planet + B_other_SB

As O is still linear with respect to w, the conclusions reached earlier regarding the optimum value of w still hold. This means we essentially have two cases to worry about - the case where w = 1, and the case where w = 0. Both of these result in equations which would probably be best solved numerically rather than analytically.