/** Returns the length in km of this lighptath, as the sum of the lengths of the traversed fibers * @return see above */ public double getLengthInKm () { return r.getLengthInKm(); } /** Returns the propagation delay in ms of this lighptath, as the sum of the propagation delays of the traversed fibers
/** * <p>Returns a vector with the length in km 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 length in km per route */ public DoubleMatrix1D getVectorRouteLengthInKm(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix1D res = DoubleFactory1D.dense.make(layer.routes.size()); for (Route e : layer.routes) res.set(e.index, e.getLengthInKm()); return res; }
final int wcPassesInAlink = thisRun.getLinks().stream().mapToInt(e->e.getTraversingRoutesAndMultiplicity().values().stream().mapToInt(ee->(int)ee).sum()).max().orElse(0); summaryString.add(wcPassesInAlink + ""); summaryString.add(thisRun.getRoutes ().stream().map(r->r.getLengthInKm() + "").collect(Collectors.joining(" "))); summaryString.add(thisRun.getRoutes ().stream().map(r->r.getAttributeAsDouble(ATTNAME_TRUCKNUMCONTAINERSCOLLECTED, null) + "").collect(Collectors.joining(" "))); summaryString.add(thisRun.getRoutes ().stream().map(r->r.getAttributeAsDouble(ATTNAME_TRUCKSUMCOLLECTEDWASTE_KG, null) + "").collect(Collectors.joining(" "))); writeFile (new File (folder , "summaryResults_" + run + ".txt") , summaryString); thisRun.saveToFile(new File (folder , "n2pFile_" + run + ".n2p")); final double totalKm = netPlan.getRoutes().stream().mapToDouble(r->r.getLengthInKm()).sum(); final double totalWasteCollected = thisRun.getRoutes ().stream().mapToDouble(r->r.getAttributeAsDouble(ATTNAME_TRUCKSUMCOLLECTEDWASTE_KG, 0.0)).sum(); infoString = "Used trucks = " + thisRun.getNumberOfRoutes() + ", total km: " + totalKm + ", total waste collected: " + totalWasteCollected;
if (demand.cache_worstCaseLengthInKm <= this.getLengthInKm()) for (Route r : demand.cache_routes) demand.cache_worstCaseLengthInKm = Math.max(demand.cache_worstCaseLengthInKm, r.getLengthInKm());
for (Route r : netPlan.getRoutes()) final double d_r = r.getLengthInKm(); final String st_a_r = r.getIngressNode().getName(); final String st_b_r = r.getEgressNode().getName(); final double d_r = r.getLengthInKm(); final String st_a_r = r.getIngressNode().getName(); final String st_b_r = r.getEgressNode().getName();
for (Route r : netPlan.getRoutes()) final double d_r = r.getLengthInKm(); final String st_a_r = r.getIngressNode().getName(); final String st_b_r = r.getEgressNode().getName(); final double d_r = r.getLengthInKm(); final String st_a_r = r.getIngressNode().getName(); final String st_b_r = r.getEgressNode().getName();
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>" + printNode(segment.getEgressNode()) + "</td>"); out.append("<td>" + seqNodesString(segment.getSeqLinks()) + "</td>"); out.append("<td>" + df_2.format(segment.getLengthInKm()) + "</td>"); out.append("<td>" + df_2.format(segment.getPropagationDelayInMiliseconds()) + "</td>"); out.append("<td>" + rsa.getNumSlots() + "</td>");
@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)
if (numUsedTrucks != netPlan.getNumberOfRoutes()) throw new RuntimeException (); final double totalKm = x_te.zMult(netPlan.getVectorLinkLengthInKm() , null).zSum(); if (Math.abs (totalKm - netPlan.getRoutes().stream().mapToDouble(r->r.getLengthInKm()).sum()) > 1e-3) throw new RuntimeException ();
lpLengthKm.add(r.getLengthInKm()); lpLengthMs.add(r.getPropagationDelayInMiliseconds());
SimEvent.LinkAdd evIp = new SimEvent.LinkAdd(addLpEvent.ingressNode , addLpEvent.egressNode , ipLayer , addLpEvent.lineRateGbps , addedLp.getLengthInKm() , addedLp.getPropagationSpeedInKmPerSecond()); ospfNetwork.processEvent(currentNetPlan , new SimEvent(event.getEventTime() , SimEvent.DestinationModule.EVENT_GENERATOR , -1 , evIp)); if (evIp.linkAddedToFillByProcessor == null) throw new RuntimeException ("Bad");
final Link ipLayerLightpath = netPlan.addLink(ingressNode, egressNode, lineRatePerLightpath_Gbps, wdmLayerRoute.getLengthInKm(), wdmLayerRoute.getPropagationSpeedInKmPerSecond(), null, ipLayer); IPUtils.setLinkWeight(ipLayerLightpath, fixedOSPFWeight); final Link ipLayerLightpath = netPlan.addLink(originNode, destinationNode, lineRatePerLightpath_Gbps, wdmLayerRoute.getLengthInKm(), wdmLayerRoute.getPropagationSpeedInKmPerSecond(), null, ipLayer); IPUtils.setLinkWeight(ipLayerLightpath, fixedOSPFWeight);
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; if (maxDistanceOriginToDestinationInKm.getDouble() > 0) check (netPlan.getRoutes().stream().filter(r->r.getCarriedTraffic() > 0).allMatch(r->r.getLengthInKm() <= maxDistanceOriginToDestinationInKm.getDouble())); check (totalNumPlants <= maxNumberOfPlants.getInt()); check (Math.abs(totalBlockedTraffic - b_d.zSum()) < 1e-3); return "#Plants: " + totalNumPlants + ", #DCs: " + totalNumDcs + ", #paths: " + netPlan.getRoutes().size() + ", Total length (km): " + netPlan.getRoutes().stream().mapToDouble(r->r.getLengthInKm()).sum() + ", blocked traffic: " + totalBlockedTraffic + ", total cost: " + totalCost;