public class CloudletToVmMappingSolution extends Object implements HeuristicSolution<Map<Cloudlet,Vm>>
Heuristic
implementation.Heuristic
Modifier and Type | Field and Description |
---|---|
static double |
MIN_DIFF
When two double values are subtracted to check if they are equal zero,
there may be some precision issues.
|
LOGGER, NULL
Constructor and Description |
---|
CloudletToVmMappingSolution(CloudletToVmMappingSolution solution)
Clones a given solution.
|
CloudletToVmMappingSolution(Heuristic heuristic)
Creates a new solution for mapping a set of cloudlets to VMs using
a given heuristic implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
bindCloudletToVm(Cloudlet cloudlet,
Vm vm)
Binds a cloudlet to be executed by a given Vm.
|
int |
compareTo(HeuristicSolution solution)
Compares this solution with another given one, based on the solution
cost.
|
double |
getCost()
Defines the cost of using this solution.
|
double |
getCost(boolean forceRecompute)
It computes the costs of the entire mapping between Vm's and cloudlets.
|
Heuristic<HeuristicSolution<Map<Cloudlet,Vm>>> |
getHeuristic() |
protected List<Map.Entry<Cloudlet,Vm>> |
getRandomMapEntries()
Try to get 2 randomly selected entries from the
cloudletVmMap . |
Map<Cloudlet,Vm> |
getResult()
Gets the result of the solution.
|
double |
getVmCost(Map.Entry<Vm,List<Map.Entry<Cloudlet,Vm>>> entry)
Computes the cost of all Cloudlets hosted by a given Vm.
|
double |
getVmCost(Vm vm,
List<Cloudlet> cloudlets)
Computes the cost of all Cloudlets hosted by a given Vm.
|
protected boolean |
swapVmsOfTwoMapEntries(List<Map.Entry<Cloudlet,Vm>> entries)
Swap the Vm's of 2 randomly selected cloudlets
in the
cloudletVmMap in order to
provide a neighbor solution. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFitness
public static final double MIN_DIFF
public CloudletToVmMappingSolution(Heuristic heuristic)
heuristic
- the heuristic implementation used to find the solution
being created.public CloudletToVmMappingSolution(CloudletToVmMappingSolution solution)
solution
- the solution to be clonedpublic void bindCloudletToVm(Cloudlet cloudlet, Vm vm)
cloudlet
- the cloudlet to be added to a Vmvm
- the Vm to assign a cloudlet topublic Heuristic<HeuristicSolution<Map<Cloudlet,Vm>>> getHeuristic()
getHeuristic
in interface HeuristicSolution<Map<Cloudlet,Vm>>
public double getCost()
getCost
in interface HeuristicSolution<Map<Cloudlet,Vm>>
HeuristicSolution.getFitness()
public double getCost(boolean forceRecompute)
forceRecompute
- indicate if the cost has to be recomputed anywaygetCost()
public double getVmCost(Map.Entry<Vm,List<Map.Entry<Cloudlet,Vm>>> entry)
entry
- a Map Entry where the key is a VM hosting some Cloudlets
and the value is the Cloudlets hosted in this VM.public double getVmCost(Vm vm, List<Cloudlet> cloudlets)
vm
- the VM to compute the cost to host some Cloudletscloudlets
- the list of Cloudlets to be hosted by the VM in order to compute the costpublic int compareTo(HeuristicSolution solution)
compareTo
in interface Comparable<HeuristicSolution<Map<Cloudlet,Vm>>>
solution
- the solution to compare this instance topublic Map<Cloudlet,Vm> getResult()
HeuristicSolution
Map<Cloudlet, Vm>
, that will indicate which Vm will
run each Cloudlet.
This way, the type T of the solution is totally dependent of the problem
being solved by the heuristic implementation.
The result of solution is generated by a heuristic. Getting an optimal or sub-optimal solution is the final goal of a heuristic.
getResult
in interface HeuristicSolution<Map<Cloudlet,Vm>>
protected final boolean swapVmsOfTwoMapEntries(List<Map.Entry<Cloudlet,Vm>> entries)
cloudletVmMap
in order to
provide a neighbor solution.
The method change the given Map entries, moving the
cloudlet of the first entry to the Vm of the second entry
and vice-versa.entries
- a List of 2 entries containing Cloudlets to swap their VMs.
If the entries don't have 2 elements, the method will
return without performing any change in the entries.protected List<Map.Entry<Cloudlet,Vm>> getRandomMapEntries()
cloudletVmMap
.cloudletVmMap
if the map size is at least 2;
an unitary List if the map has only 1 entry;
or an empty List if there is no entry in the map.swapVmsOfTwoMapEntries(List)
Copyright © 2015–2019 Systems, Security and Image Communication Lab - Instituto de Telecomunica����es (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educa����o Ci��ncia e Tecnologia do Tocantins (IFTO). All rights reserved.