Functions to solve Quadratic Programming Problems