private static void checkSolution(NetPlan netPlan, String type11) { 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 (Route route : netPlan.getRoutesAreNotBackup()) { if (route.getBackupRoutes().size () != 1) throw new RuntimeException("Bad"); final Route backupRoute = route.getBackupRoutes().get(0); if (type11.equalsIgnoreCase("srgDisjoint")) if (!Collections.disjoint(route.getSRGs(), backupRoute.getSRGs())) throw new RuntimeException("Bad"); else if (type11.equalsIgnoreCase("linkDisjoint")) if (!Collections.disjoint(route.getSeqLinks(), backupRoute.getSeqLinks())) throw new RuntimeException("Bad"); else throw new RuntimeException ("Bad"); } } }
/** * Checks if solution is valid. * * @param netPlan Network design * @param type11 Type of 1:1 protection * @since 1.1 */ private static void checkSolution(NetPlan netPlan, String type11) { 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 (Route route : netPlan.getRoutesAreNotBackup()) { if (route.getBackupRoutes().size () != 1) throw new RuntimeException("Bad"); final Route backupRoute = route.getBackupRoutes().get(0); if (type11.equalsIgnoreCase("srgDisjoint")) if (!Collections.disjoint(route.getSRGs(), backupRoute.getSRGs())) throw new RuntimeException("Bad"); else if (type11.equalsIgnoreCase("linkDisjoint")) if (!Collections.disjoint(route.getSeqLinks(), backupRoute.getSeqLinks())) throw new RuntimeException("Bad"); else throw new RuntimeException ("Bad"); } } }
/** * <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; }
/** * 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; }
if (r.getBackupRoutes().size() != 1) throw new RuntimeException ("Bad: " + r.getBackupRoutes().size()); final Route backupRoute = r.getBackupRoutes().get(0); List<Link> seqLinks = new ArrayList<Link> (r.getSeqLinks()); seqLinks.retainAll(backupRoute.getSeqLinks());
for (Route route : netPlan.getRoutes (layer)) Collection<List<Link>> backupPaths = route.getBackupRoutes().stream().map(e -> e.getSeqLinks()).collect(Collectors.toList()); if (backupPaths.isEmpty()) continue;
out.append("</td>"); out.append("<td>"); for (Route backupRoute : r.getBackupRoutes()) out.append("<a href=\"#lpProt" + backupRoute.getIndex() + "\">BU" + backupRoute.getIndex() + "</a> "); out.append("</td>");
/** * <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; }
@Override public List<AjtColumnInfo<Route>> getNonBasicUserDefinedColumnsVisibleOrNot() { final NetPlan np = callback.getDesign(); final NetworkLayer layer = this.getTableNetworkLayer(); final List<AjtColumnInfo<Route>> res = new LinkedList<> (); res.add(new AjtColumnInfo<Route>(this , Demand.class, null , "Demand", "Associated demand", null , d->d.getDemand() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Node.class, null , "A", "Ingress node", null , d->d.getIngressNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Node.class, null , "B", "Egress node", null , d->d.getEgressNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Boolean.class, null , "Is up?", "The route is considered up if it is not traversing failed links or nodes", null , d->!d.isDown() , AGTYPE.COUNTTRUE, r->r.getCarriedTrafficInNoFailureState() > 0 && r.isDown()? Color.RED : null)); res.add(new AjtColumnInfo<Route>(this , Boolean.class, null , "Trav. 0-cap links?", "Indicates if the route is traversing links with zero capacity", null , d->!d.isTraversingZeroCapLinks() , AGTYPE.COUNTTRUE, r->r.getCarriedTrafficInNoFailureState() > 0 && r.isTraversingZeroCapLinks()? Color.RED : null)); res.add(new AjtColumnInfo<Route>(this , Demand.class, null , "Bidirectional pair", "If the route is bidirectional, provides its bidirectional pair", null , d->d.getBidirectionalPair() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Route>(this , Collection.class, null , "Main routes", "If this is a backup route, shows the routes I am backing up", null , d->d.getRoutesIAmBackup(), AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Collection.class, null , "Backup routes", "If this is a main route, shows the its back up routes", null , d->d.getBackupRoutes(), AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Double.class, null , "Carried traffic (" + layer.getDemandTrafficUnits() + ")", "Carried traffic by the route", (d,val)->d.setCarriedTraffic((Double) val , null), d->d.getCarriedTraffic() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Route>(this , Double.class, null , "Occupied capacity (" + layer.getLinkCapacityUnits() + ")", "Occupied capacity in the traversed links. If the occupied capacity is different in different links, no information is shown", null , d->d.isOccupyingDifferentCapacitiesInDifferentLinksInNoFailureState()? "--" : d.getSeqOccupiedCapacitiesIfNotFailing().get(0) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Collection.class, null , "# links", "Number of traversed links", null , d->d.getSeqLinks() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Collection.class, null , "# resources", "Number of traversed resources", null , d->d.getSeqResourcesTraversed() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Route>(this , Double.class, null , "Length (km)", "Length of the route, considering also the length of the lower layer links traversed if any", null , d->d.getLengthInKm() , AGTYPE.MAXDOUBLE , null)); res.add(new AjtColumnInfo<Route>(this , Double.class, null , "E2e latency (ms)", "End-to-end latency considering links and resources traversed, and propagation time in lower layer links if any", null , d->d.getPropagationDelayInMiliseconds() , AGTYPE.MAXDOUBLE , d->{ final double m = d.getDemand().getMaximumAcceptableE2EWorstCaseLatencyInMs(); if (m >= 0) return null; return d.getPropagationDelayInMiliseconds () > m? Color.RED : null; })); return res; }
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)
Route routeToRemove = routeEvent.route; if (routeToRemove == null) throw new RuntimeException ("Bad"); for (Route backup : new ArrayList<> (routeToRemove.getBackupRoutes())) backup.remove (); routeToRemove.remove(); this.routeOriginalLinks.remove(routeToRemove); if (r.hasBackupRoutes()) r.getBackupRoutes().get(0).setCarriedTraffic(0, null); // primary to up => carried in backup to zero if (r.hasBackupRoutes()) final Route backupRoute = r.getBackupRoutes().get(0); backupRoute.setCarriedTraffic(r.getCarriedTrafficInNoFailureState(), null); if (!backupRoute.isDown())
List<Route> currentBackupRoutes = route.getBackupRoutes();
Set<SharedRiskGroup> affectingSRGs = currentRoute.hasBackupRoutes()? currentRoute.getBackupRoutes().get(0).getSRGs() : new HashSet<> (); for (SharedRiskGroup srg : affectingSRGs) if (affectingSRGs_primaryOrBackup.contains(srg)) numOverlappingSRGs ++;
final Route lpToRemove = lpEvent.lp; WDMUtils.releaseResources(new WDMUtils.RSA(lpToRemove , false) , wavelengthFiberOccupancy, null); for (Route backupLp : new ArrayList<> (lpToRemove.getBackupRoutes())) final Demand.IntendedRecoveryType recoveryType = wdmDemand.getIntendedRecoveryType() == Demand.IntendedRecoveryType.NOTSPECIFIED? defaultRecoveryType : wdmDemand.getIntendedRecoveryType(); if (recoveryType == Demand.IntendedRecoveryType.PROTECTION_REVERT) for (Route backup : r.getBackupRoutes()) backup.setCarriedTraffic(0, null); // primary to up => carried in backup to zero final Route backupRoute = r.getBackupRoutes().get(0); backupRoute.setCarriedTraffic(r.getCarriedTrafficInNoFailureState(), null); if (!backupRoute.isDown())