当前位置: 首页>>代码示例>>Java>>正文


Java NodeLinkAssignation.vnm方法代码示例

本文整理汇总了Java中vnreal.algorithms.utils.NodeLinkAssignation.vnm方法的典型用法代码示例。如果您正苦于以下问题:Java NodeLinkAssignation.vnm方法的具体用法?Java NodeLinkAssignation.vnm怎么用?Java NodeLinkAssignation.vnm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vnreal.algorithms.utils.NodeLinkAssignation的用法示例。


在下文中一共展示了NodeLinkAssignation.vnm方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performNodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * This method performs the node mapping taking into account the solver
 * response in the variable x (containing the optimal node mapping)
 * 
 * @param vNet
 * @param x
 * @return boolean value indicating whether the node mapping has been
 *         successful
 */
private boolean performNodeMapping(SubstrateNetwork sNet, VirtualNetwork vNet,
		Map<List<String>, Double> x) {
	List<String> tmpValues;
	VirtualNode currVnode;
	SubstrateNode currSnode;
	for (Iterator<List<String>> cad = x.keySet().iterator(); cad.hasNext();) {
		tmpValues = cad.next();
		if (x.get(tmpValues) == 1) {
			currVnode = getVnodeById(vNet,
					Integer.parseInt(tmpValues.get(0)));
			currSnode = getSnodeById(sNet, Integer.parseInt(tmpValues.get(1)));
			if (NodeLinkAssignation.vnm(currVnode, currSnode)) {
				if (!nodeMapping.containsKey(currVnode))
					nodeMapping.put(currVnode, currSnode);
			} else {
				throw new AssertionError(
						"Implementation mistake MIP model checks");
			}
		}
	}
	return true;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:32,代码来源:OptimalEnergyMappingHiddenHop.java

示例2: mapNode

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * This Method tries to map the given {@link VirtualNode} on given {@link SubstrateNode}
 * @param vn {@link VirtualNode}
 * @param sn {@link SubstrateNode}
 * @return true if mapping ok, false otherwise
 */
private boolean mapNode(VirtualNode vn,  SubstrateNode sn) {
	//Check if the Node is still available for mapping
	if(!isAvailable(sn))
		return false; //Mapping not possible
	
	//Try map it
	if(!NodeLinkAssignation.vnm(vn, sn))
		return false; //Mapping failed or not possible
	
	//If Mapping is successfull
	//System.out.println(vn+":"+MLSUtils.getMLSDemand(vn));
	//System.out.println(sn+":"+MLSUtils.getMLSResource(sn));
	nodeMapping.put(vn, sn); //Add it to the mappinglist
	incrementCounter(sn);
	
	return true;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:24,代码来源:MlsNodeMapping_BestFit.java

示例3: mapNode

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * This Method tries to map the given {@link VirtualNode} on given {@link SubstrateNode}
 * @param vn {@link VirtualNode}
 * @param sn {@link SubstrateNode}
 * @return true if mapping ok, false otherwise
 */
private boolean mapNode(VirtualNode vn,  SubstrateNode sn) {
	//Check if the Node is still available for mapping
	if(!isAvailable(sn))
		return false; //Mapping not possible
	
	//Try map it
	if(!NodeLinkAssignation.vnm(vn, sn)) 
		return false; //Mapping failed or not possible
	
	if(flexNodes.contains(vn)) {
		count_flexibilty++;
		System.out.println("Mapped("+this.phase+") VNode "+vn+" on SNode "+sn+" with felexibility.");
	}
	//If Mapping is successfull
	//System.out.println(vn+":"+MLSUtils.getMLSDemand(vn));
	//System.out.println(sn+":"+MLSUtils.getMLSResource(sn));
	nodeMapping.put(vn, sn); //Add it to the mappinglist
	incrementCounter(sn);
	
	return true;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:28,代码来源:MlsNodeMapping_BestFit_Lower.java

示例4: performNodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * This method performs the node mapping taking into account the solver
 * response in the variable x (containing the optimal node mapping)
 * 
 * @param vNet
 * @param x
 * @return boolean value indicating whether the node mapping has been
 *         successful
 */
private boolean performNodeMapping(VirtualNetwork vNet,
		Map<List<String>, Double> x) {
	List<String> tmpValues;
	VirtualNode currVnode;
	SubstrateNode currSnode;
	for (Iterator<List<String>> cad = x.keySet().iterator(); cad.hasNext();) {
		tmpValues = cad.next();
		if (x.get(tmpValues) == 1) {
			currVnode = getVnodeById(vNet,
					Integer.parseInt(tmpValues.get(0)));
			currSnode = getSnodeById(Integer.parseInt(tmpValues.get(1)));
			if (NodeLinkAssignation.vnm(currVnode, currSnode)) {
				if (!nodeMapping.containsKey(currVnode))
					nodeMapping.put(currVnode, currSnode);
			} else {
				throw new AssertionError(
						"Implementation mistake MIP model checks");
			}
		}
	}
	return true;
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:32,代码来源:OptimalEnergyMappingHiddenHop.java

示例5: match

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * Match function (see Algorithm 5).
 * X. Cheng, S. Su, Z. Zhang, H. Wang, F. Yang, Y. Luo, J. Wang, Virtual network embedding 
 * through topology-aware node ranking, SIGCOMM Comput. Commun. Rev. 41 (2011) 38--47.
 * 
 * @param vNet
 * @param vNode
 * @param candidates
 * @return a boolean value indicating whether the virtual node could be mapped 
 * or not 
 */
private boolean match(SubstrateNetwork sNet, VirtualNetwork vNet, VirtualNode vNode,
		List<SubstrateNode> candidates) {
	Iterator<Node<?>> tempIt = SortedNodeNR_i_opt_virt.keySet().iterator();
	List<SubstrateNode> tempCandiNodes = null;

	if (((VirtualNode) tempIt.next()).equals(vNode)) {
		if (NodeLinkAssignation.vnm(vNode, candidates.iterator().next())) {
			nodeMapping.put(vNode, candidates.iterator().next());
			return true;
		} else {
			throw new AssertionError("But we checked before!");
		}
	}
	GenericTreeNode<Node<?>> tempNode = bfsTree.find(vNode);
	VirtualNode parentNode = (VirtualNode) tempNode.getParent().getData();

	for (int tmpK = 1; tmpK < k + 1; tmpK++) {
		DijkstraDistance<SubstrateNode, SubstrateLink> distanceGraph = new DijkstraDistance<SubstrateNode, SubstrateLink>(
				sNet, new SubstrateLinkSingleTransformer(), false);
		distanceGraph.setMaxDistance(tmpK);
		Map<SubstrateNode, Number> orderedMappedCandidates = distanceGraph
				.getDistanceMap(nodeMapping.get(parentNode));
		tempCandiNodes = new LinkedList<SubstrateNode>(
				orderedMappedCandidates.keySet());
		candidates = new LinkedList<SubstrateNode>();

		if (!orderedMappedCandidates.isEmpty()) {
			if (withDist) {
				if (!nodeOverload) {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, dist, nodeMapping);
				} else {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, dist);
				}

			} else {
				if (!nodeOverload) {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, nodeMapping);
				} else {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes);
				}
			}
			for (SubstrateNode sCorrNode : candidates) {
				if (MapPathsWithMappedNodes(sNet, vNet, vNode, sCorrNode)) {
					if (!NodeLinkAssignation.vnm(vNode, sCorrNode)) {
						throw new AssertionError("But we checked before!");
					} else {
						nodeMapping.put(vNode, sCorrNode);
						return true;
					}
				} else {
					MiscelFunctions.clearVnodeMappings(vNet, vNode);
				}
			}
		}
	}
	return false;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:73,代码来源:BFSNRCoordinatedMapping.java

示例6: nodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * Node mapping method implementation
 */
@Override
protected boolean nodeMapping(SubstrateNetwork sNet, VirtualNetwork vNet) {
	List<SubstrateNode> unmappedSnodes = super.getUnmappedsNodes();
	List<SubstrateNode> allNodes = new LinkedList<SubstrateNode>(
			sNet.getVertices());
	SubstrateNode mappedSnode = null;

	VirtualNode currVnode;
	List<SubstrateNode> candidates = new LinkedList<SubstrateNode>();

	// Move through the virtual nodes
	for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
			.hasNext();) {
		currVnode = itt.next();
		// Find the candidate substrate nodes accomplishing the virtual node
		// demands
		for (AbstractDemand dem : currVnode) {
			if (dem instanceof CpuDemand) {
				if (!nodeOverload) {
					if (distance < 0) {
						candidates = findFulfillingNodes(dem,
								unmappedSnodes);
					} else {
						candidates = findFulfillingNodes(currVnode, dem,
								unmappedSnodes, distance);
					}
				} else {
					if (distance < 0) {
						candidates = findFulfillingNodes(dem, allNodes);
					} else {
						candidates = findFulfillingNodes(currVnode, dem,
								allNodes, distance);
					}
				}

			} else {
				continue;	// Ignore all demands other than CPU 
			}
			// Find the feasible node with greatest available resources
			// The available resources are the H value defined in the
			// "Rethinking virtual network embedding" paper

			mappedSnode = bestAvailableResources(sNet, candidates);
			if (mappedSnode != null) {
				// Realize the node mapping
				if (NodeLinkAssignation.vnm(currVnode, mappedSnode)) {
					nodeMapping.put(currVnode, mappedSnode);
				} else {
					// If this exception is thrown, it means that something
					// in the code is wrong. The feasibility of nodes is
					// checked in findFulfillingNodes

					throw new AssertionError("But we checked before!");
				}
			} else {
				// Mapping is not possible, not feasible nodes
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:66,代码来源:AvailableResourcesNodeMapping.java

示例7: nodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
@Override
protected boolean nodeMapping(SubstrateNetwork sNet, VirtualNetwork vNet) {
	/*
	 * Node ranking calculation for virtual and substrate network
	 * see (Algorithm 1 and 2)
	 * 
	 * X. Cheng, S. Su, Z. Zhang, H. Wang, F. Yang, Y. Luo, J. Wang, Virtual network embedding 
	 * through topology-aware node ranking, SIGCOMM Comput. Commun. Rev. 41 (2011) 38--47.
	 * 
	 */
	Map<Node<?>, Double> SortedNodeNR_i_opt_subs = MiscelFunctions
			.sortByValue(MiscelFunctions.create_NR(sNet, epsilon));
	Map<Node<?>, Double> SortedNodeNR_i_opt_virt = MiscelFunctions
			.sortByValue(MiscelFunctions.create_NR(vNet, epsilon));
	boolean mappingPerformed;

	for (Iterator<Node<?>> vNode = SortedNodeNR_i_opt_virt.keySet()
			.iterator(); vNode.hasNext();) {
		VirtualNode toMapvNode = (VirtualNode) vNode.next();
		mappingPerformed = false;
		if (!nodeMapping.containsKey(toMapvNode)) {
			for (Iterator<Node<?>> sNode = SortedNodeNR_i_opt_subs.keySet()
					.iterator(); sNode.hasNext();) {
				SubstrateNode candidateSnode = (SubstrateNode) sNode.next();
				if (!nodeMapping.containsValue(candidateSnode)) {
					if (dist >= 0) {
						if (NodeLinkAssignation.isMappable(toMapvNode,
								candidateSnode)
								&& MiscelFunctions.nodeDistance(toMapvNode,
										candidateSnode, dist)) {
							if (NodeLinkAssignation.vnm(toMapvNode,
									candidateSnode)) {
								nodeMapping.put(toMapvNode, candidateSnode);
								mappingPerformed = true;
							} else {
								throw new AssertionError(
										"But we checked before!");
							}
						}
					} else {
						if (NodeLinkAssignation.isMappable(toMapvNode,
								candidateSnode)) {
							if (NodeLinkAssignation.vnm(toMapvNode,
									candidateSnode)) {
								nodeMapping.put(toMapvNode, candidateSnode);
								mappingPerformed = true;
								break;
							} else {
								throw new AssertionError(
										"But we checked before!");
							}
						}

					}
				}

			}
		} else {
			mappingPerformed = true;
		}

		if (!mappingPerformed)
			return false;

	}

	return true;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:69,代码来源:NodeRankingBasedAlgorithm.java

示例8: match

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
private boolean match(SubstrateNetwork sNet, VirtualNetwork vNet, VirtualNode vNode,
		List<SubstrateNode> candidates) {
	Iterator<Node<?>> tempIt = SortedNodeNR_i_opt_virt.keySet().iterator();
	List<SubstrateNode> tempCandiNodes = null;

	if (((VirtualNode) tempIt.next()).equals(vNode)) {
		if (NodeLinkAssignation.vnm(vNode, candidates.iterator().next())) {
			nodeMapping.put(vNode, candidates.iterator().next());
			return true;
		} else {
			throw new AssertionError("But we checked before!");
		}
	}
	GenericTreeNode<Node<?>> tempNode = bfsTree.find(vNode);
	VirtualNode parentNode = (VirtualNode) tempNode.getParent().getData();

	for (int tmpK = 1; tmpK < maxHop + 1; tmpK++) {
		DijkstraDistance<SubstrateNode, SubstrateLink> distanceGraph = new DijkstraDistance<SubstrateNode, SubstrateLink>(
				sNet, new SubstrateLinkSingleTransformer(), false);
		distanceGraph.setMaxDistance(tmpK);
		Map<SubstrateNode, Number> orderedMappedCandidates = distanceGraph
				.getDistanceMap(nodeMapping.get(parentNode));
		tempCandiNodes = new LinkedList<SubstrateNode>(
				orderedMappedCandidates.keySet());
		candidates = new LinkedList<SubstrateNode>();
		
		if(!orderedMappedCandidates.isEmpty()){
			if (dist >= 0) {
				candidates = MiscelFunctions.findFulfillingNodes(vNode,
						tempCandiNodes, dist, nodeMapping);
			} else {
				candidates = MiscelFunctions.findFulfillingNodes(vNode,
						tempCandiNodes, nodeMapping);
			}
			for (SubstrateNode sCorrNode : candidates) {
				if (MapPathsWithMappedNodes(sNet, vNet, vNode, sCorrNode)) {
					if (!NodeLinkAssignation.vnm(vNode, sCorrNode)) {
						throw new AssertionError("But we checked before!");
					} else {
						nodeMapping.put(vNode, sCorrNode);
						return true;
					}
				} else {
					MiscelFunctions.clearVnodeMappings(vNet, vNode);
				}
			}
		}
	}
	return false;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:51,代码来源:BFSNRnodeMappingPathSplitting.java

示例9: nodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * Node mapping method implementation
 */
@Override
protected boolean nodeMapping(VirtualNetwork vNet) {
    List<SubstrateNode> unmappedSnodes = super.getUnmappedsNodes();
    List<SubstrateNode> allNodes = new LinkedList<SubstrateNode>(sNet
            .getVertices());
    SubstrateNode mappedSnode = null;

    VirtualNode currVnode;
    List<SubstrateNode> candidates = new LinkedList<SubstrateNode>();

    // Move through the virtual nodes
    for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
            .hasNext(); ) {
        currVnode = itt.next();
        // Find the candidate substrate nodes accomplishing the virtual node
        // demands
        for (AbstractDemand dem : currVnode) {
            if (dem instanceof CpuDemand) {
                if (!nodeOverload) {
                    if (!withDist) {
                        candidates = findFulfillingNodes(dem,
                                unmappedSnodes);
                    } else {
                        candidates = findFulfillingNodes(currVnode, dem,
                                unmappedSnodes, distance);
                    }
                } else {
                    if (!withDist) {
                        candidates = findFulfillingNodes(dem, allNodes);
                    } else {
                        candidates = findFulfillingNodes(currVnode, dem,
                                allNodes, distance);
                    }
                }

            }
            // Find the feasible node with greatest available resources
            // The available resources are the H value defined in the
            // "Rethinking virtual network embedding" paper

            mappedSnode = bestAvailableResources(candidates);
            if (mappedSnode != null) {
                // Realize the node mapping
                if (NodeLinkAssignation.vnm(currVnode, mappedSnode)) {
                    nodeMapping.put(currVnode, mappedSnode);
                } else {
                    // If this exception is thrown, it means that something
                    // in the code is wrong. The feasibility of nodes is
                    // checked in findFulfillingNodes

                    throw new AssertionError("But we checked before!");
                }
            } else {
                // Mapping is not possible, not feasible nodes
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:64,代码来源:AvailableResourcesNodeMapping.java

示例10: match

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * Match function (see Algorithm 5).
 * X. Cheng, S. Su, Z. Zhang, H. Wang, F. Yang, Y. Luo, J. Wang, Virtual network embedding 
 * through topology-aware node ranking, SIGCOMM Comput. Commun. Rev. 41 (2011) 38�47.
 * 
 * @param vNet
 * @param vNode
 * @param candidates
 * @return a boolean value indicating whether the virtual node could be mapped 
 * or not 
 */
private boolean match(VirtualNetwork vNet, VirtualNode vNode,
		List<SubstrateNode> candidates) {
	Iterator<Node<?>> tempIt = SortedNodeNR_i_opt_virt.keySet().iterator();
	List<SubstrateNode> tempCandiNodes = null;

	if (((VirtualNode) tempIt.next()).equals(vNode)) {
		if (NodeLinkAssignation.vnm(vNode, candidates.iterator().next())) {
			nodeMapping.put(vNode, candidates.iterator().next());
			return true;
		} else {
			throw new AssertionError("But we checked before!");
		}
	}
	GenericTreeNode<Node<?>> tempNode = bfsTree.find(vNode);
	VirtualNode parentNode = (VirtualNode) tempNode.getParent().getData();

	for (int tmpK = 1; tmpK < k + 1; tmpK++) {
		DijkstraDistance<SubstrateNode, SubstrateLink> distanceGraph = new DijkstraDistance<SubstrateNode, SubstrateLink>(
				sNet, new SubstrateLinkSingleTransformer(), false);
		distanceGraph.setMaxDistance(tmpK);
		Map<SubstrateNode, Number> orderedMappedCandidates = distanceGraph
				.getDistanceMap(nodeMapping.get(parentNode));
		tempCandiNodes = new LinkedList<SubstrateNode>(
				orderedMappedCandidates.keySet());
		candidates = new LinkedList<SubstrateNode>();

		if (!orderedMappedCandidates.isEmpty()) {
			if (withDist) {
				if (!nodeOverload) {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, dist, nodeMapping);
				} else {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, dist);
				}

			} else {
				if (!nodeOverload) {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes, nodeMapping);
				} else {
					candidates = MiscelFunctions.findFulfillingNodes(vNode,
							tempCandiNodes);
				}
			}
			for (SubstrateNode sCorrNode : candidates) {
				if (MapPathsWithMappedNodes(vNet, vNode, sCorrNode)) {
					if (!NodeLinkAssignation.vnm(vNode, sCorrNode)) {
						throw new AssertionError("But we checked before!");
					} else {
						nodeMapping.put(vNode, sCorrNode);
						return true;
					}
				} else {
					MiscelFunctions.clearVnodeMappings(vNet, vNode);
				}
			}
		}
	}
	return false;
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:73,代码来源:BFSNRCoordinatedMapping.java

示例11: nodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
/**
 * Node mapping method implementation
 */
@Override
protected boolean nodeMapping(VirtualNetwork vNet) {
	List<SubstrateNode> unmappedSnodes = super.getUnmappedsNodes();
	List<SubstrateNode> allNodes = new LinkedList<SubstrateNode>(
			sNet.getVertices());
	SubstrateNode mappedSnode = null;

	VirtualNode currVnode;
	List<SubstrateNode> candidates = new LinkedList<SubstrateNode>();

	// Move through the virtual nodes
	for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
			.hasNext();) {
		currVnode = itt.next();
		// Find the candidate substrate nodes accomplishing the virtual node
		// demands
		for (AbstractDemand dem : currVnode) {
			if (dem instanceof CpuDemand) {
				if (!nodeOverload) {
					if (!withDist) {
						candidates = findFulfillingNodes(dem,
								unmappedSnodes);
					} else {
						candidates = findFulfillingNodes(currVnode, dem,
								unmappedSnodes, distance);
					}
				} else {
					if (!withDist) {
						candidates = findFulfillingNodes(dem, allNodes);
					} else {
						candidates = findFulfillingNodes(currVnode, dem,
								allNodes, distance);
					}
				}

			}
			// Find the feasible node with greatest available resources
			// The available resources are the H value defined in the
			// "Rethinking virtual network embedding" paper

			mappedSnode = bestAvailableResources(candidates);
			if (mappedSnode != null) {
				// Realize the node mapping
				if (NodeLinkAssignation.vnm(currVnode, mappedSnode)) {
					nodeMapping.put(currVnode, mappedSnode);
				} else {
					// If this exception is thrown, it means that something
					// in the code is wrong. The feasibility of nodes is
					// checked in findFulfillingNodes

					throw new AssertionError("But we checked before!");
				}
			} else {
				// Mapping is not possible, not feasible nodes
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:64,代码来源:AvailableResourcesNodeMapping.java

示例12: nodeMapping

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean nodeMapping(VirtualNetwork vNet) {
	/*
	 * Node ranking calculation for virtual and substrate network
	 * see (Algorithm 1 and 2)
	 * 
	 * X. Cheng, S. Su, Z. Zhang, H. Wang, F. Yang, Y. Luo, J. Wang, Virtual network embedding 
	 * through topology-aware node ranking, SIGCOMM Comput. Commun. Rev. 41 (2011) 38�47.
	 * 
	 */
	Map<Node<?>, Double> SortedNodeNR_i_opt_subs = MiscelFunctions
			.sortByValue(MiscelFunctions.create_NR(sNet, epsilon));
	Map<Node<?>, Double> SortedNodeNR_i_opt_virt = MiscelFunctions
			.sortByValue(MiscelFunctions.create_NR(vNet, epsilon));
	boolean mappingPerformed;

	for (Iterator<Node<?>> vNode = SortedNodeNR_i_opt_virt.keySet()
			.iterator(); vNode.hasNext();) {
		VirtualNode toMapvNode = (VirtualNode) vNode.next();
		mappingPerformed = false;
		if (!nodeMapping.containsKey(toMapvNode)) {
			for (Iterator<Node<?>> sNode = SortedNodeNR_i_opt_subs.keySet()
					.iterator(); sNode.hasNext();) {
				SubstrateNode candidateSnode = (SubstrateNode) sNode.next();
				if (!nodeMapping.containsValue(candidateSnode)) {
					if (withDist) {
						if (NodeLinkAssignation.isMappable(toMapvNode,
								candidateSnode)
								&& MiscelFunctions.nodeDistance(toMapvNode,
										candidateSnode, dist)) {
							if (NodeLinkAssignation.vnm(toMapvNode,
									candidateSnode)) {
								nodeMapping.put(toMapvNode, candidateSnode);
								mappingPerformed = true;
							} else {
								throw new AssertionError(
										"But we checked before!");
							}
						}
					} else {
						if (NodeLinkAssignation.isMappable(toMapvNode,
								candidateSnode)) {
							if (NodeLinkAssignation.vnm(toMapvNode,
									candidateSnode)) {
								nodeMapping.put(toMapvNode, candidateSnode);
								mappingPerformed = true;
								break;
							} else {
								throw new AssertionError(
										"But we checked before!");
							}
						}

					}
				}

			}
		} else {
			mappingPerformed = true;
		}

		if (!mappingPerformed)
			return false;

	}

	return true;
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:70,代码来源:NodeRankingBasedAlgorithm.java

示例13: match

import vnreal.algorithms.utils.NodeLinkAssignation; //导入方法依赖的package包/类
private boolean match(VirtualNetwork vNet, VirtualNode vNode,
		List<SubstrateNode> candidates) {
	Iterator<Node<?>> tempIt = SortedNodeNR_i_opt_virt.keySet().iterator();
	List<SubstrateNode> tempCandiNodes = null;

	if (((VirtualNode) tempIt.next()).equals(vNode)) {
		if (NodeLinkAssignation.vnm(vNode, candidates.iterator().next())) {
			nodeMapping.put(vNode, candidates.iterator().next());
			return true;
		} else {
			throw new AssertionError("But we checked before!");
		}
	}
	GenericTreeNode<Node<?>> tempNode = bfsTree.find(vNode);
	VirtualNode parentNode = (VirtualNode) tempNode.getParent().getData();

	for (int tmpK = 1; tmpK < maxHop + 1; tmpK++) {
		DijkstraDistance<SubstrateNode, SubstrateLink> distanceGraph = new DijkstraDistance<SubstrateNode, SubstrateLink>(
				sNet, new SubstrateLinkSingleTransformer(), false);
		distanceGraph.setMaxDistance(tmpK);
		Map<SubstrateNode, Number> orderedMappedCandidates = distanceGraph
				.getDistanceMap(nodeMapping.get(parentNode));
		tempCandiNodes = new LinkedList<SubstrateNode>(
				orderedMappedCandidates.keySet());
		candidates = new LinkedList<SubstrateNode>();
		
		if(!orderedMappedCandidates.isEmpty()){
			if (withDist) {
				candidates = MiscelFunctions.findFulfillingNodes(vNode,
						tempCandiNodes, dist, nodeMapping);
			} else {
				candidates = MiscelFunctions.findFulfillingNodes(vNode,
						tempCandiNodes, nodeMapping);
			}
			for (SubstrateNode sCorrNode : candidates) {
				if (MapPathsWithMappedNodes(vNet, vNode, sCorrNode)) {
					if (!NodeLinkAssignation.vnm(vNode, sCorrNode)) {
						throw new AssertionError("But we checked before!");
					} else {
						nodeMapping.put(vNode, sCorrNode);
						return true;
					}
				} else {
					MiscelFunctions.clearVnodeMappings(vNet, vNode);
				}
			}
		}
	}
	return false;
}
 
开发者ID:fabe85,项目名称:Alevin,代码行数:51,代码来源:BFSNRnodeMappingPathSplitting.java


注:本文中的vnreal.algorithms.utils.NodeLinkAssignation.vnm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。