本文整理汇总了Java中vnreal.network.substrate.SubstrateLink类的典型用法代码示例。如果您正苦于以下问题:Java SubstrateLink类的具体用法?Java SubstrateLink怎么用?Java SubstrateLink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubstrateLink类属于vnreal.network.substrate包,在下文中一共展示了SubstrateLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
@Before
public void create() {
resources = new LinkedList<AbstractResource>();
BandwidthResource bwRes = new BandwidthResource(new SubstrateLink());
bwRes.setBandwidth(4.2);
resources.add(bwRes);
CpuResource cpuRes = new CpuResource(new SubstrateNode());
cpuRes.setCycles(3.0);
resources.add(cpuRes);
demands = new LinkedList<AbstractDemand>();
BandwidthDemand bwDem = new BandwidthDemand(new VirtualLink(1));
bwDem.setDemandedBandwidth(3.1);
demands.add(bwDem);
CpuDemand cpuDem = new CpuDemand(new VirtualNode(1));
cpuDem.setDemandedCycles(2.0);
demands.add(cpuDem);
}
示例2: createSubstrateNetwork
import vnreal.network.substrate.SubstrateLink; //导入依赖的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, Random random) {
WaxmanGraphGenerator<SubstrateNode, SubstrateLink> sGenerator = new WaxmanGraphGenerator<SubstrateNode, SubstrateLink>(
random, 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;
}
示例3: createSubstrateNetwork
import vnreal.network.substrate.SubstrateLink; //导入依赖的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;
}
示例4: generateRandomBandwidthResources
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
public static void generateRandomBandwidthResources(
SubstrateNetwork sNetwork, int minResourceBandwidth,
int maxResourceBandwidth, Random random,
boolean useCommonConstraints) {
for (SubstrateLink l : sNetwork.getEdges()) {
int value = Utils.rnd(minResourceBandwidth, maxResourceBandwidth, random);
if (useCommonConstraints) {
CommonResource r = new CommonResource(value, l);
l.add(r);
} else {
BandwidthResource bw = new BandwidthResource(l);
bw.setBandwidth((double) value);
l.add(bw);
}
}
}
示例5: calculate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
double remainingLinkRes = 0;
BandwidthResource tmpBwRes;
for (Iterator<SubstrateLink> tmpSLink = stack.getSubstrate().getEdges()
.iterator(); tmpSLink.hasNext();) {
SubstrateLink currSLink = tmpSLink.next();
for (AbstractResource res : currSLink) {
if (res instanceof BandwidthResource) {
tmpBwRes = (BandwidthResource) res;
remainingLinkRes += tmpBwRes.getAvailableBandwidth();
}
}
}
return remainingLinkRes;
}
示例6: calculate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
int inactiveLinks = 0;
boolean isActive;
for (SubstrateLink l : stack.getSubstrate().getEdges()) {
isActive = false;
for (AbstractResource res : l)
if (!res.getMappings().isEmpty()) {
isActive = true;
break;
}
if (!isActive)
inactiveLinks++;
}
return (inactiveLinks / ((double)stack.getSubstrate().getEdges().size()));
}
示例7: calculate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
double linkCost = 0;
BandwidthDemand tmpBwDem;
for (Iterator<SubstrateLink> tmpSLink = stack.getSubstrate().getEdges()
.iterator(); tmpSLink.hasNext();) {
SubstrateLink currSLink = tmpSLink.next();
AbstractResource res = currSLink.get(BandwidthResource.class);
if (res != null) {
for (Mapping f : res.getMappings()) {
tmpBwDem = (BandwidthDemand) f.getDemand();
linkCost += tmpBwDem.getDemandedBandwidth();
}
}
}
RejectedNetworksNumber numRej = new RejectedNetworksNumber();
return linkCost / ((stack.size() - 1) - numRej.calculate(stack));
}
示例8: calculate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
public double calculate(NetworkStack stack) {
double sum = 0.0;
int i = 0;
SubstrateNetwork sNetwork = stack.getSubstrate();
for (SubstrateLink sl : sNetwork.getEdges()) {
for (AbstractResource res : sl.get()) {
for (Mapping m : res.getMappings()) {
AbstractDemand dem = m.getDemand();
if (dem instanceof BandwidthDemand) {
sum += ((BandwidthDemand) dem).getDemandedBandwidth();
i++;
}
}
}
}
return (i == 0 ? 0.0 : (sum / (double) i));
}
示例9: calculate
import vnreal.network.substrate.SubstrateLink; //导入依赖的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);
}
示例10: generateConstraintsSubstrate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
/**
* Generates the constraints specified by the classes in resClasss. The
* values of the parameters of this constraints are randomly determined
* according to a uniform distribution in the interval [0, maxValue], with
* maxValue specified in the resMaxParamValues and demMaxParamValues as
* described below.
*
* @param resClasses
* The classes of the resources to generate.
* @param resParamNames
* The parameter names of the resources to generate.
* resParamNames.get(i) returns an array containing the parameter
* names for the resource class in resClasses.get(i).
* @param resParamMaxValues
* The maximum values for the parameters of the resources to
* generate. resParamMaxValues.get(i) returns an array containing
* the maximum values for the parameters of the resource class in
* resClasses.get(i).
*/
public static void generateConstraintsSubstrate(List<Class<?>> resClasses,
List<String[]> resParamNames, List<String[]> resParamMaxValues, NetworkStack stack) {
// generate the constraints from the tables
for (int r = 0; r < resClasses.size(); r++) {
// generate resources for the substrate network
if (isNodeClass(resClasses.get(r))) {
// node resource, get the parameters
for (SubstrateNode sNode : stack.getSubstrate()
.getVertices()) {
addResource(sNode, resClasses.get(r), resParamNames.get(r),
resParamMaxValues.get(r), stack);
}
} else {
// link resource
for (SubstrateLink sLink : stack.getSubstrate()
.getEdges()) {
addResource(sLink, resClasses.get(r), resParamNames.get(r),
resParamMaxValues.get(r), stack);
}
}
}
}
示例11: mapInEdges
import vnreal.network.substrate.SubstrateLink; //导入依赖的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;
}
示例12: calcLinksRes
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
/**
*
* @param sn
* Substrate node
* @return The available resources of the node sn
*/
private double calcLinksRes(SubstrateNetwork sNet, SubstrateNode sn) {
SubstrateNode srcSnode = null;
double resBW = 0;
double total_resBW = 0;
for (SubstrateLink sl : sNet.getEdges()) {
srcSnode = sNet.getSource(sl);
// If the processing SubstrateNode is equals to the source of a
// SubstrateLink then add the link
if (sn.equals(srcSnode)) {
for (AbstractResource res : sl) {
if (res instanceof BandwidthResource) {
resBW = ((BandwidthResource) res)
.getAvailableBandwidth();
total_resBW += resBW;
}
}
}
}
return total_resBW;
}
示例13: maxLinkResource
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
private Double maxLinkResource(SubstrateNetwork sNet) {
double max = 0;
for (Iterator<SubstrateLink> links = sNet.getEdges().iterator(); links
.hasNext();) {
SubstrateLink temp = links.next();
for (AbstractResource res : temp) {
if (res instanceof BandwidthResource) {
if ((((BandwidthResource) res).getAvailableBandwidth()) >= max)
max = (((BandwidthResource) res)
.getAvailableBandwidth());
}
}
}
return (max * 100);
}
示例14: generate
import vnreal.network.substrate.SubstrateLink; //导入依赖的package包/类
@Override
public List<CostResource> generate(ArrayList<Object> parameters) {
ArrayList<CostResource> resList = new ArrayList<CostResource>();
NetworkStack ns = (NetworkStack)parameters.get(0);
Integer minLC = ConversionHelper.paramObjectToInteger(parameters.get(1));
Integer maxLC = ConversionHelper.paramObjectToInteger(parameters.get(2));
Random random = new Random();
SubstrateNetwork sNet = ns.getSubstrate();
for (SubstrateLink l : sNet.getEdges()) {
CostResource bw = new CostResource(l);
int value = (int) (minLC + (maxLC
- minLC + 1)
* random.nextDouble());
bw.setCost((double) value);
l.add(bw);
resList.add(bw);
}
return resList;
}
示例15: mapOutEdges
import vnreal.network.substrate.SubstrateLink; //导入依赖的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;
}