-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rao_parameters_remove_curative_stop_criterion' of https…
…://github.com/powsybl/open-rao into rao_parameters_separate_unit_from_objective_function_type Signed-off-by: Philippe Edwards <philippe.edwards@rte-france.com>
- Loading branch information
Showing
205 changed files
with
8,565 additions
and
1,514 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
commons/src/main/java/com/powsybl/openrao/commons/TemporalData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.commons; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>} | ||
*/ | ||
public interface TemporalData<T> { | ||
Map<OffsetDateTime, T> getDataPerTimestamp(); | ||
|
||
default Optional<T> getData(OffsetDateTime timestamp) { | ||
return Optional.ofNullable(getDataPerTimestamp().get(timestamp)); | ||
} | ||
|
||
default List<OffsetDateTime> getTimestamps() { | ||
return getDataPerTimestamp().keySet().stream().sorted().toList(); | ||
} | ||
|
||
void add(OffsetDateTime timestamp, T data); | ||
} |
35 changes: 35 additions & 0 deletions
35
commons/src/main/java/com/powsybl/openrao/commons/TemporalDataImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.commons; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>} | ||
*/ | ||
public class TemporalDataImpl<T> implements TemporalData<T> { | ||
private final Map<OffsetDateTime, T> dataPerTimestamp; | ||
|
||
public TemporalDataImpl() { | ||
this(new HashMap<>()); | ||
} | ||
|
||
public TemporalDataImpl(Map<OffsetDateTime, T> dataPerTimestamp) { | ||
this.dataPerTimestamp = new HashMap<>(dataPerTimestamp); | ||
} | ||
|
||
public Map<OffsetDateTime, T> getDataPerTimestamp() { | ||
return new HashMap<>(dataPerTimestamp); | ||
} | ||
|
||
public void add(OffsetDateTime timestamp, T data) { | ||
dataPerTimestamp.put(timestamp, data); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
commons/src/test/java/com/powsybl/openrao/commons/TemporalDataImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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.commons; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.ZoneOffset; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static org.ejml.UtilEjml.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>} | ||
*/ | ||
class TemporalDataImplTest { | ||
final OffsetDateTime timestamp1 = OffsetDateTime.of(2024, 6, 12, 17, 41, 0, 0, ZoneOffset.UTC); | ||
final OffsetDateTime timestamp2 = OffsetDateTime.of(2024, 6, 12, 17, 42, 0, 0, ZoneOffset.UTC); | ||
final OffsetDateTime timestamp3 = OffsetDateTime.of(2024, 6, 12, 17, 43, 0, 0, ZoneOffset.UTC); | ||
|
||
@Test | ||
void testCreateEmptyTemporalData() { | ||
assertTrue(new TemporalDataImpl<>().getDataPerTimestamp().isEmpty()); | ||
} | ||
|
||
@Test | ||
void testCreateTemporalDataFromMap() { | ||
Map<OffsetDateTime, String> stringPerTimestamp = Map.of(timestamp1, "Hello world!", timestamp2, "OpenRAO"); | ||
TemporalData<String> stringTemporalData = new TemporalDataImpl<>(stringPerTimestamp); | ||
|
||
assertEquals(stringPerTimestamp, stringTemporalData.getDataPerTimestamp()); | ||
assertEquals(List.of(timestamp1, timestamp2), stringTemporalData.getTimestamps()); | ||
assertEquals(Optional.of("Hello world!"), stringTemporalData.getData(timestamp1)); | ||
assertEquals(Optional.of("OpenRAO"), stringTemporalData.getData(timestamp2)); | ||
assertTrue(stringTemporalData.getData(timestamp3).isEmpty()); | ||
} | ||
|
||
@Test | ||
void testAddData() { | ||
TemporalData<String> stringTemporalData = new TemporalDataImpl<>(); | ||
stringTemporalData.add(timestamp3, "ABC"); | ||
assertEquals(Map.of(timestamp3, "ABC"), stringTemporalData.getDataPerTimestamp()); | ||
assertEquals(List.of(timestamp3), stringTemporalData.getTimestamps()); | ||
assertEquals(Optional.of("ABC"), stringTemporalData.getData(timestamp3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.