can i use the absolute value function as an inequality constraint
abs(x)<=eps
i’m getting the error : Disciplined convex programming error:
Illegal operation: {invalid} - {real affine}
can i use the absolute value function as an inequality constraint
abs(x)<=eps
i’m getting the error : Disciplined convex programming error:
Illegal operation: {invalid} - {real affine}
If x and eps are both CVX variables, affine expressions, or constants, then abs(x)<=eps
should be accepted by CVX…
Please show a reproducible example. Perhaps you have an NaN
somewhere in the line in which you got an error.
x is a cvx variable , eps is a constant
Show a complete reproducible example.
%% CVX routine
w=ones(1,T-t0-1);
for j=1:nbr_iterations
cvx_begin
variables p(n) z(T-t0-1) p_hat(n)
minimize (w*z)
s=1;
for i=t0+1:T
r=[y(i-1) y(i-2) u(i-1)];
abs(y(i)-r*p)<=eps
s=s+1;
end
for s=1:T-t0-1
norm(p-p_hat,inf)<=z(s);
end
cvx_end
for i=1:T-t0-1
w(i)=1/(delta+z(i));
end
end
eps is just a constant
That is not a reproducible example, and it is not what you originally claimed.
You haven;t shown what y
is. Apparently, (y(i)-r*p
is something invalid at least one time though its loop. But I can’t tell you which of many possible things is wrong because you haven’t provided a reproducible example. This should be easy to debug.
It appears that the only thing which changes across the nbr_iterations
outer iterations is the value of w
used in the objective function, which seems like it should not affect the acceptance of a later constraint statement. But then again, sometimes CVX prints out an error message which is not very indicative of what the actual problem is. So if a CVX problem is not solved, then z
will be NaN
,which makes w
used in the next CVX problem ‘NaN`’, which will cause that next problem to produce an error message.