Esempio n. 1
0
 private static Double calculateCost_Network(
     int i, IChromosome chromos, IMSApplication app, IMSProvider prov) {
   MSApplicationNode node = app.getNodes().get(i);
   Double cpu_cost = cpuCost(node, prov);
   Double r_cost = ramCost(node, prov);
   Double s_cost = storageCost(node, prov);
   Double net_cost = netCost(i, chromos, app, prov);
   // System.out.println(r_cost + " + " + s_cost);
   return r_cost + s_cost + cpu_cost + net_cost;
 }
Esempio n. 2
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();
  }
Esempio 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;
  }