CPLEX can compute multiple solutions in one solve run, but AMPL needs to read the solutions one at a time from files. There is not an option to get the solutions any other way.
Are you writing 105724 files and then reading them in the AMPL for-loop? Then AMPL is taking about 2.25 seconds per file, but still that adds up to a lot. There are some things you could do to test what is taking all the time and to speed up the loop.
First, AMPL normally displays a solver message every time that a "solution" command is executed, and that is inefficient. You can turn off those solver messages by adding this command (
before the loop):
option solver_msg 0;Second, it seems to me that the variables should be x[k] (running over k in 1..n}, and also that you can make the loop more efficient by not using s:
for {i in 1 .. Current.npool} {
solution ("filename" & i & ".sol");
let {k in 1..n} X_sol[k,i] := x[k];
};Third, you should check how many numbers are being stored in X_sol, by giving this command (
after solving):
print n * Current.npool;If this number is more than 100 million, you may be running out of physical memory to store X_sol, which will slow down the "let" statement considerably. If this is the situation, there are some more tests you can do to measure the slowdown.
Finally, it can make a difference how you measure time. Are you using _ampl_time, or _ampl_elapsed_time, or some other measure?