Change the solvers using loop

Hope all is well.
I want to compare the performances of a lot of different solvers, 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;
display cost >> output.txt;


1 Like

When your specify “option solver i;” AMPL sets option solver to the literal character string “i”. To instead set option solver to the value of index i, use this command:

option solver (i);

The general rules for this situation are given in the subsection on String expressions in AMPL commands in Chapter 13 of the AMPL book.

1 Like

This did work. Thank you very much!