invalid subscripts discarded

2,584 views
Skip to first unread message

D.T. Fokum

unread,
Oct 22, 2009, 10:30:40 PM10/22/09
to AMPL Modeling Language
Hello,

I have a model that uses a parameter y. In my data file I have the
following statements:

param y default 0 :=
[*,*,1]:
0 1 2 :=
2 1 . .
3 . . 1
4 . 1 .
[*,*,2]:
0 1 2 :=
5 1 . .
7 . 1 .
[*,*,3]:
0 1 2 :=
1 1 . .
6 . 1 . ;

However, when I try to solve my model I get a message that states:
Error executing "solve" command:
error processing param y:
2 invalid subscripts discarded:
y[5,0,2]
y[7,1,2]

From earlier posts on this group I found this link:
http://www.ampl.com/FAQ/#WhydoIgetaninvalidsubscriptdiscardedmessagewhenIdisplayanAMPLparameter,
unfortunately the information there doesn't appear to be related to my
problem. What am I doing incorrectly?

Thanks,
Daniel

Robert Fourer

unread,
Oct 24, 2009, 3:20:05 PM10/24/09
to am...@googlegroups.com, D.T. Fokum

The discarded invalid subscripts [5,0,2] and [7,1,2] correspond to the two
values in the parameter y data that have a third index equal to 2. So most
likely the problem is that 2 is not a member of the third indexing set for
y.

Bob Fourer
4...@ampl.com

Daniel Fokum

unread,
Oct 26, 2009, 12:44:46 PM10/26/09
to 4...@ampl.com, am...@googlegroups.com
Bob,

Thanks for your response; my problem is resolved. The third indexing set for y was UNIT, which I had defined as:
set UNIT:= 0 .. 3 by 1;

I dropped " by 1" from the set declaration and the model was solved correctly without any subscripts discarded.

Thanks,
Daniel

Paul

unread,
Apr 21, 2013, 4:34:39 PM4/21/13
to am...@googlegroups.com, 4...@ampl.com
Are MOSD, MOLD etc. supposed to belong to set DEST? If so, you omitted the final "D" when declaring values for DEST.

Paul

shed...@gmail.com

unread,
Apr 5, 2014, 9:25:48 PM4/5/14
to am...@googlegroups.com, 4...@ampl.com
I have a similar problem. the invalid subscript problem. I've tried the default empty set someone mentioned however, I still have the following issues:
Is there a way to suppress the errors noted below and loop it so I don't have to type each let statement? AMPL  solves my problem, but the invalid subscripts causes problems when try to put it in a  for loop ?  I understand the error comes from the size of the set changing from 8 down to 3 and now the parameters linked to the dropped sets are producing invalid subscripts. please help ? 

here are my sets 

set pairs[1] := 1 2 3;
set pairs[2] := 1 2 4;
set pairs[3] := 1 2 5;
set pairs[4] := 1 2 6;
set pairs[5] := 1 2 7;
set pairs[6] := 1 2 8;
set pairs[7] := 1 3 4;
set pairs[8] := 1 3 5;
set pairs[9] := 1 3 6;

ampl: update data;
ampl: data CR3_14_14ver1.dat;
ampl: solve;

ampl: let AVAIL := pairs[1];
ampl: display PAT;
Error executing "display" command:
error processing param PAT:
90 invalid subscripts discarded:
PAT[5,1,1]
PAT[5,2,1]
PAT[5,3,1]
and 87 more.
PAT [1,*,*] (tr)
:   1   2   3   4   5   6    :=
1   1   1   0   0   1   1
2   0   1   1   1   1   1
3   1   1   1   1   1   1

 [2,*,*] (tr)
:   1   2   3   4   5   6    :=
1   1   1   0   0   1   1
2   0   0   1   1   1   1
3   1   1   1   1   1   1

 [3,*,*] (tr)
:   1   2   3   4   5   6    :=
1   1   1   0   0   1   1
2   0   1   1   1   1   1
3   1   1   1   0   1   1
;

ampl: 

How can i structure a loop without getting the subscript errors ?

charles shedrick

unread,
Apr 6, 2014, 2:24:53 PM4/6/14
to am...@googlegroups.com

Just a quick update. I figured out a work around. Using the option eexit command I can suppress the bailout and allow my loop to run. I still get the discarded subscript message but I think I will have to totally rework the model to fix those.

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Wr_KxvKWBpM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Robert Fourer

unread,
Apr 6, 2014, 2:35:11 PM4/6/14
to am...@googlegroups.com
Instead of defining "set AVAIL;", define

set AVAILall;
set AVAIL within AVAILall;

Index your data (sets and parameters) over AVAILall, but index your model (variables, objectives, constraints) over AVAIL. Then you can make all the changes you want like "let AVAIL := pairs[1];" and you won't get any error messages about data being discarded.

Bob Fourer
am...@googlegroups.com

=======

charles shedrick

unread,
Apr 6, 2014, 4:07:34 PM4/6/14
to am...@googlegroups.com
thanks Bob!! that was an even better solution. very clean.  initially I was getting no data in set AVAIL so I defined it similar to set AVAILall in my data file and it appears to work nicely !!. 

Reply all
Reply to author
Forward
0 new messages