本文整理汇总了Java中vnreal.network.virtual.VirtualLink类的典型用法代码示例。如果您正苦于以下问题:Java VirtualLink类的具体用法?Java VirtualLink怎么用?Java VirtualLink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualLink类属于vnreal.network.virtual包,在下文中一共展示了VirtualLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import vnreal.network.virtual.VirtualLink; //导入依赖的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: createVirtualNetworks
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
/**
* This method creates the virtual networks
*
* @param alpha
* @param beta
* @param numVNets
* @param numVNodesPerNet
* @return
*/
protected List<VirtualNetwork> createVirtualNetworks(Double alpha,
Double beta, Integer numVNets, Integer numVNodesPerNet, Random random) {
WaxmanGraphGenerator<VirtualNode, VirtualLink> vGenerator = new WaxmanGraphGenerator<VirtualNode, VirtualLink>(
random,
alpha, beta, false);
List<VirtualNetwork> vNetworks = new LinkedList<VirtualNetwork>();
for (int i = 1; i <= numVNets; ++i) {
VirtualNetwork vNetwork = new VirtualNetwork(i);
vNetwork.setName(i + "");
for (int n = 0; n < numVNodesPerNet; ++n) {
VirtualNode vn = new VirtualNode(i);
vNetwork.addVertex(vn);
}
vGenerator.generate(vNetwork);
vNetworks.add(vNetwork);
}
return vNetworks;
}
示例3: createVirtualNetworks
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
/**
* This method creates the virtual networks
*
* @param alpha
* @param beta
* @param numVNets
* @param numVNodesPerNet
* @return
*/
protected List<VirtualNetwork> createVirtualNetworks(Double alpha,
Double beta, Integer numVNets, Integer numVNodesPerNet) {
WaxmanGraphGenerator<VirtualNode, VirtualLink> vGenerator = new WaxmanGraphGenerator<VirtualNode, VirtualLink>(
alpha, beta, false);
List<VirtualNetwork> vNetworks = new LinkedList<VirtualNetwork>();
for (int i = 1; i <= numVNets; ++i) {
VirtualNetwork vNetwork = new VirtualNetwork(i);
vNetwork.setName(i + "");
for (int n = 0; n < numVNodesPerNet; ++n) {
VirtualNode vn = new VirtualNode(i);
vNetwork.addVertex(vn);
}
vGenerator.generate(vNetwork);
vNetworks.add(vNetwork);
}
return vNetworks;
}
示例4: 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);
}
}
}
示例5: transform
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
@Override
public AbstractDemand transform(AbstractDemand input) {
if (!accepts(input))
throw new AssertionError("have to check before");
BandwidthDemand bwDem = (BandwidthDemand) input;
// this cast is needed, as the constructor CpuDemand(NetworkEntity) was
// not compatible with the ScenarioImporter/Exporter and had to be
// replaced with CpuDemand(Link).
CpuDemand hh = new CpuDemand((VirtualLink) input.getOwner());
hh.setDemandedCycles(MiscelFunctions.round(factor * bwDem.getDemandedBandwidth(), 3));
return hh;
}
示例6: transform
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
@Override
public String transform(E e) {
if (enabled) {
StringBuilder labelSb = new StringBuilder();
labelSb.append("<html>" + e.toString() + "<ul>");
for (AbstractConstraint c : e.get()) {
labelSb.append("<li>");
labelSb.append(c.toString());
labelSb.append("</li>");
}
if (e.getClass().equals(VirtualLink.class))
for (AbstractConstraint hh : ((VirtualLink) e)
.getHiddenHopDemands()) {
labelSb.append("<li>HH ");
labelSb.append(hh.toString());
labelSb.append("</li>");
}
labelSb.append("</ul></html>");
return labelSb.toString();
} else
return null;
}
示例7: mapOutEdges
import vnreal.network.virtual.VirtualLink; //导入依赖的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;
}
示例8: mapInEdges
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
Collection<ResourceDemandEntry> mapInEdges(
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.getInEdges(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,
sOpposite, candidate.u, 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;
}
示例9: f
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
Collection<VirtualNode> f(Set<VirtualNode> vns, VirtualNetwork g) {
Collection<VirtualNode> result = new LinkedList<VirtualNode>();
for (VirtualLink vl : g.getEdges()) {
Pair<VirtualNode> endpoints = g.getEndpoints(vl);
VirtualNode n_i = endpoints.getFirst();
VirtualNode n_j = endpoints.getSecond();
if (Utils.contains(n_j, vns)) {
if (!Utils.contains(n_i, vns)) {
if (!Utils.contains(n_i, result)) {
result.add(n_i);
}
}
} else {
if (Utils.contains(n_i, vns)) {
if (!Utils.contains(n_j, result)) {
result.add(n_j);
}
}
}
}
return result;
}
示例10: setHhMappings
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
public void setHhMappings(List<IHiddenHopMapping> hhs) {
for (Network<?,?,?> net : ns.getVirtuals()) {
VirtualNetwork vNet = (VirtualNetwork) net;
for (VirtualLink vLink : vNet.getEdges()) {
// Clearing past hidden hops demands
vLink.clearHiddenHopDemands();
for (AbstractDemand dem : vLink) {
for (IHiddenHopMapping hh : hhs)
if (hh.accepts(dem))
vLink.addHiddenHopDemand(hh.transform(dem));
}
}
}
// Adding the hiddenhops mapping to the link and node mapping algorithm
linkMappingAlgorithm.setHhMappings(hhs);
nodeMappingAlgorithm.setHhMappings(hhs);
}
示例11: vlm
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
/**
* Performs virtual link mapping of a single virtual link into a substrate
* path
*
* @param vl
* virtual link
* @param spath
* list of substrate link forming the path
* @param sNet
* substrate network
* @param srcSNode
* source substrate node
* @return boolean value indicating whether mapping has been Successful or
* not.
*/
public final static boolean vlm(VirtualLink vl, List<SubstrateLink> spath,
SubstrateNetwork sNet, SubstrateNode srcSNode) {
for (SubstrateLink sl : spath) {
// ... a resource to each link demand must be assigned.
if (!occupy(vl.get(), sl)) {
return false;
} else {
if (!sNet.getSource(sl).equals(srcSNode)) {
if (!occupy(vl.getHiddenHopDemands(), sNet.getSource(sl)))
return false;
}
}
}
return true;
}
示例12: verifyPath
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
/**
* This method verifies if all the substrate links of a path accomplish the
* bandwidth and CPU (hidden hops) demands.
*
* @param demBW
* @param demCpu
* @param path
* @return boolean value indicating whether the path accomplishes the
* demands
*/
public final static boolean verifyPath(VirtualLink vl,
List<SubstrateLink> path, SubstrateNode srcSNode,
SubstrateNetwork sNet) {
for (SubstrateLink tSLink : path) {
if (!fulfills(vl.get(), tSLink)) {
return false;
} else {
if (!sNet.getSource(tSLink).equals(srcSNode)) {
if (!fulfills(vl.getHiddenHopDemands(),
sNet.getSource(tSLink)))
return false;
}
}
}
return true;
}
示例13: occupyResources
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
public static Collection<ResourceDemandEntry> occupyResources(
VirtualLink n1,
SubstrateNode n2) {
Collection<ResourceDemandEntry> resources =
new LinkedList<ResourceDemandEntry>();
for (AbstractDemand dem : n1.getHiddenHopDemands()) {
boolean found = false;
for (AbstractResource res : n2) {
if (res.accepts(dem) && res.fulfills(dem) && dem.occupy(res)) {
found = true;
resources.add(new ResourceDemandEntry(res, dem));
break;
}
}
assert (found);
}
return resources;
}
示例14: greatest
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
/**
*
* @param srcSNode
* Source substrate node of the substrate path
* @param candidatePaths
* set of candidate paths
* @param demBW
* Bandwidth demanded by the virtual link being processed
* @param vl
* virtual link
* @return the position of the great value of a set of paths. The method
* returns null if no path accomplishes the demands.
*/
private List<SubstrateLink> greatest(SubstrateNetwork sNet, SubstrateNode srcSNode,
Map<List<SubstrateLink>, Double> candidatePaths, VirtualLink vl) {
double greater = 0;
List<SubstrateLink> tmpPath;
List<SubstrateLink> greaterPath = null;
for (Iterator<List<SubstrateLink>> it = candidatePaths.keySet()
.iterator(); it.hasNext();) {
tmpPath = it.next();
if (candidatePaths.get(tmpPath) > greater
&& NodeLinkAssignation.verifyPath(vl, tmpPath, srcSNode,
sNet)) {
greater = candidatePaths.get(tmpPath);
greaterPath = tmpPath;
}
}
return greaterPath;
}
示例15: notifyMsg
import vnreal.network.virtual.VirtualLink; //导入依赖的package包/类
private LinkedList<Message> notifyMsg(int reqId, VirtualNode vNode,
SubstrateNode sNode, VirtualLink vLink) {
Request request = null;
for (Request r : requests) {
if (reqId == r.getRequestId()) {
request = r;
}
}
if (request == null) {
return (new LinkedList<Message>());
}
request.getVirtualNodesToEmbed().remove(vNode);
request.getSubNodesWithoutEmbeddedVirtNodes().remove(sNode);
// link and reversed link are removed in the mapALink method
// request.getVirtualLinksToEmbed().remove(vLink);
// request.getMapping().add(vNode, sNode);
return (new LinkedList<Message>());
}