/** Adds a backup lightpath to this lightpath * @param backup see above */ public void addBackupLightpath (WLightpathUnregenerated backup) { r.addBackupRoute(backup.getNe ()); }
@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)
public AdvancedJTable_route(GUINetworkDesign callback , NetworkLayer layerThisTable) { super(callback, AJTableType.ROUTES , layerThisTable , true , r->r.isDown() && r.getCarriedTrafficInNoFailureState() > 0? Color.RED : null); }
void copyFrom (Route origin) { if ((this.id != origin.id) || (this.index != origin.index)) throw new RuntimeException ("Bad"); if ((this.netPlan == null) || (origin.netPlan == null) || (this.netPlan == origin.netPlan)) throw new RuntimeException ("Bad"); this.currentCarriedTrafficIfNotFailing = origin.currentCarriedTrafficIfNotFailing; this.currentLinksAndResourcesOccupationIfNotFailing = new ArrayList<Double> (origin.currentLinksAndResourcesOccupationIfNotFailing); this.initialStateCarriedTrafficIfNotFailing = origin.initialStateCarriedTrafficIfNotFailing; this.initialStateOccupationIfNotFailing = new ArrayList<Double> (origin.initialStateOccupationIfNotFailing); this.currentPath = (List<NetworkElement>) getInThisNetPlan(origin.currentPath); try { this.initialStatePath = (List<NetworkElement>) getInThisNetPlan(origin.initialStatePath); } catch (Exception e) { this.initialStatePath = new ArrayList<> (currentPath); } this.backupRoutes = (List<Route>) getInThisNetPlan(origin.backupRoutes); this.cache_routesIAmBackUp = (SortedSet<Route>) getInThisNetPlan(origin.cache_routesIAmBackUp); this.cache_seqLinksRealPath = (List<Link>) getInThisNetPlan(origin.cache_seqLinksRealPath); this.cache_seqNodesRealPath = (List<Node>) getInThisNetPlan(origin.cache_seqNodesRealPath); this.cache_hasLoops = origin.cache_hasLoops; this.cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.clear(); this.bidirectionalPair = origin.bidirectionalPair == null? null : netPlan.getRouteFromId(origin.bidirectionalPair.getId()); for (Entry<NetworkElement,Double> e : origin.cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.entrySet()) this.cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.put(getInThisNetPlan (e.getKey()) , e.getValue()); }
private Map<Long,Double> netPlanRouteCarriedTrafficMap (NetPlan np) { Map<Long,Double> res = new HashMap<Long,Double> (); for (Route r : np.getRoutes ()) res.put (r.getId () , r.getCarriedTraffic()); return res; } private class PacketInfo
wdmLayerRoute.addBackupRoute(wdmLayerBackupRoute); WDMUtils.allocateResources(rwa.getSecond() , wavelengthFiberOccupancy , null); if (DEBUG) { checkWaveOccupEqualsNp(currentNetPlan); checkClashing (currentNetPlan); } checkDisjointness(wdmLayerRoute.getSeqLinks() , rwa.getSecond().seqLinks , protectionTypeCode); this.transponderTypeOfNewLps.put(wdmLayerRoute , transponderTypeUsed); this.stat_numCarriedConnections ++; final Route lpToRemove = lpEvent.lp; WDMUtils.releaseResources(new WDMUtils.RSA(lpToRemove , false) , wavelengthFiberOccupancy, null); for (Route backupLp : new ArrayList<> (lpToRemove.getBackupRoutes())) backupLp.remove(); this.transponderTypeOfNewLps.remove(backupLp); lpToRemove.remove (); this.transponderTypeOfNewLps.remove(lpToRemove); if (DEBUG) { checkWaveOccupEqualsNp(currentNetPlan); checkClashing (currentNetPlan); } final Demand wdmDemand = r.getDemand(); 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 Demand wdmDemand = r.getDemand(); final Demand.IntendedRecoveryType recovType = wdmDemand.getIntendedRecoveryType() == Demand.IntendedRecoveryType.NOTSPECIFIED? defaultRecoveryType : wdmDemand.getIntendedRecoveryType(); if (r.isBackupRoute()) continue; this.stat_numAttemptedToRecoverConnections ++;
out.append("<tr><th align=\"left\" colspan=\"2\"><b>Format errors</b></th></tr>"); for (Link e : netPlan.getLinks()) if (!WDMUtils.isWDMFormatCorrect(e)) { correctFormat = false ; out.append("<tr><td>Fiber " + e.getIndex() + ": incorrect format</td></tr>"); } for (Route r : netPlan.getRoutes(wdmLayer)) if (!WDMUtils.isWDMFormatCorrect(r)) { correctFormat = false ; out.append("<tr><td>Route " + r.getIndex() + ": incorrect format. Is backup route: " + r.isBackupRoute() + "</td></tr>"); } if (correctFormat) out.append("<tr><td bgcolor=\"PaleGreen\">No format errors!!!</td></tr>"); out.append("</table>"); final int numLpsBackup = (int) lps.stream().filter(ee -> ee.isBackupRoute()).count(); final int numLpsPrimary = lps.size() - numLpsBackup; numSlotsUsedThisFiber += numLpsPrimary + numLpsBackup > 0? 1 : 0; else { color = "red"; everythingOk = false; } thisLine.append("<td bgcolor=\"" + color + "\">"); if (lps != null) for (Route r : lps) thisLine.append("<a href=\"#lp" + r.getIndex() + "\">L" + r.getIndex() + " </a>"); thisLine.append("</td>"); out.append("<td><a name=\"lp" + r.getIndex() + "\">" + r.getIndex() + " (id: " + r.getId() + ")"+ "</a></td>"); out.append("<td>" + r.getDemand().getIndex() + "</td>"); out.append("<td>" + printNode(r.getIngressNode())+ "</td>"); out.append("<td>" + printNode(r.getEgressNode())+ "</td>"); out.append("<td>" + seqNodesString(r.getSeqLinks()) + "</td>"); out.append("<td>" + df_2.format(r.getLengthInKm()) + "</td>"); out.append("<td>" + df_2.format(r.getPropagationDelayInMiliseconds()) + "</td>"); out.append("<td>" + df_2.format(r.getCarriedTraffic()) + "</td>"); out.append("<td>" + rsa.getNumSlots() + "</td>"); out.append("<td>" + occupiedSlotsString(rsa) + "</td>"); out.append("</td>"); out.append("<td>"); for (Route backupRoute : r.getBackupRoutes())
addedRoute.addBackupRoute(addedBackupRoute); addRouteEvent.routeAddedToFillByProcessor = addedRoute; this.routeOriginalLinks.put (addedRoute , spLinks.getFirst()); 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); } else if (event.getEventObject () instanceof SimEvent.DemandModify) if (r.hasBackupRoutes()) r.getBackupRoutes().get(0).setCarriedTraffic(0, null); // primary to up => carried in backup to zero if (r.isBackupRoute()) continue; this.stat_numAttemptedToRecoverConnections ++; this.stat_trafficAttemptedToRecoverConnections += r.getCarriedTrafficInNoFailureState(); if (r.hasBackupRoutes()) final Route backupRoute = r.getBackupRoutes().get(0); backupRoute.setCarriedTraffic(r.getCarriedTrafficInNoFailureState(), null); if (!backupRoute.isDown()) this.stat_trafficSuccessfullyRecoveredConnections += r.getCarriedTrafficInNoFailureState(); this.stat_trafficAttemptedToRecoverConnections += r.getCarriedTrafficInNoFailureState(); List<Link> spLinks = computeValidPathNewRoute (r.getDemand() , r.getOccupiedCapacityInNoFailureState()); if (!spLinks.isEmpty()) r.setSeqLinks(spLinks);
for (Route r : netPlan.getRoutes()) double sumCa = 0; for (Link a : r.getSeqLinks()) sumCa += vector_Ca.get(a.getIndex()); vector_Ck.set(r.getIndex() , sumCa); out.append("<td>" + r.getIndex() + "</td>"); out.append("<td>" + r.getIngressNode().getName() + "</td>"); out.append("<td>" + r.getEgressNode().getName() + "</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>"); out.append("<td>" + df_6.format(worstUtilization) + "</td>");
final Node o = r.getIngressNode(); final Node d = r.getEgressNode(); final int oIndex = cand_o.get(o); final int dIndex = cand_d.get(d); if (r.getSeqLinks().size() > 1) final Node a = r.getSeqLinks().get(0).getDestinationNode(); final int aIndex = cand_a.get(a); A_ap.set(aIndex , r.getIndex() , 1.0); A_op.set(oIndex , r.getIndex() , 1.0); A_destp.set(dIndex , r.getIndex() , 1.0); final double [] h_dest = new double [NUM_D]; for (int cont = 0 ; cont < NUM_D ; cont ++) h_dest [cont] = Math.max(0, getDemandSize(cand_d.inverseBidiMap().get(cont) , 0.0)); final double [] minHDestAndMaxBlockedGoods_dest = new double [NUM_D]; for (int cont = 0 ; cont < NUM_D ; cont ++) minHDestAndMaxBlockedGoods_dest [cont] = Math.max(0, Math.min(h_dest [cont] , getMaxBlockedGoods(cand_d.inverseBidiMap().get(cont) , 0.0))); final double [] maxTraffic_p = new double [P]; for (int cont = 0 ; cont < P ; cont ++) maxTraffic_p [cont] = maxDistanceOriginToDestinationInKm.getDouble() > 0? (netPlan.getRoute(cont).getLengthInKm() > maxDistanceOriginToDestinationInKm.getDouble()? 0.0 : Double.MAX_VALUE ) : Double.MAX_VALUE; final int p = r.getIndex(); final double traf = x_p.get(p) < 1e-3? 0.0 : x_p.get(p); r.setCarriedTraffic(traf , traf); for (Route r : new ArrayList<> (netPlan.getRoutes())) if (r.getCarriedTraffic() <= 1e-3) r.remove(); for (Demand d : netPlan.getDemands()) d.setOfferedTraffic(d.getCarriedTraffic()); for (Demand d : new ArrayList<> (netPlan.getDemands())) if (maxDistanceOriginToDestinationInKm.getDouble() > 0) check (netPlan.getRoutes().stream().filter(r->r.getCarriedTraffic() > 0).allMatch(r->r.getLengthInKm() <= maxDistanceOriginToDestinationInKm.getDouble())); final double trafReceived = n.getIncomingRoutes().stream().mapToDouble(r->r.getCarriedTraffic()).sum(); final double maxBlockedTraffic = Math.max(0, getMaxBlockedGoods(n, 0.0));
for (Route other : otherDemand.getRoutes()) final Triple<Double,List<NetworkElement>,List<Double>> initialStateOther = other.getInitialState(); final List<NetworkElement> pathThisInitial = initialStateOther.getSecond().stream(). map(x->thatToThisTranslation.get(x)). collect(Collectors.toList()); final List<NetworkElement> pathThis = other.getPath().stream(). map(x->thatToThisTranslation.get(x)). collect(Collectors.toList()); r.setPath(other.getCarriedTrafficInNoFailureState(), pathThis, new ArrayList<>(other.getSeqOccupiedCapacitiesIfNotFailing())); this.addServiceChain(thisDemand, other.getCarriedTrafficInNoFailureState(), new ArrayList<>(other.getSeqOccupiedCapacitiesIfNotFailing()) , pathThis, null); r.setAttributeMap(other.getAttributes()); // previous attributes are not removed, just new added or existing updated for (String tag : other.getTags()) r.addTag(tag); thatToThisTranslation.put(other , r); for (Route mainOther : backupOther.getRoutesIAmBackup()) thisMain.addBackupRoute(thisBackup);
this.nSRGs = netPlan.getNumberOfSRGs(); this.routeList_d = new int [D][]; for (Demand d : netPlan.getDemands ()) routeList_d [d.getIndex ()] = getIndexes (d.getRoutes ()); this.traversedLinks_r = new int [R][]; for (Route r : netPlan.getRoutes ()) traversedLinks_r [r.getIndex ()] = getIndexes (r.getSeqLinks()); A_se.set(contSRG+1 , e.getIndex () , 0.0); 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); this.Ain_ne = netPlan.getMatrixNodeLinkIncomingIncidence(); this.Abid_dd = DoubleFactory2D.sparse.make(D,D); for (Entry<Demand,Demand> entry : opposite_d.entrySet()) { Abid_dd.set(entry.getKey().getIndex (), entry.getValue().getIndex (), 1.0); Abid_dd.set(entry.getValue().getIndex (), entry.getKey().getIndex (), 1.0); } this.Abid_rr = DoubleFactory2D.sparse.make(R,R); for (Entry<Route,Route> entry : opposite_r.entrySet()) { Abid_rr.set(entry.getKey().getIndex (), entry.getValue().getIndex (), 1.0); Abid_rr.set(entry.getValue().getIndex (), entry.getKey().getIndex (), 1.0); } this.Abid_ee = DoubleFactory2D.sparse.make(Efm,Efm); for (Link e : netPlan.getLinks ()) { Abid_ee.set(e.getIndex (), oppositeLink(e).getIndex (), 1.0); Abid_ee.set(oppositeLink(e).getIndex (), e.getIndex (), 1.0); } for (Route r : netPlan.getRoutes ()) r.setCarriedTraffic(tcfa_circuitCapacity_Gbps.getDouble () * best_xr.get(r.getIndex ()) , tcfa_circuitCapacity_Gbps.getDouble () * best_xr.get(r.getIndex ())); for (Link e : netPlan.getLinks ()) e.setCapacity(tcfa_linkCapacity_numCirc.getInt () * tcfa_circuitCapacity_Gbps.getDouble () * best_pe.get(e.getIndex())); } else if (tcfa_recoveryType.getString ().equals("1+1")) if (Math.abs(best_x2r.viewSelection(routeList_d [d.getIndex ()]).zSum() - 1) > 1E-3) throw new RuntimeException ("Bad"); Route primaryRoute = null; Route backupRoute = null; for (Route r : d.getRoutes ()) if (Math.abs(best_xr.get(r.getIndex ()) - 1) <= 1e-3) { primaryRoute = r; primaryRoute.setCarriedTraffic(tcfa_circuitCapacity_Gbps.getDouble () , tcfa_circuitCapacity_Gbps.getDouble ()); break; } for (Route r : d.getRoutes ()) if (Math.abs(best_x2r.get(r.getIndex ()) - 1) <= 1e-3) { backupRoute = r; backupRoute.setCarriedTraffic(0 , tcfa_circuitCapacity_Gbps.getDouble ()); break; } primaryRoute.addBackupRoute(backupRoute); for (Route r : netPlan.getRoutes ()) r.setCarriedTraffic(tcfa_circuitCapacity_Gbps.getDouble () * best_xrs.get(r.getIndex (),0) , tcfa_circuitCapacity_Gbps.getDouble () * best_xrs.get(r.getIndex (),0)); for (Link e : netPlan.getLinks ()) e.setCapacity(tcfa_linkCapacity_numCirc.getInt () * tcfa_circuitCapacity_Gbps.getDouble () * best_pe.get(e.getIndex())); } else throw new RuntimeException ("Bad"); for (Route r : new HashSet<Route>(netPlan.getRoutes())) if (!r.isBackupRoute() && r.getCarriedTraffic() == 0) r.remove();
if (route.isBackupRoute()) throw new Net2PlanException("A backup route cannot have backup routes itself."); long routeId = route.getId(); Set<Route> candidateBackupRoutes = route.getDemand().getRoutesAreNotBackup(); List<Route> currentBackupRoutes = route.getBackupRoutes(); final List<NetworkElement> seqLinksAndResources = route.getPath(); long backupRouteId = (Long) ((StringLabeller) selectedItem).getObject(); Route backupRoute = netPlan.getRouteFromId(backupRouteId); route.addBackupRoute(backupRoute); callback.getPickManager().reset(); callback.updateVisualizationAfterChanges(); List<NetworkElement> backupRoutePath = netPlan.getRouteFromId(backupRouteId).getPath(); callback.putTransientColorInElementTopologyCanvas(seqLinksAndResources, Color.ORANGE); callback.putTransientColorInElementTopologyCanvas(backupRoutePath, Color.ORANGE); String segmentLabel = "Backup route id " + backupRoute.getId() + ": path = " + getSequenceLinkResourceIndexes(backupRoute) + ", seq. nodes = " + getSequenceNodeIndexesWithResourceInfo(backupRoute) + ", occupied capacity = " + getSequenceOccupiedCapacities(backupRoute); backupRouteSelector.addItem(StringLabeller.of(backupRoute.getId(), segmentLabel)); model.addRow(new Object[]{backupRoute.getId(), getSequenceLinkResourceIndexes(backupRoute), getSequenceNodeIndexesWithResourceInfo(backupRoute), getSequenceOccupiedCapacities(backupRoute), "Remove", "View"});
/** Creates a RSA object reading the information from the existing Route object (and its WDM-related attributes). * @param r the route object * @param initializeWithTheInitialState if {@code true}, the RSA object created gets the information from the route primary path: sequence of links, and if not, from the route current sequence of traversed links. */ public RSA (Route r , boolean initializeWithTheInitialState) { this.ingressNode = r.getIngressNode(); this.egressNode = r.getEgressNode(); this.seqLinks = initializeWithTheInitialState ? new ArrayList<>(Route.getSeqLinks(r.getInitialState().getSecond())) : new ArrayList<> (r.getSeqLinks()); try { if (!isNonNegativeInteger(r.getOccupiedCapacity())) throw new WDMException (""); if (!isNonNegativeInteger(r.getOccupiedCapacityInNoFailureState())) throw new WDMException (""); final IntMatrix2D candidateSeqFreqSlots = StringUtils.readIntMatrix (r.getAttribute(initializeWithTheInitialState? WDMUtils.SEQUENCE_OF_FREQUENCYSLOTS_INITIAL_ROUTE_ATTRIBUTE_NAME : WDMUtils.SEQUENCE_OF_FREQUENCYSLOTS_ATTRIBUTE_NAME)); this.seqFrequencySlots_se = candidateSeqFreqSlots.rows() > 0? candidateSeqFreqSlots : IntFactory2D.dense.make(0,this.seqLinks.size()); final int[] candidateSeqRegenerators = r.getAttribute(initializeWithTheInitialState? WDMUtils.SEQUENCE_OF_REGENERATORS_INITIAL_ROUTE_ATTRIBUTE_NAME : WDMUtils.SEQUENCE_OF_REGENERATORS_ATTRIBUTE_NAME) == null? new int [seqLinks.size()] : StringUtils.toIntArray(StringUtils.split(initializeWithTheInitialState? r.getAttribute(SEQUENCE_OF_REGENERATORS_INITIAL_ROUTE_ATTRIBUTE_NAME): r.getAttribute(SEQUENCE_OF_REGENERATORS_ATTRIBUTE_NAME), " ")); this.seqRegeneratorsOccupancy_e = candidateSeqRegenerators.length == 0 ? new int[this.seqLinks.size()] : candidateSeqRegenerators; } catch (Exception e) { throw new WDMException("RSA not correctly defined"); } if (initializeWithTheInitialState && getNumSlots() != r.getInitialState().getThird().get(0)) throw new WDMException("The occupied link capacity is different to the number of slots"); if (!initializeWithTheInitialState && getNumSlots() != r.getOccupiedCapacityInNoFailureState()) throw new WDMException("The occupied link capacity is different to the number of slots"); checkValidity(); }
final boolean isRouteLayerVisibleInTheCanvas = vs.isLayerVisibleInCanvas(pickedRoute.getLayer()); if (vs.isShowInCanvasThisLayerPropagation() && isRouteLayerVisibleInTheCanvas) final List<Link> linksPrimary = pickedRoute.getSeqLinks(); DrawUtils.drawCollateralLinks(vs, linksPrimary, pickedRoute.isBackupRoute() ? VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_BACKUP : VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); final Pair<SortedSet<Demand>, SortedSet<Pair<MulticastDemand, Node>>> downInfo = DrawUtils.getDownCoupling(pickedRoute.getSeqLinks()); final InterLayerPropagationGraph ipg = new InterLayerPropagationGraph(downInfo.getFirst(), null, downInfo.getSecond(), false); DrawUtils.drawCollateralLinks(vs, ipg.getLinksInGraph(), pickedRoute.isBackupRoute() ? VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_BACKUP : VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); DrawUtils.drawDownPropagationInterLayerLinks(vs, ipg.getLinksInGraph(), pickedRoute.isBackupRoute() ? VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_BACKUP : VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); if (vs.isShowInCanvasUpperLayerPropagation() && (vs.getNetPlan().getNumberOfLayers() > 1) && pickedRoute.getDemand().isCoupled()) final InterLayerPropagationGraph ipg = new InterLayerPropagationGraph(null, new TreeSet<> (Arrays.asList(pickedRoute.getDemand().getCoupledLink())), null, true); DrawUtils.drawCollateralLinks(vs, ipg.getLinksInGraph(), VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); DrawUtils.drawDownPropagationInterLayerLinks(vs, ipg.getLinksInGraph(), VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); final GUINode gnOrigin = vs.getCanvasAssociatedGUINode(pickedRoute.getIngressNode(), pickedRoute.getLayer()); final GUINode gnDestination = vs.getCanvasAssociatedGUINode(pickedRoute.getEgressNode(), pickedRoute.getLayer()); gnOrigin.setBorderPaint(VisualizationConstants.DEFAULT_GUINODE_COLOR_ORIGINFLOW); gnOrigin.setFillPaint(VisualizationConstants.DEFAULT_GUINODE_COLOR_ORIGINFLOW);
/** * Obtains the average route length among the current routes according to * certain link cost metric. Route lengths are weighted by their carried traffic. * * @param routes List of routes * @param linkCostMap Cost metric per link * @return Average route length */ public static double getRouteAverageLength(List<Route> routes , DoubleMatrix1D linkCostMap) { double R_d = 0; double average = 0; for (Route r : routes) { R_d += r.getCarriedTraffic(); for (Link e : r.getSeqLinks()) average += r.getCarriedTraffic() * ((linkCostMap == null)? 1 : linkCostMap.get(e.getIndex())); } return R_d == 0? 0 : average / R_d; }
/** * <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; }
for (Route r : routes) control_routeIndexes_d [d.getIndex ()][counter_r ++] = r.getIndex (); r.setCarriedTraffic(h_d / routes.size() , h_d / routes.size()); control_previousXp.set(r.getIndex(), h_d / routes.size()); log.println("Initial route: " + r + " demand: " +d + ", h_d: " + h_d + ", h_r = " + r.getCarriedTraffic() + ", seqLinks: "+ r.getSeqLinks());
if (r.isDown()) continue; for (Link e : r.getSeqLinks()) if (r.isBackupRoute()) SortedSet<Link> linksSoFar = resBackup.get(r.getDemand()); if (linksSoFar == null) { linksSoFar = new TreeSet<> (); resBackup.put(r.getDemand(), linksSoFar); } linksSoFar.add(e); SortedSet<Link> linksSoFar = resPrimary.get(r.getDemand()); if (linksSoFar == null) { linksSoFar = new TreeSet<> (); resPrimary.put(r.getDemand(), linksSoFar); } linksSoFar.add(e);