Welfare function in General Capital model (Search and Matching)?

i'm working on a model from the Mortensen textbook: "Wage dispersion why are similar workers paid differently?". To be precise, i'm working on the model about general capital. In this case, capital is viewed as embodied in the job rather than the match. In other words, when the job is created, investments are made in the equipment any worker needs to be productive in the job.

I have resolved the model and make some simulation on Matlab, but I'm stuck when it comes to find the optimal "b" which represent the optimal reservation wage/unemployment benefit. I assume that it could be found with the Welfare function (maximizing output minus costs).

Here are some the equation from the model:

$rJ=f(k)-w-\delta J + \lambda(1-F(w))(V-J)$ $rV=\dfrac{\lambda}{v}\dfrac{\delta}{\delta + \lambda(1-F(w))}(J-V)-c-\delta V$

where $rJ$ is the expected value of a filled post, $rV$ the expected value of a vacancy, $\delta$ the exogenous destruction rate and $c$ the recruiting cost.