当前位置: 首页>>代码示例>>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;未经允许,请勿转载。