Code for linear and quadratic optimization