Skip to content
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

Problem managing the violations in N #40

Closed
pgambier opened this issue Aug 11, 2016 · 2 comments
Closed

Problem managing the violations in N #40

pgambier opened this issue Aug 11, 2016 · 2 comments
Assignees
Labels

Comments

@pgambier
Copy link

A bug is to be fixed in the code for managing situations with violations in N (pull request #33).

The problem was found in class ConstraintsModifier in methods getNewUpperLimit and getNewLowerLimit.

Here is a description of the problem for the method getNewUpperLimit (the problem is symmetrical for getNewLowerLimit).

private float getNewUpperLimit(LimitViolation violation, float margin) {
    float newLimit = 9999;
    if ( config.isInAreaOfInterest(violation, network) ) {
        float increment = (float) ((violation.getLimit() == 0) 
             ? Math.ceil(violation.getValue()*100) 
             : Math.ceil((violation.getValue()-violation.getLimit())*100/violation.getLimit()));
        increment += margin;
        newLimit = (violation.getLimit() == 0) 
             ? (increment/100) 
             : (violation.getLimit()+(violation.getLimit()*increment/100));
    }
    return newLimit;
}

Major problem : the ceil method is used on line 273 (or line 6 of the excerpt above) on a value which is often inferior to 1 (current or voltage value is usually close to the limit when there is a violation in N) therefore the increment value is likely to be equal to one.
Because the value of violation limits can be high (around 2000 A in 400kV in France), with increment = 1, newLimit ends up being much higher than the initial limit with margin = 0 which is hardly understandable and dangerous for the user.

Minor problem : using the intermediary variable increment for the calculation makes the code difficult to understand.

A suggestion is to remove the increment variable and directly calculate new limit without rounding anything
new limit = load flow value in N + (load flow value in N * margin in %)
or rounding as the last step of the calculation
new limit = ceil(load flow value in N + (load flow value in N * margin in %))

@mathbagu
Copy link
Contributor

Written in java, it could be something like this:

private float getNewUpperLimit(LimitViolation violation, float margin) {
    float newLimit = 9999;
    if ( config.isInAreaOfInterest(violation, network) ) {
        newLimit = violation.getValue() * (1.0f + margin);
    }
    return newLimit;
}

 private float getNewLowerLimit(LimitViolation violation, float margin) {
     float newLimit = -9999;
     if ( config.isInAreaOfInterest(violation, network) ) {
         newLimit = violation.getValue() * (1.0f - margin);
     }
     return newLimit;
 }

I think that the checkModifiedNetworkLimits method should also be modified.

@CBiasuzzi
Copy link
Contributor

just a small change to the new code ( since the margin is given in pct ..... )

private float getNewUpperLimit(LimitViolation violation, float margin) {
    float newLimit = 9999;
    if ( config.isInAreaOfInterest(violation, network) ) {
        newLimit = violation.getValue() * (1.0f + margin / 100.0f );
    }
    return newLimit;
}

private float getNewLowerLimit(LimitViolation violation, float margin) {
     float newLimit = -9999;
     if ( config.isInAreaOfInterest(violation, network) ) {
         newLimit = violation.getValue() * (1.0f - margin / 100.0f );
     }
     return newLimit;
 }

CBiasuzzi pushed a commit that referenced this issue Aug 30, 2016
geofjamg added a commit that referenced this issue Aug 31, 2016
changes new limits computations ( ref #40 )
@mathbagu mathbagu closed this as completed Sep 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants