-
Notifications
You must be signed in to change notification settings - Fork 376
Add feasibility checks to optimizers/converters #1199
Add feasibility checks to optimizers/converters #1199
Conversation
Please change the title to be more informative to denote what this PR adds and merge master to your branch. There are some conflicts. |
Done and Done. 😄 |
@t-imamichi I am confused by this PR. It already incorporates the changes of |
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.
Keeping going! All good as an intermediate version!
Please think of adding unit tests. Also, pay attention at the pipeline output, stuff like pylint, code style, spelling, etc.
if(detailed == True): | ||
|
||
for i in range(len(satisfied_variables)): | ||
(print(f'{self.get_variable(i)._name} is within the bounds') if satisfied_variables[i] | ||
else logger.warning(f'{self.get_variable(i)._name} is outside the bounds')) | ||
|
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.
The initial idea was to return a list of violations, not just printing them.
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.
The initial idea was to return a list of violations, not just printing them.
This is for debug purposes only. I was not sure about how the return value was required. I will change it into a list.
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.
This is a good question how to return them back. May be we should postpone this feature, I mean returning a list of violations and focus on the boolean result.
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'd expect to see a list of something, but what is float here?
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.
So currently I will print the violations and just return the bool result. One way would be to change the return type from ->bool to ->Tuple[bool, List[float]] and return empty list whenever detailed = False.
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.
The list can contain float values as well. Like x = [1.0, 2.0, 1.0, 1.99999982]
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.
Yeah, but what do they mean, these float values?
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 am sorry I didn't get your question. I would try to explain from what I understood.
So if we define a quadratic problem with variables x, y and z, then we get results.x = [1.0, 2.0, 1.0] would mean x = 1.0, y = 2.0 and z = 1.0.
As I understood from the description of that PR, you don't have to follow that PR. Main purpose of #1196 is to change the |
Yes. You can ignore |
@woodsp-ibm, @t-imamichi please take a look, should be fine now. |
Thank you! It looks good. We need just a reno text to explain the new APIs. |
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Thank you everyone 😄. I am glad that my first ever PR has been accepted and merged successfully. Thank you @adekusar-drl and @t-imamichi for giving me the opportunity to work on this 🎉. |
Congrats! Enjoy Qiskit hacking. |
* Draft for issue#1134 * resolved issue in quadratic_problem.py * incorporated changes as suggested by @adekusar-drl * fix linting issues * added is_feasible method in all optimizers, added changes suggested by @ woodsp-ibm * removed cast import * made changes as per points 1 to 3 * made suggested changes by @adekusar-drl * some cleaning * added reno * fixed reno * Update releasenotes/notes/feasibility-check-b99605f771e745b7.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Update releasenotes/notes/feasibility-check-b99605f771e745b7.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * code review Co-authored-by: Manoel Marques <Manoel.Marques@ibm.com> Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> Co-authored-by: Anton Dekusar <62334182+adekusar-drl@users.noreply.github.com> Co-authored-by: Anton Dekusar <adekusar@ie.ibm.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
…kit-aqua#1199) * Draft for issue#1134 * resolved issue in quadratic_problem.py * incorporated changes as suggested by @adekusar-drl * fix linting issues * added is_feasible method in all optimizers, added changes suggested by @ woodsp-ibm * removed cast import * made changes as per points 1 to 3 * made suggested changes by @adekusar-drl * some cleaning * added reno * fixed reno * Update releasenotes/notes/feasibility-check-b99605f771e745b7.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Update releasenotes/notes/feasibility-check-b99605f771e745b7.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * code review Co-authored-by: Manoel Marques <Manoel.Marques@ibm.com> Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com> Co-authored-by: Anton Dekusar <62334182+adekusar-drl@users.noreply.github.com> Co-authored-by: Anton Dekusar <adekusar@ie.ibm.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Summary
draft of #1134
Added is_feasible() function to check whether the returned result of the optimizers and to check whether they are feasible or not
Details and comments
Please check for the same and provide valuable feedback. Thank you 😃