Optimizing Shaft Design?

How would you go about designing a shaft with 2 bearings, 2 gears, and the shaft has various diameters (d1, d2, d3)?
You know how much power needs to be transferred from one gear to another, the distance between both of the gears, the minimum allowed distance between gear and bearing centers, the material of the shaft, rotational velocity of input gear, the maximum length of the shaft, there will be 2 shoulders, input gear is somewhere along the second diameter, output gear is somewhere on the third diameter, bearings are somewhere on the first and third diameters.

I'd like to use a program like matlab for optimization to graphically identify changes as unknown values fluctuate. With so many unknown variables, how would you recommend approaching this?

If the gears have been designed and it is only the shaft that you wish to optimise then you probably know where the gears and bearings must be on the shaft. Do you know what type of bearings they will be? Are the gears straight cut or helical? Left or Right handed? Driven or driving?

Draw a diagram showing your hypothetical shaft. Parameterise the diagram.
Now, there are a number of parameters that are fixed.
How many parameters remain free?