Example #1
0
  /**
   * Returns if the classifier of the class is equal to the classifier given as a parameter.
   *
   * @param cl is a classifier.
   * @return a boolean indicating if they are equals.
   */
  public boolean equals(Classifier cl) {
    try {
      if (rep.getAction() != cl.rep.getAction()) return false;
      return rep.equals(cl.rep);

    } catch (Exception e) {
      return false;
    }
  } // end equals
Example #2
0
  /**
   * Returns if the classifier of the class subsumes the classifier passed as a parameter.
   *
   * @param cl is the subsumed classifier.
   * @return a boolean indicating if it subsumes
   */
  public boolean doesSubsume(Classifier cl) {

    if (rep.getAction() != cl.rep.getAction()) return false;

    if (parameters.couldSubsume()) {
      if (rep.isMoreGeneral(cl.rep)) {
        return true;
      }
    }
    return false;
  } // end doesSubsume
Example #3
0
  /**
   * Indicate if the current representation is more general than the representation passed as a
   * parameter.
   *
   * @param r is the representation to which the current representation is compared.
   * @return a boolean indicating if the current representation is more general.
   */
  public boolean isMoreGeneral(Representation r) {
    boolean ret = false;
    // We need to check the condition for the "insertInPSubsumingCl
    if (action != r.action) return false;

    if (numberOfDontCareSymbols() >= r.numberOfDontCareSymbols()) {
      for (int i = 0; i < rep.length; i++) {
        if (!rep[i].isMoreGeneral(r.rep[i])) return false;
      }
      return true;
    }

    return false;
  }
Example #4
0
 /**
  * It draws the population to a file. A character allele is drawn as 1 o 0. Otherwise, a real
  * allele is drawn in ten points, which represent the interval [0..1] divided in ten fragments. In
  * each fragment, there can be three types of symbols: . --> The fragment is not covered by the
  * classifier. o --> The fragment is partially covered by the classifier. O --> The fragment is
  * totally covered by the classifier.
  *
  * <p>This notation has been got from Wilson2000 XCSR
  *
  * @param fout is the file where the population has to be drawn.
  */
 public void draw(PrintWriter fout) {
   rep.draw(fout);
 } // end draw
Example #5
0
 /**
  * Prints the desnormalized classifier to the specified file.
  *
  * @param fout is the file output where the classifier has to be printed.
  */
 public void printNotNorm(PrintWriter fout) {
   rep.printNotNorm(fout);
   if (parameters != null) parameters.print(fout);
 }
Example #6
0
 /** Prints the classifier. */
 public void print() {
   rep.print();
   if (parameters != null) parameters.print();
 }
Example #7
0
 /**
  * Indicates if the classifier is more general than the classifier passed as a parameter.
  *
  * @param cl is the classifier to which the current classifier is compared.
  * @return a boolean indicating if the current classifier is more general
  */
 public boolean isMoreGeneral(Classifier cl) {
   return rep.isMoreGeneral(cl.rep);
 }
Example #8
0
 /**
  * Returns the number of don't care symbols in the classifier. It is used by the action set
  * subsumption
  *
  * @return a double with the number of don't care symbols.
  */
 public double numberOfDontCareSymbols() {
   return rep.numberOfDontCareSymbols();
 }
Example #9
0
 /**
  * Changes all the don't care symbols by the state in the environment, with Pspecify probability
  *
  * @param env is the environment.
  */
 public void makeSpecify(double[] env) {
   rep.makeSpecify(env);
 }
Example #10
0
 /**
  * Indicates if the classifier matches with the environmental state
  *
  * @param envState is the environment state
  * @return a boolean indicating if the classifier matches.
  */
 public boolean match(double[] envState) {
   return rep.match(envState);
 } // end match
Example #11
0
 /**
  * Sets the action passed to the classifier
  *
  * @param act is the action to be set.
  */
 public void setAction(int act) {
   rep.setAction(act);
 } // end setAction
Example #12
0
 /**
  * Returns the action of the classifier
  *
  * @return an integer with the action of the classifier
  */
 public int getAction() {
   return rep.getAction();
 } // end getAction
Example #13
0
 /**
  * sets the allele value
  *
  * @param i is the position.
  * @param cl is the classifier that has to be copied.
  */
 public void setAllele(int i, Classifier cl) {
   rep.setAllele(i, cl.rep);
 } // end setAllele
Example #14
0
 /**
  * Sets the allele value
  *
  * @param i is the position.
  * @param lowerValue is the lower value that has to be set.
  * @param upperValue is the upper value that has to be set.
  */
 public void setAllele(int i, double lowerValue, double upperValue) {
   rep.setAllele(i, lowerValue, upperValue);
 } // end setAllele
Example #15
0
 /**
  * It crosses a real allele within two parents. If the representation is a ternary representation,
  * a crossover within intervals is not possible because there is only one gene in each position.
  * So, in this case, the gene of the second parent will be copied. In case of being a real
  * representation, a random number is generated to decide where to cross the interval. It it's
  * crossed within the inteval, the crossAllele method will do it.
  *
  * @param parent1 is the first parent classifier.
  * @param parent2 is the second parent classifier.
  */
 public void crossAllele(int i, Classifier parent1, Classifier parent2) {
   rep.crossAllele(i, parent1.rep, parent2.rep);
 } // end crossAllele
Example #16
0
 /**
  * It constructs a classifier with the condition and the action specified. It's used by the
  * covering operator.
  *
  * <p>
  *
  * @param condition is the environtment state
  * @param action is the action chosen
  * @param size is the size of the set.
  * @param tStamp is the time
  */
 public Classifier(double[] condition, int action, int size, int tStamp) {
   rep = new Representation(condition, action);
   parameters = new Parameters(tStamp, size, rep.getGenerality());
 } // end Classifier
Example #17
0
 /**
  * Computes the generality of the classifier. Its result is stored in the generality parameter.
  */
 public void calculateGenerality() {
   parameters.setGenerality(rep.getGenerality());
 } // end calculateGenerality
Example #18
0
 /**
  * Mutates the classifier. It mutates the action and the condition.
  *
  * @param envState is the current environtment state. It is necessary for the niched mutation.
  * @return a boolean indicating if the action has been mutated.
  */
 public boolean mutate(double[] envState) {
   return rep.mutate(envState);
 } // end mutate