Error: {positive constant} ./ {convex}

That is not allowed by CVX’s DCP rules. You are basically taking the reciprocal of squared terms, so maybe pow_pos can be used, but I’m not sure it can due to sums of squares.

Even if you get that fixed up, you can’t use if statements whose conditions involve CVX variables or expressions, as you seem to do with sort1. You will need to use logic modeling using Big M.

Bottom line, even if Big M logic modeling is used, i have not looked carefully enough at your model to know whether it is convex, and can be formulated in compliance with CVX’s (MI)DCP rules. But convexity (of continuous relaxation) is the first thing you need to figure out.