# \[AMPL 24893\] Run a set of instances

**URL:** <https://discuss.ampl.com/t/ampl-24893-run-a-set-of-instances/818>\
**Category:** Google Group Mirror\
**Created:** [November 18, 2023, 8:26pm UTC](https://discuss.ampl.com/t/ampl-24893-run-a-set-of-instances/818 "2023-11-18T20:26:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yelky\_Alberto\_Castro](https://avatars.discourse-cdn.com/v4/letter/y/ed8c4c/32.png) [@Yelky\_Alberto\_Castro](https://discuss.ampl.com/u/Yelky_Alberto_Castro)\
**Post date:** [November 18, 2023, 8:26pm UTC](https://discuss.ampl.com/t/ampl-24893-run-a-set-of-instances/818/1 "2023-11-18T20:26:00Z")

</div>

Good afternoon

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

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

for {i in IS}{  
reset;  
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”);  
solve;

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.

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AMPL\_Google\_Group](https://discuss.ampl.com/u/AMPL_Google_Group)\
**Post date:** [November 21, 2023, 7:14pm UTC](https://discuss.ampl.com/t/ampl-24893-run-a-set-of-instances/818/2 "2023-11-21T19:14:18Z")

</div>

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:

```auto
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).
