private List<Triple<String,String,String>> getLayerInfoTables (NetworkLayer layer) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = layer.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String capUnits = np.getLinkCapacityUnitsName(layer); final String trafUnits = np.getDemandTrafficUnitsName(layer); res.add(Triple.of("Layer index/id" , "Layer " + layer.getIndex() + " (id " + layer.getId() + ")", "layer" + layer.getId())); res.add(Triple.of("Name" , layer.getName().equals("")? "No name" : layer.getName(), "")); res.add(Triple.of("Description" , layer.getDescription().equals("")? "No description" : layer.getDescription(), "")); res.add(Triple.of("Demand traffic units" , trafUnits.equals("")? "Not specified" : trafUnits, "")); res.add(Triple.of("Link capacity units" , capUnits.equals("")? "Not specified" : capUnits, "")); final double totalOccupiedCap = np.getLinks(layer).stream().mapToDouble(e->e.getOccupiedCapacity()).sum(); final double totalCap = np.getLinks(layer).stream().mapToDouble(e->e.getCapacity()).sum(); final double totalOfferedTrac = np.getDemands(layer).stream().mapToDouble(e->e.getOfferedTraffic()).sum(); final double totalCarriedTrac = np.getDemands(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum(); final double totalOffMultTraffic = np.getMulticastDemands(layer).stream().mapToDouble(e->e.getOfferedTraffic()).sum(); final double totalCarMultTraffic = np.getMulticastDemands(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum(); res.add(Triple.of("# links (total occupied / capacity)", "" + np.getNumberOfLinks(layer) + " (" + df.format(totalOccupiedCap) + " / " + df.format(totalCap) + ") " + capUnits + ")" , "")); res.add(Triple.of("# demands (total carried / offered)", "" + np.getNumberOfDemands(layer) + " (" + df.format(totalCarriedTrac) + " / " + df.format(totalOfferedTrac) + ") " + trafUnits, "")); res.add(Triple.of("# routes", "" + np.getNumberOfRoutes(layer) , "")); res.add(Triple.of("# forwarding rules", "" + np.getNumberOfForwardingRules(layer) , "")); res.add(Triple.of("# multicast demands (total carried / offered)", "" + np.getNumberOfMulticastDemands(layer) + " (" + df.format(totalCarMultTraffic) + " / " + df.format(totalOffMultTraffic) + ") " + trafUnits, "")); res.add(Triple.of("# multicast trees", "" + np.getNumberOfMulticastTrees(layer) , "")); return res; } private List<Triple<String,String,String>> getNodeInfoTables (Node n , NetworkLayer layer)
if (npNoFailure.getNumberOfDemands(noFailureLayer) != 0)
newLayer2RoutingTypeMap.put(mapOldId2Layer.get(layerId), RoutingType.HOP_BY_HOP_ROUTING); final NetworkLayer layer = mapOldId2Layer.get(layerId); final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); DoubleMatrix2D f_de = DoubleFactory2D.sparse.make (D,E);
final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); DoubleMatrix2D f_de = DoubleFactory2D.sparse.make (D,E);
private void loadTrafficMatrices(File[] files, Collection<NetPlan> netPlans) { List<DoubleMatrix2D> trafficMatrices_theseFiles = new LinkedList<DoubleMatrix2D>(); int i = 0; for (NetPlan netPlan : netPlans) { int D = netPlan.getNumberOfDemands(); if (D == 0) throw new Net2PlanException("File " + files[i] + " does not contain any demand"); DoubleMatrix2D trafficMatrix = netPlan.getMatrixNode2NodeOfferedTraffic(); trafficMatrices_theseFiles.add(trafficMatrix); i++; } int removeExistingMatrices = askForRemovingExistingMatrices(); if (removeExistingMatrices == JOptionPane.CLOSED_OPTION) return; else if (removeExistingMatrices == JOptionPane.YES_OPTION) removeAllMatrices(); int firstMatrixId = -1; i = 0; for (DoubleMatrix2D trafficMatrix : trafficMatrices_theseFiles) { int N = trafficMatrix.rows(); int matrixId = addTrafficMatrix(N); if (i == 0) firstMatrixId = matrixId; setTrafficMatrix(trafficMatrix, getNumberOfTrafficMatrices() - 1); i++; } tabbedPane.setSelectedIndex(firstMatrixId); }
private void parseHopByHopRouting(NetPlan netPlan, long layerId) throws XMLStreamException final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); DoubleMatrix2D f_de = DoubleFactory2D.sparse.make (D,E);
@Override public List<AjtColumnInfo<NetworkLayer>> getNonBasicUserDefinedColumnsVisibleOrNot() { final List<AjtColumnInfo<NetworkLayer>> res = new LinkedList<> (); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Name", "Layer name", (d,val)->d.setName((String)val) , d->d.getName() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Description", "Layer description", (d,val)->d.setDescription((String)val) , d->d.getDescription() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Link capacity units", "Name of the capacity units of the links", (d,val)->d.getNetPlan().setLinkCapacityUnitsName((String)val, d) , d->d.getLinkCapacityUnits() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , String.class, null , "Demand traffic units", "Name of the traffic units of the demands", (d,val)->d.getNetPlan().setDemandTrafficUnitsName((String)val, d) , d->d.getDemandTrafficUnits() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# links", "Number of links", null , d->d.getNetPlan().getNumberOfLinks(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# demands", "Number of demands", null , d->d.getNetPlan().getNumberOfDemands(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# multicast demands", "Number of multicast demands", null , d->d.getNetPlan().getNumberOfMulticastDemands(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# routes", "Number of routes", null , d->d.getNetPlan().getNumberOfRoutes(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# forw. rules", "Number of forwarding rules", null , d->d.getNetPlan().getNumberOfForwardingRules(d) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<NetworkLayer>(this , Integer.class, null , "# multicast trees", "Number of multicast trees", null , d->d.getNetPlan().getNumberOfMulticastTrees(d) , AGTYPE.NOAGGREGATION , null)); return res; }
netPlan.setRoutingTypeAllDemands (RoutingType.HOP_BY_HOP_ROUTING , netPlan.getNetworkLayerFromId(layerId) ); final NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); DoubleMatrix2D f_de = DoubleFactory2D.sparse.make (D,E);
/** 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; }
this.D = currentNetPlan.getNumberOfDemands (); this.E = currentNetPlan.getNumberOfLinks (); this.N = currentNetPlan.getNumberOfNodes ();
this.E = currentNetPlan.getNumberOfLinks(); this.N = currentNetPlan.getNumberOfNodes(); this.D = currentNetPlan.getNumberOfDemands();
this.D = this.currentNetPlan.getNumberOfDemands(); if ((E == 0) || (D == 0)) throw new Net2PlanException ("The input design should have links and demands");
int N = netPlan.getNumberOfNodes(); int E = netPlan.getNumberOfLinks(); int D = netPlan.getNumberOfDemands(); if (N == 0 || E == 0 || D == 0) throw new Net2PlanException("A physical topology (nodes and links) and a demand set are required");
private Pair<NetPlan,double[][]> computeOptimumSolution () final int D = this.currentNetPlan.getNumberOfDemands(); final int E = this.currentNetPlan.getNumberOfLinks(); final DoubleMatrix1D u_e = this.currentNetPlan.getVectorLinkCapacity();
this.E = currentNetPlan.getNumberOfLinks(); this.N = currentNetPlan.getNumberOfNodes(); this.D = currentNetPlan.getNumberOfDemands();
this.control_epsilonOrMuFactor = control_isBarrierMethod? gradient_interiorPenaltyEpsilonFactor.getDouble() : gradient_exteriorPenaltyMuFactor.getDouble(); this.rng = new Random (simulation_randomSeed.getLong()); this.D = currentNetPlan.getNumberOfDemands (); this.E = currentNetPlan.getNumberOfLinks (); if ((E == 0) || (D == 0)) throw new Net2PlanException ("The input design should have links and demands");
private Pair<NetPlan,double [][]> computeOptimumSolution (boolean xdeVariablesAsFractionsOfTraffic) final int D = this.currentNetPlan.getNumberOfDemands(); final int E = this.currentNetPlan.getNumberOfLinks(); final DoubleMatrix1D h_d = this.currentNetPlan.getVectorDemandOfferedTraffic();
private Triple<DoubleMatrix1D,DoubleMatrix1D,Double> computeOptimumSolution () { /* Modify the map so that it is the pojection where all elements sum h_d, and are non-negative */ final int D = this.currentNetPlan.getNumberOfDemands(); OptimizationProblem op = new OptimizationProblem(); /* Add the decision variables to the problem */ op.addDecisionVariable("h_d", false, new int[] {1, D}, control_minHd.getDouble(), control_maxHd.getDouble()); /* Set some input parameters */ op.setInputParameter("u_e", currentNetPlan.getVectorLinkCapacity() , "row"); op.setInputParameter("alpha", control_fairnessFactor.getDouble()); op.setInputParameter("R_de", currentNetPlan.getMatrixDemand2LinkAssignment()); /* Sets the objective function */ if (control_fairnessFactor.getDouble() == 1) op.setObjectiveFunction("maximize", "sum(ln(h_d))"); else if (control_fairnessFactor.getDouble() == 0) op.setObjectiveFunction("maximize", "sum(h_d)"); else op.setObjectiveFunction("maximize", "(1-alpha) * sum(h_d ^ (1-alpha))"); op.addConstraint("h_d * R_de <= u_e" , "pi_e"); // the capacity constraints (E constraints) /* Call the solver to solve the problem */ op.solve("ipopt"); /* If an optimal solution was not found, quit */ if (!op.solutionIsOptimal()) throw new Net2PlanException("An optimal solution was not found"); /* Retrieve the optimum solutions */ DoubleMatrix1D h_d = op.getPrimalSolution("h_d").view1D (); DoubleMatrix1D pi_e = op.getMultipliersOfConstraint("pi_e").assign(DoubleFunctions.abs).view1D (); return Triple.of(h_d,pi_e,NetworkPerformanceMetrics.alphaUtility(currentNetPlan.getVectorDemandOfferedTraffic() , control_fairnessFactor.getDouble())); }
int N = netPlan.getNumberOfNodes(); int E = netPlan.getNumberOfLinks(); int D = netPlan.getNumberOfDemands(); if (N == 0 || E == 0 || D == 0) throw new Net2PlanException("A physical topology (nodes and links) and a demand set are required");
"</td><td>" + valString(totalTrafficOfDemandsWithExcessiveWorseCaseLatency) + percentage(totalTrafficOfDemandsWithExcessiveWorseCaseLatency,totalOfferedTraffic) + "</td><td>" + valString(totalBlockedConsideringUserDefinedExtraLimitations) + percentage(totalBlockedConsideringUserDefinedExtraLimitations,totalOfferedTraffic) + "</td><td>" + percentage(numberOfDemandsWithoutBlocking,unicastDemands? np.getNumberOfDemands (layer) : np.getNumberOfMulticastDemands (layer)) + "</td></tr>");