當前位置: 首頁>>代碼示例>>Java>>正文


Java Utils類代碼示例

本文整理匯總了Java中vnreal.algorithms.utils.SubgraphBasicVN.Utils的典型用法代碼示例。如果您正苦於以下問題:Java Utils類的具體用法?Java Utils怎麽用?Java Utils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Utils類屬於vnreal.algorithms.utils.SubgraphBasicVN包,在下文中一共展示了Utils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sort

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
void sort(List<MappingCandidate<VirtualNode, SubstrateNode>> c) {
	Collections.sort(c,
			new Comparator<MappingCandidate<VirtualNode, SubstrateNode>>() {
				public int compare(
						MappingCandidate<VirtualNode, SubstrateNode> o1,
						MappingCandidate<VirtualNode, SubstrateNode> o2) {

					double tmp = Utils.getCpuRemaining(o1.u, o1.t)
							- Utils.getCpuRemaining(o2.u, o2.t);

					if (tmp < 0.0) { // NOTE: not really a good way
						// comparing doubles ...
						return -1;
					}
					if (tmp > 0.0) {
						return 1;
					}
					return 0;
				}
			});
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:22,代碼來源:OptimalMappingsAlgorithm.java

示例2: generateRandomBandwidthDemands

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
public static void generateRandomBandwidthDemands(
		VirtualNetwork vNetwork, int minDemandBandwidth,
		int maxDemandBandwidth, Random random,
		boolean useCommonConstraints) {
	
	for (VirtualLink l : vNetwork.getEdges()) {
		int value = Utils.rnd(minDemandBandwidth, maxDemandBandwidth, random);
		if (useCommonConstraints) {
			CommonDemand d = new CommonDemand(value, l);
			l.add(d);
		} else {
			BandwidthDemand bw = new BandwidthDemand(l);
			bw.setDemandedBandwidth((double) value);
			l.add(bw);
		}
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:18,代碼來源:RandomDemandGenerator.java

示例3: generateRandomCPUResources

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
public static void generateRandomCPUResources(SubstrateNetwork sNetwork,
		int minResourceCPU, int maxResourceCPU, Random random, boolean useCommonConstraints) {

	for (SubstrateNode n : sNetwork.getVertices()) {
		int value = Utils.rnd(minResourceCPU, maxResourceCPU, random);
		
		if (useCommonConstraints) {
			CommonResource r = new CommonResource(value, n);
			n.add(r);
		} else {
			CpuResource cpu = new CpuResource(n);
			cpu.setCycles((double) value);
			n.add(cpu);
		}
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:17,代碼來源:RandomResourceGenerator.java

示例4: mapEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapEdges(
		SubstrateNetwork sNetwork,
		VirtualNetwork vNetwork,
		MappingCandidate<VirtualNode, SubstrateNode> candidate,
		NodeLinkMapping m,
		Collection<ResourceDemandEntry> demandedNodeEnergyResource,
		int epsilon) {

	Collection<ResourceDemandEntry> out = mapOutEdges(
			sNetwork, vNetwork, candidate, m, epsilon);
	if (out == null) {
		return null;
	}
	Collection<ResourceDemandEntry> in = mapInEdges(
			sNetwork, vNetwork, candidate, m, epsilon);
	if (in == null) {
		Utils.freeResources(out);
		return null;
	}

	out.addAll(in);
	return out;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:24,代碼來源:OptimalMappingsAlgorithm.java

示例5: calculate

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
public double calculate(NetworkStack stack) {
	SubstrateNetwork sNetwork = stack.getSubstrate();

	int sumLinkStress = 0;
	int counter = 0;
	for (SubstrateLink sl : sNetwork.getEdges()) {
		int stress = Utils.getStressLevel(sl);
		sumLinkStress += stress;
		if (stress != 0) {
			++counter;
		}
	}
	
	if (counter == 0)
		return Double.NaN;

	return (sumLinkStress / (double) counter);
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:19,代碼來源:AvActiveLinkStress.java

示例6: mapInEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapInEdges(
		SubstrateNetwork sNetwork, VirtualNetwork vNetwork,
		MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
		int epsilon) {

	Collection<ResourceDemandEntry> result = new LinkedList<ResourceDemandEntry>();

	for (VirtualLink vl : vNetwork.getInEdges(candidate.t)) {
		VirtualNode opposite = vNetwork.getOpposite(candidate.t, vl);
		SubstrateNode sOpposite = m.getSubstrateNode(opposite);

		if (sOpposite != null && sOpposite.getId() != candidate.u.getId()) {
			List<SubstrateLink> path = findShortestPath(sNetwork,
					sOpposite, candidate.u, vl.get(), epsilon);

			if (path == null) {
				Utils.freeResources(result);
				return null;
			}

			result.addAll(Utils.occupyPathResources(vl, path, sNetwork));
			m.add(vl, path);
		}
	}
	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:27,代碼來源:OptimalMappingsAlgorithm.java

示例7: findShortestPath

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
LinkedList<SubstrateLink> findShortestPath(SubstrateNetwork sNetwork,
		SubstrateNode n1, SubstrateNode n2,
		Collection<AbstractDemand> vldemands, int epsilon) {

	if (n1.getId() == n2.getId()) {
		return new LinkedList<SubstrateLink>();
	}

	MyDijkstraShortestPath<SubstrateNode, SubstrateLink> dijkstra = new MyDijkstraShortestPath<SubstrateNode, SubstrateLink>(
			sNetwork, new SubstrateLinkDemandTransformer(vldemands), true);

	LinkedList<SubstrateLink> path = dijkstra.getPath(n1, n2, epsilon);
	assert (path == null || Utils.fulfills(path, vldemands));

	return path;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:17,代碼來源:SubgraphIsomorphismAlgorithm.java

示例8: mapEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapEdges(
		VirtualNetwork g_V, SubstrateNetwork orig_g_P,
		MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
		int epsilon) {

	Collection<ResourceDemandEntry> out = mapOutEdges(
			g_V, orig_g_P, candidate, m, epsilon);
	if (out == null) {
		return null;
	}
	Collection<ResourceDemandEntry> in = mapInEdges(
			g_V, orig_g_P, candidate, m, epsilon);
	if (in == null) {
		Utils.freeResources(out);
		return null;
	}

	out.addAll(in);
	return out;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:21,代碼來源:SubgraphIsomorphismAlgorithm.java

示例9: mapOutEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapOutEdges(
		VirtualNetwork g_V, SubstrateNetwork orig_g_P,
		MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
		int epsilon) {

	Collection<ResourceDemandEntry> result = new LinkedList<ResourceDemandEntry>();

	for (VirtualLink vl : g_V.getOutEdges(candidate.t)) {
		VirtualNode opposite = g_V.getOpposite(candidate.t, vl);
		SubstrateNode sOpposite = m.getSubstrateNode(opposite);

		if (sOpposite != null && sOpposite.getId() != candidate.u.getId()) {
			List<SubstrateLink> path = findShortestPath(orig_g_P,
					candidate.u, sOpposite, vl.get(), epsilon);

			if (path == null) {
				Utils.freeResources(result);
				return null;
			}

			result.addAll(Utils.occupyPathResources(vl, path, orig_g_P));
			m.add(vl, path);
		}
	}
	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:27,代碼來源:SubgraphIsomorphismAlgorithm.java

示例10: mapInEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapInEdges(
		VirtualNetwork g_V, SubstrateNetwork orig_g_P,
		MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
		int epsilon) {

	Collection<ResourceDemandEntry> result = new LinkedList<ResourceDemandEntry>();

	for (VirtualLink vl : g_V.getInEdges(candidate.t)) {
		VirtualNode opposite = g_V.getOpposite(candidate.t, vl);
		SubstrateNode sOpposite = m.getSubstrateNode(opposite);

		if (sOpposite != null && sOpposite.getId() != candidate.u.getId()) {
			List<SubstrateLink> path = findShortestPath(orig_g_P,
					sOpposite, candidate.u, vl.get(), epsilon);

			if (path == null) {
				Utils.freeResources(result);
				return null;
			}

			result.addAll(Utils.occupyPathResources(vl, path, orig_g_P));
			m.add(vl, path);
		}
	}
	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:27,代碼來源:SubgraphIsomorphismAlgorithm.java

示例11: f

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<VirtualNode> f(Set<VirtualNode> vns, VirtualNetwork g) {
	Collection<VirtualNode> result = new LinkedList<VirtualNode>();

	for (VirtualLink vl : g.getEdges()) {
		Pair<VirtualNode> endpoints = g.getEndpoints(vl);
		VirtualNode n_i = endpoints.getFirst();
		VirtualNode n_j = endpoints.getSecond();
		if (Utils.contains(n_j, vns)) {
			if (!Utils.contains(n_i, vns)) {
				if (!Utils.contains(n_i, result)) {
					result.add(n_i);
				}
			}
		} else {
			if (Utils.contains(n_i, vns)) {
				if (!Utils.contains(n_j, result)) {
					result.add(n_j);
				}
			}
		}
	}

	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:25,代碼來源:SubgraphIsomorphismAlgorithm.java

示例12: evaluate

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
@Override
protected void evaluate() {
	// allDemandedResources = new LinkedList<ResourceDemandEntry<? extends
	// AbstractResource, ? extends AbstractDemand>>();

	SubstrateNetwork sNetwork = stack.getSubstrate();
	NodeLinkMapping mapping = new NodeLinkMapping();
	while (hasNext()) {
		demandedResources = new LinkedList<ResourceDemandEntry>();
		if (!mapNetwork(sNetwork, getNext(), mapping)) {
			Utils.freeResources(demandedResources);
			// Utils.freeResources(allDemandedResources);
			// mapping = null;
			// break;
		}
		// allDemandedResources.addAll(demandedResources);
	}
	if (mapping != null) {
		mapping.setMappings(demandedResources);
	}
	demandedResources = null;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:23,代碼來源:BasicVNAssignmentAlgorithm.java

示例13: mapOutEdges

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
Collection<ResourceDemandEntry> mapOutEdges(
		SubstrateNetwork sNetwork, VirtualNetwork vNetwork,
		MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
		int epsilon) {

	Collection<ResourceDemandEntry> result = new LinkedList<ResourceDemandEntry>();

	for (VirtualLink vl : vNetwork.getOutEdges(candidate.t)) {
		VirtualNode opposite = vNetwork.getOpposite(candidate.t, vl);
		SubstrateNode sOpposite = m.getSubstrateNode(opposite);

		if (sOpposite != null && sOpposite.getId() != candidate.u.getId()) {
			List<SubstrateLink> path = findShortestPath(sNetwork,
					candidate.u, sOpposite, vl.get(), epsilon);

			if (path == null) {
				Utils.freeResources(result);
				return null;
			}

			result.addAll(Utils.occupyPathResources(vl, path, sNetwork));
			m.add(vl, path);
		}
	}
	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:27,代碼來源:OptimalMappingsAlgorithm.java

示例14: generateRandomCPUDemands

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
public static void generateRandomCPUDemands(VirtualNetwork vNetwork,
		Integer[] cpuDemands, Random random) {

	for (VirtualNode n : vNetwork.getVertices()) {
		CpuDemand cpu = new CpuDemand(n);
		int pos = Utils.rnd(0, cpuDemands.length - 1, random);
		int value = cpuDemands[pos];
		cpu.setDemandedCycles((double) value);
		n.add(cpu);
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:12,代碼來源:RandomSetDemandGenerator.java

示例15: generateRandomBandwidthDemands

import vnreal.algorithms.utils.SubgraphBasicVN.Utils; //導入依賴的package包/類
public static void generateRandomBandwidthDemands(
		VirtualNetwork vNetwork,
		Integer[] bandwidthDemands, Random random) {

	for (VirtualLink l : vNetwork.getEdges()) {
		BandwidthDemand bw = new BandwidthDemand(l);
		int pos = Utils.rnd(0, bandwidthDemands.length - 1, random);
		int value = bandwidthDemands[pos];
		bw.setDemandedBandwidth((double) value);
		l.add(bw);
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:13,代碼來源:RandomSetDemandGenerator.java


注:本文中的vnreal.algorithms.utils.SubgraphBasicVN.Utils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。