Skip to content

Conversation

@EtienneLt
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?
no

What kind of change does this PR introduce?
feature

What is the current behavior?
for the extension GeneratorStartUp, there is no control on rate fields. But they should be between 0 and 1 to be coherent

What is the new behavior (if this is a feature change)?
add tests

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Other information:
we try to keep compatibility with the SerDe. if in a network there is a value below 0 it is set to 0 and if the value is higher than 1 it is set to 1

@EtienneLt EtienneLt self-assigned this Jan 14, 2026
Comment on lines 70 to 74
if (plannedOutageRate > 1) {
plannedOutageRate = 1;
} else if (plannedOutageRate < 0) {
plannedOutageRate = 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use a small method to avoid code duplication?
For example:

    private double readOutageRate(DeserializerContext context, String attributeName) {
        double outageRate = context.getReader().readDoubleAttribute(attributeName);
        // compatibility
        if (outageRate > 1) {
            outageRate = 1.0;
        } else if (outageRate < 0) {
            outageRate = 0.0;
        }
        return outageRate;
    }

}

public static void checkRate(Validable validable, String validableType, double rate, String fieldName) {
if (!Double.isNaN(rate) && (rate < 0 || rate > 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the values be defined as a public static variables somewhere, in order to avoid having the values in multiple places directly in the code?

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:gs="http://www.powsybl.org/schema/iidm/ext/generator_startup/1_1" id="sim1" caseDate="2026-01-14T10:21:31.745Z" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:gs="http://www.powsybl.org/schema/iidm/ext/generator_startup/1_1" id="sim1" caseDate="2026-01-14T10:21:31.745Z" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_16" xmlns:gs="http://www.powsybl.org/schema/iidm/ext/generator_startup/1_1" id="sim1" caseDate="2026-01-14T10:21:31.745Z" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">

@EtienneLt EtienneLt force-pushed the add-controls-on-rates branch 2 times, most recently from 13348a9 to 6c03064 Compare February 2, 2026 07:28
Copy link
Member

@rolnico rolnico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit history + DCO have to be fixed


public static void checkRate(Validable validable, String validableType, double rate, String fieldName) {
if (!Double.isNaN(rate) && (rate < MIN_RATE || rate > MAX_RATE)) {
throw new ValidationException(validable, "Unexpected value for " + fieldName + " of " + validableType + " : " + rate + " is not included in [0, 1]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constants in the message too

private double readOutageRate(DeserializerContext context, String attributeName) {
double outageRate = context.getReader().readDoubleAttribute(attributeName);
// compatibility
if (outageRate > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the constants

assertEquals(5.0, generatorStartup.getStartupCost());
assertEquals(10.0, generatorStartup.getMarginalCost());
// planned outage rate is greater than 1 so it is set to 1
assertEquals(1, generatorStartup.getPlannedOutageRate());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare to the constants

Signed-off-by: Etienne LESOT <[email protected]>
Signed-off-by: Etienne LESOT <[email protected]>
Signed-off-by: Etienne LESOT <[email protected]>
Signed-off-by: Etienne LESOT <[email protected]>
Signed-off-by: EtienneLt <[email protected]>
@EtienneLt EtienneLt force-pushed the add-controls-on-rates branch from f416c34 to 0dcf9d2 Compare February 2, 2026 08:52
Signed-off-by: Etienne LESOT <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants