@Override public void setValueAt(Object aValue, int row, int column) { if (column == 3) { boolean value = (boolean) aValue; Link link = netPlan.getLinkFromId((long) getValueAt(row, 0)); if (value && !srg.getLinksAllLayers().contains(link)) { srg.addLink(link); callback.putTransientColorInElementTopologyCanvas(srg.getNodes(), Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(srg.getLinksAllLayers(), Color.ORANGE); } else if (!value && srg.getLinksAllLayers().contains(link)) { srg.removeLink(link); callback.putTransientColorInElementTopologyCanvas(srg.getNodes(), Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(srg.getLinksAllLayers(), Color.ORANGE); } } super.setValueAt(aValue, row, column); } };
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)
@Override public void setValueAt(Object aValue, int row, int column) { if (column == 2) { boolean value = (boolean) aValue; Node node = netPlan.getNodeFromId((long) getValueAt(row, 0)); if (value && !srg.getNodes().contains(node)) { netPlan.getSRGFromId(srgId).addNode(node); callback.putTransientColorInElementTopologyCanvas(srg.getNodes(), Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(srg.getLinksAllLayers(), Color.ORANGE); } else if (!value && srg.getNodes().contains(node)) { netPlan.getSRGFromId(srgId).removeNode(node); callback.putTransientColorInElementTopologyCanvas(srg.getNodes(), Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(srg.getLinksAllLayers(), Color.ORANGE); } } super.setValueAt(aValue, row, column); } };
/** * <p>Sets nodes and links associated to the SRG as down (in case they are not yet). The network state is updated with the affected routes, * segments, trees and hop-by-hop routing associated to the new nodes/links down </p> */ public void setAsDown () { checkAttachedToNetPlanObject(); netPlan.setLinksAndNodesFailureState (null , getLinksAllLayers() , null , getNodes ()); }
public boolean isDynamicCurrentlyEmptySrg () { return isDynamicSrg() && this.getLinksAllLayers().isEmpty() && this.getNodes().isEmpty(); }
/** * <p>Returns the set of multicast trees affected by the SRG (fail, when the SRG is in failure state). </p> * @return The set of failing multicast trees */ public SortedSet<MulticastTree> getAffectedMulticastTreesAllLayers () { SortedSet<MulticastTree> res = new TreeSet<MulticastTree> (); for (Link e : getLinksAllLayers()) res.addAll (e.cache_traversingTrees); for (Node n : getNodes()) res.addAll (n.cache_nodeAssociatedulticastTrees); return res; }
SharedRiskGroup thisSrg = this.getSRGFromId(other.getId()); if (thisSrg == null) thisSrg = this.addSRG(other.getMeanTimeToFailInHours(), other.getMeanTimeToRepairInHours(), null); else if (thisSrg.isDynamicSrg()) continue; // dynamic SRGs are not merged final SortedSet<Node> thisNodes = other.getNodes().stream().map(x->(Node) thatToThisTranslation.get(x)).collect(Collectors.toCollection(TreeSet::new)); final SortedSet<Link> thisLinks = other.getLinksAllLayers().stream().map(x->(Link) thatToThisTranslation.get(x)).collect(Collectors.toCollection(TreeSet::new)); for (Node n : thisNodes) thisSrg.addNode(n); for (Link e : thisLinks) thisSrg.addLink(e); thisSrg.setAttributeMap(other.getAttributes()); // previous attributes are not removed, just new added or existing updated for (String tag : other.getTags()) thisSrg.addTag(tag);
@Override public List<AjtColumnInfo<SharedRiskGroup>> getNonBasicUserDefinedColumnsVisibleOrNot() { final NetPlan np = callback.getDesign(); final NetworkLayer layer = this.getTableNetworkLayer(); final List<AjtColumnInfo<SharedRiskGroup>> res = new LinkedList<> (); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Collection.class, null , "Nodes", "The nodes belonging to this SRG", null , d->d.getNodes() , AGTYPE.SUMCOLLECTIONCOUNT , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Collection.class, null , "Links", "The links in this layer belonging to this SRG", null , d->d.getLinks(layer) , AGTYPE.SUMCOLLECTIONCOUNT , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Collection.class, null , "Links all layers", "The links in this layer or other layers belonging to this SRG", null , d->d.getLinksAllLayers() , AGTYPE.SUMCOLLECTIONCOUNT , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Double.class, null , "MTTF (hours)" , "The average Mean-Time-To-Fail value measued in hours (the time since the element is repaired until it fails again)", (d,val)->d.setMeanTimeToFailInHours((Double) val), d->d.getMeanTimeToFailInHours() , AGTYPE.MAXDOUBLE , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Double.class, null , "MTTR (hours)" , "The average Mean-Time-To-Repair value measued in hours (the time betweem the element fails, and is up again since it is repaired)", (d,val)->d.setMeanTimeToRepairInHours((Double) val), d->d.getMeanTimeToRepairInHours() , AGTYPE.MAXDOUBLE , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Double.class, null , "Availability" , "The probability of findig the element not failed (MTTF / (MTTF + MTTR)) ", (d,val)->d.setMeanTimeToRepairInHours((Double) val), d->d.getMeanTimeToRepairInHours() , AGTYPE.MAXDOUBLE , null)); res.add(new AjtColumnInfo<SharedRiskGroup>(this , Boolean.class, null , "Is dynamic SRG?" , "Indicates if the SRG is dnyamic (and then its belonging nodes and links may change)", null , d->d.isDynamicSrg() , AGTYPE.NOAGGREGATION , null)); return res; }
Set<Node> nodesUpToDown = new HashSet<Node> (currentNetPlan.getNodesUp()); nodesUpToDown.retainAll(srg.getNodes()); Set<Link> linksUpToDown = new HashSet<Link> (currentNetPlan.getLinksUpAllLayers()); linksUpToDown.retainAll(srg.getLinksAllLayers()); if (!nodesUpToDown.isEmpty() || !linksUpToDown.isEmpty()) scheduleEvent(new SimEvent(simTime + Exponential.staticNextDouble(1 / srg.getMeanTimeToRepairInHours()) , SimEvent.DestinationModule.EVENT_GENERATOR , -1 , new GenerateRepairSRG(srg))); for (SharedRiskGroup srgStillFailed : fail_currentlyFailedSRGs) nodesDownAfterRepair.addAll (srgStillFailed.getNodes()); linksDownAfterRepair.addAll (srgStillFailed.getLinksAllLayers()); scheduleEvent(new SimEvent(simTime + Exponential.staticNextDouble(1 / srg.getMeanTimeToFailInHours()) , SimEvent.DestinationModule.EVENT_GENERATOR , -1 , new GenerateFailureSRG(srg)));
SRGUtils.configureSRGs(netPlan, -1, defaultMTTR_hours, SRGUtils.SharedRiskModel.PER_BIDIRECTIONAL_LINK_BUNDLE, true, wdmLayer); for (SharedRiskGroup srg : netPlan.getSRGs()) { Link link = srg.getLinks(wdmLayer).iterator().next(); double mtbf_years = 1000.0 / (link.getLengthInKm() * 1.9); double mtbf_hours = 365 * 24 * mtbf_years; double mttf_hours = mtbf_hours - srg.getMeanTimeToRepairInHours(); if (mttf_hours < 0) throw new RuntimeException("Bad"); srg.setMeanTimeToFailInHours(mttf_hours); NetPlan netPlan_thisFailure = netPlan.copy(); final NetworkLayer ipLayer_thisFailure = netPlan_thisFailure.getNetworkLayer(ipLayer.getIndex()); final SharedRiskGroup thisNp_srg = netPlan_thisFailure.getSRG(srg.getIndex()); thisNp_srg.setAsDown();
writer.writeAttribute("description", srg.getDescription()); writer.writeAttribute("name", srg.getName()); writer.writeAttribute("meanTimeToFailInHours", Double.toString(srg.meanTimeToFailInHours)); writer.writeAttribute("meanTimeToRepairInHours", Double.toString(srg.meanTimeToRepairInHours)); writer.writeAttribute("isDynamic", Boolean.toString(srg.isDynamicSrg())); if (srg.isDynamicSrg()) writer.writeAttribute("dynamicSrgClassName", srg.getDynamicSrgImplementation().getClass().getName()); writer.writeAttribute("dynamicSrgConfigString", srg.getDynamicSrgImplementation().getInitializationString()); writer.writeAttribute("nodes", CollectionUtils.join(NetPlan.getIds(srg.getNodes()), " ")); writer.writeAttribute("links", CollectionUtils.join(NetPlan.getIds(srg.getLinksAllLayers()), " "));
long srgId = srg.getId(); callback.putTransientColorInElementTopologyCanvas(srg.getNodes(), Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(srg.getLinksAllLayers(), Color.ORANGE); nodeData[n][0] = node.getId(); nodeData[n][1] = node.getName(); nodeData[n][2] = srg.getNodes().contains(node); linkData[e][1] = link.getOriginNode().getId() + (link.getOriginNode().getName().isEmpty() ? "" : " (" + link.getOriginNode().getName() + ")"); linkData[e][2] = link.getDestinationNode().getId() + (link.getDestinationNode().getName().isEmpty() ? "" : " (" + link.getDestinationNode().getName() + ")"); linkData[e][3] = srg.getLinksAllLayers().contains(link);
String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key")); String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value")); newSRG.setAttribute(key, name); break; newSRG.addNode(mapOldId2Node.get(nodeId)); break; newSRG.addLink(mapOldId2Link.get(linkId)); break;
for (SharedRiskGroup srg : auxNetPlan.getSRGs()) if (F_s.get(failureState , srg.getIndex ()) != 1) continue; nodesToSetAsDown.addAll (srg.getNodes ()); linksToSetAsDown.addAll (srg.getLinksAllLayers ());
for (Node node : riskGroup.getNodes()) for (Link link : riskGroup.getLinksAllLayers()) final Set<Link> links = riskGroup.getLinks(layer);
private List<Triple<String,String,String>> getNodeInfoTables (Node n , NetworkLayer layer) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = n.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); res.add(Triple.of("Node index/id" , "Node " + n.getIndex() + " (id " + n.getId() + ")", "node" + n.getId())); res.add(Triple.of("Name" , n.getName().equals("")? "No name" : n.getName(), "")); res.add(Triple.of("Site", (n.getSiteName() != null) ? n.getSiteName() : "undefined","")); res.add(Triple.of("Coordinates (x,y)" , "(" + n.getXYPositionMap().getX() + "," + n.getXYPositionMap().getY() + ")" , "")); res.add(Triple.of("Is up?", "" + n.isUp() , "")); res.add(Triple.of("# Resources" , n.getResources().isEmpty() ? "none" : ""+n.getResources().size() , "")); for (Resource r : n.getResources()) res.add(Triple.of("- " + getResourceName(r) , "" , "resource" + r.getId())); res.add(Triple.of("Information at layer" , getLayerName(layer) , "")); res.add(Triple.of("# output links", "" + n.getOutgoingLinks(layer).size() , "")); res.add(Triple.of("# input links" , "" + n.getIncomingLinks(layer).size() , "")); res.add(Triple.of("Output traffic" , "" + df.format(n.getOutgoingLinks(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum()) + " " + trafUnits , "")); res.add(Triple.of("Input traffic" , df.format(n.getIncomingLinks(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum()) + " " + trafUnits , "")); res.add(Triple.of("# SRGs" , n.getSRGs().isEmpty() ? "none" : ""+n.getSRGs().size() , "")); for (SharedRiskGroup srg : n.getSRGs()) res.add(Triple.of("- Sh. risk group index/id" , "" + srg.getIndex() + " (id " + srg.getId() + ")" , "srg" + srg.getId())); return res; } private List<Triple<String,String,String>> getResourceInfoTables (Resource r)
private void parseSRG(NetPlan netPlan) throws XMLStreamException { final long srgId = getLong ("id"); if (srgId >= netPlan.nextElementId.toLong()) throw new Net2PlanException ("A network element has an id higher than the nextElementId"); final double meanTimeToFailInHours = getDouble ("meanTimeToFailInHours"); final double meanTimeToRepairInHours = getDouble ("meanTimeToRepairInHours"); boolean isDynamic = false; try { isDynamic = getBoolean("isDynamic"); } catch (Exception e) {} SharedRiskGroup newSRG = null; if (isDynamic) { final String className = getString("dynamicSrgClassName"); final String configString = getString("dynamicSrgConfigString"); newSRG = netPlan.addSRGDynamic(srgId , meanTimeToFailInHours, meanTimeToRepairInHours, className , configString , null); } else { newSRG = netPlan.addSRG(srgId , meanTimeToFailInHours, meanTimeToRepairInHours, null); SortedSet<Node> srgNodes = getNodeSetFromIds(netPlan, getListLong("nodes")); SortedSet<Link> srgLinks = getLinkSetFromIds(netPlan, getListLong("links")); for (Node n : srgNodes) newSRG.addNode(n); for (Link e : srgLinks) newSRG.addLink(e); } newSRG.setName(getStringOrDefault("name", "")); newSRG.setDescription(getStringOrDefault("description", "")); readAndAddAttributesToEndAndPdForNodes(newSRG, "srg"); }
private static void checkSolution(NetPlan netPlan, DoubleMatrix2D xx_de , DoubleMatrix3D xx_des) { if (!netPlan.getLinksOversubscribed().isEmpty()) throw new Net2PlanException("Bad - Some link is oversubscribed (constraint violated)"); if (!netPlan.getDemandsBlocked().isEmpty()) throw new Net2PlanException("Bad - Some demand is blocked (constraint violated)"); for (SharedRiskGroup srg : netPlan.getSRGs()) { NetPlan npThis = netPlan.copy (); npThis.removeAllUnicastRoutingInformation(); DoubleMatrix2D this_xxde = xx_des.viewColumn (srg.getIndex ()).copy (); for (Link e : srg.getAffectedLinksAllLayers()) if (this_xxde.viewColumn(e.getIndex ()).zSum () != 0) throw new Net2PlanException("Bad - some failing links carry traffic"); npThis.setRoutingFromDemandLinkCarriedTraffic(this_xxde , true , false , null); if (!npThis.getLinksOversubscribed().isEmpty()) throw new Net2PlanException("Bad - Some link is oversubscribed (constraint violated) in a failure"); if (!npThis.getDemandsBlocked().isEmpty()) throw new Net2PlanException("Bad - Some demand is blocked (constraint violated) in a failure"); for (Demand d : netPlan.getDemands ()) { IntArrayList es_noFailure = new IntArrayList (); xx_de.viewRow (d.getIndex ()).getNonZeros(es_noFailure , new DoubleArrayList ()); boolean affectedByThisFailure = false; for (Link e : srg.getAffectedLinksAllLayers()) if (xx_de.get(d.getIndex() , e.getIndex ()) != 0) { affectedByThisFailure = true; break; } if (!affectedByThisFailure) { IntArrayList es_thisFailure = new IntArrayList (); this_xxde.viewRow (d.getIndex ()).getNonZeros(es_thisFailure , new DoubleArrayList ()); if (!es_noFailure.equals(es_thisFailure)) throw new Net2PlanException("Routing cannot change when a demand is not affected by the failure"); } } } } }