Drake Version: v1.40, from pip
Platform: Macbook M4 Pro
I am attempting to use the Snopt via MathematicalProgram
and am running into an exit condition of 83, which corresponds with exceeding the storage limit of the integer workspace. I tried setting the Total integer workspace
option, but there seems to be no effect for any value for this option.
Here is my abbreviated script:
...
prog = MathematicalProgram()
Z = prog.NewContinuousVariables(N, nz)
U = prog.NewContinuousVariables(N-1, 2)
prog.AddLinearConstraint(Z[0] - z0, np.zeros(nz), np.zeros(nz))
for i in range(N-1):
z_k = z0 if i==0 else Z[i]
s = Z[i+1, nq:]
x_k = z_k[:nq]
v_next = s[:nq]
u = np.concatenate([U[i], np.zeros(nq-2)])
for row in dynamics_residual(z_k, s, u, params):
prog.AddQuadraticConstraint(row, 0, 0, hessian_type=QuadraticConstraint.HessianType.kIndefinite)
prog.AddLinearConstraint(Z[i+1, :nq] - (x_k + dt*v_next), np.zeros(nq), np.zeros(nq))
for i, hand_pos in enumerate(hand_path[:-1]):
prog.AddLinearConstraint(hand_pos - Z[i, :2], np.zeros(2), np.zeros(2))
solver = SnoptSolver()
filename = "/tmp/debug.txt"
solver_options = SolverOptions()
solver_options.SetOption(CommonSolverOption.kPrintFileName, filename)
solver_options.SetOption(SnoptSolver.id(), "Total integer workspace", 1e6)
solver_options.SetOption(SnoptSolver.id(), "Total real workspace", 4e6)
solver_options.SetOption(SnoptSolver.id(), "User integer workspace", 1e6)
solver_options.SetOption(SnoptSolver.id(), "User real workspace", 4e6)
solver_options.SetOption(SnoptSolver.id(), "Major print level", 5)
result = solver.Solve(prog, solver_options=solver_options)
...
From Snopt output:
lu1fac error... insufficient storage
Increase lena from 166326 to at least 243971
Current Recommended
Total integer workspace 632738 788028
Total real workspace 2850909 2928554
1
SNOPTA EXIT 80 -- insufficient storage allocated
SNOPTA INFO 83 -- not enough integer storage
My overall device memory is not being filled so it seems likely that this is an issue with the option setting.
Seems to be a similar error as with:
Am I setting the integer workspace option incorrectly or is there a different parameter that should be set?
Thanks!
As of v1.41.0, Drake sets the integer workspace to be exactly what's calculated by snmema
:
Snopt::snmema(&snopt_status, nF, nx, lenA, lenG, &miniw, &minrw, storage.iw(),
storage.leniw(), storage.rw(), storage.lenrw());
if (miniw > storage.leniw()) {
storage.resize_iw(miniw);
const std::string option = "Total int workspace";
Snopt::snseti(option.c_str(), option.length(), storage.leniw(), &errors,
storage.iw(), storage.leniw(), storage.rw(), storage.lenrw());
This means that the any user-provided value for "Total integer workspace" will be ignored.
Reading SNOPT the manual for snMemA, other options like "Superbasics limit" can affect what snMemA reports so possibly setting those option(s) could be work-around.
Ideally, Drake would notice that the user has set a larger workspace in the options, and use that setting instead of asking snmema. See https://github.com/RobotLocomotion/drake/issues/23032.