changed code to create and optimize qp and sqps directly