bug-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GMPL do not detect invalid subscript


From: Domingo Alvarez Duarte
Subject: Re: GMPL do not detect invalid subscript
Date: Wed, 12 Aug 2020 20:12:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello Andrew !

Thank you for reply again !

My bad !

You are right again, somehow I missed the error message because of the "display message".

Sorry by the noise and thank you so much !

Cheers !

On 12/8/20 17:04, Andrew Makhorin wrote:
On Wed, 2020-08-12 at 16:38 +0200, Domingo Alvarez Duarte wrote:
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
    Nigel_Galloway@operamail.com
    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 !



It works for me.

------

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;

------

GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
  -m foo.mod
Reading model section from foo.mod...
21 lines were read
card Sample 1048575 : 1048475.000000
Generating zumVariance...
foo.mod:11: E[1048576] out of domain
MathProg model processing error



reply via email to

[Prev in Thread] Current Thread [Next in Thread]