# \[AMPL 24620\] change the solver using loop

**URL:** <https://discuss.ampl.com/t/ampl-24620-change-the-solver-using-loop/514>\
**Category:** Google Group Mirror\
**Created:** [April 23, 2023, 6:47am UTC](https://discuss.ampl.com/t/ampl-24620-change-the-solver-using-loop/514 "2023-04-23T06:47:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sd1](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/sd1/32/256_2.png) [@sd1](https://discuss.ampl.com/u/sd1)\
**Post date:** [April 23, 2023, 6:47am UTC](https://discuss.ampl.com/t/ampl-24620-change-the-solver-using-loop/514/1 "2023-04-23T06:47:25Z")

</div>

Hope all is well.

I want to compare the performance of a lot of different solvers in ampl so I tried these commands in the console. However, it did not work. Is there any other way to avoid setting up the solver repeatedly?

set SOLVERS = {“minos”, “baron”, “gurobi”};  
model ‘ex1.mod’;  
data ‘ex1.dat’;  
for {i in SOLVERS}{  
option solver i;  
solve;  
display result \>\> output.txt;  
}

Thanks!

---

<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:** [April 24, 2023, 5:06pm UTC](https://discuss.ampl.com/t/ampl-24620-change-the-solver-using-loop/514/2 "2023-04-24T17:06:11Z")

</div>

This question has been answered in our new, enhanced user forum at [https://discuss.ampl.com](https://discuss.ampl.com/t/change-the-solvers-using-loop/512/2).
