A nonlinear programming approach to stand optimization