$W_{opt}=\arg \{\max(\pi_0 F_{L_0}(W)-\frac{\pi_1}{W}\int_0^W F_{L_1}( \alpha )d \alpha )\}$  

subject to $\quad \int_0^W F_{L_0} (\alpha)d\alpha <\xi$ 

We should find  analytically the optimal $W >0$ which maximize the first equation subject to the second equation, where $F( \cdot )$ is comulative distribution function (CDF), and $L_0$ and $L_1$ are positive random variables. $\xi$, $\pi_0$, $\pi_1$ are constant. Also, $0<\pi_0, \pi_1<1$ and $\pi_0 + \pi_1 =1$. All variables are real. Further, if needed, we can assume that, for example, $L_0$ and $L_1$ may have Erlang or exponential distribution.