How can I save the number of iterations as a variable when I use the IPOPT solver to obtain the optimal solution? Does ampl have built-in iteration times to save variables?
When a solver finishes, it returns a result summary that is stored in the built-in AMPL parameter solve_message
. Many solvers include the number of iterations in this message, and the number of iterations can be extracted from solve_message
using AMPL’s string functions.
Ipopt does not include the number of iterations in solve_message
, however. Thus the only way to get the number of iterations is to read the Ipopt output. This could be changed; the AMPL interface to Ipopt is part of the Ipopt distribution, which is available under an open source license as explained on the Ipopt Documentation page.