amplglpkmathprog

How to read data file with coordinates in GLPK


I this example is used

# random locations for the cities
param cx{i in N} := Uniform01();
param cy{i in N} := Uniform01();

for generate random locations for the cities

How to read data file with coordinates in GLPK and how format?

1 2 3 4
1,2,3,4
(1,2),(3,4)
{1,2},{3,4}

Solution

  • Glpk uses GNU MathProg, a subset of AMPL, so given the following parameter and set declarations:

    set N := 1..2;
    param cx{i in N};
    param cy{i in N};
    

    you can read the data as follows

    data;
    param:
      cx cy :=
    1  1  2
    2  3  4;
    

    Note that in this case parameters cx and cy shouldn't be defined in the model, so you should either remove the := Uniform01() part or change it to default Uniform01().