-
Notifications
You must be signed in to change notification settings - Fork 8
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
Split NR and outer loops max iterations #730
Conversation
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@@ -146,12 +158,9 @@ public AcLoadFlowResult run() { | |||
outerLoop.cleanup(outerLoopContext); | |||
} | |||
|
|||
int nrIterations = runningContext.lastNrResult.getIteration(); | |||
int outerLoopIterations = runningContext.outerLoopIterationByType.values().stream().mapToInt(MutableInt::getValue).sum() + 1; | |||
|
|||
AcLoadFlowResult result = new AcLoadFlowResult(context.getNetwork(), |
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.
To fix: add a status for max outer loop iterations reached.
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.
Done
# Conflicts: # src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
@@ -54,6 +54,10 @@ private static class RunningContext { | |||
private NewtonRaphsonResult lastNrResult; | |||
|
|||
private final Map<String, MutableInt> outerLoopIterationByType = new HashMap<>(); | |||
|
|||
private int cumulatedOuterLoopIterations = 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.
cumulated -> cumulative
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.
after discussions -> total
private NewtonRaphsonStatus runIteration(StateVectorScaling svScaling) { | ||
LOGGER.debug("Start iteration {}", iteration); | ||
private NewtonRaphsonStatus runIteration(StateVectorScaling svScaling, MutableInt iterations) { | ||
LOGGER.debug("Start iteration {}/{}", iterations, parameters.getMaxIterations()); |
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 weird: the max iterations is not always the total number of iterations.
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
@@ -13,23 +13,19 @@ | |||
*/ | |||
public class NewtonRaphsonParameters { | |||
|
|||
public static final int DEFAULT_MAX_ITERATION = 30; | |||
public static final int DEFAULT_MAX_ITERATIONS = 15; |
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.
Why 15?
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.
10 might be too low for very rare and difficult cases, 20 is probably too much so 15...
# Conflicts: # src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java # src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java # src/test/java/com/powsybl/openloadflow/OpenLoadFlowProviderTest.java
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
# Conflicts: # src/test/java/com/powsybl/openloadflow/OpenLoadFlowParametersTest.java
// continue with outer loops only if initial Newton-Raphson succeed | ||
if (runningContext.lastNrResult.getStatus() == NewtonRaphsonStatus.CONVERGED) { | ||
|
||
// re-run all outer loops until Newton-Raphson failed or no more Newton-Raphson iterations are needed | ||
int oldIterationCount; | ||
int oldCumulatedNrIterations; |
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 have kept here oldCumulatedNrIterations.
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.
Fixed
Kudos, SonarCloud Quality Gate passed! |
} | ||
} | ||
throw new PowsyblException("No tap position found (should never happen)"); |
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.
Do we need to log an error message or not? It is the issue I met last week but I am not sure to understand why we can have no tap position...
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.
Maybe just a log but all is okay!
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian geoffroy.jamgotchian@gmail.com
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)Does this PR already have an issue describing the problem ? If so, link to this issue using
'#XXX'
and skip the restNo
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature
What is the current behavior? (You can also link to an open issue here)
We can only control the max number of cumulated NR iterations.
What is the new behavior (if this is a feature change)?
We can control the max number of iterations for each NR run and the max number of outer loop iterations. This will allow to better adapt the max number of outer loop iterations when more and more controls (outer loops) are added without changing the NR configuration.
Does this PR introduce a breaking change or deprecate an API? If yes, check the following:
Other information:
(if any of the questions/checkboxes don't apply, please delete them entirely)