/** Returns the current IP link capacity. In general, the nominal capacity if the link is up, or zero if the link is down * @return see above */ public double getCurrentCapacityGbps () { return npLink.getCapacity(); }
private static double getCapacity (Link n) { return n.getCapacity(); } private static void setCapacity (Link n , double value) { n.setCapacity(value); }
private double computeLinkPriceFromNetPlan (Link e) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); if (u_e == 0) throw new RuntimeException ("Zero capacity in a link means"); final double gradient = (y_e / u_e > 0.99)? 1/Math.pow(u_e * 0.01,2) : 1/Math.pow(u_e - y_e,2); return gradient; }
/** * Returns the number of frequency slots for the given fiber. It is equivalent to * the method {@link Link#getCapacity() getCapacity()} * from the {@link Link Link} object, * but converting capacity value from {@code double} to {@code int}. * * @param fiber Link fiber * @return Number of frequency slots */ public static int getFiberNumFrequencySlots(Link fiber) { if (!isNonNegativeInteger(fiber.getCapacity())) throw new WDMException("Link capacity must be a non-negative integer representing the number of wavelengths of the fiber"); return (int) fiber.getCapacity(); }
private double computeSecondOrderPriceFromNetPlan (Link e) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); if (u_e == 0) throw new RuntimeException ("Zero capacity in a link"); double priceDiagScaling = 0; if (control_isBarrierMethod) { if (y_e / u_e < 1) priceDiagScaling = 2 * u_e / Math.pow(u_e - y_e , 3); else priceDiagScaling = Double.MAX_VALUE; //2 * u_e / Math.pow(u_e - 0.999999 * u_e , 3); } else priceDiagScaling = (y_e <= u_e)? 0 : 2; return priceDiagScaling; }
private double computeFirstOrderPriceFromNetPlan (Link e) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); if (u_e == 0) throw new RuntimeException ("Zero capacity in a link"); double price = 0; if (control_isBarrierMethod) { if (y_e / u_e < 1) price = u_e / Math.pow(u_e - y_e , 2); else price = Double.MAX_VALUE; } else price = Math.max(0, y_e - u_e); return price; }
private double computeObjectiveFunctionFromNetPlan(NetPlan np) { double optCost = 0; double maxOverssubs = 0; for (Link e : np.getLinks()) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); maxOverssubs = Math.max(maxOverssubs, y_e - u_e); optCost += Math.min(y_e, u_e); } optCost += PENALIZATIONOVERSUBSCRIBED * maxOverssubs; return optCost; }
private double computeObjectiveFucntionFromNetPlan () { double objFunc = 0; for (Link e : this.currentNetPlan.getLinks()) { final double y_e = e.getCarriedTraffic(); final double u_e = e.getCapacity(); if (y_e / u_e > 0.99) objFunc += 1/(0.01*u_e) + 1/Math.pow(u_e * 0.01,2) * (y_e - 0.99*u_e); else objFunc += 1/(u_e - y_e); } return objFunc; }
public FigureLinkSequencePanel(GUINetworkDesign callback, List<? extends NetworkElement> path, NetworkLayer layer, List<Double> occupationsPerElement, double carriedTraffic, String... titleMessage) { super(callback); this.np = layer.getNetPlan(); this.layer = layer; this.path = path; this.occupationsPerElement = occupationsPerElement; this.capacitiesPerElement = path.stream().map(e -> (e instanceof Link) ? ((Link) e).getCapacity() : ((Resource) e).getCapacity()).collect(Collectors.toList()); if (carriedTraffic >= 0) { this.generalMessage = new ArrayList<>(); this.generalMessage.addAll(Arrays.asList(titleMessage)); this.generalMessage.add(" traffic: " + String.format("%.2f ", carriedTraffic) + " " + np.getDemandTrafficUnitsName(layer)); } else { this.generalMessage = Arrays.asList(titleMessage); } this.preferredSize = null; }
private double getMinimumNonZeroTrafficOrCapacityValue (NetPlan netPlan) { double res = Double.MAX_VALUE; for (Demand d : netPlan.getDemands ()) if (d.getOfferedTraffic() > 0) res = Math.min (res , d.getOfferedTraffic()); for (Link e : netPlan.getLinks ()) if (e.getCapacity() > 0) res = Math.min (res , e.getCapacity()); if (res == Double.MAX_VALUE) throw new Net2PlanException ("Too large offered traffics and link capacities"); return res; } }
private double getMinimumNonZeroTrafficOrCapacityValue (NetPlan netPlan) { double res = Double.MAX_VALUE; for (Demand d : netPlan.getDemands ()) if (d.getOfferedTraffic() > 0) res = Math.min (res , d.getOfferedTraffic()); for (Link e : netPlan.getLinks ()) if (e.getCapacity() > 0) res = Math.min (res , e.getCapacity()); if (res == Double.MAX_VALUE) throw new Net2PlanException ("Too large offered traffics and link capacities"); return res; } }
private double getMinimumNonZeroTrafficOrCapacityValue (NetPlan netPlan) { double res = Double.MAX_VALUE; for (Demand d : netPlan.getDemands ()) if (d.getOfferedTraffic() > 0) res = Math.min (res , d.getOfferedTraffic()); for (Link e : netPlan.getLinks ()) if (e.getCapacity() > 0) res = Math.min (res , e.getCapacity()); if (res == Double.MAX_VALUE) throw new Net2PlanException ("Too large offered traffics and link capacities"); return res; } }
private double computeMeFactor_e (Link e) { final double u_e = e.getCapacity(); final double snr_e = Math.exp(u_e); return Math.pow(u_e,-this.control_fairnessFactor.getDouble()) * snr_e / (Math.exp(this.mac_transmissionPower_logu_e.get(e.getIndex ())) * this.mac_g_nu_ee.get(e.getIndex (),e.getIndex ())); }
private double computeMeFactor_e (Link e) { final double snr_e = Math.exp(e.getCapacity()); final double pi_e = this.cc_price_e.get(e.getIndex ()); final double g_ee = this.mac_g_nu_ee.get(e.getIndex (),e.getIndex ()); return pi_e * snr_e / (Math.exp(this.mac_transmissionPower_logu_e.get(e.getIndex ())) * g_ee); }
/** * Creates a link in the opposite direction as this, and with the same attributes, and associate both as bidirectional pairs. * If this link is already a bidirectional link, makes nothing and returns null * @return the newly created link */ public Link createBidirectionalPair () { checkAttachedToNetPlanObject(); if (this.isBidirectional()) return null; final Link e = netPlan.addLink(this.destinationNode, this.originNode, this.getCapacity(), this.getLengthInKm(), this.getPropagationDelayInMs(), this.attributes, this.layer); this.bidirectionalPair = e; e.bidirectionalPair = this; return e; }
private static Pair<Boolean,Double> isValidPath (List<Link> seqLinks , double routeOccupiedCapacity) { final double minimumCapacityNeeded = routeOccupiedCapacity; boolean validPath = true; double thisPathIdleCapacity = Double.MAX_VALUE; for (Link e : seqLinks) { final double thisLinkIdleCapacity = e.getCapacity() - e.getCarriedTraffic(); thisPathIdleCapacity = Math.min(thisPathIdleCapacity, thisLinkIdleCapacity); if (e.isDown() || e.getOriginNode().isDown() || e.getDestinationNode().isDown() || (thisLinkIdleCapacity <= minimumCapacityNeeded)) { validPath = false; break; } } return Pair.of(validPath, thisPathIdleCapacity); } }
private Triple<Boolean,Integer,Double> computeValidWAFirstFit_path (List<Link> seqLinks , int numContiguousSlots , double maxOpticalReachKm) { if (seqLinks.isEmpty()) throw new RuntimeException ("Bad"); if (seqLinks.get(0).getOriginNode().isDown()) return Triple.of(false,-1,-1.0); if (getLengthInKm(seqLinks) > maxOpticalReachKm) return Triple.of(false,-1,-1.0); double worseCaseSpareCapacity = Double.MAX_VALUE; for (Link e : seqLinks) { worseCaseSpareCapacity = Math.min(worseCaseSpareCapacity, e.getCapacity() - e.getOccupiedCapacity()); if (e.getDestinationNode().isDown() || e.isDown()) return Triple.of(false,-1,-1.0); } int wavelength = WDMUtils.spectrumAssignment_firstFit(seqLinks, wavelengthFiberOccupancy , numContiguousSlots); if (wavelength != -1) return Triple.of(true , wavelength , worseCaseSpareCapacity); else return Triple.of(false,-1,-1.0); }
Pair<Double,DoubleMatrix1D> computeObjectiveFunction (DoubleMatrix1D sol) { Quadruple<DoubleMatrix2D, DoubleMatrix2D, DoubleMatrix1D, DoubleMatrix1D> q = IPUtils.computeCarriedTrafficFromIGPWeights(netPlan, sol); DoubleMatrix1D y_e = q.getFourth(); double congestion = 0; double accumUtilization = 0; for (Link e : netPlan.getLinks ()) { final double linkTraf = y_e.get(e.getIndex ()); final double u_e = e.getCapacity(); final double utilization = (linkTraf == 0)? 0 : (u_e == 0)? Double.MAX_VALUE : linkTraf / u_e; accumUtilization += utilization; congestion = Math.max(congestion, utilization); } final double objFunc = weightOfMaxUtilizationInObjectiveFunction * congestion + (1-weightOfMaxUtilizationInObjectiveFunction) * accumUtilization / netPlan.getNumberOfLinks(); return Pair.of(objFunc, y_e); } }
private double computeGradient (Link thisLink) { final double u_e = thisLink.getCapacity(); final DoubleMatrix1D infoIKnow_me = control_mostUpdatedMe2ValueKnownByLink1_e1e2.viewRow(thisLink.getIndex ()); double gradient = Math.pow(u_e, -this.control_fairnessFactor.getDouble()); double accumFactor = 0; for (Link epp : this.currentNetPlan.getLinks()) if (epp != thisLink) accumFactor += this.mac_g_nu_ee.get(thisLink.getIndex (),epp.getIndex ()) * infoIKnow_me.get(epp.getIndex ()); accumFactor *= Math.exp(this.mac_transmissionPower_logu_e.get(thisLink.getIndex ())); //System.out.println("Gradient: positive factor: " + gradient + ", negative factor: " + accumFactor); gradient -= accumFactor; return gradient; }
void saveNetPlan (NetPlan netPlan , DoubleMatrix2D x_te , DoubleMatrix1D n_e) { /* Set the routing at the IP layer */ netPlan.setRoutingTypeAllDemands(RoutingType.HOP_BY_HOP_ROUTING); netPlan.removeAllForwardingRules(); netPlan.setRoutingFromDestinationLinkCarriedTraffic(x_te , true); for (Link e : netPlan.getLinks()) e.setCapacity(moduleCapacity.getDouble() * n_e.get(e.getIndex ())); for (Demand d : netPlan.getDemandsBlocked()) if (d.getBlockedTraffic() > PRECISIONFACTOR) throw new RuntimeException ("Bad"); for (Link e : netPlan.getLinksOversubscribed()) if (e.getOccupiedCapacity() - e.getCapacity() > PRECISIONFACTOR) throw new RuntimeException ("Bad"); }