/** * Returns a matrix indicating the SRGs going down (columns) on each failure state (rows). * * @param srgs SRGs * @param considerNoFailureState Flag to indicate whether or not no failure state is included * @param considerDoubleFailureStates Flag to indicate whether or not double failure states are included * @return Matrix of SRGs going down on each failure state */ public static DoubleMatrix2D getMatrixFailureState2SRG (Collection<SharedRiskGroup> srgs, boolean considerNoFailureState, boolean considerDoubleFailureStates) { List<SortedSet<SharedRiskGroup>> F_s = SRGUtils.enumerateFailureStates(srgs, considerNoFailureState, considerDoubleFailureStates); final int F = F_s.size (); final int S = srgs.size (); DoubleMatrix2D A_fs = DoubleFactory2D.sparse.make (F,S); int f = 0; for (SortedSet<SharedRiskGroup> failingSRGs : F_s) { for (SharedRiskGroup srg : failingSRGs) A_fs.set (f , srg.getIndex () , 1.0); f ++; } return A_fs; }
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 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)
res.add(Triple.of("# Affecting SRGs", "" + affectingSRGs.size() , "")); for (SharedRiskGroup srg : affectingSRGs) res.add(Triple.of("- Sh. risk group index/id" , "" + srg.getIndex() + " (id " + srg.getId() + ")" , "srg" + srg.getId())); return res;
st.append("Elements in all layers affected by failure in SRG " + e.getIndex());
for (SharedRiskGroup srg : auxNetPlan.getSRGs()) if (F_s.get(failureState , srg.getIndex ()) != 1) continue; nodesToSetAsDown.addAll (srg.getNodes ()); linksToSetAsDown.addAll (srg.getLinksAllLayers ());
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();
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"); } } } } }
this.A_rs = DoubleFactory2D.dense.make(R , 1 + nSRGs , 1.0); // 1 if link OK, 0 if fails for (Route r : netPlan.getRoutes ()) for (Link e : r.getSeqLinks()) for (SharedRiskGroup srg : e.getSRGs()) A_rs.set(r.getIndex (),1+srg.getIndex () , 0.0);
final FigureSRGSequencePanel fig = new FigureSRGSequencePanel(callback, srg, "Shared risk group " + srg.getIndex()); this.add(fig , BorderLayout.WEST); this.add(createPanelInfo(getSRGInfoTables(srg), srg) , BorderLayout.CENTER);
op.setInputParameter("A_nd", netPlan.getMatrixNodeDemandIncidence()); op.setInputParameter("A_es", netPlan.getMatrixLink2SRGAssignment()); DoubleMatrixND A_des = new DoubleMatrixND (new int []{D,E,S} , "sparse"); for (SharedRiskGroup srg : netPlan.getSRGs()) for (Link e : srg.getAffectedLinksAllLayers()) for (int d = 0; d < D ; d ++) A_des.set(new int [] {d,e.getIndex (),srg.getIndex()} , 1.0); DoubleMatrixND A_nds = new DoubleMatrixND (new int []{N,D,S} , "sparse"); for (Demand d : netPlan.getDemands()) for (int s = 0; s < S ; s ++) { A_nds.set(new int [] {d.getIngressNode().getIndex(),d.getIndex(),s}, 1.0); A_nds.set(new int [] {d.getEgressNode().getIndex(),d.getIndex(),s}, -1.0); } op.setInputParameter("A_des", A_des);