r code on convex optimization