public String toString(ShortIdDictionary dict) { return (dict != null ? dict.getShortId(id) : id) + ":" + duplicateIndex; }
private static ShortIdDictionary createDict(Set<Set<TopoBus>> topos) { Set<String> ids = new TreeSet<>(); for (Set<TopoBus> topo : topos) { for (TopoBus b : topo) { ids.addAll(b.getEquipments()); } } return new ShortIdDictionary(ids); }
if (dictFile != null) { ShortIdDictionary dict = createDict(topos.keySet()); dict.write(dictFile); topos2 = translate(topos, dict); } else {
private static Map<Set<TopoBus>, AtomicInteger> translate(Map<Set<TopoBus>, AtomicInteger> topos, ShortIdDictionary dict) { Map<Set<TopoBus>, AtomicInteger> topos2 = new LinkedHashMap<>(); for (Map.Entry<Set<TopoBus>, AtomicInteger> e : topos.entrySet()) { Set<TopoBus> topo = e.getKey(); AtomicInteger count = e.getValue(); Set<TopoBus> topo2 = new HashSet<>(); for (TopoBus b : topo) { topo2.add(new TopoBus(b.getEquipments().stream().map(s -> dict.getShortId(s)).collect(Collectors.toSet()), b.getSubstation())); } topos2.put(topo2, count); } return topos2; }
dict = new ShortIdDictionary(dictFile);
@Override public void visitEquipment(Connectable eq) { set.add(dict != null ? dict.getShortId(eq.getId()) : eq.getId()); } });
dict = new ShortIdDictionary(dictFile);
private static Set<Set<String>> toTopoSet(PossibleTopology.Substation ps, ShortIdDictionary dict) { Set<Set<String>> sets = new HashSet<>(); for (PossibleTopology.Bus b : ps.getBuses()) { if (isBusValid(b)) { Set<String> set = new HashSet<>(); for (PossibleTopology.Equipment eq : b.getEquipments()) { set.add(dict != null ? dict.getShortId(eq.getId()) : eq.getId()); } sets.add(set); } } return sets; }
@Override public void printTopology(PrintStream out, ShortIdDictionary dict) { out.println("-------------------------------------------------------------"); out.println("Topology of " + BusBreakerVoltageLevel.this.id); Function<ConfiguredBus, String> vertexToString = bus -> { StringBuilder builder = new StringBuilder(); builder.append(bus.getId()) .append(" ["); for (Iterator<TerminalExt> it = bus.getConnectedTerminals().iterator(); it.hasNext(); ) { TerminalExt terminal = it.next(); builder.append(dict != null ? dict.getShortId(terminal.getConnectable().getId()) : terminal.getConnectable().getId()); if (it.hasNext()) { builder.append(", "); } } builder.append("]"); return builder.toString(); }; Function<SwitchImpl, String> edgeToString = aSwitch -> { StringBuilder builder = new StringBuilder(); builder.append("id=").append(aSwitch.getId()) .append(" status=").append(aSwitch.isOpen() ? "open" : "closed"); return builder.toString(); }; graph.print(out, vertexToString, edgeToString); }