Skip to content

IPOPT Solver Options Not Promoting Int to Float #22926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cohnt opened this issue Apr 24, 2025 · 2 comments · Fixed by #22927
Closed

IPOPT Solver Options Not Promoting Int to Float #22926

cohnt opened this issue Apr 24, 2025 · 2 comments · Fixed by #22927
Assignees
Labels
component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries type: bug

Comments

@cohnt
Copy link
Contributor

cohnt commented Apr 24, 2025

What happened?

If you set the max wall clock time in IPOPT to an integer value, it throws an error, but it works correctly if it's a double. Maybe connected to #18024, but it seems like the error is specifically in the IPOPT interface.

from pydrake.all import MathematicalProgram, IpoptSolver, SolverOptions

prog = MathematicalProgram()
x = prog.NewContinuousVariables(1)

options = SolverOptions()
# options.SetOption(IpoptSolver().solver_id(), "max_wall_time", 10) # Fails
options.SetOption(IpoptSolver().solver_id(), "max_wall_time", 10.0) # Works

result = IpoptSolver().Solve(prog, solver_options=options)

Bug output:

Tried to set Option: max_wall_time. It is a valid option, but it is of type  Number, not of type Integer. Please check the documentation for options.

### max_wall_time (Real Number)  ###
Category: Termination
Description: Maximum number of walltime clock seconds.
0 < (1e+20) <= +inf
Traceback (most recent call last):
  File "/home/tommy/temp.py", line 10, in <module>
    result = IpoptSolver().Solve(prog, solver_options=options)
RuntimeError: Error setting IPOPT integer option max_wall_time=10

Version

No response

What operating system are you using?

No response

What installation option are you using?

No response

Relevant log output

@jwnimmer-tri
Copy link
Collaborator

To solve this, I believe we would need to ask the IpoptApplication for its RegOptions() and then check the registered type of the option name, to know if we need to promote int to float. This would be in solvers/ipopt_solver.cc inside our SetAppOptions.

@jwnimmer-tri jwnimmer-tri added the component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries label Apr 24, 2025
@sherm1
Copy link
Member

sherm1 commented Apr 25, 2025

Assigned to @hongkai-dai for disposition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants