[Top][All Lists]

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

GMPL do not detect invalid subscript

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

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
  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;


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



Cheers !

reply via email to

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