本文整理汇总了Java中vnreal.network.virtual.VirtualLink.add方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualLink.add方法的具体用法?Java VirtualLink.add怎么用?Java VirtualLink.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnreal.network.virtual.VirtualLink
的用法示例。
在下文中一共展示了VirtualLink.add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRandomBandwidthDemands
import vnreal.network.virtual.VirtualLink; //导入方法依赖的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);
}
}
}
示例2: loadFromFile
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
protected VirtualNetwork loadFromFile(String graphFile) throws Exception {
VirtualNetwork virtualNetwork = (VirtualNetwork) new GtItmVirtualNetworkLoader().loadFromFile(graphFile);
for (VirtualNode virtualNode : virtualNetwork.getVertices()) {
CpuDemand cpuDemand = new CpuDemand(virtualNode);
cpuDemand.setDemandedCycles(resource());
virtualNode.add(cpuDemand);
}
for (VirtualLink virtualLink : virtualNetwork.getEdges()) {
BandwidthDemand bandwidthDemand = new BandwidthDemand(virtualLink);
bandwidthDemand.setDemandedBandwidth(resource());
virtualLink.add(bandwidthDemand);
}
return virtualNetwork;
}
示例3: create
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public VirtualNetwork create() {
VirtualNetwork virtualNetwork = new VirtualNetwork(1);
int nodeCount = randomUtility.nextInt(maxNodeCount - minNodeCount) + minNodeCount;
for (int i = 0; i < nodeCount; i++) {
VirtualNode virtualNode = new VirtualNode(virtualNetwork.getLayer());
CpuDemand cpuDemand = new CpuDemand(virtualNode);
cpuDemand.setDemandedCycles(resource());
virtualNode.add(cpuDemand);
virtualNetwork.addVertex(virtualNode);
}
new WaxmanGraphGenerator<VirtualNode, VirtualLink>(0.5, 0.5, false).generate(virtualNetwork);
for (VirtualLink virtualLink : virtualNetwork.getEdges()) {
BandwidthDemand bandwidthDemand = new BandwidthDemand(virtualLink);
bandwidthDemand.setDemandedBandwidth(resource());
virtualLink.add(bandwidthDemand);
}
return virtualNetwork;
}
示例4: generateRandomBandwidthDemands
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
public static void generateRandomBandwidthDemands(
VirtualNetwork vNetwork, int minDemandBandwidth,
int maxDemandBandwidth, Long seed) {
Random random = new Random();
if(seed != null)
random.setSeed(seed);
for (VirtualLink l : vNetwork.getEdges()) {
BandwidthDemand bw = new BandwidthDemand(l);
int value = (int) (minDemandBandwidth + (maxDemandBandwidth
- minDemandBandwidth + 1)
* random.nextDouble());
bw.setDemandedBandwidth((double) value);
l.add(bw);
}
}
示例5: generateRandomBandwidthDemands
import vnreal.network.virtual.VirtualLink; //导入方法依赖的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);
}
}
示例6: generateRandomDelayDemands
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
public static void generateRandomDelayDemands(
VirtualNetwork vNetwork,
Integer[] delayDemands, Random random) {
for (VirtualLink l : vNetwork.getEdges()) {
int pos = Utils.rnd(0, delayDemands.length - 1, random);
int value = delayDemands[pos];
StaticMaxDelayDemand bw = new StaticMaxDelayDemand(l, value);
l.add(bw);
}
}
示例7: process
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public Scenario process(Scenario scen) {
for (VirtualNetwork vnet : scen.getVirtuals()) {
for (VirtualLink l : vnet.getEdges()) {
BandwidthDemand bw = new BandwidthDemand(l);
int value = min.intValue() + rng.nextInt(max.intValue() - min.intValue());
bw.setDemandedBandwidth((double) value);
l.add(bw);
}
}
return scen;
}
示例8: generate
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minBW = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxBW = ConversionHelper.paramObjectToInteger(parameters.get(2));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(3));
Random random = new Random();
random.setSeed(seed);
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for (VirtualLink l : vNetwork.getEdges()) {
BandwidthDemand bw = new BandwidthDemand(l);
int value = (int) (minBW + (maxBW
- minBW + 1)
* random.nextDouble());
bw.setDemandedBandwidth((double) value);
l.add(bw);
}
}
return 0;
}
示例9: generate
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
Random random = new Random();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minBW = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxBW = ConversionHelper.paramObjectToInteger(parameters.get(2));
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for (VirtualLink l : vNetwork.getEdges()) {
BandwidthDemand bw = new BandwidthDemand(l);
int value = (int) (minBW + (maxBW
- minBW + 1)
* random.nextDouble());
bw.setDemandedBandwidth((double) value);
l.add(bw);
}
}
return 0;
}
示例10: generate
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
Random random = new Random();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minCost = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxCost = ConversionHelper.paramObjectToInteger(parameters.get(2));
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for (VirtualLink l : vNetwork.getEdges()) {
CostDemand bw = new CostDemand(l);
int value = (int) (minCost + (maxCost
- minCost + 1)
* random.nextDouble());
bw.setCost((double) value);
l.add(bw);
}
}
return 0;
}
示例11: generate
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minCost = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxCost = ConversionHelper.paramObjectToInteger(parameters.get(2));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(3));
Random random = new Random();
random.setSeed(seed);
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for (VirtualLink l : vNetwork.getEdges()) {
CostDemand bw = new CostDemand(l);
int value = (int) (minCost + (maxCost
- minCost + 1)
* random.nextDouble());
bw.setCost((double) value);
l.add(bw);
}
}
return 0;
}
示例12: create
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
@Override
public VirtualNetwork create() {
VirtualNetwork virtualNetwork = new VirtualNetwork(1);
int nodeCount = randomUtility.nextInt(maxNodeCount - minNodeCount) + minNodeCount;
for (int i = 0; i < nodeCount; i++) {
VirtualNode virtualNode = new VirtualNode(virtualNetwork.getLayer());
CpuDemand cpuDemand = new CpuDemand(virtualNode);
cpuDemand.setDemandedCycles(resource());
virtualNode.add(cpuDemand);
virtualNetwork.addVertex(virtualNode);
}
for (VirtualNode v : virtualNetwork.getVertices()) {
for (VirtualNode w : virtualNetwork.getVertices()) {
if (v == w) continue;
if (randomUtility.nextDouble() < connectProbability) {
VirtualLink virtualLink = new VirtualLink(virtualNetwork.getLayer());
BandwidthDemand bandwidthDemand = new BandwidthDemand(virtualLink);
bandwidthDemand.setDemandedBandwidth(resource());
virtualLink.add(bandwidthDemand);
virtualNetwork.addEdge(virtualLink, v, w);
}
}
}
return virtualNetwork;
}
示例13: generateRandomMaxDelayDemands
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
public static void generateRandomMaxDelayDemands(VirtualNetwork vNetwork, int minDelayDemand, int maxDelayDemand, Random random) {
for (VirtualLink n : vNetwork.getEdges()) {
int value = Utils.rnd(minDelayDemand, maxDelayDemand, random);
n.add(new StaticMaxDelayDemand(n, value));
}
}
示例14: processVirtualNetworks
import vnreal.network.virtual.VirtualLink; //导入方法依赖的package包/类
/**
* Creates a list of {@link VirtualNetwork}s as specified in the XML file.
*
* @param n the {@link VirtualNetwork}'s Node.
*/
private void processVirtualNetworks(Node n) {
int layer;
int id;
VirtualNode virtualNode;
for (Node virtualNet = XMLUtils.firstElementNodeChild(n); virtualNet != null; virtualNet = XMLUtils
.nextElementNode(virtualNet)) {
layer = XMLUtils.getIntAttribute(virtualNet, "layer");
ToolKit.getScenario().getNetworkStack()
.addLayer(new VirtualNetwork(layer));
Node virtualNodes = XMLUtils.firstElementNodeChild(virtualNet);
Node virtualLinks = XMLUtils.nextElementNode(virtualNodes);
// create virtual nodes
for (Node vNode = XMLUtils.firstElementNodeChild(virtualNodes); vNode != null; vNode = XMLUtils
.nextElementNode(vNode)) {
id = XMLUtils.getIntAttribute(vNode, "id");
virtualNode = new VirtualNode(id, layer);
virtualNode.setCoordinateX(XMLUtils.getDoubleAttribute(vNode,
"coordinateX"));
virtualNode.setCoordinateY(XMLUtils.getDoubleAttribute(vNode,
"coordinateY"));
if (!((VirtualNetwork) ToolKit.getScenario().getNetworkStack()
.getLayer(layer)).addVertex(virtualNode)) {
System.err.println("Failed to add Node " + id
+ " to virtual network");
throw new Error();
}
for (Node dem = XMLUtils.firstElementNodeChild(vNode); dem != null; dem = XMLUtils
.nextElementNode(dem)) {
// add the demand and the mappings
virtualNode.add(getDemand(dem, virtualNode));
}
}
// create virtual links
for (Node vLink = XMLUtils.firstElementNodeChild(virtualLinks); vLink != null; vLink = XMLUtils
.nextElementNode(vLink)) {
id = XMLUtils.getIntAttribute(vLink, "id");
Integer source = XMLUtils.getIntAttribute(vLink, "source");
Integer destination = XMLUtils.getIntAttribute(vLink,
"destination");
VirtualLink virtualLink = new VirtualLink(id, layer);
if (!((VirtualNetwork) ToolKit.getScenario().getNetworkStack()
.getLayer(layer)).addEdge(virtualLink,
getVirtualNodeForId(layer, source),
getVirtualNodeForId(layer, destination))) {
System.err.println("Failed to add Link " + id
+ " to virtual network");
throw new Error();
}
for (Node dem = XMLUtils.firstElementNodeChild(vLink); dem != null; dem = XMLUtils
.nextElementNode(dem)) {
if (dem.getNodeName().equals("Demand"))
// add the demand and the mappings
virtualLink.add(getDemand(dem, virtualLink));
else if (dem.getNodeName().equals("HiddenHopDemand"))
// also add HH Demands if present
virtualLink.addHiddenHopDemand(getDemand(dem,
virtualLink));
}
}
}
}