# Size Limit ? problem works fine with less variables

(Menna Khaled) #1

The problem works perfectly fine with less number of variables, when they’re 36 it gives me this error, so is there a limit on the problem size in cvx ?

(Mark L. Stone) #2

Show the entire problems, those which work successfully and those which don’t. Also show cvx_version.

There should be no limit on the problem size in CVX, unless you run out of memory.

(Michael C. Grant) #3

I’m going to guess that you’re introducing `NaN` or `Inf` values unintentionally into your model.

(Menna Khaled) #4

Is there a way I could check if an expression is NaN or Inf ?

I mean when a cvx matrix has some zeros it prints in the command line for example (1x6 vector,2 non-zeros), is there a similar thing for NaNs or Inf ?

Can a NaN or Inf value be a cvx log-convex expression as in the attached photo ?
Because for the totalInvRate to be invalid, I think at least one of it’s factors shoulf be invalid, true ?

(Menna Khaled) #5

Here’s an example that causes this error when I run the script:

``````G(:,:,1) = [0.0012    0.0009    0.0017    0.0051    0.0016   0.1534
0.0104    0.0178    0.0342    0.0173    0.0901   0.0002
0.0003    0.0002    0.0003    0.0007    0.0004    0.0015
0.0223    0.0399    0.1534    0.0705    0.0796     0.0104
0.0004    0.0001    0.0028    0.0014    0.0009     0.0002
0.0015    0.0018    0.0017    0.0010    0.0001      0.0399 ];
G(:,:,1) = G(:,:,1)*10^(-8);
G(:,:,2) =  [0.0030    0.0147    0.0081    0.0140    0.0293    0.0112
0.0795    0.0451    0.0144    0.0431    0.0392     0.1176
0.1176    0.1430    0.0291    0.2552    0.1191    0.0030
0.0138    0.0445    0.0112    0.1745    0.0270    0.1430
0.0024    0.0108    0.0003    0.0009    0.0069    0.0081
0.0562    0.2330    0.0724    0.0707    0.0177    0.1745];
G(:,:,2) =  G(:,:,2)*10^(-9);
G(:,:,3) = [0.0026    0.0059    0.0380    0.0163    0.0121   0.0380
0.1737    0.2544    0.2378    0.0208    0.0559  0.0121
0.0001    0.0001    0.0009    0.0016    0.0003  0.0080
0.0222    0.0137    0.0080    0.0013    0.0031   0.0006
0.0042    0.0009    0.0171    0.0031    0.0025   0.0042
0.0137    0.0006    0.0014    0.0023    0.0004    0.1737];
G(:,:,3) = G(:,:,3)*10^(-8);
G(:,:,4) = [0.1206    0.0456    0.1369    0.2484    0.1282  .0049
0.1867    0.0814    0.0301    0.0279    0.0181  .1021
0.2027    0.0625    0.1458    0.1217    0.0959  .062
0.0191    0.0049    0.0001    0.0015    0.0643  .0142
0.1410    0.1021    0.0911    0.7755    0.4131  .0031
0.0620    0.0142    0.0125    0.1126    0.0534  .0009 ]
G(:,:,4) = G(:,:,4)*10^(-10);
G(:,:,5) = [0.0060    0.0016    0.0252    0.0019    0.0027   .0194
0.0592    0.0044    0.0331    0.0257    0.0105   .0025
0.1254    0.2448    0.2193    0.2491    0.0547   .0077
0.0296    0.0194    0.0912    0.0252    0.0026   .0331
0.0053    0.0119    0.0025    0.0030    0.0081   .0066
0.0608    0.0077    0.0934    0.0066    0.0227   .0081];
G(:,:,5) = G(:,:,5)*10^(-9);
G(:,:,6) = [  0.0019    0.0057    0.0033    0.0040    0.0078  .0057
0.0023    0.0023    0.0002    0.0003    0.0055  .0171
0.1113    0.0109    0.0403    0.0603    0.0330  .0489
0.0322    0.0027    0.0057    0.0155    0.0091  .0377
0.0864    0.0377    0.1577    0.0333    0.0345  .0109
0.0489    0.0368    0.0171    0.0160    0.0766  .0155 ];
G(:,:,6) = G(:,:,6)*10^(-6);
s = 2.4023*10^(-13);
MP = 2;
rowsOnesTemp = [ 1     2     2     4     1     1     4     5     6     5     1     5     2     3     5     3     3     6     2     4     1     3     4     6     1     3     5     6     2     3     6     4    2     6     4     5];
coloumnsOnesTemp = [  2     4     5     5     6     1     2     2     2     3     5     6     1     1     1     2     4     5     3     3     4     5     6     1     3     3     4     4     6     6     6     1       2     3     4     5];
thirdDimensionOnesTemp = [ 1     1     1     1     1     2     2     2     2     2     2     2     3     3     3     3     3     3     4     4     4     4     4     5     5     5     5     5     5     5     5     6   6     6     6     6];
numOnes = length(thirdDimensionOnesTemp);
nU =6;
nG =5;
nR =6;
cvx_begin gp
variable vars(numOnes)

H = cvx(zeros(nU,nG,nR));
for m = 1:numOnes
H(rowsOnesTemp(m),coloumnsOnesTemp(m),thirdDimensionOnesTemp(m))= vars(m);
end

nug = cvx(zeros(nU,nG));
dug = cvx(zeros(nU,nG));
nu = cvx(zeros(1,nU));
du = cvx(zeros(1,nU));

for u = 1:nU
GsN = [];
for g = 1:nG
tR = thirdDimensionOnesTemp(find(rowsOnesTemp==u & coloumnsOnesTemp == g));
if ~isempty(tR)
nug(u,g) = H(u,g,tR)*G(u,g,tR);
GsN = [GsN g];
end
end
nu(u) = prod(nug(u,GsN));
end
for g = 1: nG
urThisG = H(:,g,:);
for u = 1:nU
copy = urThisG;
copy(u,:,:)=[];
dug(u,g) = 0;
for r = 1:nR
dug(u,g) = dug(u,g) + sum(copy(:,:,r))*G(u,g,r);
end
end
end
dug = dug + s;

for u = 1:nU
GsD = [];
for g = 1: nG
tR = thirdDimensionOnesTemp(find(rowsOnesTemp==u & coloumnsOnesTemp == g));
if ~isempty(tR)
GsD = [GsD g];
end

end
du(u) = prod(dug(u,GsD));

end

IRPU = du./nu;
IRAll = prod(IRPU);

minimize(IRAll)

subject to
sum(vars)<=MP;
IRPU<=ones(1,nU);

cvx_end
``````

Sorry I know it’s too much

(Mark L. Stone) #6

I don’t really know what you’re doing. I don’t know what cvx() does.

Nevertheless, you have some very small numbers in those arrays. Perhaps you are “getting away with” whatever operations you are performing on them for small problems, but for large problems you are encountering overwhelming numerical difficulties, resulting in NaN or Inf values, as mcg guessed. Can you try to reformulate/re-scale your problem to have more “reasonable” numbers?