/** Returns the list of fibers, in increasing order according to its id * @return see above */ public List<WFiber> getFibers () { return np.getLinks(getWdmLayer().getNe()).stream().map(n->new WFiber(n)).collect(Collectors.toCollection(ArrayList::new)); } /** Returns the list of lightpath requests, in increasing order according to its id
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"); }
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; }
public static SortedSet<Date> getDatesWithAtLeastOneLinkMonitorInfo (NetworkLayer layer) { return layer.getNetPlan().getLinks(layer).stream().map(e->e.getMonitoredOrForecastedCarriedTraffic().getDatesWithValue()).flatMap(e->e.stream()).collect(Collectors.toCollection(TreeSet::new)); } public static SortedSet<Date> getDatesWithAtLeastOneUnicastDemandMonitorInfo (NetworkLayer layer)
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; }
/** Returns the list of IP links, in increasing order according to its id * @return see above */ public List<WIpLink> getIpLinks () { return np.getLinks(getIpLayer().getNe()).stream().map(n->new WIpLink(n)).filter(e->!e.isVirtualLink()).collect(Collectors.toCollection(ArrayList::new)); }
/** * Sets the weight associated to every link. * * @param netPlan Network design * @param linkWeight IGP weight associated to each link (must be greater or equal than one) * @param optionalLayer Network layer (optional) */ public static void setLinkWeights(NetPlan netPlan, double linkWeight , NetworkLayer ... optionalLayer) { NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayer); checkIPWeight(linkWeight); for (Link link : netPlan.getLinks (layer)) link.setAttribute (IP_WEIGHT_ATTRIBUTE_NAME, Double.toString(linkWeight)); }
private List<List<Link>> getAndUpdateCplWdm (Pair<Node,Node> pair , NetPlan np) { List<List<Link>> res = cplWdm.get(pair); if (res != null) return res; final Map<Link,Double> linkCostMap = new HashMap<> (); for (Link e : np.getLinks(wdmLayer)) linkCostMap.put(e, e.getLengthInKm()); res = GraphUtils.getKLooplessShortestPaths(np.getNodes(), np.getLinks(wdmLayer), pair.getFirst(), pair.getSecond(), linkCostMap, wdmK.getInt(), tpInfo.getMaxOpticalReachKm(), wdmMaxLightpathNumHops.getInt(), -1, -1, -1, -1); if (res.isEmpty()) throw new Net2PlanException ("There is no path between nodes: " + pair.getFirst() + " -> " + pair.getSecond()); cplWdm.put(pair , res); return res; } private List<Pair<List<Link>,List<Link>>> getAndUpdateCplWdm11 (Pair<Node,Node> pair , NetPlan np)
/** * Sets the number of frequency slots available in each fiber to the same value. * * @param netPlan A {@link NetPlan} representing a WDM physical topology * @param numFrequencySlots Number of wavelengths for all fibers * @param optionalLayerParameter WDM network layer. If not present, the default layer is assumed */ public static void setFibersNumFrequencySlots(NetPlan netPlan, int numFrequencySlots , NetworkLayer ... optionalLayerParameter) { NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); if (numFrequencySlots < 0) throw new WDMException("'numWavelengths' must be a non-negative integer"); for (Link fiber : netPlan.getLinks (layer)) fiber.setCapacity(numFrequencySlots); }
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; } }
Pair<DoubleMatrix1D,Double> getInitialSolution (String initializationType) { DoubleMatrix1D currentSol = DoubleFactory1D.dense.make (netPlan.getNumberOfLinks ()); if (initializationType.equalsIgnoreCase("random")) for (Link e : netPlan.getLinks()) currentSol.set(e.getIndex (), rng.nextInt(maxLinkWeight) + 1.0); else if (initializationType.equalsIgnoreCase("ones")) for (Link e : netPlan.getLinks()) currentSol.set(e.getIndex (), 1.0); else throw new Net2PlanException ("Non recognized initialization type"); double currentObjFunction = computeObjectiveFunction (currentSol).getFirst(); return Pair.of(currentSol , currentObjFunction); }
public WNode getNearestCoreNode(NetPlan netPlan, WNet wNet, WNode node) { int minStepsBetweenNodes = Integer.MAX_VALUE; WNode nearestCoreNode = null; for (WNode coreNode : wNet.getNodesConnectedToCore()) { int currentStepsBetweenNodes = GraphUtils .getShortestPath(netPlan.getNodes(), netPlan.getLinks(), node.getNe(), coreNode.getNe(), null) .size(); if (minStepsBetweenNodes > currentStepsBetweenNodes) { minStepsBetweenNodes = currentStepsBetweenNodes; nearestCoreNode = coreNode; } } return nearestCoreNode; }
private double computeSINR_e (Link e) { final double receivedPower_nu = Math.exp(this.mac_transmissionPower_logu_e.get(e.getIndex())) * this.mac_g_nu_ee.get(e.getIndex (),e.getIndex ()); double interferencePower_nu = this.mac_receptionThermalNoise_nu; for (Link eInt : this.currentNetPlan.getLinks ()) if (eInt != e) interferencePower_nu += Math.exp(this.mac_transmissionPower_logu_e.get(eInt.getIndex())) * this.mac_g_nu_ee.get(eInt.getIndex (),e.getIndex ()); return receivedPower_nu / interferencePower_nu; }
private double computeSINR_e (Link e) { final double receivedPower_nu = Math.exp(this.mac_transmissionPower_logu_e.get(e.getIndex ())) * this.mac_g_nu_ee.get(e.getIndex (),e.getIndex ()); double interferencePower_nu = this.mac_receptionThermalNoise_nu; for (Link eInt : this.currentNetPlan.getLinks ()) if (eInt != e) interferencePower_nu += Math.exp(this.mac_transmissionPower_logu_e.get(eInt.getIndex ())) * this.mac_g_nu_ee.get(eInt.getIndex (),e.getIndex ()); // System.out.println ("SINR link " + e + ": " + receivedPower_nu / interferencePower_nu); // System.out.println ("receiver power link " + e + ": " + receivedPower_nu + ", total interf power: " + interferencePower_nu + "thermal noise: " + mac_receptionThermalNoise_nu); return receivedPower_nu / interferencePower_nu; }
private double computeSINR_e (Link e , DoubleMatrix1D p_e , DoubleMatrix2D mac_g_nu_ee , double mac_receptionThermalNoise_nu , NetPlan np) { final double receivedPower_nu = Math.exp(p_e.get(e.getIndex ())) * mac_g_nu_ee.get(e.getIndex (),e.getIndex ()); double interferencePower_nu = mac_receptionThermalNoise_nu; for (Link eInt : np.getLinks ()) if (eInt != e) interferencePower_nu += Math.exp(p_e.get(eInt.getIndex ())) * mac_g_nu_ee.get(eInt.getIndex (),e.getIndex ()); return receivedPower_nu / interferencePower_nu; }
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; }
/** * Obtains the vector of ink weights from a given a network design. * * @param netPlan Network design * @param optionalLayer Network layer (optional) * @return Link weight vector */ public static DoubleMatrix1D getLinkWeightVector (NetPlan netPlan, NetworkLayer ... optionalLayer) { NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayer); DoubleMatrix1D linkWeights = DoubleFactory1D.dense.make (netPlan.getNumberOfLinks(layer)); for(Link link : netPlan.getLinks(layer)) linkWeights.set (link.getIndex(), getLinkWeight(link)); return linkWeights; }
private double computeGradient (Link thisLink) { final DoubleMatrix1D infoIKnow_me = mac_mostUpdatedMe2ValueKnownByLink1_e1e2.viewRow (thisLink.getIndex ()); double gradient = cc_price_e.get(thisLink.getIndex ()); 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 ())); gradient -= accumFactor; return gradient; }