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

create class InterTemporalRaoInput #1232

Merged
merged 2 commits into from
Dec 11, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.raoapi;

import com.powsybl.openrao.commons.TemporalData;

import java.time.OffsetDateTime;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>}
* @author Roxane Chen {@literal <roxane.chen at rte-france.com>}
*/
public class InterTemporalRaoInput {
private final TemporalData<RaoInput> raoInputs;
private final Set<OffsetDateTime> timestampsToRun;

public InterTemporalRaoInput(TemporalData<RaoInput> raoInputs, Set<OffsetDateTime> timestampsToRun) {
this.raoInputs = raoInputs;
this.timestampsToRun = timestampsToRun;
}

public InterTemporalRaoInput(TemporalData<RaoInput> raoInputs) {
this(raoInputs, raoInputs.getTimestamps().stream().collect(Collectors.toSet()));
}

public TemporalData<RaoInput> getRaoInputs() {
return raoInputs;
}

public Set<OffsetDateTime> getTimestampsToRun() {
return timestampsToRun;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.raoapi;

import com.powsybl.openrao.commons.TemporalData;
import com.powsybl.openrao.commons.TemporalDataImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Map;
import java.util.Set;

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

/**
* @author Thomas Bouquet {@literal <thomas.bouquet at rte-france.com>}
* @author Roxane Chen {@literal <roxane.chen at rte-france.com>}
*/
class InterTemporalRaoInputTest {

private OffsetDateTime timestamp1;
private OffsetDateTime timestamp2;
private OffsetDateTime timestamp3;
private TemporalData<RaoInput> temporalData;

@BeforeEach
void setUp() {
RaoInput raoInput1 = Mockito.mock(RaoInput.class);
RaoInput raoInput2 = Mockito.mock(RaoInput.class);
RaoInput raoInput3 = Mockito.mock(RaoInput.class);
timestamp1 = OffsetDateTime.of(2024, 12, 10, 16, 21, 0, 0, ZoneOffset.UTC);
timestamp2 = OffsetDateTime.of(2024, 12, 10, 17, 21, 0, 0, ZoneOffset.UTC);
timestamp3 = OffsetDateTime.of(2024, 12, 10, 18, 21, 0, 0, ZoneOffset.UTC);
temporalData = new TemporalDataImpl<>(Map.of(timestamp1, raoInput1, timestamp2, raoInput2, timestamp3, raoInput3));
}

@Test
void testInstantiateInterTemporalRaoInput() {
InterTemporalRaoInput input = new InterTemporalRaoInput(temporalData, Set.of(timestamp1, timestamp3));
assertEquals(temporalData, input.getRaoInputs());
assertEquals(Set.of(timestamp1, timestamp3), input.getTimestampsToRun());
}

@Test
void testInstantiateInterTemporalRaoInputAllTimestamps() {
InterTemporalRaoInput input = new InterTemporalRaoInput(temporalData);
assertEquals(temporalData, input.getRaoInputs());
assertEquals(Set.of(timestamp1, timestamp2, timestamp3), input.getTimestampsToRun());
}
}
Loading