-
Notifications
You must be signed in to change notification settings - Fork 248
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
[OptApp] adding QNBB shape vector support #12804
Conversation
applications/OptimizationApplication/python_scripts/utilities/opt_line_search.py
Outdated
Show resolved
Hide resolved
if isinstance(d[i], (float, int, numpy.float64)): | ||
if self.step_numpy[i] > self._max_step / norm: | ||
self.step_numpy[i] = self._max_step / norm | ||
elif isinstance(d[i], (numpy.ndarray)): | ||
if self.step_numpy[i][0] > self._max_step / norm: | ||
self.step_numpy[i] = self._max_step / norm | ||
|
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.
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.
if statement doesn't work with vector data correctly
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.
Thanks @Igarizza . I only have minor concern.
|
||
if isinstance(d[i], (float, int, numpy.float64)) and self.step_numpy[i] > self._max_step / norm: | ||
self.step_numpy[i] = self._max_step / norm | ||
elif isinstance(d[i], (numpy.ndarray)) and self.step_numpy[i][0] > self._max_step / norm: |
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.
Woudn't it be better to use a norm like L2 in here instead of checking the first entry?
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.
You can see, that all 3 positions have the same value, hence 1 Alfa for x y z. So, I can check the first value or check l2 norm. If we check l2 norm we need to give max step * sqrt(3) to have the same behavior.
📝 Description
This pull request includes changes to enhance the
ComputeStep
method in theopt_line_search.py
file. The main improvement is the addition of type checks for elements in thed
array to handle both scalar and array types correctly.🆕 Changelog
Enhancements to
ComputeStep
methodapplications/OptimizationApplication/python_scripts/utilities/opt_line_search.py
: Added type checks to handlefloat
,int
,numpy.float64
, andnumpy.ndarray
types separately, ensuring correct computation ofdy
anddd
values and appropriate updates toself.step_numpy
.