Hello !

Trying to make changes to make less tuple copies I found that GMPL actually do not detect invalid subscripts see the modified huge.mod bellow, when we add an arbitry number to the "z" index it would fall outside the valid subscript range but actually GMPL do not detect this situation and silently goes forward.

=====

/*Arithmetic Mean of a large number of Integers
  - or - solve a very large constraint matrix
         over 1 million rows and columns
  [email protected]
  March 18th., 2008.
*/

param e := 20;
#param e := 15;
/* set Sample := {-2**e..2**e-1}; */
set Sample := {1..2**e-1};
printf "card Sample %d : %f\n", card(Sample), sum{i in Sample: i = (card(Sample)-100)} i;
var Mean;

var E{z in Sample};

/* sum of variances is zero */
zumVariance: sum{z in Sample} E[z+10] = 0; #!!!! +x would fall out of valid indexes

/* Mean + variance[n] = Sample[n] */
variances{z in Sample}: Mean + E[z] = z;

solve;

printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean;

end;

=====

Cheers !


Reply via email to