Exemple #1
0
 /**
  * It prints on a string the content of the complex
  *
  * @return String a string with the content of the complex
  */
 public String printString() {
   String cad = "";
   for (int x = 0; x < compl.size(); x++) {
     Selector s = (Selector) compl.get(x);
     cad += nombreAtributos[s.getAttribute()] + " ";
     switch (s.getOperator()) {
       case 0:
         cad += "=";
         break;
       case 1:
         cad += "<>";
         break;
       case 2:
         cad += "<=";
         break;
       case 3:
         cad += ">";
         break;
     }
     double[] valores = s.getValues();
     if (valores.length > 1) {
       cad += " " + valores[0];
       for (int i = 1; i < valores.length - 1; i++) {
         cad += " ^ " + valores[i];
       }
       cad += " ^ " + valores[valores.length - 1] + "";
     } else {
       cad += " " + valores[0] + "";
     }
     if (x < compl.size() - 1) {
       cad += " AND ";
     }
   }
   return cad;
 }
Exemple #2
0
 /**
  * It checks if the complex covers a given example
  *
  * @param m The example
  * @return boolean True if it covers the example. False in other case
  */
 public boolean covered(Instance m) {
   boolean cubierto = true;
   double[] ejemplo = m.getMuest();
   for (int i = 0; i < this.size() && cubierto; i++) {
     Selector s = this.getSelector(i);
     switch (s.getOperator()) {
       case 0: // equal operator
         double[] valor = s.getValues();
         cubierto = false;
         for (int j = 0; (j < valor.length) && (!cubierto); j++) {
           cubierto = (ejemplo[s.getAttribute()] == valor[j]);
         }
         break;
       case 1: // distinct operator
         cubierto = ejemplo[s.getAttribute()] != s.getValue();
         break;
       case 2: // lower or equal
         cubierto = ejemplo[s.getAttribute()] <= s.getValue();
         break;
       case 3: // higher
         cubierto = ejemplo[s.getAttribute()] > s.getValue();
         break;
     }
   }
   return cubierto;
 }
Exemple #3
0
 /** It prints the complex content */
 public void print() {
   for (int x = 0; x < compl.size(); x++) {
     Selector s = (Selector) compl.get(x);
     System.out.print("(" + nombreAtributos[s.getAttribute()] + " ");
     switch (s.getOperator()) {
       case 0:
         System.out.print("=");
         break;
       case 1:
         System.out.print("<>");
         break;
       case 2:
         System.out.print("<=");
         break;
       default:
         System.out.print(">");
     }
     double[] valores = s.getValues();
     if (valores.length > 1) {
       System.out.print(" " + valores[0]);
       for (int i = 1; i < valores.length - 1; i++) {
         System.out.print(" ^ " + valores[i]);
       }
       System.out.print(" ^ " + valores[valores.length - 1] + ")");
     } else {
       System.out.print(" " + valores[0] + ")");
     }
     if (x < compl.size() - 1) {
       System.out.print(" AND ");
     }
   }
 }