mechmotum / cyipopt

Cython interface for the interior point optimzer IPOPT
Eclipse Public License 2.0
227 stars 54 forks source link

`print_level` doesn't seem to work correctly for `minimize_ipopt` #234

Closed AlexanderThebeltQC closed 9 months ago

AlexanderThebeltQC commented 11 months ago

When I give options = {"disp": 5} to minimize_ipopt it always ends up using {b"print_level": 0}, meaning no output is printed. I believe the problem is here in the code. Given that options is a dict it will always end up in the else case. Maybe option.get() is more suitable here? And it would be great if we can allow for display levels greater than 1. Apologies if I'm missing something or using the interface wrong!

Robbybp commented 10 months ago

This looks like a bug to me, and your proposed fix sounds good. I see no reason not to allow print_level > 1 in the SciPy interface. PRs welcome!

MarkusZimmerDLR commented 9 months ago

The linked PR is not making any progress and is mixing issues which are not related.

I suggest creating a simple hotfix for this, changing

if getattr(options, 'print_level', False) is True:
    options[b'print_level'] = 1

to

options[b'print_level'] = int(options.get(b'print_level', 5) )
AlexanderThebeltQC commented 9 months ago

Sounds good! I was under the impression that this would get fixed in the other PR but I have a bit of time to submit something tomorrow. Thanks for the update!