private double computeHdFromPrices (Demand d) { /* compute the demand price as weighted sum in the routes of route prices */ final int index_ad = d.getIngressNode().getIndex (); final int index_d = d.getIndex (); final double demandInitialNodeQueueSize = this.routing_numTrafficUnitsOfOnePacket.getDouble() * ((double) this.ctlNumPacketsQueue_nd [index_ad][index_d]) * this.routing_gradient_gammaStep.getDouble(); /* compute the new h_d */ final double new_hd = Math.max(this.cc_control_minHd.getDouble() , Math.min(this.cc_control_maxHd.getDouble(), Math.pow(demandInitialNodeQueueSize, -1/this.cc_control_fairnessFactor.getDouble()))); return new_hd; }
private double [] getVectorIPDemandAverageAllStatesBlockedTraffic () { double [] res = new double [Dip]; for (Demand ipDemand : netPlan.getDemands(ipLayer)) { res [ipDemand.getIndex()] = ipDemand.getBlockedTraffic(); if (singleSRGToleranceNot11Type) { for (SharedRiskGroup srg : netPlan.getSRGs()) { Set<Route> affectedRoutes = srg.getAffectedRoutes(wdmLayer); double carriedTrafficThisFailure = 0; for (Route ipRoute : ipDemand.getRoutes()) { final Set<Route> wdmRoutes = ipRoute.getSeqLinks().get(0).getCoupledDemand().getRoutes(); for (Route r : wdmRoutes) if (!affectedRoutes.contains(r)) carriedTrafficThisFailure += r.getCarriedTraffic(); } res [ipDemand.getIndex()] += Math.max(0 , ipDemand.getOfferedTraffic() - carriedTrafficThisFailure); } } res [ipDemand.getIndex()] /= (singleSRGToleranceNot11Type? (netPlan.getNumberOfSRGs() + 1) : 1); } return res; }
private double computeHdFromPrices (Demand d) { DoubleMatrix1D infoIKnow_price_e = this.control_mostUpdatedLinkPriceKnownDemand_de.viewRow(d.getIndex ()); /* compute the demand price as weighted sum in the routes of route prices */ double demandWeightedSumLinkPrices = 0; double demandCarriedTraffic = 0; for (Route r : d.getRoutes ()) { final double h_r = r.getCarriedTraffic(); demandCarriedTraffic += h_r; for (Link e : r.getSeqLinks()) demandWeightedSumLinkPrices += h_r * infoIKnow_price_e.get(e.getIndex ()); } //if (Math.abs(demandCarriedTraffic - this.currentNetPlan.getDemandCarriedTraffic(dIdMe)) > 1E-3) throw new RuntimeException ("Not all the traffic is carried"); demandWeightedSumLinkPrices /= demandCarriedTraffic; /* compute the new h_d */ final double alpha = (demandType.get(d.getIndex ()) == 1)? this.cc_control_fairnessFactor_1.getDouble() : this.cc_control_fairnessFactor_2.getDouble(); final double weight = (demandType.get(d.getIndex ()) == 1)? this.cc_control_weightFairness_1.getDouble() : this.cc_control_weightFairness_2.getDouble(); final double new_hd = Math.max(this.cc_control_minHd.getDouble() , Math.min(this.cc_control_maxHd.getDouble(), Math.pow(demandWeightedSumLinkPrices/weight, -1/alpha))); return new_hd; }
private List<Triple<String,String,String>> getForwardingRuleInfoTables (Pair<Demand,Link> fr) { final DecimalFormat df = new DecimalFormat("###.##"); final Demand d = fr.getFirst(); final Link e = fr.getSecond(); final NetworkLayer layer = d.getLayer(); final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); final String capUnits = np.getLinkCapacityUnitsName(layer); res.add(Triple.of("Demand index/id" , "Demand " + d.getIndex() + " (id " + d.getId() + ")", "demand" + d.getId())); res.add(Triple.of("Link index/id" , "Link " + e.getIndex() + " (id " + e.getId() + ")", "link" + e.getId())); res.add(Triple.of("Splitting factor", "" + df.format(np.getForwardingRuleSplittingFactor(d,e)) , "")); res.add(Triple.of("Carried traffic", "" + df.format(np.getForwardingRuleCarriedTraffic(d,e)) + " " + trafUnits , "")); return res; } private List<Triple<String,String,String>> getRouteInfoTables (Route r)
private double computeHdFromPrices (Demand d) { DoubleMatrix1D infoIKnow_price_e = this.cc_mostUpdatedLinkPriceKnownByDemand_de.viewRow(d.getIndex()); /* compute the demand price as weighted sum in the routes of route prices */ double demandWeightedSumLinkPrices = 0; double demandCarriedTraffic = 0; for (Route r : d.getRoutes ()) { final double h_r = r.getCarriedTraffic(); demandCarriedTraffic += h_r; for (Link e : r.getSeqLinks()) demandWeightedSumLinkPrices += h_r * infoIKnow_price_e.get(e.getIndex()); } //if (Math.abs(demandCarriedTraffic - this.currentNetPlan.getDemandCarriedTraffic(dIdMe)) > 1E-3) throw new RuntimeException ("Not all the traffic is carried"); demandWeightedSumLinkPrices /= demandCarriedTraffic; /* compute the new h_d */ final double new_hd = Math.max(this.cc_minHd.getDouble() , Math.min(this.cc_maxHd.getDouble(), Math.pow(demandWeightedSumLinkPrices, -1/this.cc_fairnessFactor.getDouble()))); return new_hd; }
private double computeHdFromPrices (Demand d) { DoubleMatrix1D infoIKnow_price_e = this.control_mostUpdatedLinkPriceKnownByDemand_de.viewRow (d.getIndex ()); /* compute the demand price as weighted sum in the routes of route prices */ double demandWeightedSumLinkPrices = 0; double demandCarriedTraffic = 0; for (Route r : d.getRoutes ()) { final double h_r = r.getCarriedTraffic(); demandCarriedTraffic += h_r; for (Link e : r.getSeqLinks()) demandWeightedSumLinkPrices += h_r * infoIKnow_price_e.get(e.getIndex ()); } demandWeightedSumLinkPrices /= demandCarriedTraffic; /* compute the new h_d */ final double new_hd = Math.max(this.control_minHd.getDouble() , Math.min(this.control_maxHd.getDouble(), Math.pow(demandWeightedSumLinkPrices, -1/this.control_fairnessFactor.getDouble()))); return new_hd; }
private void drawDemand(Graphics2D g2d) { final FontMetrics fontMetrics = g2d.getFontMetrics(); final int regularInterlineSpacePixels = fontMetrics.getHeight(); final Demand demand = forwardingRule.getFirst(); final Node demandIngress = demand.getIngressNode(); final Node demandEgress = demand.getEgressNode(); final DrawNode ingressNode = new DrawNode(demandIngress, demand.getLayer(), maxIconSize); final DrawNode egressNode = new DrawNode(demandEgress, demand.getLayer(), maxIconSize); textRow = addIconJump(iconRow); textRow = addLineJump(textRow); textRow = addLineJump(textRow); iconRow = addLineJump(textRow); int topCoordinateLineNodes = maxIconSize + (generalMessage.size() * regularInterlineSpacePixels) + (maxNumberOfTagsPerNodeNorResource * regularInterlineSpacePixels) * iconRow; Point initialDnTopLeftPosition = new Point(maxIconSize, topCoordinateLineNodes); int xSeparationDnCenters = maxIconSize * 3; g2d.setFont(headerFont); g2d.drawString("Demand " + demand.getIndex(), maxIconSize, maxIconSize + (regularInterlineSpacePixels * (textRow))); g2d.setFont(plainFont); DrawNode.addNodeToGraphics(g2d, ingressNode, initialDnTopLeftPosition, fontMetrics, regularInterlineSpacePixels, null); DrawNode.addNodeToGraphics(g2d, egressNode, new Point(initialDnTopLeftPosition.x + xSeparationDnCenters, initialDnTopLeftPosition.y), fontMetrics, regularInterlineSpacePixels, null); drawnNodes.add(ingressNode); drawnNodes.add(egressNode); final DrawLine demandDL = new DrawLine(ingressNode, egressNode, ingressNode.posEast(), egressNode.posWest()); DrawLine.addLineToGraphics(g2d, demandDL, fontMetrics, regularInterlineSpacePixels, lineStroke); }
DrawLine(DrawNode from, DrawNode to, Link e, Point pFrom, Point pTo, double occupiedToShow) { final String capUnits = e.getNetPlan().getLinkCapacityUnitsName(e.getLayer()); this.from = from; this.to = to; this.pFrom = pFrom; this.pTo = pTo; this.labels = new ArrayList<>(); this.urlsLabels = new ArrayList<>(); final DecimalFormat df = new DecimalFormat("###.##"); String length_km = df.format((e.getLengthInKm() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getLengthInKm()); String delay_ms = df.format((e.getPropagationDelayInMs() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getPropagationDelayInMs()); this.labels.addAll(Arrays.asList( "Link " + e.getIndex() , length_km + " km (" + delay_ms + " ms)" , "Occup: " + String.format("%.1f" , occupiedToShow) + " " + capUnits, "Total: " + String.format("%.1f" , e.getOccupiedCapacity()) + "/" + String.format("%.1f" , e.getCapacity()) + " " + capUnits )); this.urlsLabels.addAll(Arrays.asList("link" + e.getId(), "", "", "")); if (e.getCoupledDemand() != null) { labels.add("Coupled: Demand " + e.getCoupledDemand().getIndex() + ", " + getLayerName(e.getCoupledDemand().getLayer())); urlsLabels.add("demand" + e.getCoupledDemand().getId()); } else if (e.getCoupledMulticastDemand() != null) { labels.add("Coupled: Multicast demand " + e.getCoupledMulticastDemand().getIndex() + ", " + getLayerName(e.getCoupledMulticastDemand().getLayer())); urlsLabels.add("multicastDemand" + e.getCoupledMulticastDemand().getId()); } this.associatedElement = e; }
/** Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), and an offered traffic to the network, it generates the resulting demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e). * If the routing of a demand has closed loops a {@code ClosedCycleRoutingException} is thrown * * @param numNodes Number of nodes * @param numDemandsInLayer Number of demand in the layer * @param links List of links * @param demandsToConvert List of demands * @param f_te For each destination node <i>t</i> and each link <i>e</i>, {@code f_te[t][e]} sets the fraction of the traffic targeted to node <i>t</i> that arrives (or is generated in) node <i>a(e)</i> (the origin node of link <i>e</i>), that is forwarded through link <i>e</i>. It must hold that for every node <i>n</i> different of <i>t</i>, the sum of the fractions <i>f<sub>te</sub></i> along its outgoing links must be lower or equal than 1 (unchecked) * @return Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e), total carried traffic per demand, carried traffic per link, and routing cycle type (loopless, with open cycles...) per demand */ public static Quadruple<DoubleMatrix2D, DoubleMatrix1D, DoubleMatrix1D, List<RoutingCycleType>> convert_fte2xde(int numNodes, int numDemandsInLayer , List<Link> links, SortedSet<Demand> demandsToConvert, DoubleMatrix2D f_te) { final DoubleMatrix2D f_de = convert_fte2fde(numDemandsInLayer , demandsToConvert, f_te); DoubleMatrix1D h_d = DoubleFactory1D.dense.make(numDemandsInLayer); for (Demand d : demandsToConvert) h_d.set(d.getIndex(), d.getOfferedTraffic()); return convert_fde2xde(numNodes, links, demandsToConvert, h_d, f_de); }
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)
/** Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), it generates the resulting demand-link routing in the form f_de (fractions of traffic in a node from demand d, transmitted through link e). * * @param numDemandsInLayer Number of demands in the layer. * @param demandsToConvert List of demands in the layer to apply conversion, the rest are untouched * @param f_te For each destination node <i>t</i> (<i>t = 0</i> refers to the first node index, <i>t = 1</i> refers to the second one, and so on), and each link <i>e</i> (<i>e = 0</i> refers to the first link index, <i>e = 1</i> refers to the second one, and so on), {@code f_te[t][e]} sets the fraction of the traffic targeted to node <i>t</i> that arrives (or is generated in) node <i>a(e)</i> (the origin node of link <i>e</i>), that is forwarded through link <i>e</i>. It must hold that for every node <i>n</i> different of <i>t</i>, the sum of the fractions <i>f<sub>te</sub></i> along its outgoing links must be lower or equal than 1 (unchecked) * @return Demand-link routing in the form f_de (fractions of traffic in a node from demand d, transmitted through link e) */ public static DoubleMatrix2D convert_fte2fde(int numDemandsInLayer , SortedSet<Demand> demandsToConvert, DoubleMatrix2D f_te) { int E = f_te.columns(); int D = numDemandsInLayer; DoubleMatrix2D f_de = DoubleFactory2D.sparse.make(D, E); for (Demand d : demandsToConvert) f_de.viewRow(d.getIndex()).assign(f_te.viewRow(d.getEgressNode().getIndex())); return f_de; }
/** Given a path-based routing, returns the amount of traffic for each demand d traversing each link e. The link * occupation information is not used, only the route carried traffic (recall that a route carried traffic is zero if * it traverses a failed link/node) * @param E Number of links * @param D Number of demands * @param routes List of routes * @return Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e) */ public static DoubleMatrix2D convert_xp2xde(int D , int E , List<Route> routes) { DoubleMatrix2D x_de = DoubleFactory2D.sparse.make(D, E, 0); if (routes.isEmpty()) return x_de; final NetworkLayer layer = routes.iterator().next().getLayer(); if (E != layer.getNetPlan().getNumberOfLinks(layer)) throw new Net2PlanException ("Wrong format"); if (D != layer.getNetPlan().getNumberOfDemands(layer)) throw new Net2PlanException ("Wrong format"); for (Route route : routes) { final int d = route.getDemand().getIndex(); for (Link link : route.getSeqLinks()) { final int e = link.getIndex(); x_de.setQuick(d, e, x_de.getQuick(d, e) + route.getCarriedTraffic()); } } return x_de; }
/** Given a demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e), returns the equivalent forwarding rule mapping (fractions of traffic entering a node from demand 'd', leaving that node through link 'e'). * @param numNodes Number of nodes * @param demandsToConsider List of demands * @param x_de Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e) * @return Forwarding rule matrix (a <i>N</i>x<i>E</i> matrix where each element <i>δ<sub>ne</sub></i> equals the fraction of traffic entering a node 'n' from demand 'd', leaving that node through link 'e') */ public static DoubleMatrix2D convert_xde2xte(int numNodes, SortedSet<Demand> demandsToConsider, DoubleMatrix2D x_de) { final int E = x_de.columns(); DoubleMatrix2D x_te = DoubleFactory2D.sparse.make(numNodes, E); for (Demand demand : demandsToConsider) { final int t = demand.getEgressNode().getIndex(); final int d = demand.getIndex(); DoubleMatrix1D x_e_thisDemand = x_de.viewRow(d); x_te.viewRow(t).assign(x_e_thisDemand, DoublePlusMultFirst.plusMult(1)); } return x_te; }
private static void checkSolution(NetPlan netPlan, DoubleMatrix2D xx_de , DoubleMatrix3D xx_des) { if (!netPlan.getLinksOversubscribed().isEmpty()) throw new Net2PlanException("Bad - Some link is oversubscribed (constraint violated)"); if (!netPlan.getDemandsBlocked().isEmpty()) throw new Net2PlanException("Bad - Some demand is blocked (constraint violated)"); for (SharedRiskGroup srg : netPlan.getSRGs()) { NetPlan npThis = netPlan.copy (); npThis.removeAllUnicastRoutingInformation(); DoubleMatrix2D this_xxde = xx_des.viewColumn (srg.getIndex ()).copy (); for (Link e : srg.getAffectedLinksAllLayers()) if (this_xxde.viewColumn(e.getIndex ()).zSum () != 0) throw new Net2PlanException("Bad - some failing links carry traffic"); npThis.setRoutingFromDemandLinkCarriedTraffic(this_xxde , true , false , null); if (!npThis.getLinksOversubscribed().isEmpty()) throw new Net2PlanException("Bad - Some link is oversubscribed (constraint violated) in a failure"); if (!npThis.getDemandsBlocked().isEmpty()) throw new Net2PlanException("Bad - Some demand is blocked (constraint violated) in a failure"); for (Demand d : netPlan.getDemands ()) { IntArrayList es_noFailure = new IntArrayList (); xx_de.viewRow (d.getIndex ()).getNonZeros(es_noFailure , new DoubleArrayList ()); boolean affectedByThisFailure = false; for (Link e : srg.getAffectedLinksAllLayers()) if (xx_de.get(d.getIndex() , e.getIndex ()) != 0) { affectedByThisFailure = true; break; } if (!affectedByThisFailure) { IntArrayList es_thisFailure = new IntArrayList (); this_xxde.viewRow (d.getIndex ()).getNonZeros(es_thisFailure , new DoubleArrayList ()); if (!es_noFailure.equals(es_thisFailure)) throw new Net2PlanException("Routing cannot change when a demand is not affected by the failure"); } } } } }
/** <p>Given a list of Network Element, it computes the node-network element incoming incidence matrix. This is a matrix with as many rows as nodes, and as many columns as network elements. Position (<i>n</i>, <i>e</i>) has a 1 if element <i>e</i> (<i>e = 0</i> refers to the first element n {@code elements}, <i>e = 1</i> refers to the second one, and so on) is terminated in node <i>n</i> (<i>n = 0</i> refers to the first node in {@code nodes}, <i>n = 1</i> refers to the second one, and so on), and 0 otherwise.</p> * * @param nodes List of nodes * @param elements List of Network Elements * @return Node-link incoming incidence matrix * @see com.net2plan.interfaces.networkDesign.NetworkLayer */ public static DoubleMatrix2D getIncomingIncidenceMatrix(List<Node> nodes, List<? extends NetworkElement> elements) { int N = nodes.size(); int E = elements.size(); DoubleMatrix2D A_ne = DoubleFactory2D.sparse.make(N, E); for (NetworkElement o : elements) if (o instanceof Link) { Link e = (Link) o; A_ne.set(e.getDestinationNode().getIndex(), e.getIndex(), 1); } else if (o instanceof Demand) { Demand e = (Demand) o; A_ne.set(e.getEgressNode().getIndex(), e.getIndex(), 1); } else if (o instanceof Route) { Route e = (Route) o; A_ne.set(e.getEgressNode().getIndex(), e.getIndex(), 1); } else throw new Net2PlanException("Error making the matrix"); return A_ne; }
/** <p>Given a list of Network elements, it computes the node-network element outgoing incidence matrix. This is a matrix with as many rows as nodes, and as many columns as elements. Position (<i>n</i>, <i>e</i>) has a 1 if element <i>e</i> (<i>e = 0</i> refers to the first element, <i>e = 1</i> refers to the second one, and so on) is initiated in node <i>n</i> (<i>n = 0</i> refers to the first node , <i>n = 1</i> refers to the second one, and so on), and 0 otherwise.</p> * * @param nodes List of nodes * @param elements List of elements * @return Node-link outgoing incidence matrix * @see com.net2plan.interfaces.networkDesign.NetworkElement */ public static DoubleMatrix2D getOutgoingIncidenceMatrix(List<Node> nodes, List<? extends NetworkElement> elements) { int N = nodes.size(); int E = elements.size(); DoubleMatrix2D A_ne = DoubleFactory2D.sparse.make(N, E); for (NetworkElement o : elements) if (o instanceof Link) { Link e = (Link) o; A_ne.set(e.getOriginNode().getIndex(), e.getIndex(), 1); } else if (o instanceof Demand) { Demand e = (Demand) o; A_ne.set(e.getIngressNode().getIndex(), e.getIndex(), 1); } else if (o instanceof Route) { Route e = (Route) o; A_ne.set(e.getIngressNode().getIndex(), e.getIndex(), 1); } else throw new Net2PlanException("Error making the matrix"); return A_ne; }
final int type = (int) this.demandType.get(d.getIndex()); final List<Link> seqLinks = d.getRoutes ().iterator().next().getSeqLinks(); for (Link e : seqLinks)
/** <p>Given a list of Network Elements, it computes the node-network element incidence matrix. This is a matrix with as many rows as nodes, and as many columns as elements. Position (<i>n</i>, <i>e</i>) has a 1 if element <i>e</i> (<i>e = 0</i> refers to the first element}, <i>e = 1</i> refers to the second one, and so on) is initiated in node <i>n</i> (<i>n = 0</i> refers to the first node , <i>n = 1</i> refers to the second one, and so on), -1 if it ends in node n, and 0 otherwise.</p> * @param nodes List of nodes * @param elements List of elements * @return Incidence matrix * @see com.net2plan.interfaces.networkDesign.NetworkLayer */ public static DoubleMatrix2D getIncidenceMatrix(List<Node> nodes, List<? extends NetworkElement> elements) { int N = nodes.size(); int E = elements.size(); DoubleMatrix2D A_ne = DoubleFactory2D.sparse.make(N, E); for (NetworkElement o : elements) if (o instanceof Link) { Link e = (Link) o; A_ne.set(e.getOriginNode().getIndex(), e.getIndex(), 1); A_ne.set(e.getDestinationNode().getIndex(), e.getIndex(), -1); } else if (o instanceof Demand) { Demand e = (Demand) o; A_ne.set(e.getIngressNode().getIndex(), e.getIndex(), 1); A_ne.set(e.getEgressNode().getIndex(), e.getIndex(), -1); } else if (o instanceof Route) { Route e = (Route) o; A_ne.set(e.getIngressNode().getIndex(), e.getIndex(), 1); A_ne.set(e.getEgressNode().getIndex(), e.getIndex(), -1); } else throw new Net2PlanException("Error making the matrix"); return A_ne; }
private void updateDemandRoutingFromWeightsKnown (Demand d) { final Node a_d = d.getIngressNode(); final double h_d = d.getOfferedTraffic(); final DoubleMatrix1D weightsKnown_e = this.routing_mostUpdatedLinkPriceKnownByNode_ne.viewRow(a_d.getIndex ()); DoubleMatrix1D a_k = DoubleFactory1D.dense.make (R); for (Route r : d.getRoutes()) { double val = 0; for (Link e : r.getSeqLinks()) val += weightsKnown_e.get(e.getIndex()) + 1; a_k.set(r.getIndex (), val); } DoubleMatrix1D x_r = GradientProjectionUtils.regularizedProjection_sumEquality (a_k , control_routeIndexes_d [d.getIndex ()] , null , h_d , this.gradient_regularizationEpsilon.getDouble()); for (Route r : d.getRoutes ()) r.setCarriedTraffic(x_r.get(r.getIndex ()) , x_r.get(r.getIndex ())); }