You should not remove members from a set that indexes a param. In your latest example, you index myData over allSet. But then you reduce endNum; since you defined "set allSet = 1..endNum;" this has the effect of removing members from allSet.
To avoid the errors you are seeing, first set up the complete data like this:
param endNum default 5;
set allSet = 1..endNum;
param allData {allSet};
let {i in allSet} allData[i] := i;
Then define your subset:
param myNum <= endNum;
set mySet = 1..myNum;
Do not index any parameters over mySet. Only use mySet for indexing your model. Then you can change myNum whenever you want, and when you change myNum, it will change the problem that is generated from your model.
Bob Fourer
am...@googlegroups.com
=======
From:
am...@googlegroups.com [mailto:
am...@googlegroups.com] On Behalf Of
yiz...@lehigh.edu
Sent: Tuesday, November 18, 2014 3:56 PM
To:
am...@googlegroups.com
Subject: [AMPL 9562] To remove members from a set
I am currently confronted with an algorithm that I have to change the elements of an array often.
But when remove the members from the set, or change the "length" of the set, I am seen the error: 2 invalid subscripts discarded:
Do you have some ideas to fix this?