[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GMPL do not detect invalid subscript
From: |
Andrew Makhorin |
Subject: |
Re: GMPL do not detect invalid subscript |
Date: |
Wed, 12 Aug 2020 20:01:06 +0300 |
On Wed, 2020-08-12 at 19:44 +0300, Andrew Makhorin wrote:
> On Wed, 2020-08-12 at 17:33 +0200, Domingo Alvarez Duarte wrote:
> > Hello Andrew !
> >
> > Thank you for reply !
> >
> > That's the problem It should not work, the constraint "zumVariance:
> > sum{z in Sample} E[z+10] = 0;" should give an error because when "z =
> > last_valid_subscript - 9" the resulting expression will be
> > "last_valid_subscript+1" and so on.
>
> You declare E as
>
> var E{z in Sample};
>
> so evaluating
>
> sum{z in Sample} E[z+10]
>
> causes a domain (indexing) error as expected.
>
> If, for example, Sample = {1..100}, the error will be detected on z = 91,
> since z + 10 = 101 is not in Sample.
>
More precisely, the error will be detected on any 91 <= z <= 100, because
the order, in which sum enumerates elements from Sample, may be arbitrary.