Optimizing for unnecessary variables?

Hi,

This may be contrived example, but my question is more about the principal of this.
Lets say I have an intermediate variable y which is a linear function of variable x.

I specify
y == A*x - b

and I want to minimize norm(y,2).
Therefore, I need to have both y and x be variables.

Is CVX able to identify that one of y or x is an unnecessary variable? If not, will this make the optimization method run slower because of the extra variables?

Use an assignment rather than equality operator. For safety and clarity, and with no downside of which I am aware, declare y as an expression.

% define A, b, n
cvx_begin
variable x(n)
expression y
y = A*X-b
minimize(norm(y,2)) % same as minimize(norm(y))
% insert constraints here
cvx_end

Alternatively,

% define A, b, n
cvx_begin
variable x(n)
minimize(norm(A*X-b,2)) % same as minimize(norm(A*x-b))
% insert constraints here
cvx_end

I hate to disagree even slightly with our esteemed Dr. Stone, but there is really no downside to using equality constraints in the manner mikeylp is proposing. I personally have a slight preference for equality constraints (or, in the case of convex/concave expressions, inequality constraints) over expression holders. Expressions are good but I worry sometimes that supporting both assignment = and equality == causes more problems than it solves.

CVX’s presolver will take care of the extra variables, eliminating them if it makes sense to do so. Do not assume that it does, however! There may be good reasons to keep them around.

In general, please do not spend a lot of time worrying about optimizing your CVX models for performance. CVX is not intended to be a tool for building fast models, it is a tool for building models fast. Yes, sometimes there will be changes that result in significant shifts in performance, but you never really know where those are going to crop up before you hit them. Premature optimization is bad coding practice, and it’s bad model building practice too.