Hi I am using this format to input the values of my set N and param PP in the txt file:
set N := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50;
param PP :=
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 10
27 12
28 14
29 0
30 0
31 5
32 0
33 0
34 0
35 0
36 10
37 10
38 0
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 10
47 0
48 0
49 10
50 0
;
Please note that N and PP are defined in my model as
set N; # number of Manufacturing features
param PP{n in N} default 0;
When I run AMPL form Pycharm it gives me this error:
PP is already defined
This happens also to other parameters .
Could you please help?
thanks a lot
I also tried defining N := 1…50 but does not work too
This kind of error occurs when you are reading the data statements in “model mode”. Be sure that you are using an AMPL “data” statement to read any files that contain AMPL text data.
If you need more help, please reply with your files attached.
Kindly, I need more help. The model and the data file are attached. I am running this from Pycharm using the script below:
import sys
from amplpy import AMPL, Environment
ampl = AMPL(Environment(r’C:/bin’))
def main(argc, argv):
ampl.set_option(“solver”, “gurobi”)
if argc > 1:
ampl.set_option(“solver”, argv[1])
ampl.read(“C:/bin/lin_strategies.mod”)
ampl.read_data(“C:/bin/family_2_reduced.txt”)
ampl.solve()
if name == “main”:
try:
main(len(sys.argv), sys.argv)
except Exception as e:
print(e)
raise
(Attachment family_2_reduced.txt is missing)
lin_strategies.mod (16.7 KB)
You have some “let” statements in the middle of your data file (family_2_reduced.txt), which cause AMPL to return to “model mode”. To get AMPL back into “data mode” to read more data tables, add a “data” statement. For example, where you have “let IR[11,13] := 1;” in your data file followed by a table for param PP, add a “data” statement like this:
set T:= 1 2;
# tight tolerance relationship data , Inclusion relations
let IR[11,13] := 1;
data;
# post processing time
param PP :=
1 0
2 0
Alternatively, if you move all “let” statements to the end of the data file, then AMPL will only switch back to model mode after all the data is read, and there will not be any problem.