/** * <p>Returns the <i>N</i>x<i>N</i> Euclidean distance matrix (derived * from node coordinates), where <i>N</i> is the number of nodes within the network.</p> * * @return The Euclidean distance matrix */ public DoubleMatrix2D getMatrixNode2NodeEuclideanDistance() { int N = nodes.size(); DoubleMatrix2D out = DoubleFactory2D.dense.make(N, N); for (Node node_1 : nodes) { for (Node node_2 : nodes) { if (node_1.index >= node_2.index) continue; double physicalDistance = getNodePairEuclideanDistance(node_1, node_2); out.setQuick(node_1.index, node_2.index, physicalDistance); out.setQuick(node_2.index, node_1.index, physicalDistance); } } return out; }
long destinationNodeId = nodeName2Id.get(data[2]); Node destinationNode = netPlan.getNodeFromId (destinationNodeId); double capacity = Double.parseDouble(data[3]); double lengthInKm = isEuclidean ? netPlan.getNodePairEuclideanDistance(originNode, destinationNode) : netPlan.getNodePairHaversineDistanceInKm(originNode, destinationNode); SortedMap<String, String> attributeMap = new TreeMap<String, String>(); attributeMap.put("name", name);
final double distance_km = netPlan.getNodePairEuclideanDistance(a_e, b_ep); double attenuation_nu = ((e == ep)? 1 : interferenceAttenuationFactor_nu); if (a_e != b_ep) attenuation_nu *= Math.pow (distance_km , pathLossExponent);
Link addLink(Long linkId, Node originNode, Node destinationNode, double capacity, double lengthInKm, double propagationSpeedInKmPerSecond, Map<String, String> attributes, NetworkLayer... optionalLayerParameter) { capacity = NetPlan.adjustToTolerance(capacity); checkIsModifiable(); NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); checkInThisNetPlan(originNode); checkInThisNetPlan(destinationNode); if (originNode.equals(destinationNode)) throw new Net2PlanException("Self-links are not allowed"); if (capacity < 0) throw new Net2PlanException("Link capacity must be non-negative"); if (lengthInKm < 0) lengthInKm = getNodePairEuclideanDistance(originNode, destinationNode); if (propagationSpeedInKmPerSecond <= 0) throw new Net2PlanException("Propagation speed must be positive"); if (linkId == null) { linkId = nextElementId.longValue(); nextElementId.increment(); } Link link = new Link(this, linkId, layer.links.size(), layer, originNode, destinationNode, lengthInKm, propagationSpeedInKmPerSecond, capacity, new AttributeMap(attributes)); cache_id2LinkMap.put(linkId, link); layer.links.add(link); originNode.cache_nodeOutgoingLinks.add(link); destinationNode.cache_nodeIncomingLinks.add(link); SortedSet<Link> setLinksNodePair = layer.cache_nodePairLinksThisLayer.get(Pair.of(originNode, destinationNode)); if (setLinksNodePair == null) { setLinksNodePair = new TreeSet<> (); layer.cache_nodePairLinksThisLayer.put(Pair.of(originNode, destinationNode) , setLinksNodePair); } setLinksNodePair.add(link); if (ErrorHandling.isDebugEnabled()) this.checkCachesConsistency(); return link; }
final double distance = euclideanDistance.isSelected() ? netPlan.getNodePairEuclideanDistance(filteredNodes.get(i), filteredNodes.get(j)) : netPlan.getNodePairHaversineDistanceInKm(filteredNodes.get(i), filteredNodes.get(j)); distanceMatrix.set(i, j, distance);
/** * <p>Creates new links in the given layer, from the demand ingress node to each one of the demand egress nodes, and couples these newly created links to the multicast demand.</p> * @param newLinkLayer The layer where the new links will be created * @return The set of created links, already coupled to the demand */ public SortedSet<Link> coupleToNewLinksCreated (NetworkLayer newLinkLayer) { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); newLinkLayer.checkAttachedToNetPlanObject(this.netPlan); if (this.layer.equals (newLinkLayer)) throw new Net2PlanException ("Cannot couple a link and a demand in the same layer"); if (isCoupled()) throw new Net2PlanException ("The multicast demand is already coupled"); SortedSet<Link> newLinks = new TreeSet<Link> (); try { for (Node egressNode : egressNodes) { Link newLink = netPlan.addLink(ingressNode , egressNode , carriedTraffic , netPlan.getNodePairEuclideanDistance(ingressNode , egressNode) , 200000 , null , newLinkLayer); newLinks.add (newLink); } couple (newLinks); } catch (Exception e) { for (Link link : newLinks) link.remove (); throw e; } if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return newLinks; }
getSelectedElements().stream().filter(ee->!ee.isCoupled()).forEach(ee->ee.setLengthInKm(np.getNodePairEuclideanDistance(ee.getOriginNode(), ee.getDestinationNode()))); } , (a,b)->b>0, null));
/** * <p>Creates a new link in the given layer with same end nodes, and couples it to this demand.</p> * @param newLinkLayer Layer where the link will be created. * @return The new created link */ public Link coupleToNewLinkCreated (NetworkLayer newLinkLayer) { netPlan.checkIsModifiable(); checkAttachedToNetPlanObject(); newLinkLayer.checkAttachedToNetPlanObject(this.netPlan); if (isCoupled()) throw new Net2PlanException ("The demand is already coupled"); Link newLink = null; try { newLink = netPlan.addLink(ingressNode , egressNode , carriedTraffic , netPlan.getNodePairEuclideanDistance(ingressNode , egressNode) , 200000 , null , newLinkLayer); coupleToUpperOrSameLayerLink(newLink); } catch (Exception e) { if (newLink != null) newLink.remove (); throw e; } if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return newLink; }
public void create() { assert callback != null; NetPlan netPlan = callback.getDesign(); // Ask for current element removal if (netPlan.hasLinks(table.getTableNetworkLayer ())) { final int answer = JOptionPane.showConfirmDialog(null, "Remove all existing links?", "", JOptionPane.YES_NO_CANCEL_OPTION); if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.CLOSED_OPTION) return; if (answer == JOptionPane.OK_OPTION) netPlan.removeAllLinks(table.getTableNetworkLayer ()); } for (long nodeId_1 : netPlan.getNodeIds()) { for (long nodeId_2 : netPlan.getNodeIds()) { if (nodeId_1 >= nodeId_2) continue; Node n1 = netPlan.getNodeFromId(nodeId_1); Node n2 = netPlan.getNodeFromId(nodeId_2); Pair<Link, Link> out = netPlan.addLinkBidirectional(n1, n2, 0, euclidean ? netPlan.getNodePairEuclideanDistance(n1, n2) : netPlan.getNodePairHaversineDistanceInKm(n1, n2), 200000, null); } } callback.getVisualizationState().recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(); callback.addNetPlanChange(); }
if (nodePairLinks.size() > 1) nodePairLinks.forEach(e->e.remove()); if (nodePairLinks.isEmpty()) netPlan.addLink(origin, dc, defaultLinkCapacityInTraversableGoods.getDouble(), netPlan.getNodePairEuclideanDistance(origin, dc), 90.0/3600, null); if (nodePairLinks.size() > 1) nodePairLinks.forEach(e->e.remove()); if (nodePairLinks.isEmpty() && !forbidRoutesNotTraversingADistributionCenter.getBoolean()) netPlan.addLink(origin, dest, defaultLinkCapacityInTraversableGoods.getDouble(), netPlan.getNodePairEuclideanDistance(origin, dest), 90.0/3600, null); if (nodePairLinks.size() > 1) nodePairLinks.forEach(e->e.remove()); if (nodePairLinks.isEmpty()) netPlan.addLink(dc, dest, defaultLinkCapacityInTraversableGoods.getDouble(), netPlan.getNodePairEuclideanDistance(dc, dest), 90.0/3600, null);
for (Node n1 : netPlan.getNodes()) for (Node n2 : netPlan.getNodes()) if (n1 != n2) netPlan.addLink(n1, n2, 0.01, netPlan.getNodePairEuclideanDistance(n1, n2), 200000 , null); final double linkLengthKmFromEuclideanDistanceFactor = tcfa_networkDiameterKmToNormalize.getDouble() / netPlan.getVectorLinkLengthInKm().getMaxLocation() [0]; for (Link e : netPlan.getLinks()) e.setLengthInKm(e.getLengthInKm() * linkLengthKmFromEuclideanDistanceFactor);
for (Node i : netPlan.getNodes ()) for (Node j : netPlan.getNodes ()) if (i.getId () > j.getId ()) netPlan.addLinkBidirectional(i, j, 1.0 , netPlan.getNodePairEuclideanDistance(i, j), linkPropagationSpeedInKmPerSecond.getDouble() , null);
final Link link = netPlan.addLink (i, j,0 , netPlan.getNodePairEuclideanDistance(i, j), 200000 , null , upperLayer); final Demand demand = netPlan.addDemand(i, j, 0, RoutingType.HOP_BY_HOP_ROUTING , null,lowerLayer); if (link.getIndex() != demand.getIndex()) throw new RuntimeException ("Bad");
c_a [e] = linkInfo [2]; q_a [e] = linkInfo [3]; final Link link = netPlan.addLink(s , t , q_a [e] , netPlan.getNodePairEuclideanDistance(s,t) , 50 , null); priorFlow_a [e] = linkInfo [4]; link.setAttribute(UtnConstants.ATTRNAME_C0A , "" + c_a [e]);