Fortunately, they have the mathematical tool of programming (not to be confused with programming computers) to work with. In its simplest form, linear programming, a certain value (e.g. profit, costs, or in this case a warlock tank's DPS) will need to be optimised (maximised or minimised). Of course, two chosen factors will influence that value (for this case, the number of casts of Shadow Bolt and Searing Pain), and, subject to several constraints, the right combination of both will need to be found.
This exercise gives a little insight to the workings of stat optimising utilities like Rawr.