I would like to write the parameters ( Cd, Fs, Ef ) and also the sets (set F1T, set F1H) that I have given the sample data below in a spreadsheet file to make then read by Ampl. I am not sure I’am writing then in the correct way.
I am writing the aks for your help.
Sets
set ND
set F1 {ND} ;
set F1T {d in ND} within F1[d] ;
set F1H {d in ND} within F1[d] ;
set F1E {d in ND} within F1[d] ;
Parameters
param Cd {d in ND, t in (F1T[d] union F1H[d])} >=0 ;
param Fs {d in ND, t in (F1T[d] union F1H[d])} >=0 ;
param Ef {d in ND, t in (F1T[d] union F1H[d])} >=0 ;
Data
set ND := DC1
set F1[DC1]:= TT1 TT2 TH1 TH2 TE1 TE2 ;
set F1T [DC1]:= TT1 TT2 ;
set F1H [DC1]:= TH1 TH2 ;
set F1E [DC1]:= TE1 TE2 ;
syntax error
context: sum {d in ND, t in F1T[d], i in ({d} union NS), j in ({d} union NS): i <> j} >>> ((Ze/(KaPs))EfE <<< sEd*(D_LINKS_F1 [i,j]/V_F1)*X_F1[d,t,i,j]
ampl:
I do not see anything in your objective function that is clearly an error, except that you have not given it a name. The name should go between “minimize” and the “:” character.
To get more help, reply with your model file attached. (Actually just a part of the model file, with the objective function and everything before it, should be enough.)
Dear Mr Fourer,
I have put the model as well as the run file, spreadsheet files for data on your private folder you previously provided me (Submit files).
Many thanks in advance for your help.
param Ef {d in ND, t in (F1T[d] union F1H[d])} >= 0 ;
So in the expression for your objective function, you need to replace all occurrences of “Ef” by “Ef[d,t]”. There is also the same problem with other parameters in the objective function.
The error “could not find a range or sheet named setF1T” means that you did not tell AMPL where the table setF1T is located in the spreadsheet.
Since you have several tables on the same sheet, the easiest was to fix this is to define a name for each table where a range is located. In this example, you would select the range B24:C29 in 5_10_Param_veh.xlsx, and then where B24 appears in the box at the upper left, you would replace it with setF1T.
table X_F1out OUT "amplxl" "Xresults.xlsx":
{d in ND, t in F1[d], i in ({d} union NS), j in ({d} union NS):
i<>j and X_F1[d,t,i,j]=1} -> [Dval,Tval,Ival,Jval],
X_F1[d,t,i,j];
Note that [Dval,Tval,Ival,Jval] just gives some names for the columns of the spreadsheet table; they are not names from the model, and you can replace them by whatever column names you want to have. There’s an explanation of this form of table statement in Section 10.4 Writing Data of the AMPL book, particularly in the sub-section on Writing rows inferred from a key specification.