1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/huge.mod Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,25 @@
1.4 +/*Arithmetic Mean of a large number of Integers
1.5 + - or - solve a very large constraint matrix
1.6 + over 1 million rows and columns
1.7 + Nigel_Galloway@operamail.com
1.8 + March 18th., 2008.
1.9 +*/
1.10 +
1.11 +param e := 20;
1.12 +/* set Sample := {-2**e..2**e-1}; */
1.13 +set Sample := {1..2**e-1};
1.14 +
1.15 +var Mean;
1.16 +var E{z in Sample};
1.17 +
1.18 +/* sum of variances is zero */
1.19 +zumVariance: sum{z in Sample} E[z] = 0;
1.20 +
1.21 +/* Mean + variance[n] = Sample[n] */
1.22 +variances{z in Sample}: Mean + E[z] = z;
1.23 +
1.24 +solve;
1.25 +
1.26 +printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean;
1.27 +
1.28 +end;