Search code examples
drake

Pydrake: Accessing extra SNOPT solver outputs (iter)


According to the SNOPT docs (page 57), one of the outputs of SNOPT upon exit is iter, the number of major iterations performed. I was wondering if there is any way to access this output when using SnoptSolver in pydrake. Thanks!


Solution

  • iter is available in SNOPT's npOpt interface,unfortunately we use snoptA interface (chapter 3 of SNOPT doc https://web.stanford.edu/group/SOL/guides/sndoc7.pdf) in Drake's wrapper class SnoptSolver, I don't think this snoptA interface returns iter on exit.

    If you want to know the number of iterations, you could print the snopt progress. One example to do that is

    # Print out the progress to my_output.txt
    prog.SetSolverOption(SnoptSolver.solver_id(), "Print file", "my_output.txt")
    result = snopt_solver.Solve(prog)
    

    In my_output.txt you will see the number of iterations.