Skip to content

Commit

Permalink
review remarks
Browse files Browse the repository at this point in the history
Signed-off-by: David BRAQUART <[email protected]>
  • Loading branch information
dbraquart committed Sep 25, 2023
1 parent 905a6f5 commit d5d4f8d
Showing 1 changed file with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,21 @@ private static Map<Double, List<String>> getGeneratorsByMarginalCost(List<Genera
generators.forEach(generator -> generator.setTargetP(0.));

// get generators with marginal cost
List<Generator> generatorsWithMarginalCost = generators.stream().filter(generator -> {
Double marginalCost = getGeneratorMarginalCost(generator);
if (marginalCost == null) {
report(reporter, reporterSuffixKey, "MissingMarginalCostForGenerator", "The generator ${generator} does not have a marginal cost",
Map.of(GENERATOR, generator.getId()), TypedValue.TRACE_SEVERITY);
}
return marginalCost != null;
}).collect(Collectors.toList());

List<Generator> generatorsWithMarginalCost = generators.stream()
.filter(generator -> getGeneratorMarginalCost(generator) != null)
.toList();
int nbNoCost = generators.size() - generatorsWithMarginalCost.size();
if (nbNoCost > 0) {
report(reporter, reporterSuffixKey, "NbGeneratorsWithNoCost", "${nbNoCost} generator${isPlural} been discarded from generation dispatch because of missing marginal cost. Their active power set point has been set to 0",
Map.of("nbNoCost", nbNoCost,
"isPlural", nbNoCost > 1 ? "s have" : " has"),
TypedValue.WARN_SEVERITY);
}
generators.stream()
.filter(generator -> getGeneratorMarginalCost(generator) == null)
.forEach(g -> report(reporter, reporterSuffixKey, "MissingMarginalCostForGenerator", "The generator ${generator} does not have a marginal cost",
Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY)
);

// build map of generators by marginal cost
generatorsWithMarginalCost.sort(Comparator.comparing(GenerationDispatch::getGeneratorMarginalCost));
Expand Down Expand Up @@ -295,16 +294,17 @@ public void onUpdate(Identifiable identifiable, String attribute, String variant
public void endReport(List<Generator> adjustableGenerators) {
report(reporter, suffixKey, "TotalGeneratorSetTargetP", "The active power set points of ${nbUpdatedGenerator} generator${isPlural} have been updated as a result of generation dispatch",
Map.of("nbUpdatedGenerator", updatedGenerators.size(), "isPlural", updatedGenerators.size() > 1 ? "s" : ""), TypedValue.INFO_SEVERITY);

// what are unchanged generators ?
adjustableGenerators.stream()
.filter(g -> !updatedGenerators.contains(g.getId()))
.forEach(g -> report(reporter, suffixKey, "GeneratorUnchangedTargetP", "Generator ${generator} has not been selected by the merit order algorithm. Its active power set point has been set to 0",
Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY));
int nbUnchangedGenerators = adjustableGenerators.size() - updatedGenerators.size();
if (nbUnchangedGenerators > 0) {
report(reporter, suffixKey, "TotalGeneratorUnchangedTargetP", "${nbUnchangedGenerator} eligible generator${isPlural} not been selected by the merit order algorithm. Their active power set point has been set to 0",
Map.of("nbUnchangedGenerator", nbUnchangedGenerators,
"isPlural", nbUnchangedGenerators > 1 ? "s have" : " has"), TypedValue.INFO_SEVERITY);
adjustableGenerators.stream()
.filter(g -> !updatedGenerators.contains(g.getId()))
.forEach(g -> report(reporter, suffixKey, "GeneratorUnchangedTargetP", "Generator ${generator} has not been selected by the merit order algorithm. Its active power set point has been set to 0",
Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY));
}
}
}
Expand Down Expand Up @@ -414,21 +414,20 @@ private double reduceGeneratorMaxPValue(Generator generator,
return Math.max(generator.getMinP(), res * (1. - genFrequencyReserve / 100.));
}

private void reportDisconnectedGenerators(List<Generator> disconnectedGenerators, int componentNum, Reporter reporter) {
AtomicInteger disconnectedGeneratorCounter = new AtomicInteger(0);
disconnectedGenerators.stream()
private void reportDisconnectedGenerators(List<Generator> globalDisconnectedGenerators, int componentNum, Reporter reporter) {
List<Generator> componentDisconnectedGenerators = globalDisconnectedGenerators.stream()
.filter(g -> g.getTerminal().getBusView() != null && g.getTerminal().getBusView().getConnectableBus() != null &&
g.getTerminal().getBusView().getConnectableBus().getSynchronousComponent().getNum() == componentNum)
.forEach(g -> {
report(reporter, Integer.toString(componentNum), "DisconnectedGenerator", "Generator ${generator} has been discarded from generation dispatch because it is disconnected. Its active power set point remains unchanged",
Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY);
disconnectedGeneratorCounter.getAndIncrement();
});
if (disconnectedGeneratorCounter.get() > 0) {
.toList();
if (!componentDisconnectedGenerators.isEmpty()) {
report(reporter, Integer.toString(componentNum), "TotalDisconnectedGenerator", "${nbDisconnectedGenerator} generator${isPlural} been discarded from generation dispatch because their are disconnected. Their active power set point remains unchanged",
Map.of("nbDisconnectedGenerator", disconnectedGeneratorCounter.get(),
"isPlural", disconnectedGeneratorCounter.get() > 1 ? "s have" : " has"),
Map.of("nbDisconnectedGenerator", componentDisconnectedGenerators.size(),
"isPlural", componentDisconnectedGenerators.size() > 1 ? "s have" : " has"),
TypedValue.INFO_SEVERITY);
componentDisconnectedGenerators.forEach(g ->
report(reporter, Integer.toString(componentNum), "DisconnectedGenerator", "Generator ${generator} has been discarded from generation dispatch because it is disconnected. Its active power set point remains unchanged",
Map.of(GENERATOR, g.getId()), TypedValue.TRACE_SEVERITY)
);
}
}

Expand Down

0 comments on commit d5d4f8d

Please sign in to comment.