-
Notifications
You must be signed in to change notification settings - Fork 2
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
WIP: XnecProvider accepts paired Dangling Lines #173
Conversation
Signed-off-by: Caio Luke <caioluke97@gmail.com>
@OpenSuze @murgeyseb what do you think about this idea? Extending the XnecProvider API to also accept paired DanglingLines. It is not finished, I will still need to do some work on the PTDF calculations and most likely in other places of the code. But before doing so, please tell me what you think about this implementation! Thanks |
Quality Gate failedFailed conditions |
@caioluke I think that this proposal is not a good solution as it clearly opens many potential issues in the usage of the algorithm. public class XnecProviderImpl implements XnecProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(XnecProviderImpl.class);
private final String danglingLineId;
public XnecProviderImpl(String danglingLineId) {
this.danglingLineId = Objects.requireNonNull(danglingLineId);
}
@Override
public Set<Branch> getNetworkElements(Network network) {
DanglingLine danglingLine = network.getDanglingLine(danglingLineId);
if (danglingLine == null) {
LOGGER.warn("Branch {} was not found in network {}", danglingLineId, network.getId());
return Collections.emptySet();
}
// check if dangling line is duly paired
if (danglingLine.isPaired()) {
return Set.of(danglingLine.getTieLine().get());
} else {
LOGGER.warn("DanglingLine {} is not paired: will not decompose such flows", danglingLineId);
return Collections.emptySet();
}
}
@Override
public Set<Branch> getNetworkElements(String contingencyId, Network network) {
return Collections.emptySet();
}
@Override
public Map<String, Set<Branch>> getNetworkElementsPerContingency(Network network) {
return Collections.emptyMap();
}
@Override
public List<Contingency> getContingencies(Network network) {
return Collections.emptyList();
}
} You can also add the same kind of implementation for your observers |
@murgeyseb The observer part is being handled in #171, so the only thing remaining is really the final decomposed flows. |
@caioluke You can do something like that : Network network = Network.read("");
Set<String> danglingLineIds = Set.of("dl1", "dl2");
Map<String, String> tieLineOfDanglingLine = danglingLineIds.stream()
.collect(Collectors.toMap(
Function.identity(),
id -> network.getDanglingLine(id).getTieLine().get().getId()
));
XnecProvider xnecProvider = XnecProviderByIds.builder().addNetworkElementsOnBasecase(Set.copyOf(tieLineOfDanglingLine.values())).build();
FlowDecompositionResults results = new FlowDecompositionComputer().run(xnecProvider, network);
Map<String, DecomposedFlow> decomposedFlowByDanglingLine = tieLineOfDanglingLine.entrySet().stream()
.collect(Collectors.toMap(
entry -> entry.getKey(),
entry -> results.getDecomposedFlowMap().get(entry.getValue())
)); You can use same type of trick (mapping from dangling line to tie line) in your own Observer implementation |
@murgeyseb |
@murgeyseb |
WORK IN PROGRESS
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
Feature
What is the current behavior?
XnecProvider currently accepts only Branches.
What is the new behavior (if this is a feature change)?
XnecProvider will also accept paired DanglingLines.
Does this PR introduce a breaking change or deprecate an API?