[AMPL 24893] Run a set of instances

Good afternoon

I am trying to run the same model for several instances, but I can’t, I attached the code:

set IS:= ‘GPFS1.dat’ ‘GPFS2.dat’ ‘GPFS3.dat’ ‘GPFS4.dat’ ‘GPFS5.dat’;

for {i in IS}{
printf(“Corrida de modelo “&date(”%Y%m%d %H.%M.%S”));
model TSOP.mod;
data i;

option solver gurobi;
option gurobi_options “logfreq 5 mipgap 0.001 outlev 1 timelim 3600”;
option log_file (“log_timetable”& date(“%Y%m%d %H.%M.%S”) &“.log”);

printf (“\n\n\n\nSOLUCIÓN para MOSTRAR\n”);
option omit_zero_rows 1;
display x;
display w;
display B;
display Max_bloq;

If anyone can guide me how I can do this in AMPL I would greatly appreciate it.

A “reset” inside a for-loop will delete the loop index (i in IS) and the loop will not run properly. Since you are using the same model each time through the loop, but with different data, you should instead use “reset data” like this:

model TSOP.mod;
set IS := {'GPFS1.dat','GPFS2.dat','GPFS3.dat','GPFS4.dat','GPFS5.dat'};

for {i in IS} {
   printf("Corrida de modelo "&date("%Y%m%d %H.%M.%S"));
   reset data;
   data (i);

Note that you have to write “data (i);” so that AMPL knows to interpret i as an expression (rather than as the name of a file).