Max() function problem

Uncategorized
Apr 16, 2018
1

When i use max() function inside the cvx to get max values for one dimension of a matrix inside cvx i get false results for max values.If i do it after cvx_end ,it gives me correct results.I cant do it afterwards because i want the max values for a constraint inside cvx. The matrix has some of the variables as items.Any help?

M

You haven’t shown us reproducible code, nor explained what these “false results” consist of.

Have you been following CVX’s rules?

help cvx/max
Disciplined convex/geometric programming information:
max is convex, log-log-convex, and nondecreasing in its first
two arguments. Thus when used in disciplined convex programs,
both arguments must be convex (or affine). In disciplined
geometric programs, both arguments must be log-convex/affine.

Here is an example of max being used in CVX.

cvx_begin
variable x(4)
minimize(max(x))
1 <= x <= 2
sum(x) == 5
x(1)  + .5 <= x(2) <= x(3) +.2
cvx_end

With the result:

disp(x)
   1.000000001845220
   1.500000003654262
   1.394764374540845
   1.105235619953878

max can also be used in constraints, when in compliance with DCP rules.