To make this easier to conceptualize, both for myself and for the reader, let us say that you have 5 machines with varying costs and varying rates expressed as dollars per hour.
Let us say that we start with no money, but we get given machine 1 for free, which generates $3/h. There are 4 more machines, each machine after the other costing more, but having a greater dollar/hour rate, generating money more quickly.
Based off only this information – the price of the machine, and their dollar/hour rate – how could one calculate the fastest of accumulating the sum total of $5000?
Note that am not at all interested in the aforementioned example, only the overarching principles which could be applied to any given scenario such as this.