/** <p>Returns the link occupied capacity (in link capacity units). </p> * @return The occupied capacity as described above * */ public double getOccupiedCapacityOnlyBackupRoutes () { return cache_traversingRoutes.keySet().stream ().filter(e -> e.isBackupRoute()).mapToDouble(e -> e.getOccupiedCapacity(this)).sum (); }
/** 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(); }
private static String getSequenceOccupiedCapacities(Route r) { if (r.isDown()) return "0"; if (r.getSeqOccupiedCapacitiesIfNotFailing().equals(Collections.nCopies(r.getPath().size(), r.getOccupiedCapacity()))) return "" + r.getOccupiedCapacity(); return CollectionUtils.join(r.getSeqOccupiedCapacitiesIfNotFailing(), ", "); } }
/** * <p>Returns a vector with the occupied capacity traffic per route, at the given layer. i-th vector corresponds to i-th index of the element. If no layer is provided, the defaulf layer is assumed.</p> * * @param optionalLayerParameter Network layer (optional) * @return The vector with the occupied traffic per route */ public DoubleMatrix1D getVectorRouteOccupiedCapacity(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix1D res = DoubleFactory1D.dense.make(layer.routes.size()); for (Route e : layer.routes) res.set(e.index, e.getOccupiedCapacity()); return res; }
public double getOccupiedCapacityFromDemand (Demand d) { if (d.isSourceRouting()) { double res = 0; for (Route travRoute : cache_traversingRoutes.keySet()) if (travRoute.getDemand().equals(d)) res += travRoute.getOccupiedCapacity(this); return res; } else { final Pair<Double,Double> normalizedRespectoToDemandCarriedAndCarried = cacheHbH_normCarriedOccupiedPerTraversingDemandCurrentState.get(d); if (normalizedRespectoToDemandCarriedAndCarried == null) return 0; return normalizedRespectoToDemandCarriedAndCarried.getSecond(); } }
/** Returns the amount of occupied capacity of the demand in a particular link * @param e see above * @return see above */ public double getOccupiedCapacity (Link e) { if (isSourceRouting()) { double accum = 0; for (Route r : getRoutes ()) if (r.getSeqLinks().contains(e)) accum += r.getOccupiedCapacity(e); return accum; } else { final Pair<Double,Double> info = this.cacheHbH_normCarriedOccupiedPerLinkCurrentState.get(e); return info == null? 0 : info.getSecond(); } }
void updateLinkTrafficAndOccupation () { /* Add the info of the demands with traversing routes */ this.cache_totalCarriedTraffic = 0; this.cache_totalOccupiedCapacity = 0; for (Entry<Route,Integer> travRouteInfo : cache_traversingRoutes.entrySet()) { final Route r = travRouteInfo.getKey(); final double carriedTraffic = r.getCarriedTraffic(); final double occupiedCapacity = r.getOccupiedCapacity(this); this.cache_totalCarriedTraffic += carriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacity; } /* Add the info of the demands with forwarding rules */ for (Entry<Demand,Pair<Double,Double>> entryInfo : this.cacheHbH_normCarriedOccupiedPerTraversingDemandCurrentState.entrySet()) { final Demand demand = entryInfo.getKey(); final double occupiedCapacityAndCarriedTraffic = entryInfo.getValue().getSecond(); this.cache_totalCarriedTraffic += occupiedCapacityAndCarriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacityAndCarriedTraffic; } for (MulticastTree t : cache_traversingTrees) { final MulticastDemand demand = t.getMulticastDemand(); final double occupiedCapacity = t.getOccupiedLinkCapacity(); final double carriedTraffic = t.getCarriedTraffic(); this.cache_totalCarriedTraffic += carriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacity; } }
String str_seqLinks = CollectionUtils.join(route.cache_seqLinksRealPath, " => "); 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); netPlanInformation.append(NEWLINE);
throw new RuntimeException ("Bad"); if (Math.abs(cache_totalOccupiedCapacity) > 1e-3) throw new RuntimeException ("Bad"); for (Route r : cache_traversingRoutes.keySet()) if ((r.getCarriedTraffic() != 0) || (r.getOccupiedCapacity(this) != 0)) throw new RuntimeException ("Bad"); for (MulticastTree r : cache_traversingTrees) if ((r.getCarriedTraffic() != 0) || (r.getOccupiedLinkCapacity() != 0)) throw new RuntimeException ("Bad"); check_totalOccupiedCapacity += route.getOccupiedCapacity(this); final String qos = route.demand.getQosType(); if (check_occupAndViolationPerQos.containsKey(qos)) check_occupAndViolationPerQos.put(qos , check_occupAndViolationPerQos.get(qos) + route.getOccupiedCapacity(this)); else check_occupAndViolationPerQos.put(qos , route.getOccupiedCapacity(this));
if (!seqLinks.isEmpty()) System.out.println ("Route : "+ r + " links: " + r.getSeqLinks() + ", backup route " + backupRoute + " links: " + backupRoute.getSeqLinks() + ", route carried traffic: " + r.getCarriedTraffic() + ", backup occupied capacity: " + backupRoute.getOccupiedCapacity()); throw new RuntimeException ("Bad");
final double occupiedCapacity = r.getOccupiedCapacity(this); check_totalCarriedTraffic += carriedTraffic; check_cache_totalOccupiedCapacity += occupiedCapacity;
private Pair<Map<Demand,Demand>,Map<Route,Route>> initializeNetPlanLinksBidirDemandsAndRoutes (NetPlan np) { /* Remove lower half demands from np */ np.removeAllRoutes(); for (Node n1 : np.getNodes()) for (Node n2 : np.getNodes()) if (n1.getIndex () > n2.getIndex ()) for (Demand d : np.getNodePairDemands(n1, n2,false)) d.remove (); np.addRoutesFromCandidatePathList(netPlan.computeUnicastCandidatePathList(null , tcfa_maxNumberPathsPerDemand.getInt(), tcfa_maxPathLengthInKm.getDouble(), tcfa_maxPathNumberOfHops.getInt(), -1, -1, -1, -1 , null)); /* Add symmetric demands and routes */ Map<Demand,Demand> opposite_d = new HashMap<Demand,Demand> (); Map<Route,Route> opposite_r = new HashMap<Route,Route> (); for (Demand d : new HashSet<Demand> (np.getDemands())) { final Demand opDemand = np.addDemand(d.getEgressNode(), d.getIngressNode(), d.getOfferedTraffic(), RoutingType.SOURCE_ROUTING , null); opposite_d.put(d,opDemand); opposite_d.put(opDemand,d); for (Route r : new HashSet<Route> (d.getRoutes ())) { final Route oppRoute = np.addRoute(opDemand, r.getCarriedTraffic(), r.getOccupiedCapacity() , oppositeSeqLinks (r.getSeqLinks()), null); opposite_r.put(r,oppRoute); opposite_r.put(oppRoute,r); } } return Pair.of(opposite_d,opposite_r); }
if (Math.abs (newRoute.getOccupiedCapacity() - occupiedCapacity) > 1e-3) throw new RuntimeException ("Bad");