GNU MathProg: symbolic set vs. integer set

402 views Asked by At

My simplified data set in GNU MathProg is as follows, with Verts being a set of indices for vertices and coords being a table of coordinates of these vertices:

data;
set Indices := X Y;
set Verts := 1 2 3 4;

param Coords : X Y :=
1 1.2   0.3
2 4.2   13.0
3 1.5   1.0
4 0.5 0.8;
end;

This works, but if I replace the definition of Verts as follows:

set Verts := (1..4);

the compilation succeeds at this stage but Verts now cannot index the parameter table Coords. To be specific, glpsol returns Coords[1,X] out of domain.

Intuitively, I would assume the definition using the shorthand defines an integer set while for indexing I need some sort of symbolic, "string" type. Is my intuition correct? And if so, how should I write set Verts := ?; if I have not 4, but 10 000 elements in the table?

1

There are 1 answers

0
vitaut On BEST ANSWER

Set expressions such as .. are not recognized in the AMPL (or MathProg, which is a subset of AMPL) data mode. You should list all set members explicitly or move

set Verts := 1..4;

to the model.