Skip to content

Commit

Permalink
add topologyKind to distinct buses from TopologyKind.NODE_BREAKER and…
Browse files Browse the repository at this point in the history
… TopologyKind.BUS_BREAKER
  • Loading branch information
thangqp committed Dec 6, 2023
1 parent 455ef69 commit 9b56e19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/gridsuite/filter/server/FilterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.springframework.web.server.ResponseStatusException;

import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -593,11 +594,17 @@ private List<Identifiable<?>> getVscConverterStationList(Network network, Abstra

private List<Identifiable<?>> getBusList(Network network, AbstractFilter filter) {
if (filter instanceof ExpertFilter expertFilter) {
var rule = expertFilter.getRules();
// topologyKind is an optional info attached into expert filter when filtering bus for optimizing the perf
// note that with voltage levels of kind TopologyKind.NODE_BREAKER, buses are computed on-the-fly => expensive
var topologyKind = expertFilter.getTopologyKind();
Predicate<VoltageLevel> voltageLevelFilter = (vl -> topologyKind == null || vl.getTopologyKind() == topologyKind);

Stream<Identifiable<?>> stream = network.getVoltageLevelStream()
.filter(elem -> elem.getTopologyKind() == TopologyKind.BUS_BREAKER) // get only bus for BUS_BREAKER voltage level
.filter(voltageLevelFilter)
.map(VoltageLevel::getBusBreakerView)
.flatMap(VoltageLevel.BusBreakerView::getBusStream).map(bus -> bus);

var rule = expertFilter.getRules();
return stream.filter(rule::evaluateRule).toList();
} else {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package org.gridsuite.filter.server.dto.expertfilter;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.powsybl.iidm.network.TopologyKind;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -31,6 +32,9 @@ public class ExpertFilter extends AbstractFilter {
@Schema(description = "Rules")
private AbstractExpertRule rules;

@Schema(description = "TopologyKind is an optional information used when filtering bus")
private TopologyKind topologyKind;

public ExpertFilter(UUID id, Date modificationDate, EquipmentType equipmentType, AbstractExpertRule rules) {
super(id, modificationDate, equipmentType);
this.rules = rules;
Expand Down

0 comments on commit 9b56e19

Please sign in to comment.