Why does “set S := 50 .. 70” give me a set of only 3 members?

You have declared set S in your model and set S := 50 .. 70 in your data. Set expressions are not recognized in AMPL’s data mode, however. Instead AMPL tries to recognize 50 .. 70 as a space-delimited list of members of S , with the result that it has found three members: the numbers 50 and 70 , and the string ".." .

To define S to equal 50 .. 70 by use of your data file, first declare S in your model by

param begin; 
param end > begin; 
set S := begin .. end;

Then state in the data file:

param begin := 50; 
param end := 70;

Alternatively, it’s legal to give set S = 50 .. 70 as your declaration of S . This is a less desirable approach, however, because it moves some of the specific data values into the model.

1 Like