Syntax Error in .dat file

Hi there! I want to import data into a .dat file. I used this code before and it worked fine. But now somehow a syntax error shows. I haven#t changed anything. Do you know a solution?

Here is my code:

set AgeClass := 1..8;
set Fleet := 1..2; # [1] Active gear ; [2] Passive gear
set Year := 2023..2072;  # Years (time period in this case 50 years)

param Weight := 
	1 0.005
	2 0.051
	3 0.372
	4 0.927
	5 1.962
	6 3.104
	7 4.114
	8 5.592
;

Here is the error:

syntax error
context:  1  >>> 0.005 <<< 

Different error:

ampl: set AgeClass := 1 2 3 4 5 6 7 8;
syntax error
context:  set AgeClass := 1  >>> 2  <<< 3 4 5 6 7 8;

You can’t use set-expressions like 1..8 in a .dat file. (See the discussion of a similar situation in Why does “set S := 50 … 70” give me a set of only 3 members? in our FAQ section.) In the .dat file, you can write out the sets explicitly:

# In .dat file:
set AgeClass := 1 2 3 4 5 6 7 8 ;
set Fleet := 1 2 ;
set Year := 2023 2024 2025 ;

But I have shown only three of the years here, and you will have to actually write out 50 of them, which is prone to errors. If the membership of these sets is not going to change much, you can instead define the sets using expressions like 1..8 in the .mod file:

# In .mod file:
set AgeClass := 1..8;
set Fleet := 1..2;
set Year := 2023..2072;

Alternatively, it you want to be able to have different data files with different members for these sets, you can write the model like this:

#In .mod file:
param nAgeClasses integer > 0;
param nFleets integer > 0;
param firstYear integer > 0;
param lastYear integer > firstYear;

set AgeClass := 1..nAgeClasses;
set Fleet := 1..nFleets;
set Year := firstYear..lastYear;

Then you have just four parameters — nAgeClasses, nFleets, firstYear, and lastYear — to give values for in the in data:

# In .dat file:
param nAgeClasses := 8;
param nFleets := 2;
param firstYear := 2023;
param lastYear := 2072;