examples/huge.mod
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

- Generated files and doc/notes are removed
alpar@1
     1
/*Arithmetic Mean of a large number of Integers
alpar@1
     2
  - or - solve a very large constraint matrix
alpar@1
     3
         over 1 million rows and columns
alpar@1
     4
  Nigel_Galloway@operamail.com
alpar@1
     5
  March 18th., 2008.
alpar@1
     6
*/
alpar@1
     7
alpar@1
     8
param e := 20;
alpar@1
     9
/* set Sample := {-2**e..2**e-1}; */
alpar@1
    10
set Sample := {1..2**e-1};
alpar@1
    11
alpar@1
    12
var Mean;
alpar@1
    13
var E{z in Sample};
alpar@1
    14
alpar@1
    15
/* sum of variances is zero */
alpar@1
    16
zumVariance: sum{z in Sample} E[z] = 0;
alpar@1
    17
alpar@1
    18
/* Mean + variance[n] = Sample[n] */
alpar@1
    19
variances{z in Sample}: Mean + E[z] = z;
alpar@1
    20
alpar@1
    21
solve;
alpar@1
    22
alpar@1
    23
printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean;
alpar@1
    24
alpar@1
    25
end;