예제 #1
0
  /**
   * This method return the output of the model defuzzified
   *
   * @param x The output
   */
  public double output(double[] x) {

    FuzzyAlphaCut xfuzzy[] = new FuzzyAlphaCut[x.length];
    for (int i = 0; i < x.length; i++)
      xfuzzy[i] = new FuzzyAlphaCut(new FuzzyNumberTRIANG(x[i], x[i], x[i]));

    R.replaceTerminals(xfuzzy);
    IntDouble[] result = R.CrispEval();

    if (defuzType == RuleBase.DEFUZCDM) {
      double addcenter = 0, addweight = 0;
      for (int i = 0; i < result.length; i++) {
        addcenter += C.getComponent(result[i].consequent).massCentre() * result[i].weight;
        addweight += result[i].weight;
      }

      if (addweight == 0) return 0; // The output is not covered. This mustn't ocurr.
      return addcenter / addweight;
    }

    if (defuzType == RuleBase.DEFUZMAX) {
      double center = 0, maxweight = 0;
      for (int i = 0; i < result.length; i++) {

        if (result[i].weight >= maxweight) {
          maxweight = result[i].weight;
          center = C.getComponent(result[i].consequent).massCentre();
        }
      }

      if (maxweight == 0) return 0; // The output is not covered. This musn't ocurr.
      return center;
    }

    return 0;
  }
예제 #2
0
 /** This method is for debug */
 public void debug() {
   R.debug();
 }
예제 #3
0
 /**
  * Constructor. Inicialize a new fuzzy model for GP
  *
  * @param pR Base rule
  * @param c Fuzzy partition
  * @param td Type of defuzzifier
  */
 public FuzzyGPModel(NodeRuleBase pR, FuzzyPartition c, int td) {
   R = (NodeRuleBase) pR.clone();
   C = c.clone();
   defuzType = td;
 }