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; }
/** * Returns the weight associated to a given link. * * @param link Link * @return Link weight (or {@code Double.MAX_VALUE} if link is down) */ public static double getLinkWeight(Link link) { if (link.isDown()) return Double.MAX_VALUE; double linkWeight = 1; String str_linkWeight = link.getAttribute(IP_WEIGHT_ATTRIBUTE_NAME); try { linkWeight = Double.parseDouble(str_linkWeight); } catch(Throwable e) { } checkIPWeight(linkWeight); return linkWeight; }
private static Pair<Boolean,Double> isValidPath (List<Link> seqLinks , double routeOccupiedCapacity) { final double minimumCapacityNeeded = routeOccupiedCapacity; boolean validPath = true; double thisPathIdleCapacity = Double.MAX_VALUE; for (Link e : seqLinks) { final double thisLinkIdleCapacity = e.getCapacity() - e.getCarriedTraffic(); thisPathIdleCapacity = Math.min(thisPathIdleCapacity, thisLinkIdleCapacity); if (e.isDown() || e.getOriginNode().isDown() || e.getDestinationNode().isDown() || (thisLinkIdleCapacity <= minimumCapacityNeeded)) { validPath = false; break; } } return Pair.of(validPath, thisPathIdleCapacity); } }
/** * Creates a link in the opposite direction as this, and with the same attributes, and associate both as bidirectional pairs. * If this link is already a bidirectional link, makes nothing and returns null * @return the newly created link */ public Link createBidirectionalPair () { checkAttachedToNetPlanObject(); if (this.isBidirectional()) return null; final Link e = netPlan.addLink(this.destinationNode, this.originNode, this.getCapacity(), this.getLengthInKm(), this.getPropagationDelayInMs(), this.attributes, this.layer); this.bidirectionalPair = e; e.bidirectionalPair = this; return e; }
private double computeLinkPriceFromNetPlan (Link e) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); if (u_e == 0) throw new RuntimeException ("Zero capacity in a link means"); final double gradient = (y_e / u_e > 0.99)? 1/Math.pow(u_e * 0.01,2) : 1/Math.pow(u_e - y_e,2); return gradient; }
public BasicStroke getStroke() { if (npLink == null) return edgeStrokeIfNotActiveLayer; // interlayer link return npLink.getNetPlan().getNetworkLayerDefault() == npLink.getLayer()? edgeStrokeIfActiveLayer : edgeStrokeIfNotActiveLayer; }
else callback.getVisualizationState().hideOnCanvas(n); }, n -> !callback.getVisualizationState().isHiddenOnCanvas(n), AGTYPE.COUNTTRUE, null)); res.add(new AjtColumnInfo<Link>(this , Node.class, null , "A", "Origin node", null , d->d.getOriginNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Link>(this , Node.class, null , "B", "Destination node", null , d->d.getDestinationNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Link>(this , Link.class, null , "Bidirectional pair", "If the link is bidirectional, provides its bidirectional pair", null , d->d.getBidirectionalPair() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , Boolean.class, null , "Up?", "", (d,val)-> callback.getWhatIfAnalysisPane().whatIfLinkNodesFailureStateChanged(null, null, isLinkUp ? Sets.newHashSet(d) : null, isLinkUp ? null : Sets.newHashSet(d)); else d.setFailureState(isLinkUp); } catch (Throwable ee) { ee.printStackTrace(); throw new Net2PlanException (ee.getMessage()); } } , d->d.isUp() , AGTYPE.COUNTTRUE , e->e.isUp()? null : Color.RED)); res.add(new AjtColumnInfo<Link>(this , String.class, null , "Trav. QoS types" , "The QoS types of the traversing trafffics", null , d->allLinksPerQosOccupationAndQosViolationMap.getOrDefault(d, new TreeMap<> ()).entrySet().stream().filter(ee->ee.getValue().getFirst() > 0).map(ee->ee.getKey()).collect(Collectors.joining(",")) , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Total QoS violation (" + layer.getLinkCapacityUnits() + ")" , "The total amount of link capacity that is being used outside the QoS contract, and thus the traffic using it would not be carried (and thus would be blocked) if the network applied a drop policy to it, or just if such extra capacity is not present in the link", null , d->allLinksPerQosOccupationAndQosViolationMap.getOrDefault(d, new TreeMap<> ()).values().stream().mapToDouble(ee->ee.getSecond()).sum() , AGTYPE.SUMDOUBLE , e->allLinksPerQosOccupationAndQosViolationMap.getOrDefault(e, new TreeMap<> ()).values().stream().mapToDouble(ee->ee.getSecond()).sum() == 0? null : Color.RED)); res.add(new AjtColumnInfo<Link>(this , String.class, null , "QoS scheduling" , "The scheduling configuration for the link QoS enforcement. For each QoS type, the priority assigned (lower better), and the maximum link utilization allowed for it", null , d->d.getQosTypePriorityAndMaxLinkUtilizationMap().toString() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , NetworkElement.class, null , "Coupled demand", "The demand or multicast demand that this link is coupled to, if any", null , d->d.getCoupledDemand() != null? d.getCoupledDemand() : d.getCoupledMulticastDemand() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Capacity (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Link capacity", (d,val)->{ if (!d.isCoupled()) d.setCapacity((Double) val); }, d->d.getCapacity() , AGTYPE.SUMDOUBLE , e->e.getCapacity() == 0? Color.YELLOW : null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Occupied capacity (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Link occupied capacity", null , d->d.getOccupiedCapacity() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Carried traffic (" + getTableNetworkLayer().getDemandTrafficUnits() + ")", "Link carried traffic", null , d->d.getCarriedTraffic() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Utilization", "Link utilization (occupied capacity vs. capacity)", null , d->d.getUtilization() , AGTYPE.NOAGGREGATION, e->{ final double v = e.getUtilization(); return v == 1? Color.YELLOW : (v > 1? Color.RED : null ); })); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Length (km)", "Link length in km, considering the worst case lower layer propagation", null , d->d.getLengthInKm() , AGTYPE.SUMDOUBLE, null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Prop. speed (km/sec)", "Link average propagation speed in km per second", (d,val)->{ if (!d.isCoupled()) d.setPropagationSpeedInKmPerSecond((Double)val); } , d->d.getPropagationSpeedInKmPerSecond() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , Double.class, null , "Prop. delay (ms)", "Link propagation delay in ms, considering the worst case lower layer propagation of the traffic", null , d->d.getPropagationDelayInMs() , AGTYPE.MAXDOUBLE, null)); res.add(new AjtColumnInfo<Link>(this , Collection.class, null , "Routes", "Traversing routes", null , d->d.getTraversingRoutes() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , Collection.class, null , "Forw. rules", "Forwarding rules defined for this link", null , d->d.getForwardingRules().keySet() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , Collection.class, null , "Trees", "Traversing multicast trees", null , d->d.getTraversingTrees() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Link>(this , Collection.class, null , "SRGs", "The SRGs that this link belongs to", null , d->d.getSRGs() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Link>(this , Integer.class, null , "#Monit points" , "Number of samples of the carried traffic stored, coming from a monitoring or forecasting traffic process", null , d->d.getMonitoredOrForecastedCarriedTraffic().getSize() , AGTYPE.NOAGGREGATION , null)); return res;
final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final NetworkLayer layer = e.getLayer(); final String trafUnits = np.getDemandTrafficUnitsName(layer); final String capUnits = np.getLinkCapacityUnitsName(layer); final double max_rho_e = np.getLinks(layer).stream().mapToDouble(ee->ee.getUtilization()).max().orElse(0); res.add(Triple.of("Link index/id" , "Link " + e.getIndex() + " (id " + e.getId() + ")", "link" + e.getId())); res.add(Triple.of("Is up?", "" + e.isUp() , "")); res.add(Triple.of("Is coupled to lower layer?", e.isCoupled() + "" , "")); if (e.isCoupled()) final NetworkLayer lowerLayer = e.getCoupledDemand() == null? e.getCoupledMulticastDemand().getLayer() : e.getCoupledDemand().getLayer(); res.add(Triple.of("- Lower layer coupled to", getLayerName(lowerLayer) , "")); if (e.getCoupledDemand() == null) final MulticastDemand md = e.getCoupledMulticastDemand(); res.add(Triple.of("- Coupled to", "Multicast demand " + md.getIndex() + " (id " + md.getId() + ")" , "multicastDemand" + md.getId())); final Demand d = e.getCoupledDemand(); res.add(Triple.of("- Coupled to", "Demand " + d.getIndex() + " (id " + d.getId() + ")" , "demand" + d.getId())); res.add(Triple.of("Carried traffic", "" + df.format(e.getCarriedTraffic()) + " " + trafUnits , "")); res.add(Triple.of("Capacity occupied / total", "" + df.format(e.getOccupiedCapacity()) + " / " + df.format(e.getCapacity()) + " " + capUnits , "")); res.add(Triple.of("Utilization", "" + df.format(e.getUtilization()) , "")); res.add(Triple.of("Is bottleneck?", "" + DoubleUtils.isEqualWithinRelativeTolerance(max_rho_e, e.getUtilization(), Configuration.precisionFactor) , "")); double length_km = (e.getLengthInKm() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getLengthInKm(); res.add(Triple.of("Length (km)", "" + df.format(length_km), "")); double delay_ms = (e.getPropagationDelayInMs() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getPropagationDelayInMs(); res.add(Triple.of("Delay (ms)", "" + df.format(delay_ms), ""));
if (nodesThis_thisAndOther.contains(e.getOriginNode()) && nodesThis_thisAndOther.contains(e.getDestinationNode())) e.remove(); for (Demand e : new ArrayList<> (this.getDemands(thisLayer))) if (nodesThis_thisAndOther.contains(e.getIngressNode()) && nodesThis_thisAndOther.contains(e.getEgressNode())) if (this.getLinkFromId(other.getId()) != null) throw new RuntimeException(); final Node this_ae = (Node) thatToThisTranslation.get(other.getOriginNode()); final Node this_be = (Node) thatToThisTranslation.get(other.getDestinationNode()); final Link e = this.addLink(this_ae, this_be, 0, 0, 0.1, null, thisLayer); thatToThisTranslation.put(other,e); e.setCapacity(other.getCapacity()); e.setLengthInKm(other.getLengthInKm()); e.setPropagationSpeedInKmPerSecond(other.getPropagationDelayInMs()); e.setFailureState(!other.isDown()); e.setAttributeMap(other.getAttributes()); // previous attributes are not removed, just new added or existing updated for (String tag : other.getTags()) e.addTag(tag);
final NetPlan np = npLink.getNetPlan(); final NetworkLayer layer = npLink.getLayer(); final String capUnits = np.getLinkCapacityUnitsName(layer); final String trafUnits = np.getDemandTrafficUnitsName(layer); temp.append("<html>"); temp.append("<table border=\"0\">"); temp.append("<tr><td colspan=\"2\"><strong>Link index " + npLink.getIndex() + " (id: " + npLink.getId() + ") - Layer " + getLayerName(layer) + "</strong></td></tr>"); temp.append("<tr><td>Link carried traffic:</td><td>" + String.format("%.2f" , npLink.getCarriedTraffic()) + " " + trafUnits + "</td></tr>"); temp.append("<tr><td>Link occupied capacity:</td><td>" + String.format("%.2f" , npLink.getOccupiedCapacity()) + " " + capUnits + "</td></tr>"); temp.append("<tr><td>Link capacity:</td><td>" + String.format("%.2f" , npLink.getCapacity()) + " " + capUnits + "</td></tr>"); temp.append("<tr><td>Link utilization:</td><td>" + String.format("%.2f" , npLink.getUtilization()) + "</td></tr>"); temp.append("<tr><td>Destination layer:</td><td>" + getLayerName(destinationNode.getLayer()) + "</td></tr>"); temp.append("<tr><td>Link length:</td><td>" + String.format("%.2f" , npLink.getLengthInKm()) + " km (" + String.format("%.2f" , npLink.getPropagationDelayInMs()) + " ms)" + "</td></tr>"); temp.append("</table>"); temp.append("</html>");
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; }
for (Link a : netPlan.getLinks()) final double Qa = a.getCapacity(); final double Va = a.getCarriedTraffic(); final double c0 = Double.parseDouble(a.getAttribute(UtnConstants.ATTRNAME_C0A)); final double Ca = UtnConstants.bprCaComputation(c0,alpha.getDouble(),Va,Qa,beta.getDouble()); vector_Ca.set(a.getIndex() , Ca); vector_C0a.set(a.getIndex() , c0); double sumCa = 0; for (Link a : r.getSeqLinks()) sumCa += vector_Ca.get(a.getIndex()); vector_Ck.set(r.getIndex() , sumCa); final double c0 = Double.parseDouble(a.getAttribute(UtnConstants.ATTRNAME_C0A)); final double Qa = a.getCapacity(); final double Va = a.getCarriedTraffic(); final double Ca = UtnConstants.bprCaComputation(c0,alpha.getDouble(),Va,Qa,beta.getDouble()); out.append("<td>" + a.getIndex() + "</td>"); out.append("<td>" + a.getOriginNode().getName() + "</td>"); out.append("<td>" + a.getDestinationNode().getName() + "</td>"); out.append("<td>" + df_6.format(c0) + "</td>"); out.append("<td>" + df_6.format(Qa) + "</td>"); out.append("<td>" + r.getDemand().getIndex() + " (" + df_6.format(r.getDemand().getOfferedTraffic()) + ")</td>"); out.append("<td>" + df_6.format(r.getCarriedTraffic()) + "</td>"); double sumC0a = 0; for (Link a : r.getSeqLinks()) sumC0a += vector_C0a.get(a.getIndex()); double worstUtilization = 0; for (Link a : r.getSeqLinks()) worstUtilization = Math.max(worstUtilization , a.getUtilization()); out.append("<td>" + df_6.format(vector_Ck.get(r.getIndex())) + "</td>"); out.append("<td>" + df_6.format(sumC0a) + "</td>");
for (Link e : netPlan.getLinks()) final double rho_e = e.getUtilization(); T_e_prop [e.getIndex()] = e.getPropagationDelayInMs(); T_e_tx [e.getIndex()] = 1000 * averagePacketLength_bits.getDouble() / (e.getCapacity() * linkCapacityUnits_bps.getDouble()); T_e_buf [e.getIndex()] = 1000 * averagePacketLength_bits.getDouble() / (e.getCapacity() * linkCapacityUnits_bps.getDouble()) * Math.pow(rho_e, 1/(2*(1-hurstParameter.getDouble()))) / Math.pow(1-rho_e , hurstParameter.getDouble()/(1 - hurstParameter.getDouble())); T_e [e.getIndex()] = T_e_prop [e.getIndex()] + T_e_tx [e.getIndex()] + T_e_buf [e.getIndex()]; for (Link e : r.getSeqLinks()) T_r_prop [r.getIndex()] += T_e_prop [e.getIndex()]; T_r_tx [r.getIndex()] += T_e_tx [e.getIndex()]; T_r_buf [r.getIndex()] += T_e_buf [e.getIndex()]; T_r [r.getIndex()] += T_e [e.getIndex()]; for (Link e : netPlan.getLinks()) final int linkId = e.getIndex(); out.append(String.format("<tr><td>%d</td><td>%d (%s)</td><td>%d (%s)</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%s</td></tr>", e.getIndex(), e.getOriginNode().getIndex() , e.getOriginNode().getName(), e.getDestinationNode().getIndex(),e.getDestinationNode().getName(), T_e_prop[linkId], T_e_tx[linkId], T_e_buf[linkId], T_e[linkId], e.getAttributes()));
double currentDistanceFromRouteInit_km = 0; res.add(Triple.of(currentDistanceFromRouteInit_km, "OADM-ADD", (double) seqLinks.get(0).getOriginNode().getId())); for (Link e : seqLinks) final double d_e = e.getLengthInKm(); final String st_edfaPositions_km = e.getAttribute("edfaPositions_km") == null ? "" : e.getAttribute("edfaPositions_km"); final String st_edfaGains_dB = e.getAttribute("edfaGains_dB") == null ? "" : e.getAttribute("edfaGains_dB"); final String st_dcmPositions_km = e.getAttribute("dcmPositions_km") == null ? "" : e.getAttribute("dcmPositions_km"); final String st_dcmCDCompensation_ps_per_nm = e.getAttribute("dcmCDCompensation_ps_per_nm") == null ? "" : e.getAttribute("dcmCDCompensation_ps_per_nm"); final double[] edfaPositions_km = StringUtils.toDoubleArray(StringUtils.split(st_edfaPositions_km)); final double[] edfaGains_dB = StringUtils.toDoubleArray(StringUtils.split(st_edfaGains_dB)); final long endNodeLink = e.getDestinationNode().getId(); final long lastLink = seqLinks.get(seqLinks.size() - 1).getId(); if (e.getId() == lastLink) res.add(Triple.of(currentDistanceFromRouteInit_km, "OADM-DROP", (double) endNodeLink)); else sumLinks += e.getLengthInKm();
static void drawDownPropagationInterLayerLinks(VisualizationState vs, SortedSet<Link> links, Paint color) { for (Link link : links) { final GUILink gl = vs.getCanvasAssociatedGUILink(link); if (gl == null) continue; if (!link.isCoupled()) continue; final boolean isCoupledToDemand = link.getCoupledDemand() != null; final NetworkLayer upperLayer = link.getLayer(); final NetworkLayer lowerLayer = isCoupledToDemand ? link.getCoupledDemand().getLayer() : link.getCoupledMulticastDemand().getLayer(); if (!vs.isLayerVisibleInCanvas(lowerLayer)) continue; for (GUILink interLayerLink : vs.getCanvasIntraNodeGUILinkSequence(link.getOriginNode(), upperLayer, lowerLayer)) { setCurrentDefaultEdgeStroke(vs, interLayerLink, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED); interLayerLink.setEdgeDrawPaint(color); interLayerLink.setShownSeparated(false); interLayerLink.setHasArrow(true); } for (GUILink interLayerLink : vs.getCanvasIntraNodeGUILinkSequence(link.getDestinationNode(), lowerLayer, upperLayer)) { setCurrentDefaultEdgeStroke(vs, interLayerLink, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED); interLayerLink.setEdgeDrawPaint(color); interLayerLink.setShownSeparated(false); interLayerLink.setHasArrow(true); } } }
e.setCapacity(Math.log(sinr_e)); e.setAttribute("p_e" , "" + p_e_array.get(e.getIndex ())); e.setAttribute("pi_e" , "" + Math.abs (pi_e_array.get(e.getIndex ()))); final double p_e = Double.parseDouble(e.getAttribute("p_e")); if (p_e < mac_minTransmissionPower_logu.getDouble() - 1E-3) throw new RuntimeException ("Bad"); if (p_e > mac_maxTransmissionPower_logu.getDouble() + 1E-3) throw new RuntimeException ("Bad"); if (e.getCapacity() < e.getCarriedTraffic() - PRECISIONFACTOR) throw new RuntimeException ("Bad"); if (Math.abs(mac_maxTransmissionPower_logu.getDouble() - Double.parseDouble(e.getAttribute("p_e"))) > 1E-3) allMaxPower = false;
private void drawLink(Graphics2D g2d) { final FontMetrics fontMetrics = g2d.getFontMetrics(); final int regularInterlineSpacePixels = fontMetrics.getHeight(); final Link link = forwardingRule.getSecond(); final Node linkOrigin = link.getOriginNode(); final Node linkDestination = link.getDestinationNode(); final DrawNode originNode = new DrawNode(linkOrigin, link.getLayer(), maxIconSize); final DrawNode destinationNode = new DrawNode(linkDestination, link.getLayer(), maxIconSize); textRow = addIconJump(iconRow); textRow = addLineJump(textRow); textRow = addLineJump(textRow); iconRow = addLineJump(textRow); int topCoordinateLineNodes = maxIconSize + (generalMessage.size() * regularInterlineSpacePixels) + (maxNumberOfTagsPerNodeNorResource * regularInterlineSpacePixels) * iconRow; Point initialDnTopLeftPosition = new Point(maxIconSize, topCoordinateLineNodes); int xSeparationDnCenters = maxIconSize * 3; g2d.setFont(headerFont); g2d.drawString("Link " + link.getIndex(), maxIconSize, maxIconSize + (regularInterlineSpacePixels * (textRow))); g2d.setFont(plainFont); DrawNode.addNodeToGraphics(g2d, originNode, initialDnTopLeftPosition, fontMetrics, regularInterlineSpacePixels, null); final Dimension windowDimension = DrawNode.addNodeToGraphics(g2d, destinationNode, new Point(initialDnTopLeftPosition.x + xSeparationDnCenters, initialDnTopLeftPosition.y), fontMetrics, regularInterlineSpacePixels, null); drawnNodes.add(originNode); drawnNodes.add(destinationNode); final DrawLine linkDL = new DrawLine(originNode, destinationNode, link, originNode.posEast(), destinationNode.posWest(), link.getOccupiedCapacity()); DrawLine.addLineToGraphics(g2d, linkDL, fontMetrics, regularInterlineSpacePixels); drawnLines.add(linkDL); preferredSize = new Dimension(windowDimension.width + XYMARGIN, windowDimension.height + XYMARGIN); }
private Triple<Boolean,Integer,Double> computeValidWAFirstFit_path (List<Link> seqLinks , int numContiguousSlots , double maxOpticalReachKm) { if (seqLinks.isEmpty()) throw new RuntimeException ("Bad"); if (seqLinks.get(0).getOriginNode().isDown()) return Triple.of(false,-1,-1.0); if (getLengthInKm(seqLinks) > maxOpticalReachKm) return Triple.of(false,-1,-1.0); double worseCaseSpareCapacity = Double.MAX_VALUE; for (Link e : seqLinks) { worseCaseSpareCapacity = Math.min(worseCaseSpareCapacity, e.getCapacity() - e.getOccupiedCapacity()); if (e.getDestinationNode().isDown() || e.isDown()) return Triple.of(false,-1,-1.0); } int wavelength = WDMUtils.spectrumAssignment_firstFit(seqLinks, wavelengthFiberOccupancy , numContiguousSlots); if (wavelength != -1) return Triple.of(true , wavelength , worseCaseSpareCapacity); else return Triple.of(false,-1,-1.0); }
private List<Triple<String,String,String>> getSRGInfoTables (SharedRiskGroup srg) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = srg.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); res.add(Triple.of("SRG index/id" , "SRG " + srg.getIndex() + " (id " + srg.getId() + ")", "srg" + srg.getId())); res.add(Triple.of("Mean Time To Fail (MTTF)" , df.format(srg.getMeanTimeToFailInHours() / 24) + " days", "")); res.add(Triple.of("Mean Time To Repair (MTTR)" , df.format(srg.getMeanTimeToRepairInHours() / 24) + " days", "")); res.add(Triple.of("Availability" , String.format("%.6f" , srg.getAvailability()) + " days", "")); res.add(Triple.of("#Nodes" , "" + srg.getNodes() , "")); for (Node n : srg.getNodes()) res.add(Triple.of(getNodeName(n) , "" , "node" + n.getId())); res.add(Triple.of("#Links" , "" + srg.getNodes() , "")); for (NetworkLayer layer : np.getNetworkLayers()) { final Set<Link> linksThisLayer = srg.getLinks(layer); if (linksThisLayer.isEmpty()) continue; for (Link link : linksThisLayer) res.add(Triple.of("Link " + getNodeName(link.getOriginNode()) + " -> " + getNodeName(link.getDestinationNode()) , "Link " + link.getIndex() +" (id " + link.getId() + ")" , "link" + link.getId())); } return res; } private List<Triple<String,String,String>> getLinkInfoTables (Link e)
void saveNetPlan (NetPlan netPlan , DoubleMatrix2D x_te , DoubleMatrix1D n_e) { /* Set the routing at the IP layer */ netPlan.setRoutingTypeAllDemands(RoutingType.HOP_BY_HOP_ROUTING); netPlan.removeAllForwardingRules(); netPlan.setRoutingFromDestinationLinkCarriedTraffic(x_te , true); for (Link e : netPlan.getLinks()) e.setCapacity(moduleCapacity.getDouble() * n_e.get(e.getIndex ())); for (Demand d : netPlan.getDemandsBlocked()) if (d.getBlockedTraffic() > PRECISIONFACTOR) throw new RuntimeException ("Bad"); for (Link e : netPlan.getLinksOversubscribed()) if (e.getOccupiedCapacity() - e.getCapacity() > PRECISIONFACTOR) throw new RuntimeException ("Bad"); }