public BasicStroke getStroke() { if (npLink == null) return edgeStrokeIfNotActiveLayer; // interlayer link return npLink.getNetPlan().getNetworkLayerDefault() == npLink.getLayer()? edgeStrokeIfActiveLayer : edgeStrokeIfNotActiveLayer; }
/** * Returns a set of SRGs that are affecting the given links. * @param links Collection of links * @return SRGs affecting the links */ public static SortedSet<SharedRiskGroup> getAffectingSRGs (Collection<Link> links) { if (links == null) return new TreeSet<SharedRiskGroup> (); if (links.isEmpty()) return new TreeSet<SharedRiskGroup> (); final NetPlan np = links.iterator().next().getNetPlan(); SortedSet<SharedRiskGroup> res = new TreeSet<SharedRiskGroup> (); res.addAll (links.iterator().next().getOriginNode().getSRGs()); for (Link e : links) { res.addAll (e.getSRGs()); res.addAll (e.getDestinationNode().getSRGs()); } return res; }
void checkCachesConsistency () { super.checkCachesConsistency (); assert getNodes ().stream().allMatch(n->n.getNetPlan()== this.netPlan); assert getLinksAllLayers ().stream().allMatch(n->n.getNetPlan()== this.netPlan); if (isDynamicSrg()) { for (Link link : linksIfNonDynamic) if (!link.cache_nonDynamicSrgs.contains(this)) throw new RuntimeException ("Bad"); for (Node node : nodesIfNonDynamic) if (!node.cache_nodeNonDynamicSRGs.contains(this)) throw new RuntimeException ("Bad"); } }
private static Link oppositeLink (Link e) { return e.getNetPlan ().getNodePairLinks(e.getDestinationNode(), e.getOriginNode() , false).iterator().next(); }
private TBFToFromCarriedTraffic(Link link, boolean onlyThisLayer) { super(link.getNetPlan()); this.initialElement = link; this.onlyThisLayer = onlyThisLayer; this.initialFR = null; this.auxLayerInNodes = null; final Set<Link> linksAllLayers = new HashSet<>(); final Set<Demand> demandsAllLayers = new HashSet<>(); final Set<MulticastDemand> mDemandsAllLayers = new HashSet<>(); linksAllLayers.add(link); Triple<SortedMap<Demand, SortedSet<Link>>, SortedMap<Demand, SortedSet<Link>>, SortedMap<Pair<MulticastDemand, Node>, SortedSet<Link>>> thisLayerTraversalInfo = link.getLinksThisLayerPotentiallyCarryingTrafficTraversingThisLink(); linksAllLayers.addAll(thisLayerTraversalInfo.getFirst().values().stream().flatMap(set -> set.stream()).collect(Collectors.toSet())); linksAllLayers.addAll(thisLayerTraversalInfo.getSecond().values().stream().flatMap(set -> set.stream()).collect(Collectors.toSet())); linksAllLayers.addAll(thisLayerTraversalInfo.getThird().values().stream().flatMap(set -> set.stream()).collect(Collectors.toSet())); demandsAllLayers.addAll(thisLayerTraversalInfo.getFirst().keySet()); demandsAllLayers.addAll(thisLayerTraversalInfo.getSecond().keySet()); mDemandsAllLayers.addAll(thisLayerTraversalInfo.getThird().keySet().stream().map(p -> p.getFirst()).collect(Collectors.toSet())); if (!onlyThisLayer) updatePropagationDownWards(Arrays.asList(link), linksAllLayers, demandsAllLayers, mDemandsAllLayers); if (!onlyThisLayer) updatePropagationUpWards(demandsAllLayers, mDemandsAllLayers, linksAllLayers, demandsAllLayers, mDemandsAllLayers); final Set<NetworkLayer> layersToKeepAllElements = onlyThisLayer ? Sets.difference(new HashSet<>(netPlan.getNetworkLayers()), Sets.newHashSet(link.getLayer())) : new HashSet<>(); updateAllButLinksDemandsMDemandsUsingExistingInfo(linksAllLayers, demandsAllLayers, mDemandsAllLayers, layersToKeepAllElements); }
public BasicStroke getEdgeStroke() { if (isIntraNodeLink()) return edgeStrokeIfNotActiveLayer; return npLink.getNetPlan().getNetworkLayerDefault() == npLink.getLayer()? edgeStrokeIfActiveLayer : edgeStrokeIfNotActiveLayer; }
final NetPlan np = npLink.getNetPlan(); final NetworkLayer layer = npLink.getLayer(); final String capUnits = np.getLinkCapacityUnitsName(layer);
final int E = links.size(); if (E == 0) return new LinkedList<Pair<List<NetworkElement>,Double>> (); final NetPlan netPlan = links.get(0).getNetPlan(); if (linkCost == null) linkCost = DoubleFactory1D.dense.make(E , 1.0); if (linkCost.size() != E) throw new Net2PlanException ("Wrong size of cost array");
private List<Triple<String,String,String>> getForwardingRuleInfoTables (Pair<Demand,Link> fr) { final DecimalFormat df = new DecimalFormat("###.##"); final Demand d = fr.getFirst(); final Link e = fr.getSecond(); final NetworkLayer layer = d.getLayer(); final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); final String capUnits = np.getLinkCapacityUnitsName(layer); res.add(Triple.of("Demand index/id" , "Demand " + d.getIndex() + " (id " + d.getId() + ")", "demand" + d.getId())); res.add(Triple.of("Link index/id" , "Link " + e.getIndex() + " (id " + e.getId() + ")", "link" + e.getId())); res.add(Triple.of("Splitting factor", "" + df.format(np.getForwardingRuleSplittingFactor(d,e)) , "")); res.add(Triple.of("Carried traffic", "" + df.format(np.getForwardingRuleCarriedTraffic(d,e)) + " " + trafUnits , "")); return res; } private List<Triple<String,String,String>> getRouteInfoTables (Route r)
DrawLine(DrawNode from, DrawNode to, Link e, Point pFrom, Point pTo, double occupiedToShow) { final String capUnits = e.getNetPlan().getLinkCapacityUnitsName(e.getLayer()); this.from = from; this.to = to; this.pFrom = pFrom; this.pTo = pTo; this.labels = new ArrayList<>(); this.urlsLabels = new ArrayList<>(); final DecimalFormat df = new DecimalFormat("###.##"); String length_km = df.format((e.getLengthInKm() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getLengthInKm()); String delay_ms = df.format((e.getPropagationDelayInMs() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getPropagationDelayInMs()); this.labels.addAll(Arrays.asList( "Link " + e.getIndex() , length_km + " km (" + delay_ms + " ms)" , "Occup: " + String.format("%.1f" , occupiedToShow) + " " + capUnits, "Total: " + String.format("%.1f" , e.getOccupiedCapacity()) + "/" + String.format("%.1f" , e.getCapacity()) + " " + capUnits )); this.urlsLabels.addAll(Arrays.asList("link" + e.getId(), "", "", "")); if (e.getCoupledDemand() != null) { labels.add("Coupled: Demand " + e.getCoupledDemand().getIndex() + ", " + getLayerName(e.getCoupledDemand().getLayer())); urlsLabels.add("demand" + e.getCoupledDemand().getId()); } else if (e.getCoupledMulticastDemand() != null) { labels.add("Coupled: Multicast demand " + e.getCoupledMulticastDemand().getIndex() + ", " + getLayerName(e.getCoupledMulticastDemand().getLayer())); urlsLabels.add("multicastDemand" + e.getCoupledMulticastDemand().getId()); } this.associatedElement = e; }
public Paint getEdgeDrawPaint() { if (npLink == null) return edgeDrawPaint; if (!npLink.isUp()) return Color.RED; /* Consider worst case color if not separated links */ final Set<Link> overlappingLinksToConsider = shownSeparated ? Sets.newHashSet(npLink) : npLink.getNetPlan().getNodePairLinks(npLink.getOriginNode(), npLink.getDestinationNode(), true); /* In red if any overlapping link is down */ if (overlappingLinksToConsider.stream().anyMatch(ee->ee.isDown())) return Color.RED; if (vs.getIsActiveLinkUtilizationColorThresholdList()) { if(!npLink.getLayer().isDefaultLayer()) return edgeDrawPaint; final double worstUtilization = overlappingLinksToConsider.stream().mapToDouble(e->e.getUtilization()).max().orElse(0); return vs.getLinkColorAccordingToUtilization(worstUtilization); } else if (vs.getIsActiveLinkRunoutTimeColorThresholdList()) { return edgeDrawPaint; } else return edgeDrawPaint; }
final NetPlan netPlan = links.get(0).getNetPlan();
private List<Triple<String,String,String>> getLinkInfoTables (Link e) final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final NetworkLayer layer = e.getLayer();
for (Link e : rwa.getFirst ().seqLinks) if (e.getNetPlan() != currentNetPlan) throw new RuntimeException ("Bad. e.getNetPlan is null?: " + (e.getNetPlan() ==null) + ", currentNp is null: " + (currentNetPlan == null)); for (Link e : rwa.getSecond ().seqLinks) if (e.getNetPlan() != currentNetPlan) throw new RuntimeException ("Bad");