I have a cost function that is piecewise-linear; I tried solving the problem in CVX, but kept getting errors that I didn’t know how to deal with. This very simple example reproduces the error:
cvx_begin
variable x
maximize( min(x, 0) )
cvx_end
The error it produces is
??? Index exceeds matrix dimensions.
Error in ==> cvxprob.eliminate at 218
temp = reshape(ndxs(temp),size(temp));
Error in ==> cvxprob.solve at 17
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true, shim.dualize );
Error in ==> cvx_end at 79
solve( prob );
Error in ==> prob_3_4 at 5
cvx_end
Doing the usual trick of introducing a new variable to make it a linear program, say z:
cvx_begin
variables x z
maximize( z )
subject to
z <= x
z <= 0
cvx_end
produces the same error.
I’m very new to CVX so forgive me if I’m doing something stupid (I probably am). I’m using version 2.0 beta. Looking up the version made me realize that I’m using a beta release, maybe I’ll try the previous stable version…
Edit: Reverting to version 1.22 solves everything, so I guess it’s a bug in 2.0?