Erin
May 21, 2019, 9:44am
1
```
cvx_begin
variable W(1,dimC(3))
minimize(W*normPerSliceDiag*W');
%TotalWNorm = norm(W*normPerSliceDiag,1);
subject to
norm(W,1)<=1;
for RepeatT =1:dimC(3),
for RepeatK =1:dimC(3),
(1) sum(sum(abs(abs(W(RepeatT)*normPerSlices(RepeatT))-abs(W(RepeatK)*normPerSlices(RepeatK))))) >= 2*GiniMax*dimC(3);
%1+2*sum(abs(W(RepeatT)*normPerSlices(RepeatT))*(dimC(3)-RepeatT+0.5))/(dimC(3)*TotalWNorm)>GiniMax;%%
(2) % 1 + 2*sum(abs(W(RepeatT)*normPerSlices(RepeatT))*(dimC(3)-RepeatT+0.5)) > 2*GiniMax*(dimC(3)*norm(normPerSliceDiag,1));%%
%(1-2*sum(abs(AB{i})*(dimC(3)-i+0.5)/dimC(3)))>GiniMax;
end
end
cvx_end
```

the above code says:
(1):Disciplined convex programming error:
Illegal operation: {convex} - {convex}
or
(2):Disciplined convex programming error:
Illegal operation: {convex} - {real constant}

I am perplexed and I don’t know how to do. Please help, thanks!

Erling
(Erling D.Andersen)
May 21, 2019, 10:12am
2
Your problem must be convex. Do you have proof that your model is convex? If not you are likely to use the wrong tool.

This

{convex} - {convex}

most likely means you have something like

f(x)-g(x) <= 0

where both functions are convex, but that does NOT in general specify a convex set. An example is

x^2-y^2 <= 0

As @Erling says
`sum(sum(abs(abs(W(RepeatT)*normPerSlices(RepeatT)) - abs(W(RepeatK)*normPerSlices(RepeatK))))) >= 2*GiniMax*dimC(3);`

does not follow CVX’s DCP rules, and doesn’t look to me that it can be reformulated as a convex constraint.

Erin
May 21, 2019, 10:40am
4
Thank you very much! I will check my convex model!

Erin
May 21, 2019, 10:58am
5
Thank you very much! The model is convex, but I can try it by what you refer to YALMIP

Erin
May 21, 2019, 10:59am
6
Thank you very much! My model is convex, but it may not satisfy the DCP rulesets!

Please prove your model is convex.

You can try YALMIP, which will at least accept your problem, although it may not necessarily be easy to solve.

Erling
(Erling D.Andersen)
May 21, 2019, 11:51am
8
Do you have nice formulation using usual math you can show us? E.g. from a paper.

Erin
May 21, 2019, 1:09pm
9
Yes, your suggestion is very efficient! Many thanks!

Erin
May 21, 2019, 1:17pm
10
This is Gini Index formula

Erling
(Erling D.Andersen)
May 22, 2019, 4:57am
11
That does not look convex to me.

hfriberg
(Henrik A. Friberg)
May 22, 2019, 11:27am
12
The Gini Index formula you show here is convex if you assume f_i \geq 0 in which case you can change the formula to \sum_i \sum_j | f_i - f_j | \leq 2cN S and S = \sum_j f_j . Maybe this fact can help you reformulate your mathematical model?