Error with convex >= affine

Hi,

I’m working on model that is related to my previous post.
A slight modification is applied as:

variable a(N);
variable p(N, M);
expression b(N)
obj = obj + a * Constant;
min(obj);

subject to
for i = 1:N
    b(i) = sum(p(i));
end
for i = 1:length(list)
    b(list(i)) = max(b(list(i)), 1e-3);
end
p>=0;
non-zero_threshold*a <= b <= U.*a;

As in the model, I’d like to modify some values that is indexed by a provided list. If the values <= 1e-3, then it will be set to 1e-3. For example, if provided a list like [2, 3, 5], if b(2), b(3), or b(5) is zero, then they will be set to 1e-3.

However, I got an error showing that:
b>=non-zero_threshold*a - error: {convex}>={real affine}
sometimes.

As described in here, I think that the max() function should be convex, and thus the problem should also be convex, but sometimes things go wrong and sometimes it works well.

Am I missing something or misunderstand the usage of the max() function in cvx?

Thank you in advance!

The formulation I gave works when b is s variable, not a nonlinear expression, such as max. When b is nonlinear, one of the two inequalities will be going in the wrong direction to be convex. So you will also have to deal with the non-convex direction of max. You can see how to handle max, used in a non-convex way, in section 2.3 of https://www.fico.com/en/resource-access/download/3217 . If you need more help on this, I will refer you to https://or.stackexchange.com/ , where your questions should be written out mathematically, and not in terms of CVX.

I really don’t know what problem you are trying to solve (formulate), but your formulation attempt looks rather a mess as of now.

I will also note that the statement
min(obj);
does nothing. That is the min of a vector. That is not an objective function statement, which would be minimize(something), where something needs to evaluate to a real scalar, not a vector.

Thank you Mark! I will read the materials you provided carefully.