本文整理汇总了Java中vnreal.network.virtual.VirtualNode.add方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualNode.add方法的具体用法?Java VirtualNode.add怎么用?Java VirtualNode.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnreal.network.virtual.VirtualNode
的用法示例。
在下文中一共展示了VirtualNode.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRandomLabelDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
public static void generateRandomLabelDemands(VirtualNetwork network,
int numDemandedLabels, String[] labels, Random rnd) {
for (VirtualNode vn : network.getVertices()) {
LinkedList<String> labelsShuffle = new LinkedList<String>();
for (String s : labels)
labelsShuffle.add(s);
Collections.shuffle(labelsShuffle, rnd);
LinkedList<String> demandedLabels = new LinkedList<String>();
int i = 0;
for (String label : labelsShuffle) {
if (i >= numDemandedLabels)
break;
demandedLabels.add(label);
i++;
}
vn.add(new LabelDemand(vn, demandedLabels));
}
}
示例2: generateHetEnergyConstraints
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
public static void generateHetEnergyConstraints(NetworkStack stack, int min, int max, Scenario scen) {
SubstrateNetwork sNetwork = stack.getSubstrate();
for (SubstrateNode sn : sNetwork.getVertices()) {
int consumption = (int) (Math.random() * (max - min) + 1) + min;
sn.add(new StaticEnergyResource(sn, consumption));
}
for (int i = 1; scen.getNetworkStack().getLayer(i) != null; i++) {
VirtualNetwork vNetwork = (VirtualNetwork) scen
.getNetworkStack().getLayer(i);
for (VirtualNode vn : vNetwork.getVertices()) {
vn.add(new PowerDemand(vn));
}
}
}
示例3: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minCPU = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxCPU = ConversionHelper.paramObjectToInteger(parameters.get(2));
Random random = new Random();
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for(VirtualNode n : vNetwork.getVertices()) {
CpuDemand cpu = new CpuDemand(n);
int value = (int) (minCPU + (maxCPU
- minCPU + 1)
* random.nextDouble());
cpu.setDemandedCycles((double) value);
n.add(cpu);
}
}
return 0;
}
示例4: createVNDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
private static List<VirtualNetwork> createVNDemands() {
List<VirtualNetwork> vns = new LinkedList<VirtualNetwork>();
CpuDemand cpuDem;
BandwidthDemand bwDem;
// Network with Layer (x) MUST be instance before Network Layer (x+1)
// Virtual network: Layer 1
VirtualNetwork vn1 = new VirtualNetwork(1);
vns.add(vn1);
VirtualNode vC = new VirtualNode(1);
cpuDem = new CpuDemand(vC);
cpuDem.setDemandedCycles(990.0);
vC.add(new PowerDemand(vC));
assertTrue(vC.add(cpuDem));
assertTrue(vn1.addVertex(vC));
VirtualNode vD = new VirtualNode(1);
cpuDem = new CpuDemand(vD);
cpuDem.setDemandedCycles(25.0);
vD.add(new PowerDemand(vD));
assertTrue(vD.add(cpuDem));
assertTrue(vn1.addVertex(vD));
VirtualLink eCD = new VirtualLink(1);
bwDem = new BandwidthDemand(eCD);
bwDem.setDemandedBandwidth(10.0);
assertTrue(eCD.add(bwDem));
assertTrue(vn1.addEdge(eCD, vC, vD));
return vns;
}
示例5: generateRandomCPUDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的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);
}
}
示例6: generateRandomCPUDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
public static void generateRandomCPUDemands(VirtualNetwork vNetwork,
int minDemandCPU, int maxDemandCPU, Random random, boolean useCommonConstraints) {
for (VirtualNode n : vNetwork.getVertices()) {
int value = Utils.rnd(minDemandCPU, maxDemandCPU, random);
if (useCommonConstraints) {
CommonDemand d = new CommonDemand(value, n);
n.add(d);
} else {
CpuDemand cpu = new CpuDemand(n);
cpu.setDemandedCycles((double) value);
n.add(cpu);
}
}
}
示例7: generateMLSDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
/**
* This method generates MLS Labels for every node
* @param vNetwork Virtual Network
* @param lattice A MLS Label lattice
*/
public static void generateMLSDemands(VirtualNetwork vNetwork, MLSLattice lattice, Long seed) {
Random random = new Random();
if(seed != null)
random.setSeed(seed);
int maxLevel = lattice.getNumberOfLevels() - 1;
ArrayList<String> cats = lattice.getCategories();
for (VirtualNode n : vNetwork.getVertices()) {
//Create Random resource
int resDem = (int)((maxLevel + 1) * random.nextDouble());
int resProv = (int)((maxLevel + 1) * random.nextDouble());
//we need at least one Category
int countCat;
do {
countCat = (int)((cats.size()+1) * random.nextDouble());
} while (countCat < 1);
ArrayList<String> chosenCats = new ArrayList<String>();
for (int c = 0; c < countCat; c++) {
String cat;
do {
cat = cats.get((int)(cats.size() * random.nextDouble()));
} while (chosenCats.contains(cat));
chosenCats.add(cat);
}
MLSDemand res = new MLSDemand(n, resDem, resProv, chosenCats);
n.add(res);
}
}
示例8: generateMLSDemandsReasonable
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
/**
* This method generates MLS Labels for every node so that all demands are fulfillable
* @param vNetwork Virtual Network
* @param lattice A MLS Label lattice
* @param resList ArrayList of MLSRessources
* @param seed Seed for random, null if fully random
*/
public static void generateMLSDemandsReasonable(VirtualNetwork vNetwork, MLSLattice lattice, ArrayList<MLSResource> resList, Long seed) {
Random random = new Random();
if(seed != null)
random.setSeed(seed);
int maxLevel = lattice.getNumberOfLevels() - 1;
ArrayList<String> cats = lattice.getCategories();
for (VirtualNode n : vNetwork.getVertices()) {
MLSDemand dem;
do {
//Create Random resource
int resDem = (int)((maxLevel + 1) * random.nextDouble());
int resProv = (int)((maxLevel + 1) * random.nextDouble());
//we need at least one Category
int countCat;
do {
countCat = (int)((cats.size()+1) * random.nextDouble());
} while (countCat < 1);
ArrayList<String> chosenCats = new ArrayList<String>();
for (int c = 0; c < countCat; c++) {
String cat;
do {
cat = cats.get((int)(cats.size() * random.nextDouble()));
} while (chosenCats.contains(cat));
chosenCats.add(cat);
}
dem = new MLSDemand(n, resDem, resProv, chosenCats);
}while(!checkMLSWorking(resList, dem));
n.add(dem);
}
}
示例9: process
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Scenario process(Scenario scen) {
for (VirtualNetwork vnet : scen.getVirtuals()) {
for (VirtualNode n : vnet.getVertices()) {
CpuDemand cpu = new CpuDemand(n);
int value = min.intValue() + rng.nextInt(max.intValue() - min.intValue());
cpu.setDemandedCycles((double) value);
n.add(cpu);
}
}
return scen;
}
示例10: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for(VirtualNode node : vNetwork.getVertices()) {
PowerDemand nr = new PowerDemand(node);
node.add(nr);
}
}
return 0;
}
示例11: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for(VirtualNode node : vNetwork.getVertices()) {
StaticPowerDemand nr = new StaticPowerDemand(node);
node.add(nr);
}
}
return 0;
}
示例12: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for(VirtualNode node : vNetwork.getVertices()) {
MultiCorePowerDemand nr = new MultiCorePowerDemand(node);
node.add(nr);
}
}
return 0;
}
示例13: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minCPU = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxCPU = 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(VirtualNode n : vNetwork.getVertices()) {
CpuDemand cpu = new CpuDemand(n);
int value = (int) (minCPU + (maxCPU
- minCPU + 1)
* random.nextDouble());
cpu.setDemandedCycles((double) value);
n.add(cpu);
}
}
return 0;
}
示例14: generateEnergyDemands
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
public static void generateEnergyDemands(VirtualNetwork vNetwork) {
for (VirtualNode vn : vNetwork.getVertices()) {
vn.add(new PowerDemand(vn));
}
}
示例15: generate
import vnreal.network.virtual.VirtualNode; //导入方法依赖的package包/类
@Override
public Integer generate(ArrayList<Object> parameters) {
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer sLevels = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer sCats = ConversionHelper.paramObjectToInteger(parameters.get(2));
Long seed = ConversionHelper.paramObjectToLong(parameters.get(3));
@SuppressWarnings("unchecked")
ArrayList<MLSResource> resList = (ArrayList<MLSResource>)parameters.get(4);
Random random = new Random();
random.setSeed(seed);
MLSLattice lattice = RandomMLSResourceGenerator.createLattice(sLevels, sCats);
int maxLevel = lattice.getNumberOfLevels() - 1;
ArrayList<String> cats = lattice.getCategories();
for(int u = 1; u < ns.size(); u++) {
VirtualNetwork vNetwork = (VirtualNetwork)ns.getLayer(u);
for (VirtualNode n : vNetwork.getVertices()) {
MLSDemand res;
do {
//Create Random resource
int resDem = (int)((maxLevel + 1) * random.nextDouble());
int resProv = (int)((maxLevel + 1) * random.nextDouble());
//we need at least one Category
int countCat;
do {
countCat = (int)((cats.size()+1) * random.nextDouble());
} while (countCat < 1);
ArrayList<String> chosenCats = new ArrayList<String>();
for (int c = 0; c < countCat; c++) {
String cat;
do {
cat = cats.get((int)(cats.size() * random.nextDouble()));
} while (chosenCats.contains(cat));
chosenCats.add(cat);
}
res = new MLSDemand(n, resDem, resProv, chosenCats);
}while(!checkMLSWorking(resList, res));
n.add(res);
}
}
return 0;
}