solving constrained optimization problem using python