[AMPL 24425] Re: syntax error in .dat

Hi

Can you solve the syntax error?

Thanks!

The data for a scalar parameter (like T, Beta, or epsilon in the example) can be given in the model. But data for an indexed parameter, like D, has to be given separately from the definition of the parameter. Usually there is a model file that specifies, say,

param T := 4;
param Beta := 0.95;
param epsilon := 0.1;
param D {1..T};

Then in a data file, the values for the indexed parameter are given:

param D :=
1 60
2 83
3 91
4 83
;

The model file is read with a model statement, and the data file is read with a data statement, as in this example:

model test.mod;
data test.dat;

Alternatively, if you want to put everything in test.mod, just put a data statement without a filename before the data:

param T := 4;
param Beta := 0.95;
param epsilon := 0.1;
param D {1..T};

data;

param D :=
1 60
2 83
3 91
4 83
;

(The data for the scalar parameters can also be given in the data file rather than in the model, if that is convenient.)