本文整理汇总了Java中vnreal.network.substrate.SubstrateNetwork类的典型用法代码示例。如果您正苦于以下问题:Java SubstrateNetwork类的具体用法?Java SubstrateNetwork怎么用?Java SubstrateNetwork使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubstrateNetwork类属于vnreal.network.substrate包,在下文中一共展示了SubstrateNetwork类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findShortestPath
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
public static LinkedList<SubstrateLink> findShortestPath(
SubstrateNetwork sNetwork,
SubstrateNode n1, SubstrateNode n2,
Transformer<SubstrateLink, Double> t) {
if (n1.getId() == n2.getId()) {
return new LinkedList<SubstrateLink>();
}
MyDijkstraShortestPath<SubstrateNode, SubstrateLink> dijkstra =
new MyDijkstraShortestPath<SubstrateNode, SubstrateLink>(
sNetwork, t, true);
LinkedList<SubstrateLink> path = dijkstra.getPath(n1, n2, -1);
return path;
}
示例2: generate
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public NetworkStack generate(ArrayList<Object> parameters) {
Double alpha = (Double) parameters.get(0);
Double beta = (Double) parameters.get(1);
Integer sNetSize = ConversionHelper.paramObjectToInteger(parameters.get(2));
Integer numVNodesPerNet = ConversionHelper.paramObjectToInteger(parameters.get(3));
Integer numVNets = ConversionHelper.paramObjectToInteger(parameters.get(4));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(5));
Random random = seed == null ? new Random() : new Random(seed);
SubstrateNetwork sn = createSubstrateNetwork(alpha, beta, sNetSize, random);
List<VirtualNetwork> vns = createVirtualNetworks(alpha, beta, numVNets, numVNodesPerNet, random);
NetworkStack ns = new NetworkStack(sn, vns);
return ns;
}
示例3: map
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public NetworkStack map(AlgorithmParameter data, SubstrateNetwork substrate, List<VirtualNetwork> virtuals) {
NetworkStack stack = new NetworkStack(substrate, virtuals);
LinkedList<IHiddenHopMapping> hhMappings = new LinkedList<IHiddenHopMapping>();
double hiddenHopsFactor = 0;
hhMappings.add(new BandwidthCpuHiddenHopMapping(hiddenHopsFactor));
AlgorithmParameter param = new AlgorithmParameter();
param.put("weightCpu", "0");
param.put("weightBw", "0");
param.put("distance", "35");
param.put("PathSplitting", "true");
GenericMappingAlgorithm algo = new AvailableResources(param);
algo.setStack(stack);
if (algo instanceof GenericMappingAlgorithm)
((GenericMappingAlgorithm) algo).setHhMappings(hhMappings);
algo.performEvaluation();
return stack;
}
示例4: createSubstrateNetwork
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
/**
* This method creates the substrateNEtwork
*
* @param alpha Alpha value
* @param beta Beta value
* @param bidirectEdges True if edges should be bidrectional
* @param sNetSize size of the SubstrateNetwork
* @return
*/
protected SubstrateNetwork createSubstrateNetwork(Double alpha, Double beta, Integer sNetSize) {
WaxmanGraphGenerator<SubstrateNode, SubstrateLink> sGenerator = new WaxmanGraphGenerator<SubstrateNode, SubstrateLink>(
alpha, beta, false);
SubstrateNetwork sNetwork = new SubstrateNetwork(false);
for (int i = 0; i < sNetSize; ++i) {
SubstrateNode sn = new SubstrateNode();
sn.setName(sn.getId() + "");
sNetwork.addVertex(sn);
}
sGenerator.generate(sNetwork);
return sNetwork;
}
示例5: mapNetwork
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public boolean mapNetwork(SubstrateNetwork network, VirtualNetwork vNetwork) {
List<VirtualNetwork> vns = new LinkedList<VirtualNetwork>();
vns.add(vNetwork);
NetworkStack stack = new NetworkStack(network, vns);
LinkedList<IHiddenHopMapping> hhMappings = new LinkedList<IHiddenHopMapping>();
double hiddenHopsFactor = 0;
hhMappings.add(new BandwidthCpuHiddenHopMapping(hiddenHopsFactor));
AlgorithmParameter param = new AlgorithmParameter();
param.put("weightCpu", "0");
param.put("weightBw", "0");
param.put("distance", "35");
param.put("PathSplitting", "true");
GenericMappingAlgorithm algo = new AvailableResources(param);
algo.setStack(stack);
if (algo instanceof GenericMappingAlgorithm)
((GenericMappingAlgorithm) algo).setHhMappings(hhMappings);
algo.performEvaluation();
return VnrUtils.isMapped(vNetwork);
}
示例6: generate
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
public NetworkStack generate(int numVNets,
NetworkGeneratorParameter sNetGeneratorParam,
NetworkGeneratorParameter vNetGeneratorParam,
Random random) {
SubstrateNetwork sNetwork = sNetGenerator.generate(random, sNetConstraintGenerator, sNetGeneratorParam);
LinkedList<VirtualNetwork> vNetworks = new LinkedList<VirtualNetwork>();
for (int layer = 1; layer <= numVNets; ++layer) {
boolean validated = false;
while (!validated) {
VirtualNetwork vNetwork = vNetGenerator.generate(random, vNetConstraintGenerator, vNetGeneratorParam);
if (!vNetwork.isConnected()) {
System.out.println("NOTE: vNet was not connected -> regenerate");
continue;
}
validated = true;
vNetworks.add(vNetwork);
}
}
return new NetworkStack(sNetwork, vNetworks);
}
示例7: generateSubstrateNetwork
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public SubstrateNetwork generateSubstrateNetwork(
final boolean autoUnregisterConstraints) {
return new Generator<SubstrateNetwork, SubstrateNode, SubstrateLink>() {
@Override
protected SubstrateNetwork createNetwork() {
return new SubstrateNetwork(autoUnregisterConstraints);
}
@Override
protected SubstrateNode createNode() {
return new SubstrateNode();
}
@Override
protected SubstrateLink createLink() {
return new SubstrateLink();
}
}.generateGraph(this.numPods, this.clientsGenerated);
}
示例8: generateRandomCPUResources
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的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);
}
}
}
示例9: occupyPathResources
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
public static LinkedList<ResourceDemandEntry> occupyPathResources(
List<AbstractDemand> demands, List<AbstractDemand> hiddenhopDemands,
List<SubstrateLink> path, SubstrateNetwork sNetwork) {
LinkedList<ResourceDemandEntry> resources =
new LinkedList<ResourceDemandEntry>();
int i = 1;
for (SubstrateLink e : path) {
resources.addAll(occupyResources(demands, e.get()));
if (i != path.size()) {
Pair<SubstrateNode> endpoints = sNetwork.getEndpoints(e);
Collection<ResourceDemandEntry> entry =
occupyHiddenHop(endpoints.getSecond(), hiddenhopDemands);
resources.addAll(entry);
}
++i;
}
return resources;
}
示例10: nodePotential
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
public double nodePotential(SubstrateNetwork sNetwork, SubstrateNode v,
Collection<SubstrateNode> v_a) {
SubstrateLinkStressTransformer transformer = new SubstrateLinkStressTransformer(
this, sNetwork, null, biggestLinkStress, delta_L);
double sum = 0.0;
for (SubstrateNode n : v_a) {
DistanceEntry distance = getDistance(sNetwork, v, n, transformer);
if (distance != null) {
sum += distance.distance;
}
}
double tmp = biggestNodeStress - getStressLevel(sNetwork, v);
return tmp == 0 ? sum : (sum / tmp);
}
示例11: mapNetwork
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public boolean mapNetwork(SubstrateNetwork network, VirtualNetwork vNetwork) {
List<VirtualNetwork> vns = new LinkedList<VirtualNetwork>();
vns.add(vNetwork);
NetworkStack stack = new NetworkStack(network, vns);
LinkedList<IHiddenHopMapping> hhMappings = new LinkedList<IHiddenHopMapping>();
double hiddenHopsFactor = 0;
hhMappings.add(new BandwidthCpuHiddenHopMapping(hiddenHopsFactor));
AlgorithmParameter param = new AlgorithmParameter();
param.put("weightCpu", "0");
param.put("weightBw", "0");
param.put("randomize", "false");
param.put("overload", "false");
param.put("distance", "35");
param.put("PathSplitting", "true");
GenericMappingAlgorithm algo = new CoordinatedMapping(param);
algo.setStack(stack);
if (algo instanceof GenericMappingAlgorithm)
((GenericMappingAlgorithm) algo).setHhMappings(hhMappings);
algo.performEvaluation();
return VnrUtils.isMapped(vNetwork);
}
示例12: findDemandedNode
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
/**
*
* @param IDdem
* @param tmp
* @return the substrate node with the IDresource demanded by the virtual
* node tmp
*/
private SubstrateNode findDemandedNode(SubstrateNetwork sNet, AbstractDemand IDdem) {
SubstrateNode sNode = new SubstrateNode();
String resID = Integer.toString(0);
String demID = Integer.toString(0);
for (SubstrateNode n : sNet.getVertices()) {
for (AbstractResource res : n) {
if (res instanceof IdResource) {
resID = ((IdResource) res).getId();
demID = ((IdDemand) IDdem).getDemandedId();
if (resID.equals(demID))
sNode = n;
}
}
}
return sNode;
}
示例13: createCandidateSet
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
/**
*
* @param vNet
* @return The set of substrate candidates for each virtual node of vNet
*/
private Map<VirtualNode, List<SubstrateNode>> createCandidateSet(
SubstrateNetwork sNet, VirtualNetwork vNet) {
Map<VirtualNode, List<SubstrateNode>> candidateSet = new LinkedHashMap<VirtualNode, List<SubstrateNode>>();
List<SubstrateNode> substrateSet;
for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
.hasNext();) {
substrateSet = new LinkedList<SubstrateNode>();
VirtualNode currVnode = itt.next();
if (nodeMapping.containsKey(currVnode)) {
substrateSet.add(nodeMapping.get(currVnode));
} else {
substrateSet.addAll(findFulfillingNodes(sNet, currVnode));
}
candidateSet.put(currVnode, substrateSet);
}
return candidateSet;
}
示例14: generate
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
@Override
public List<BandwidthResource> generate(ArrayList<Object> parameters) {
ArrayList<BandwidthResource> resList = new ArrayList<BandwidthResource>();
Random random = new Random();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minBW = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxBW = ConversionHelper.paramObjectToInteger(parameters.get(2));
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
BandwidthResource bw = new BandwidthResource(l);
int value = (int) (minBW + (maxBW
- minBW + 1)
* random.nextDouble());
bw.setBandwidth((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例15: buildSubstrateNet
import vnreal.network.substrate.SubstrateNetwork; //导入依赖的package包/类
private static SubstrateNetwork buildSubstrateNet(List<Node> nodes) {
SubstrateNetwork network = new SubstrateNetwork(false);
Map<Node, SubstrateNode> nodeToSnode = new HashMap<Node, SubstrateNode>();
for (Node node : nodes) {
SubstrateNode sNode = new SubstrateNode();
sNode.setCoordinateX(ShiipImporter.rng.nextDouble() * SCALE);
sNode.setCoordinateY(ShiipImporter.rng.nextDouble() * SCALE);
nodeToSnode.put(node, sNode);
network.addVertex(sNode);
}
for (Node origin : nodes) {
SubstrateNode sOrigin = nodeToSnode.get(origin);
for (Node dest : origin.outgoing) {
SubstrateNode sDest = nodeToSnode.get(dest);
SubstrateLink sLink = new SubstrateLink();
network.addEdge(sLink, sOrigin, sDest);
}
}
return network;
}