@Override public Component getConnectedComponent() { checkValidity(); for (Bus b : buses) { Component cc = b.getConnectedComponent(); if (cc != null) { return cc; } } throw new AssertionError("Should not happen"); }
public static int getCcNum(Bus b) { int ccNum = -1; if (b != null) { Component cc = b.getConnectedComponent(); if (cc != null) { ccNum = cc.getNum(); } } return ccNum; }
private static Bus selectSlackbusCriteria1(Network network, EurostagEchExportConfig config, Set<String> busesToAvoid) { return StreamSupport.stream(EchUtil.getBuses(network, config).spliterator(), false) .sorted((b1, b2) -> b1.getId().compareTo(b2.getId())) .filter(b -> !busesToAvoid.contains(b.getId()) && b.getConnectedComponent() != null && b.getConnectedComponent().getNum() == ComponentConstants.MAIN_NUM) .map(b -> decorate(b)) .filter(db -> db.regulatingGenerator > 0 && db.maxP > 100) // only keep bus with a regulating generator and a pmax > 100 MW .sorted((db1, db2) -> Float.compare((db1.maxP - db1.minP) / 2 - db1.targetP, (db2.maxP - db2.minP) / 2 - db2.targetP)) // select first bus with a high margin .limit(1) .map(f -> f.bus) .findFirst() .orElse(null); }
@Override public Stream<Bus> getBusStream() { return networkRef.get().getBusView().getBusStream().filter(bus -> bus.getConnectedComponent() == ComponentImpl.this); } }
@Override public Iterable<Bus> getBuses() { return Iterables.filter(networkRef.get().getBusView().getBuses(), bus -> bus.getConnectedComponent() == ComponentImpl.this); }
if (bus.getConnectedComponent().getNum() == ComponentConstants.MAIN_NUM || substpilotPoint == null) { substpilotPoint = iidm2eurostagId.get(bus.getId());
public void write(OutputStream os) { Graph graph = new Graph().id("\"" + network.getId() + "\""); int maxCC = network.getBusView().getBusStream().mapToInt(b -> b.getConnectedComponent().getNum()).max().getAsInt(); String[] colors = Colors.generateColorScale(maxCC + 1); Map<String, Node> nodes = new HashMap<>(); .attr("style", "filled") .attr("fontsize", "10") .attr("fillcolor", colors[b.getConnectedComponent().getNum()]) .attr("tooltip", "load=" + load + "MW" + NEWLINE + "max generation=" + maxGeneration + "MW" + NEWLINE + "cc=" + b.getConnectedComponent().getNum()); nodes.put(busId, n); graph.node(n);