-
Notifications
You must be signed in to change notification settings - Fork 105
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
Fix sol.fStar
for NSGA2
#330
Conversation
Codecov Report
@@ Coverage Diff @@
## main #330 +/- ##
==========================================
+ Coverage 84.22% 84.25% +0.03%
==========================================
Files 22 22
Lines 3340 3347 +7
==========================================
+ Hits 2813 2820 +7
Misses 527 527
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Discussed offline, LGTM
pyoptsparse/pyNSGA2/pyNSGA2.py
Outdated
@@ -188,6 +188,12 @@ def objconfunc(nreal, nobj, ncon, x, f, g): | |||
for i in range(n): | |||
xstar[i] = nsga2.doubleArray_getitem(x, i) | |||
|
|||
if len_ff > 1: | |||
for i in range(len_ff): | |||
ff[i] = nsga2.doubleArray_getitem(f, i) |
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.
Can you add some comments to explain what's happening here? I don't understand why ff
has to be overwritten.
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 I am not mistaken, ff
is just initialized (as a 0-length array) in _assembleObjective
. Before this fix, fStar
was never updated with the value of the optimal objective f
, returned from the actual optimizer called by nsga2.nsga2()
.
Moreover, f is a swig object so nsga2.doubleArray_getitem
is necessary to convert it to a numpy array.
Purpose
This PR fixes the
sol.fStar
value for NSGA2. Basically, the optimized f value was not being passed tocreateSolution
.Expected time until merged
2 days
Type of change
Testing
An associated test is added which fails without the fix.
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable