-
Notifications
You must be signed in to change notification settings - Fork 17
🎨 Constraint function plots in plot_proc
#4049
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
base: main
Are you sure you want to change the base?
Conversation
…djust font sizes and add new plots in main function
…d normalization and improve axis annotations
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4049 +/- ##
==========================================
+ Coverage 46.49% 46.62% +0.12%
==========================================
Files 123 123
Lines 28777 29530 +753
==========================================
+ Hits 13381 13769 +388
- Misses 15396 15761 +365 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…lace dashed line with arrow annotation, and remove relative change text display
…on to ensure proper string formatting
…function for improved clarity
…ght, add z-order for layering, and improve text annotation with dynamic color and background
|
@chris-ashe could you add an image of the new output here? |
Have added to main PR text now |
jonmaddock
left a comment
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.
Great to have this working, such an improvement to our visualisation! Main points are about calculating stuff that has either been calculated already (I think) or should have been, e.g. normalisation of constraint/bound values.
| constraint_bound = con2[i] | ||
|
|
||
| # assumes f-value is 1 | ||
| # -cc because sign is reversed in constraint_eqns |
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 be totally clear here: after the sign change here, a constraint > 0 is violated, right? i.e. the convention.
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.
From my understanding and by the data the plots make it seems to be the correct way. @timothy-nunn what do you think?
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.
In PROCESS, a negative cc indicates that a constraint is violated
process/scan.py
Outdated
| constraint_value = constraint_bound * (-numerics.rcm[i] + 1) | ||
| else: | ||
| raise ProcessValueError( | ||
| f"Unknown constraint direction '{sym[i]}' for inequality constraint" |
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.
Not sure this could ever happen: this is already tested in constraints, and doesn't need to be re-done here I believe.
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.
Removed
|
|
||
| for i in range(numerics.neqns, numerics.neqns + numerics.nineqns): | ||
| name = numerics.lablcc[numerics.icc[i] - 1] | ||
| constraint_bound = con2[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.
What's con2?
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.
Its a horrible name but it is the value of the equality constraint. So for a machine of major radius 8m, the radial build consistency constraint value is 8m. Have added a comment
| if sym[i] == ">=": | ||
| constraint_value = constraint_bound * (1 - -numerics.rcm[i]) | ||
| elif sym[i] == "<=": | ||
| constraint_value = constraint_bound * (-numerics.rcm[i] + 1) |
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.
rcm is the normalised constraint residual, right? This seems rather confusing to verify without a comment. Aren't the absolute constraint values already stored on the constraint object? If not, they should be, rather than being re-calculated 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.
Before when we had f values we couldn't have the absolute value of the constraint variable as the f values were not tied to it. @timothy-nunn has a better explanation for it as we tried to make this plot with f values and found we couldnt
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 always confuses me as when you look into the code people often misuse this parameter and put in whatever they feel like. This is why I am proposing to standardise and abstract our constraints as much as possible (#3937).
| / (itvar_upper - itvar_lower) | ||
| if itvar_final != itvar_lower | ||
| else 0 | ||
| ) |
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 don't think we should be calculating this again here: I believe this is already calculated, and we should use that value.
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 don't think this is in the output. We have the final / initial value given by xcm. This is then used to find the initial value and where that sits within the normalised bounds
| # Plot main plasma information | ||
| plot_main_plasma_information( | ||
| figs[3].add_subplot(111, aspect="equal"), | ||
| figs[4].add_subplot(111, aspect="equal"), |
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 churn is a bit of a pain. Could figs just be appended to?
|
This looks fantastic now! |
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'm not sure the equality constraint plot is doing anything for me. Its quite hard to meaningfully plot the residuals of these constraints especially given the different orders of magnitude. Would this be better as just a table?
The inequality bar chart should show margin so the bars should come from the right for
This pull request enhances the post-optimization reporting for constraint handling in
process/scan.py. The main improvements involve adding more detailed output for both equality and inequality constraints, including physical values, units, symbols, and bounds, which should make debugging and analysis easier.Enhanced constraint reporting:
process_output.ovarre, improving the detail of post-optimization logs.Output formatting improvements:
Checklist
I confirm that I have completed the following checks: