Exemple #1
0
 /**
  * Check if the complex gets the given data
  *
  * @param m Muestra The example
  * @return boolean True if gets the example
  */
 public boolean isCovered(Sample m) {
   boolean cubierto = true;
   double[] sample = m.getSample();
   for (int i = 0; i < this.size() && cubierto; i++) { // recorremos los selectores del complejo
     Selector s = this.getSelector(i);
     switch (s.getOperator()) {
       case 0: // se trata del igual
         double[] valor = s.getValues();
         cubierto = false;
         // ahora cada selector solo guarda el minimo y maximo
         // para cuando se trata de una excepcion
         if (valor.length == 1) {
           if (sample[s.getAttribute()] == valor[0]) cubierto = true;
         }
         // ahora ya sabemos que valor solo va a tener 2 componentes
         else {
           if ((sample[s.getAttribute()] >= valor[0]) && (sample[s.getAttribute()] <= valor[1]))
             cubierto = true;
         }
         break;
       case 1: // se trata del distinto
         cubierto = sample[s.getAttribute()] != s.getZeroValue();
         break;
       case 2: // menor o igual
         cubierto = sample[s.getAttribute()] <= s.getZeroValue();
         break;
       case 3: // mayor
         cubierto = sample[s.getAttribute()] > s.getZeroValue();
         break;
     }
   }
   return cubierto;
 }
Exemple #2
0
  /**
   * Prints as a String the complex content (List->Attribute)
   *
   * @return a String the complex content
   */
  public String printString(int[] numValues) {

    String cad = "";
    for (int x = 0; x < compl.size(); x++) {
      Selector s = (Selector) compl.get(x);
      // cad += "Atr" + s.getAtributo() + " ";
      double[] values = s.getValues();
      String[] nValues = s.getNValues();
      // si para un atributo aparecen todos sus valores, la condicion es true
      // no imprimimos condicion
      if (values.length < numValues[s.getAttribute()]) {

        if ((x < (compl.size())) && (x > 0)) {
          cad += " AND ";
        }
        cad += attributeNames[s.getAttribute()] + " ";

        switch (s.getOperator()) {
          case 0:
            if (values.length > 1) cad += "in";
            else cad += "=";
            break;
          case 1:
            cad += "<>";
            break;
          case 2:
            cad += "<=";
            break;
          case 3:
            cad += ">";
            break;
        }

        if (Attributes.getInputAttribute(s.getAttribute()).getType() == Attribute.NOMINAL) {
          if (nValues.length > 1) {
            cad += " [" + nValues[0];
            for (int i = 1; i < nValues.length - 1; i++) {
              cad += " , " + nValues[i];
            }
            cad += " , " + nValues[nValues.length - 1] + "] ";
          } else {
            cad += " " + nValues[0] + "";
          }
        } else {
          if (values.length > 1) {
            cad += " [" + values[0];
            for (int i = 1; i < values.length - 1; i++) {
              cad += " , " + values[i];
            }
            cad += " , " + values[values.length - 1] + "]";
          } else {
            cad += " " + values[0] + "";
          }
        }
      }
    }
    return cad;
  }
Exemple #3
0
  /**
   * Prints on the standard output the content of this complex object. (List -> Attribute operator
   * value)
   */
  public void print(int nominal) {
    for (int x = 0; x < compl.size(); x++) {
      Selector s = (Selector) compl.get(x);

      double[] values = s.getValues();
      String[] nValues = s.getNValues();

      // System.out.print("(Atr" + s.getAtributo() + " ");
      System.out.print("(" + attributeNames[s.getAttribute()] + " ");

      switch (s.getOperator()) {
        case 0:
          if (values.length > 1 /*|| valoresN.length>1*/) System.out.print("in");
          else System.out.print("=");
          break;
        case 1:
          System.out.print("<>");
          break;
        case 2:
          System.out.print("<=");
          break;
        default:
          System.out.print(">");
      }

      if (nominal == 0) { // el atributo es nominal
        if (nValues.length > 1) {
          System.out.print(" " + nValues[0]);
          for (int i = 1; i < nValues.length - 1; i++) {
            System.out.print(" " + nValues[i]);
          }
          System.out.print(" " + nValues[nValues.length - 1] + ")");
        } else {
          System.out.print(" " + nValues[0] + ")");
        }
      } else {
        if (values.length > 1) {
          System.out.print(" [" + values[0]);
          for (int i = 1; i < values.length - 1; i++) {
            System.out.print(" " + values[i]);
          }
          System.out.print(" " + values[values.length - 1] + "])");
        } else {
          System.out.print(" " + values[0] + ")");
        }
      }

      if (x < compl.size() - 1) {
        System.out.print(" AND ");
      }
      // System.out.print(" -- "+heuristica+" -- ");
      System.out.println();
    }
  }
Exemple #4
0
  /**
   * Checks if the rule gets the parameter instance
   *
   * @param instance the instance
   * @return boolean True if the rule gets the instance
   */
  public boolean instanceCoveredByRule(Instance instance) {
    boolean bCovered = true;
    double cadena;
    for (int i = 0; i < this.size() && bCovered; i++) {
      Selector s = this.getSelector(i);
      switch (s.getOperator()) {
        case 0: // se trata del igual
          double[] valor = s.getValues();
          bCovered = false;
          for (int j = 0; (j < valor.length) && (!bCovered); j++) {
            cadena = instance.getInputRealValues(s.getAttribute());

            if (cadena == valor[j]) bCovered = true;
            else bCovered = false;
            /*int numInputAttributes  = Attributes.getInputNumAttributes();
            int numOutputAttributes = Attributes.getOutputNumAttributes();
            int numUndefinedAttributes = Attributes.getNumAttributes();*/
          }
          break;
      }
    }
    return bCovered;
  }