-
Notifications
You must be signed in to change notification settings - Fork 530
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
mosek_direct.py : Fixed iparam parsing and added support for Task.putparam #3488
base: main
Are you sure you want to change the base?
Conversation
…ameter and the parameter value as strings, as long as the "generic" parameter names are used. Fixed: call to putintparam was missing in the isinstance(option, str) conditional when parsing 'iparam'.
@Utkarsh-Detha - please run |
Thank you for the review, @mrmundt . I ran the formatter as you recommended, with the newest version thereof. |
@Utkarsh-Detha could you add a couple tests for these changes? |
@Utkarsh-Detha - Pinging again about this! Could you please add in some tests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks reasonable, but could be improved by some defensive checks. In addition, it would be good to test this functionality thought the unit tests.
self._solver_model.putstrparam(param, option) | ||
elif 'dparam' in key.split('.'): | ||
self._solver_model.putdouparam(param, option) | ||
elif 'iparam' in key.split('.'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that there is no else:
clause: users who forget to explicitly include .sparam
, .dparam
, or .iparam
will have those options silently ignored.
elif 'iparam' in key.split('.'): | ||
if isinstance(option, int): | ||
self._solver_model.putintparam(param, option) | ||
elif isinstance(option, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - without an else
, option values that aren't int / str will be silently skipped (this would include, e.g., numpy ints)
Fixes:
In
_apply_solver
putintparam
was missing in theisinstance(option, str)
conditional when parsingiparam
. Fixed.option.pop('mosek')
instead ofoption.pop(0)
within the same conditional. Fixed.Summary/Motivation:
A user wanted to be able to pass the value of ALL parameters as strings. MOSEK's optimizer API supports this through the
Task.putparam
function, which accepts a parameter name (string) and a value (also string).Changes proposed in this PR:
Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: