Exemplo n.º 1
0
  private void normalizeCriteriaWeights() {

    // normalize the general criteria
    System.out.println("SYSTEM: Normalizing general criteria");
    double total = 0;
    for (Criterion crit : data.getCriteria()) {
      total = total + crit.getWeight();
    }

    for (Criterion crit : data.getCriteria()) {
      double res = crit.getWeight() / total;
      System.out.println(
          "SYSTEM: Total: " + total + " || value: " + crit.getWeight() + "|| res: " + res);
      crit.setWeight(res);
    }

    // normalize each of the Service Templates
    for (ServiceTemplate template : data.getServiceTemplates()) {
      System.out.println(
          "SYSTEM: Normalizing criteria of the serviceTemplate: " + template.getId());
      double templateTotal = 0;
      for (Criterion crit : template.getCriteria()) {
        templateTotal = templateTotal + crit.getWeight();
      }

      for (Criterion crit : template.getCriteria()) {
        double res = crit.getWeight() / templateTotal;
        System.out.println(
            "SYSTEM: Total: "
                + templateTotal
                + " || value: "
                + crit.getWeight()
                + "|| res: "
                + res);
        crit.setWeight(res);
      }
    }
  }