Skip to content

[WIP] ICS importer POC #1297

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions data/inter-temporal-constraint/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>open-rao-data</artifactId>
<groupId>com.powsybl</groupId>
<version>6.4.0-SNAPSHOT</version>
</parent>

<artifactId>open-rao-inter-temporal-constraint</artifactId>
<packaging>jar</packaging>
<name>Inter-temporal Constraints</name>
<description>Module for inter-temporal constraints</description>

<dependencies>
<!-- Compile dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-crac-api</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package com.powsybl.openrao.data.intertemporalconstraint;

import com.powsybl.openrao.commons.OpenRaoException;

import java.util.Optional;

// TODO: delete this class and this module and replace by GeneratorConstraints

/**
* Power Gradient (in MW/hour) that applies on a generator or a load.
* It has a negative minimum value and/or a positive maximum value.
*
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>}
*/
@Deprecated
public final class PowerGradient {
private final String networkElementId;
private final Double minValue;
private final Double maxValue;

public PowerGradient(String networkElementId, Double minValue, Double maxValue) {
this.networkElementId = networkElementId;
this.minValue = minValue;
this.maxValue = maxValue;
}

public String getNetworkElementId() {
return networkElementId;
}

public Optional<Double> getMinValue() {
return Optional.ofNullable(minValue);
}

public Optional<Double> getMaxValue() {
return Optional.ofNullable(maxValue);
}

public static PowerGradientBuilder builder() {
return new PowerGradientBuilder();
}

public static final class PowerGradientBuilder {
private String networkElementId;
private Double minValue;
private Double maxValue;

private PowerGradientBuilder() {
}

public PowerGradientBuilder withNetworkElementId(String networkElementId) {
this.networkElementId = networkElementId;
return this;
}

public PowerGradientBuilder withMinValue(Double minPowerGradient) {
this.minValue = minPowerGradient;
return this;
}

public PowerGradientBuilder withMaxValue(Double maxPowerGradient) {
this.maxValue = maxPowerGradient;
return this;
}

public PowerGradient build() {
if (networkElementId == null) {
throw new OpenRaoException("No network element id provided.");
}
if (minValue == null && maxValue == null) {
throw new OpenRaoException("At least one of min or max power gradient's value must be provided.");
}
if (minValue != null && minValue > 0) {
throw new OpenRaoException("The min value of the power gradient must be negative.");
}
if (maxValue != null && maxValue < 0) {
throw new OpenRaoException("The max value of the power gradient must be positive.");
}
return new PowerGradient(networkElementId, minValue, maxValue);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package com.powsybl.openrao.data.intertemporalconstraint;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.powsybl.openrao.commons.OpenRaoException;
import org.junit.jupiter.api.Test;

import java.util.Optional;

/**
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>}
*/
class PowerGradientTest {
@Test
void buildExhaustivePowerGradientConstraint() {
PowerGradient powerGradient = PowerGradient.builder()
.withNetworkElementId("generator")
.withMinValue(-100.0)
.withMaxValue(100.0)
.build();
assertEquals("generator", powerGradient.getNetworkElementId());
assertEquals(Optional.of(-100.0), powerGradient.getMinValue());
assertEquals(Optional.of(100.0), powerGradient.getMaxValue());
}

@Test
void buildPowerGradientConstraintWithoutMin() {
PowerGradient powerGradient = PowerGradient.builder()
.withNetworkElementId("generator")
.withMaxValue(100.0)
.build();
assertEquals("generator", powerGradient.getNetworkElementId());
assertTrue(powerGradient.getMinValue().isEmpty());
assertEquals(Optional.of(100.0), powerGradient.getMaxValue());
}

@Test
void buildPowerGradientConstraintWithoutMax() {
PowerGradient powerGradient = PowerGradient.builder()
.withNetworkElementId("generator")
.withMinValue(-100.0)
.build();
assertEquals("generator", powerGradient.getNetworkElementId());
assertEquals(Optional.of(-100.0), powerGradient.getMinValue());
assertTrue(powerGradient.getMaxValue().isEmpty());
}

@Test
void buildPowerGradientConstraintWithoutNetworkElement() {
OpenRaoException exception = assertThrows(OpenRaoException.class, () -> PowerGradient.builder().withMinValue(-100.0).withMaxValue(100.0).build());
assertEquals("No network element id provided.", exception.getMessage());
}

@Test
void buildPowerGradientConstraintWithoutMinAndMax() {
OpenRaoException exception = assertThrows(OpenRaoException.class, () -> PowerGradient.builder().withNetworkElementId("generator").build());
assertEquals("At least one of min or max power gradient's value must be provided.", exception.getMessage());
}

@Test
void buildPowerGradientConstraintPositiveMin() {
OpenRaoException exception = assertThrows(OpenRaoException.class, () -> PowerGradient.builder().withNetworkElementId("generator").withMinValue(100.0).build());
assertEquals("The min value of the power gradient must be negative.", exception.getMessage());
}

@Test
void buildPowerGradientConstraintNegativeMax() {
OpenRaoException exception = assertThrows(OpenRaoException.class, () -> PowerGradient.builder().withNetworkElementId("generator").withMaxValue(-100.0).build());
assertEquals("The max value of the power gradient must be positive.", exception.getMessage());
}
}
1 change: 1 addition & 0 deletions data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<module>flowbased-domain</module>
<module>generator-constraints</module>
<module>glsk</module>
<module>inter-temporal-constraint</module>
<module>rao-result</module>
<module>refprog</module>
<module>virtual-hubs</module>
Expand Down
5 changes: 5 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
<artifactId>open-rao-generator-constraints</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-inter-temporal-constraint</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-loopflow-computation</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@
<artifactId>open-rao-glsk-virtual-hubs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-inter-temporal-constraint</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-rao-result</artifactId>
Expand Down
14 changes: 10 additions & 4 deletions ra-optimisation/rao-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<artifactId>open-rao-crac-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>open-rao-inter-temporal-constraint</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>open-rao-rao-result-api</artifactId>
Expand Down Expand Up @@ -61,6 +66,11 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.13.0</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down Expand Up @@ -110,9 +120,5 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>open-rao-generator-constraints</artifactId>
</dependency>
</dependencies>
</project>
Loading
Loading