Ejemplo 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);
      }
    }
  }
Ejemplo n.º 2
0
  private void convertReqsInCriterions() {
    // convert the general requirements
    ArrayList<Criterion> criteria = this.data.getCriteria();

    for (Requirement req : this.data.getRequirements()) {
      if (req.isCriterion()) {
        // create new criterion
        Criterion crit = new Criterion();
        if (req.getQuantType() != null) crit.setName(req.getQuantType().getValue());
        else if (req.getQualType() != null) crit.setName(req.getQualType().getValue());
        else
          // this is a price requirement
          crit.setName("price");

        String[] msg = {crit.getName(), "General"};
        if (this.methodID == CloudAid.SAW) {
          Float weight = Float.parseFloat(CloudAid.askData(CloudAid.GET_WEIGHT, msg, null));
          crit.setWeight(weight);
        }
        // get the criterion preference direction
        String res = CloudAid.askData(CloudAid.GET_PREFERENCE_DIRECTION, msg, null);
        if (res.equalsIgnoreCase("y")) {
          crit.setPreferenceDirection("max");
        } else if (res.equalsIgnoreCase("n")) {
          crit.setPreferenceDirection("min");
        }

        criteria.add(crit);
      }
    }
    this.data.setCriteria(criteria);

    // convert each serpiceTemplate requirements
    for (ServiceTemplate template : this.data.getServiceTemplates()) {
      ArrayList<Criterion> templateCriteria = template.getCriteria();
      for (Requirement req : template.getRequirements()) {
        if (req.isCriterion()) {
          // create new criterion
          Criterion crit = new Criterion();
          if (req.getQuantType() != null) crit.setName(req.getQuantType().getValue());
          else if (req.getQualType() != null) crit.setName(req.getQualType().getValue());
          else
            // this is a price requirement
            crit.setName("price");

          String[] msg = {crit.getName(), template.getType()};
          if (this.methodID == CloudAid.SAW) {
            Float weight = Float.parseFloat(CloudAid.askData(CloudAid.GET_WEIGHT, msg, null));
            crit.setWeight(weight);
          }

          // get the criterion preference direction
          String res = CloudAid.askData(CloudAid.GET_PREFERENCE_DIRECTION, msg, null);
          if (res.equalsIgnoreCase("y")) {
            crit.setPreferenceDirection("max");
          } else if (res.equalsIgnoreCase("n")) {
            crit.setPreferenceDirection("min");
          }

          templateCriteria.add(crit);
        }
      }
      template.setCriteria(templateCriteria);
    }
  }