Use consistent form in constraint equations#3565
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3565 +/- ##
=======================================
Coverage 31.66% 31.66%
=======================================
Files 86 86
Lines 20198 20198
=======================================
Hits 6396 6396
Misses 13802 13802 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
42c1bac to
aa36d2d
Compare
|
76 looks OK to me: In both cases |
|
86 also looks OK to me: In both cases |
00c1dea to
a0dd311
Compare
5% regression test differencesI've tried to help understand the regression test differences as a result of these changes. 6 failed, 1 passed. large_tokamak_no_f297 differences. Inequality values dominate unsurprisingly, but there are some significant other differences; some of the largest are shown below. A different solution is being found (as in our previous discussion @mkovari ): spherical_tokamak_once_throughOnly 1 difference >5%, but a dramatic one. In this case , helias_5bAgain, only 1 difference. large_tokamak_once_through12 diffs, all of them inequality constraints, as expected. stellarator_helias_once_through7 diffs, again all inequalities. large_tokamak62 diffs. This is an equality-only problem, so some equality diffs are expected, but a different solution is being found too (e.g. SummaryDue to having equality-only, mixed equality-inequality and model-evaluation (non-optimising) regression tests, we can see the impact of these changes on optimised solutions as well as model evaluations. Whilst it isn't surprising that the inequality constraint values change in the model evaluation case, it is interesting to see that significantly different optimised solutions are being found in some cases as a result of changing just the constraint values, not their limits; the value of the constraint functions affects the solution, not just the position of their limits. As @mkovari suggested previously, this could be because these problems are underdetermined; as a result of these changes the solver is now finding another non-unique solution instead. We should probably pay more attention to the possibility of non-unique solutions in future. |
148fbbb to
4b26382
Compare
|
@ajpearcey @mkovari @stuartmuldrew can I have a review for this please? |
|
Looks to be ready to merge to me. |
|
Sorry, @jonmaddock , I managed to delete my comment relating to the sign of the central solenoid current. I think once this is checked the changes can be merged, but it would be good in the near future to see the results once the lower bound for This was my previous comment: |
|
Before these changes, evaluating `large_tokamak_once_through_IN.DAT: After these changes: The constraint has changed sign, which is incorrect. My modification to this was wrong, so thank you @mkovari for spotting this! Correcting for the negative sign of ... the same as originally. I've pushed this correction. If you're happy with this @mkovari , please can you approve the review and I'll merge. Thanks for spotting this. |
| if (itart == 0) call report_error(10) | ||
| cratmx = 1.0D0 + 4.91D0*(eps-0.62D0) | ||
| tmp_cc = 1.0D0 - fipir * cratmx * c_tf_total/plasma_current | ||
| tmp_cc = cratmx * c_tf_total/plasma_current - 1.0D0 * fipir |
There was a problem hiding this comment.
Can you double check this constraint.
I have run a once-through at the initial ST design point on main and on this branch. The only constraint with a sign change is 046:
On main its feasible at the initial point:
Ip/Irod_upper_limit_normalised_residue___________________________________ (eq_con046)____________________ 9.20229325178258950e-02
but on this branch it is not:
Ip/Irod_upper_limit_normalised_residue___________________________________ (eq_con046)____________________ -1.30279815951349276e+00
Could this be because cratmx is on the top of the constraint when I thought it should be on the bottom? Maybe this is why the ST regression test is failing?
There was a problem hiding this comment.
You are absolutely right about this Tim, well spotted! I've changed this. However, when I run this on main, I get:
Ip/Irod_upper_limit_normalised_residue___________________________________ (eq_con046)____________________ -1.88737914186276612e-15
i.e. slightly violated. After my (corrected) change I get:
Ip/Irod_upper_limit_normalised_residue___________________________________ (eq_con046)____________________ -9.99200722162640886e-16
again violated by a tiny amount. The version of main I ran on is the same that I rebased this branch on.
However, the ST regression test now solves again, brilliant!
There was a problem hiding this comment.
Glad to hear it, as long as main and this branch have the same sign that is all that matters!
Ensures min and max inequality constraints are violated proportionally to each other.
Correct initialisation in regression test to agree with new L-H constraint form.
8780954 to
7d1df6c
Compare
This reverts commit d48645a.
|
|
||
| tmp_cc = 1.0D0 + fvs * vs_cs_pf_total_pulse/vs_plasma_total_required | ||
| !! vs_cs_pf_total_pulse is negative, requires sign change | ||
| tmp_cc = 1.0D0 - fvs * -vs_cs_pf_total_pulse/vs_plasma_total_required |
There was a problem hiding this comment.
Getting this warning too. Please check this is not causing a problem.
889 | tmp_cc = 1.0D0 - fvs * -vs_cs_pf_total_pulse/vs_plasma_total_required
| 1
Warning: Extension: Unary operator following arithmetic operator (use parentheses) at (1)
There was a problem hiding this comment.
Quite right, that was careless! I've enclosed it.
ajpearcey
left a comment
There was a problem hiding this comment.
I should actually formally approve this, following my review.
Following an investigation into upper limit constraint behaviour, I'm proposing to change the form of the upper limit inequality constraints from:
$$c_{max} = 1 - \frac{x_{max}}{x}$$
$$c_{max} = \frac{x}{x_{max}} - 1$$ $x$ ) passes through 0.
to
This means that lower and upper limit constraints are violated proportionately (e.g. linearly), and the constraint values for upper limit constraints are now much simpler to interpret. It also removes a discontinuity in upper limit constraints when the constrained parameter (
In particular, I'd be grateful for reviewers to carefully check my changes to constraints 12, 15 and 86, which I believe were incorrectly (or at least inconsistently) defined. I would also like 76 to be checked, as I'm not sure I've got this the right way around.