Exemplo n.º 1
0
  public static double calculateCostDesired(MSApplicationNode node, IMSProvider prov) {
    double costPerStorage =
        (Double) prov.getStorage().getCharacteristic().get(Constant.COST_STORAGE);
    long storage = (long) node.getDesiredCharacteristic().get(Constant.STORE);
    Double costS = storage * costPerStorage;

    Double costPerMem = (Double) prov.getCharacteristic().get(Constant.COST_MEM);
    Integer ram = (Integer) node.getDesiredCharacteristic().get(Constant.RAM);
    Double costM = ram * costPerMem;

    Double costPerCPU = (Double) prov.getCharacteristic().get(Constant.COST_SEC);
    Integer cpu_number = (Integer) node.getDesiredCharacteristic().get(Constant.CPU_NUMBER);
    Double costCPU = cpu_number * costPerCPU;
    return costS + costM + costCPU;
  }
Exemplo n.º 2
0
 private static double storageCost(MSApplicationNode node, IMSProvider prov) {
   double costPerStorage =
       (Double) prov.getStorage().getCharacteristic().get(Constant.COST_STORAGE);
   long storage = (long) node.getStorage().getCharacteristic().get(Constant.STORE);
   Double cost = storage * costPerStorage;
   return cost;
 }
Exemplo n.º 3
0
  private static double netCost(
      int gene_index, IChromosome chromos, IMSApplication app, IMSProvider prov) {
    Double costPerNet = (Double) prov.getNetwork().getCharacteristic().get(Constant.COST_BW);

    Gene[] genes = chromos.getGenes();
    int current_prov = (int) genes[gene_index].getAllele();
    MSApplicationNode curr_node = app.getNodes().get(gene_index); // this is safe
    int geneVmId = curr_node.getID();
    MSApplication am = (MSApplication) app;
    double cost = 0;
    Set<ApplicationEdge> set = am.getEdges();
    for (ApplicationEdge e : set) {
      if (e.getSourceVmId() == geneVmId) {
        int target_index = MSPolicy.getGeneIndexFromNodeId(e.getTargetVmId(), genes, app);

        int tProvId = (int) genes[target_index].getAllele();
        cost += CostComputer.computeLinkCost(e, geneVmId, current_prov, tProvId, costPerNet);
      }
    }
    return cost;
  }
Exemplo n.º 4
0
 private static double cpuCost(MSApplicationNode node, IMSProvider prov) {
   Double costPerCPU = (Double) prov.getCharacteristic().get(Constant.COST_SEC);
   Integer cpu_number = (Integer) node.getComputing().getCharacteristic().get(Constant.CPU_NUMBER);
   Double cost = cpu_number * costPerCPU;
   return cost;
 }
Exemplo n.º 5
0
 private static double ramCost(MSApplicationNode node, IMSProvider prov) {
   Double costPerMem = (Double) prov.getCharacteristic().get(Constant.COST_MEM);
   Integer ram = (Integer) node.getComputing().getCharacteristic().get(Constant.RAM);
   Double cost = ram * costPerMem;
   return cost;
 }