error processing param C: 38 invalid subscripts discarded: C[1,1] C[1,4] C[1,5] and 35 more.
param C: 1 2 3 4 5 6 7 := 1 . 6 4 . . . . 2 6 . 3 3 4 . . 3 4 3 . 1 . 6 . 4 . 3 1 . 3 4 . 5 . 4 . 3 . 4 1 6 . . 6 4 4 . 4 7 . . . . 1 4 . ;
Could you send the the whole code of the .dat and of .mod please ?
On Mon, May 3, 2021 at 3:45 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
In your model, you define "param C {E}" where E is {(1,2),(1,3),(2,3),(2,4),(3,4),(3,6),(4,5),(4,6),(5,6),(5,7),(6,7)}. But in your data, you give values of C for every pair of values i in V and j in V. Thus AMPL raises an "invalid subscript" error:error processing param C: 38 invalid subscripts discarded: C[1,1] C[1,4] C[1,5] and 35 more.
AMPL is telling you that (1,1), (1,4), (1,5), etc. are not in E, and thus the corresponding data values are invalid. To fix this, put a "." character rather than a 0 in your table where no data is to be given:param C: 1 2 3 4 5 6 7 := 1 . 6 4 . . . . 2 6 . 3 3 4 . . 3 4 3 . 1 . 6 . 4 . 3 1 . 3 4 . 5 . 4 . 3 . 4 1 6 . . 6 4 4 . 4 7 . . . . 1 4 . ;
You will still have a problem, because your table has data corresponding to, for example, C[1,2] and C[2,1], while E only contains (1,2). You will have to change the data for E or else change to "." all the members of the C data table that are below the diagonal. (There is a similar problem with the data for param R.)
Here's a data tip: You can change the definition of E in your model to "set E dimen 2;" and then change the first line of the C table in your data to "param: E: C:". Then both the members of E and the values of C will be determined from the C table when you read the data file.
--
Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.