Пример #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;
  }
Пример #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;
 }
Пример #3
0
  @Override
  public double evaluateGlobalPolicy(
      int gene_index,
      IChromosome chromos,
      IMSApplication app,
      IMSProvider prov,
      InternetEstimator internet) {
    List<MSApplicationNode> nodes = app.getNodes();
    MSApplicationNode node = nodes.get(gene_index);
    Double budget = (Double) node.getCharacteristic().get(Constant.BUDGET);
    Double cost = calculateCost_Network(gene_index, chromos, app, prov);

    ((CIntegerGene) chromos.getGene(gene_index)).setAllocationCost(cost);

    Double maxCost = budget;
    double distance = calculateDistance_ErrHandling(cost, budget, maxCost);

    return distance * getWeight();
  }
Пример #4
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;
  }
Пример #5
0
  @Override
  public double evaluateLocalPolicy(
      Gene gene, MSApplicationNode node, IMSProvider prov, InternetEstimator internet) {
    Double budget = (Double) node.getCharacteristic().get(Constant.BUDGET);
    Double s_maxCost = (highStorageCost * StorageConstraint.getHighStorageValue());
    Double r_maxCost = (highRamCost * RamConstraint.getHighRamValue());

    Double cost = calculateCost(node, prov);
    ((CIntegerGene) gene).setAllocationCost(cost);

    Double maxCost = r_maxCost + s_maxCost;
    // maxCost = (budget > maxCost) ? budget : maxCost; // the max value could be the budget
    maxCost = (budget);

    double distance = calculateDistance_ErrHandling(cost, budget, maxCost);
    return distance * getWeight();
  }
Пример #6
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;
 }
Пример #7
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;
 }