/** Indicates if this is a main lightpath that has a backup lightpath in the same lightpath request * @return see above */ public boolean isMainLightpathWithBackupRoutes () { return r.hasBackupRoutes(); }
/** * <p>Returns the routes associated to this demand, but only those that have no backup route themselves.</p> * <p><b>Important</b>: If network layer routing type is not {@link com.net2plan.utils.Constants.RoutingType#SOURCE_ROUTING SOURCE_ROUTING}, an exception is thrown.</p> * @return The set of routes * */ public SortedSet<Route> getRoutesHaveNoBackup () { return getRoutes ().stream().filter(e -> !e.hasBackupRoutes()).collect(Collectors.toCollection(TreeSet::new)); }
/** * <p>Returns the routes associated to this demand, but only those that are have themselves a backup route.</p> * <p><b>Important</b>: If network layer routing type is not {@link com.net2plan.utils.Constants.RoutingType#SOURCE_ROUTING SOURCE_ROUTING}, an exception is thrown.</p> * @return The set of routes * */ public SortedSet<Route> getRoutesHaveBackup () { return getRoutes ().stream().filter(e -> e.hasBackupRoutes()).collect(Collectors.toCollection(TreeSet::new)); }
/** * <p>Returns a vector with one element per route, containing the length in km of the first defined backup path for such route. * If a route has no backup path defined, an exception is thrown. If no layer is provided, the defaulf layer is assumed.</p> * * @param optionalLayerParameter network layer (optional) * @return The vector */ public DoubleMatrix1D getVectorRouteFirstBackupRouteLengthInKm(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix1D res = DoubleFactory1D.dense.make(layer.routes.size()); for (Route r : layer.routes) { if (!r.hasBackupRoutes()) throw new Net2PlanException("A route has no backup path"); final List<Link> path = r.getBackupRoutes().get(0).getSeqLinks(); final double length = path.stream().mapToDouble(e -> e.getLengthInKm()).sum(); res.set(r.index, length); } return res; }
/** * <p>Returns a vector with one element per route, containing the number of links of the first defined backup path for such route. * If a route has no backup path defined, an exception is thrown. If no layer is provided, the defaulf layer is assumed.</p> * * @param optionalLayerParameter network layer (optional) * @return The vector */ public DoubleMatrix1D getVectorRouteFirstBackupRouteNumberOfLinks(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix1D res = DoubleFactory1D.dense.make(layer.routes.size()); for (Route r : layer.routes) { if (!r.hasBackupRoutes()) throw new Net2PlanException("A route has no backup path"); final List<Link> path = r.getBackupRoutes().get(0).getSeqLinks(); res.set(r.index, path.size()); } return res; }
String numBackupPaths = route.hasBackupRoutes() ? "none" : "" + route.backupRoutes.size(); String routeInformation = String.format("r%d (id %d), demand: d%d (id %d), carried traffic: %.3g, occupied capacity: %.3g, seq. links: %s, seq. nodes: %s, number of backup paths: %s, attributes: %s", route.index, route.id, route.demand.index, route.demand.id, route.getCarriedTraffic(), route.getOccupiedCapacity(), str_seqLinks, str_seqNodes, numBackupPaths, route.attributes.isEmpty() ? "none" : route.attributes); netPlanInformation.append(routeInformation);
/** * Returns a matrix with as many rows as links and as many columns as routes in the given layer, * the position (e,r) contains the number of times that the first backup path of route r traveres link e * * @param optionalLayerParameter Network layer (optional) * @return The matrix */ public DoubleMatrix2D getMatrixLink2RouteFirstBackupRouteAssignment(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix2D delta_er = DoubleFactory2D.sparse.make(layer.links.size(), layer.routes.size()); for (Route r : layer.routes) { if (!r.hasBackupRoutes()) throw new Net2PlanException("A route has no backup path"); final List<Link> path = r.getBackupRoutes().get(0).getSeqLinks(); for (Link e : path) delta_er.set(e.index, r.index, delta_er.get(e.index, r.index) + 1); } return delta_er; }
/** * <p>Adds an existing route backupRoute in the same demand, designating it as a backup of this route. * For this to happen, this route cannot have backup routes itself, or an exception is thrown.</p> * @param backupRoute the backup route */ public void addBackupRoute (Route backupRoute) { if (backupRoute == null) throw new Net2PlanException ("The passed element is NULL"); this.checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); if (!backupRoute.demand.equals(demand)) throw new Net2PlanException ("The backup route must be of the same demand as the primary"); if (backupRoute.hasBackupRoutes()) throw new Net2PlanException ("A backup route cannot have backup routes itself"); if (this.backupRoutes.contains(backupRoute)) throw new Net2PlanException ("The route is already a backup route"); this.backupRoutes.add (backupRoute); backupRoute.cache_routesIAmBackUp.add(this); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); }
/** * <p>Returns a matrix with as many rows as routes of the given layer, and as many * columns as SRGS. The position (r,s) is 1 if the first backup route defined for route r is affected by SRG s (fails if s fails), and * 0 otherwise. If no layer is provided, the default layer is assumed.</p> * * @param optionalLayerParameter Network layer (optional) * @return The matrix */ public DoubleMatrix2D getMatrixRouteFirstBackupRoute2SRGAffecting(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix2D A_rs = DoubleFactory2D.sparse.make(layer.routes.size(), srgs.size()); for (Route r : layer.routes) { if (!r.hasBackupRoutes()) throw new Net2PlanException("A route has no backup path"); final List<Link> path = r.getBackupRoutes().get(0).getSeqLinks(); for (SharedRiskGroup srg : r.ingressNode.getSRGs ()) A_rs.set(r.index, srg.index, 1.0); for (Link e : path) { for (SharedRiskGroup srg : e.destinationNode.getSRGs ()) A_rs.set(r.index, srg.index, 1.0); for (SharedRiskGroup srg : e.getSRGs ()) A_rs.set(r.index, srg.index, 1.0); } } return A_rs; }
private List<Triple<String,String,String>> getRouteInfoTables (Route r) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = r.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); res.add(Triple.of("Route index/id" , "Route " + r.getIndex() + " (id " + r.getId() + ")", "route" + r.getId())); res.add(Triple.of("Layer" , "" + getLayerName(r.getLayer()) , "layer" + r.getLayer().getId())); res.add(Triple.of("Route demand index/id" , "" + r.getDemand().getIndex() + " (id " + r.getDemand().getId() + ")" , "demand" + r.getDemand().getId())); res.add(Triple.of("Demand offered traffic" , "" + df.format(r.getDemand().getOfferedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()) , "")); res.add(Triple.of("Demand carried traffic" , "" + df.format(r.getDemand().getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()) , "")); res.add(Triple.of("Route carried traffic" , "" + df.format(r.getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()), "")); res.add(Triple.of("Is up?" , "" + np.isUp(r.getPath()), "")); res.add(Triple.of("Worst link utilization" , "" + df.format(r.getSeqLinks().stream().mapToDouble(e->e.getUtilization()).max().orElse(0)), "")); if (r.isServiceChain()) res.add(Triple.of("Worst resource utilization" , "" + df.format(r.getSeqResourcesTraversed().stream().mapToDouble(e->e.getUtilization()).max().orElse(0)), "")); res.add(Triple.of("Is service chain?" , "" + r.getDemand().isServiceChainRequest(), "")); res.add(Triple.of("Route length (km)" , "" + df.format(r.getLengthInKm()) + " km", "")); res.add(Triple.of("Route length (ms)" , "" + df.format(r.getPropagationDelayInMiliseconds()) + " ms", "")); res.add(Triple.of("Is backup route?" , "" + r.isBackupRoute(), "")); for (Route pr : r.getRoutesIAmBackup()) res.add(Triple.of("-- Primary route" , "Route " + pr.getIndex() , "route" + pr.getId())); res.add(Triple.of("Has backup routes?" , "" + r.hasBackupRoutes(), "")); for (Route br : r.getBackupRoutes()) res.add(Triple.of("-- Backup route" , "Route " + br.getIndex() , "route" + br.getId())); return res; } private List<Triple<String,String,String>> getMulticastTreeInfoTables (MulticastTree t)
/** * <p>Returns the fraction of the total carried traffic in the given layer that has at least one backup path defined. * If a layer is not defined, the defaul layer is used.</p> * @param netPlan Current network design * @param optionalLayerParameter Network layer (optional) * @return Traffic protection degree */ public static double getTrafficProtectionDegree(NetPlan netPlan, NetworkLayer ... optionalLayerParameter) { if (optionalLayerParameter.length >= 2) throw new Net2PlanException ("None or one layer parameter can be supplied"); NetworkLayer layer = (optionalLayerParameter.length == 1)? optionalLayerParameter [0] : netPlan.getNetworkLayerDefault(); layer.checkAttachedToNetPlanObject(netPlan); double totalCarriedTraffic = 0; double totalCarriedAndProtectedTraffic = 0; for (Route route : netPlan.getRoutes(layer)) { totalCarriedTraffic += route.getCarriedTraffic(); if (route.hasBackupRoutes()) totalCarriedAndProtectedTraffic += route.getCarriedTraffic(); } return totalCarriedTraffic == 0? 0 : totalCarriedAndProtectedTraffic / totalCarriedTraffic; } }
if (r.hasBackupRoutes()) r.getBackupRoutes().get(0).setCarriedTraffic(0, null); // primary to up => carried in backup to zero this.stat_numAttemptedToRecoverConnections ++; this.stat_trafficAttemptedToRecoverConnections += r.getCarriedTrafficInNoFailureState(); if (r.hasBackupRoutes())
Set<SharedRiskGroup> affectingSRGs = currentRoute.hasBackupRoutes()? currentRoute.getBackupRoutes().get(0).getSRGs() : new HashSet<> (); for (SharedRiskGroup srg : affectingSRGs) if (affectingSRGs_primaryOrBackup.contains(srg)) numOverlappingSRGs ++;
this.stat_trafficAttemptedToRecoverConnections += r.getCarriedTrafficInNoFailureState(); if (r.hasBackupRoutes())