本文整理汇总了Java中vnreal.network.substrate.SubstrateNetwork.getVertices方法的典型用法代码示例。如果您正苦于以下问题:Java SubstrateNetwork.getVertices方法的具体用法?Java SubstrateNetwork.getVertices怎么用?Java SubstrateNetwork.getVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnreal.network.substrate.SubstrateNetwork
的用法示例。
在下文中一共展示了SubstrateNetwork.getVertices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMinPiNode
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public SubstrateNode getMinPiNode(SubstrateNetwork sNetwork,
List<AbstractDemand> demands, Collection<SubstrateNode> v_a,
Collection<SubstrateNode> ignoreNodes) {
SubstrateNode result = null;
double resultValue = 0.0, tmp = 0.0;
for (SubstrateNode n : sNetwork.getVertices()) {
if ((ignoreNodes == null || !ignoreNodes.contains(n))
&& !v_a.contains(n)) {
if (Utils.fulfills(demands, n.get())
&& (result == null | (resultValue > (tmp = nodePotential(
sNetwork, n, v_a))))) {
result = n;
resultValue = tmp;
}
}
}
return result;
}
示例2: findClusterhead
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* Returns the SubstrateNode with most CPU Ressources
* @param cluster SubstrateNetwork
* @return Node with most CPUResources
*/
public static SubstrateNode findClusterhead(SubstrateNetwork cluster) {
SubstrateNode result = null;
double cpuMax = 0.0d;
for (SubstrateNode sn : cluster.getVertices()) {
if (result == null) {
result = sn;
} else {
for (AbstractResource r : sn) {
if (r instanceof CpuResource) {
CpuResource c = (CpuResource) r;
double cpu = c.getAvailableCycles();
if (cpu > cpuMax) {
cpuMax = cpu;
result = sn;
}
}
}
}
}
return result;
}
示例3: generate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public List<CpuResource> generate(ArrayList<Object> parameters) {
ArrayList<CpuResource> resList = new ArrayList<CpuResource>();
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);
SubstrateNetwork sn = ns.getSubstrate();
for(SubstrateNode n : sn.getVertices()) {
CpuResource cpu = new CpuResource(n);
int value = (int) (minCPU + random.nextInt(maxCPU - minCPU + 1));
cpu.setCycles((double) value);
n.add(cpu);
resList.add(cpu);
}
return resList;
}
示例4: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
double sum = 0.0;
int i = 0;
SubstrateNetwork sNetwork = stack.getSubstrate();
for (SubstrateNode sn : sNetwork.getVertices()) {
for (AbstractResource res : sn.get()) {
for (Mapping m : res.getMappings()) {
AbstractDemand dem = m.getDemand();
if (dem instanceof CpuDemand) {
sum += ((CpuDemand) dem).getDemandedCycles();
i++;
}
}
}
}
return (i == 0 ? 0.0 : (sum / (double) i));
}
示例5: checkMLSResource
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* Checks that every SubstrateNode have an MLSResource
* @param sNet
* @return true if ok
*/
private boolean checkMLSResource(SubstrateNetwork sNet) {
boolean hasMLS;
for(SubstrateNode n : sNet.getVertices()) {
hasMLS = false;
for(AbstractResource r : n.get()){
if (r instanceof MLSResource)
hasMLS = true;
}
if(!hasMLS)
return false;
}
return true;
}
示例6: generateFreeSlotsResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateFreeSlotsResources(SubstrateNetwork network, HashMap<String, LinkedList<String>> labelsAndVNFTypes, int minFreeSlotsResources, int maxFreeSlotsResources, Random random) {
for (SubstrateNode n : network.getVertices()) {
int slots = Utils.rnd(minFreeSlotsResources, maxFreeSlotsResources, random);
LinkedList<String> keys = new LinkedList<String>(labelsAndVNFTypes.keySet());
String label = keys.get(Utils.rnd(0, keys.size() - 1, random));
n.add(new FreeSlotsResource(label, slots, n));
}
}
示例7: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public double calculate(NetworkStack stack) {
SubstrateNetwork sNetwork = stack.getSubstrate();
int max = 0;
for (SubstrateNode sn : sNetwork.getVertices()) {
int stress = VnrUtils.getStressLevel(sn);
if (stress > max) {
max = stress;
}
}
return max;
}
示例8: printResourceMappings
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void printResourceMappings(SubstrateNetwork sNetwork) {
for (SubstrateNode n : sNetwork.getVertices()) {
for (AbstractResource r : n.get()) {
if (!r.getMappings().isEmpty()) {
System.out.println(r.getMappings().size()
+ " mappings for node " + n);
for (vnreal.mapping.Mapping as : r.getMappings())
System.out.println(" " + as.getDemand() + " "
+ as.getResource());
}
}
}
}
示例9: generatePowerResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generatePowerResources(
SubstrateNetwork sNetwork) {
for (SubstrateNode n : sNetwork.getVertices()) {
PowerResource r = new PowerResource(n);
n.add(r);
}
}
示例10: generateFixedStaticEnergyConsumptionResources
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
public static void generateFixedStaticEnergyConsumptionResources(
SubstrateNetwork sNetwork, int consumption) {
for (SubstrateNode n : sNetwork.getVertices()) {
StaticEnergyResource r = new StaticEnergyResource(n, consumption);
n.add(r);
}
}
示例11: DistributedNode
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
DistributedNode(SubstrateNode node, SubstrateNetwork subNetwork) {
this.node = node;
this.subNetwork = subNetwork;
for (SubstrateNode sn : subNetwork.getVertices()) {
allSubstrateNodes.add(sn);
}
}
示例12: calculate
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
SubstrateNetwork sn = stack.getSubstrate();
int max = 0;
//Work through all SNodes
for (SubstrateNode n : sn.getVertices()) {
//Get the MLSResource
for(AbstractResource ar : n.get()) {
if(ar instanceof MLSResource) {
int plevel = ((MLSResource)ar).getProvide();
//Get the Mapping on this Resource
for(Mapping m : ar.getMappings()) {
//Check that the Mapping is from a Node (Links are handled in another Metric)
if(m.getDemand().getOwner() instanceof VirtualNode) {
//Calculate the difference from vNode demand minus snode provide
int diff = plevel - ((MLSDemand)m.getDemand()).getDemand();
if (diff > max)
max = diff;
}
}
}
}
}
return (max);
}
示例13: checkMLSResource
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
* Checks that every SubstrateNode have an MLSResource
* @param sNet
* @return true if ok
*/
public static boolean checkMLSResource(SubstrateNetwork sNet) {
boolean hasMLS;
for(SubstrateNode n : sNet.getVertices()) {
hasMLS = false;
for(AbstractResource r : n.get()){
if (r instanceof MLSResource)
hasMLS = true;
}
if(!hasMLS)
return false;
}
return true;
}
示例14: getSnodeById
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
/**
*
* @param id
* @return the substrate node corresponding to id
*/
private SubstrateNode getSnodeById(SubstrateNetwork sNet, int id) { // TODO: Find all instances of this and move to SubstrateNetwork
for (SubstrateNode tempSubsNode : sNet.getVertices()) {
if (tempSubsNode.getId() == id)
return tempSubsNode;
}
return null;
}
示例15: maxNodeResource
import vnreal.network.substrate.SubstrateNetwork; //导入方法依赖的package包/类
private Double maxNodeResource(SubstrateNetwork sNet) {
double max = 0;
for (SubstrateNode n : sNet.getVertices()) {
for (AbstractResource res : n) {
// Change it, and instance of abstract resource
if (res instanceof CpuResource) {
if ((((CpuResource) res).getAvailableCycles()) >= max)
max = (((CpuResource) res).getAvailableCycles());
}
}
}
return (max * 100);
}