First I feel like a disclaimer here is needed that this is NOT a homework problem but I am going to ask the question in something that looks like one. I don't know how to ask my question any other way.
Imagine you have a factory. The factory produces widgets in the following form:
\begin{aligned} W &= W_{ps}t \\ W_{ps} &= P(N_p)+R(M_R) \\ \end{aligned}
where $W$ denotes the widgets built and banked, $W_{ps}$ denotes the widgets-per-second built by the factory, $P$ denotes the production of each human worker (in WPS), $N_p$ denotes the number of human workers, $R$ denotes the production of each robot (in WPS), and finally $M_R$ denotes the number of robotic workers.
Now suppose I can use the banked widgets to hire more human workers or robotic workers (we'll just buy with widgets because $Widgets \propto Money$). At any instant if I have enough widgets to make a hire I can. I can also bank my widgets to buy a robotic worker (which for the sake of argument produces widgets faster). In addition the cost to hire humans or buy robots obey the functions
\begin{aligned} CP(N_p) &= CP_o+f(N_p) \\ CR(M_R) &= CR_o+g(M_R) \\ \end{aligned}
I need to somehow build this purchasing into the first equation given but I don't know how to do that at this moment.
I don't know how to go about optimizing this factory. Say I want to reach $x$ $W_{ps}$ the fastest. I am trying to optimize the time to a given $W_{ps}$ value. At every instant I have a decision to make. I have to see if I have enough widgets to do anything, if I do I have to decide if it's better to buy a human or wait for a robot. I don't know how to model this discrete decision making.