public void expandeRule(RuleClassification rl, Instance inst, int ruleIndex) {
		int remainder = (int)Double.MAX_VALUE;
		int numInstanciaObservers = (int)rl.obserClassDistrib.sumOfValues();		// Number of instances for this rule observers.
		this.updateRuleAttribStatistics(inst, rl, ruleIndex);
	    if (numInstanciaObservers != 0 && this.gracePeriodOption.getValue() != 0) {
	        	 remainder = (numInstanciaObservers) % (this.gracePeriodOption.getValue());    
	        }
        if (remainder == 0){
        	this.saveBestValGlobalEntropy = new ArrayList<ArrayList<Double>>();
			this.saveBestGlobalEntropy = new DoubleVector();
			this.saveTheBest = new ArrayList<Double>();
			this.minEntropyTemp = Double.MAX_VALUE;
			this.minEntropyNominalAttrib = Double.MAX_VALUE;
	        theBestAttributes(inst, rl.observers);		// The best value of entropy for each attribute.
            boolean HB = checkBestAttrib(numInstanciaObservers, rl.observers, rl.obserClassDistrib);		// Check if the best attribute value is really the best.
    		if (HB == true) {
    			double attributeValue = this.saveTheBest.get(3);
    			double symbol = this.saveTheBest.get(2);		// =, <=, > (0.0, -1.0, 1.0).
    			double value = this.saveTheBest.get(0);		// Value of the attribute.
    			this.pred = new Predicates(attributeValue, symbol, value);
    			int countPred = 0;
    			for (int i = 0; i < rl.predicateSet.size(); i++) {		// Checks if the new predicate is not yet in the predicateSet. 
					 if (this.pred.getSymbol() == 0.0) {		// Nominal Attribute.
						 if (rl.predicateSet.get(i).getAttributeValue() != this.pred.getAttributeValue()) {
							 countPred = countPred + 1;
						 }
					 }
					 else {
						 if (rl.predicateSet.get(i).getAttributeValue() != this.pred.getAttributeValue() 
								 || rl.predicateSet.get(i).getSymbol() != this.pred.getSymbol() 
								 || rl.predicateSet.get(i).getValue() != this.pred.getValue()) {
							 countPred = countPred+1;
							 }
						 }
					 }
    			if (countPred == rl.predicateSet.size()) {
    				int countDifPred = 0;
					ArrayList<Predicates> predicSetTemp = new ArrayList<Predicates>();
					for (int x = 0; x < rl.predicateSet.size(); x++) {
						predicSetTemp.add(rl.predicateSet.get(x));
					 }
					predicSetTemp.add(this.pred);
					for (int f = 0; f < this.ruleSet.size(); f++) {
						int countDifPredTemp = 0;
						if (this.ruleSet.get(f).predicateSet.size() == predicSetTemp.size()) {
							for(int x = 0; x < this.ruleSet.get(f).predicateSet.size(); x++) {
								if (this.ruleSet.get(f).predicateSet.get(x).getAttributeValue() == predicSetTemp.get(x).getAttributeValue() 
										&& this.ruleSet.get(f).predicateSet.get(x).getSymbol() == predicSetTemp.get(x).getSymbol() 
										&& this.ruleSet.get(f).predicateSet.get(x).getValue() == predicSetTemp.get(x).getValue()) {
									countDifPredTemp = countDifPredTemp+1;
									}
								}
							if (countDifPredTemp == predicSetTemp.size()) {
								break;
								}else{
									countDifPred = countDifPred + 1;
									}
							}else{
						countDifPred = countDifPred + 1;
						}
						}
					if (countDifPred == this.ruleSet.size()) {
						if (this.pred.getSymbol() == 0.0) {
							initializeRuleStatistics(rl, pred, inst);
			    			} else if (this.pred.getSymbol() == 1.0) {
			    				int countIqualPred = 0;
			    				for (int f = 0; f < rl.predicateSet.size(); f++) {
			    					if (this.pred.getAttributeValue() == rl.predicateSet.get(f).getAttributeValue()
			    							&& this.pred.getSymbol() == rl.predicateSet.get(f).getSymbol()) {
			    						countIqualPred = countIqualPred + 1;
			    						if (this.pred.getValue() > rl.predicateSet.get(f).getValue()) {
			    							rl.predicateSet.remove(f);
			    							initializeRuleStatistics(rl, pred, inst);
	    				    				}
			    						}
			    					}
			    				if (countIqualPred == 0) {
			    					initializeRuleStatistics(rl, pred, inst);
	    				    		}
			    				}else{
	    						 int countIqualPred = 0;
	    						 for (int f = 0; f < rl.predicateSet.size(); f++) {
	    							 if (this.pred.getAttributeValue() == rl.predicateSet.get(f).getAttributeValue()
	    									 && this.pred.getSymbol() == rl.predicateSet.get(f).getSymbol()) {
	    								 countIqualPred = countIqualPred + 1;
	    								 if (this.pred.getValue() < rl.predicateSet.get(f).getValue()) {
	    									 rl.predicateSet.remove(f);
	    									 initializeRuleStatistics(rl, pred, inst);
	    				    				 }
	    								 }
	    							 }
	    						 if (countIqualPred == 0) {
	    							 initializeRuleStatistics(rl, pred, inst);
	    							 }
	    						 }
						}
					}
    			}
    		}
        }
public void expandeRule ( RuleClassification rl , Instance inst , int ruleIndex ) { int remainder = ( int ) Double . MAX_VALUE ; int numInstanciaObservers = ( int ) rl . obserClassDistrib . sumOfValues ( ) ; this . updateRuleAttribStatistics ( inst , rl , ruleIndex ) ; if ( numInstanciaObservers != 0 && this . gracePeriodOption . getValue ( ) != 0 ) { remainder = ( numInstanciaObservers ) % ( this . gracePeriodOption . getValue ( ) ) ; } if ( remainder == 0 ) { this . saveBestValGlobalEntropy = new ArrayList < ArrayList < Double > > ( ) ; this . saveBestGlobalEntropy = new DoubleVector ( ) ; this . saveTheBest = new ArrayList < Double > ( ) ; this . minEntropyTemp = Double . MAX_VALUE ; this . minEntropyNominalAttrib = Double . MAX_VALUE ; theBestAttributes ( inst , rl . observers ) ; boolean HB = checkBestAttrib ( numInstanciaObservers , rl . observers , rl . obserClassDistrib ) ; if ( HB == true ) { double attributeValue = this . saveTheBest . get ( 3 ) ; double symbol = this . saveTheBest . get ( 2 ) ; double value = this . saveTheBest . get ( 0 ) ; this . pred = new Predicates ( attributeValue , symbol , value ) ; int countPred = 0 ; for ( int i = 0 ; i < rl . predicateSet . size ( ) ; i ++ ) { if ( this . pred . getSymbol ( ) == 0.0 ) { if ( rl . predicateSet . get ( i ) . getAttributeValue ( ) != this . pred . getAttributeValue ( ) ) { countPred = countPred + 1 ; } } else { if ( rl . predicateSet . get ( i ) . getAttributeValue ( ) != this . pred . getAttributeValue ( ) || rl . predicateSet . get ( i ) . getSymbol ( ) != this . pred . getSymbol ( ) || rl . predicateSet . get ( i ) . getValue ( ) != this . pred . getValue ( ) ) { countPred = countPred + 1 ; } } } if ( countPred == rl . predicateSet . size ( ) ) { int countDifPred = 0 ; ArrayList < Predicates > predicSetTemp = new ArrayList < Predicates > ( ) ; for ( int x = 0 ; x < rl . predicateSet . size ( ) ; x ++ ) { predicSetTemp . add ( rl . predicateSet . get ( x ) ) ; } predicSetTemp . add ( this . pred ) ; for ( int f = 0 ; f < this . ruleSet . size ( ) ; f ++ ) { int countDifPredTemp = 0 ; if ( this . ruleSet . get ( f ) . predicateSet . size ( ) == predicSetTemp . size ( ) ) { for ( int x = 0 ; x < this . ruleSet . get ( f ) . predicateSet . size ( ) ; x ++ ) { if ( this . ruleSet . get ( f ) . predicateSet . get ( x ) . getAttributeValue ( ) == predicSetTemp . get ( x ) . getAttributeValue ( ) && this . ruleSet . get ( f ) . predicateSet . get ( x ) . getSymbol ( ) == predicSetTemp . get ( x ) . getSymbol ( ) && this . ruleSet . get ( f ) . predicateSet . get ( x ) . getValue ( ) == predicSetTemp . get ( x ) . getValue ( ) ) { countDifPredTemp = countDifPredTemp + 1 ; } } if ( countDifPredTemp == predicSetTemp . size ( ) ) { break ; } else { countDifPred = countDifPred + 1 ; } } else { countDifPred = countDifPred + 1 ; } } if ( countDifPred == this . ruleSet . size ( ) ) { if ( this . pred . getSymbol ( ) == 0.0 ) { initializeRuleStatistics ( rl , pred , inst ) ; } else if ( this . pred . getSymbol ( ) == 1.0 ) { int countIqualPred = 0 ; for ( int f = 0 ; f < rl . predicateSet . size ( ) ; f ++ ) { if ( this . pred . getAttributeValue ( ) == rl . predicateSet . get ( f ) . getAttributeValue ( ) && this . pred . getSymbol ( ) == rl . predicateSet . get ( f ) . getSymbol ( ) ) { countIqualPred = countIqualPred + 1 ; if ( this . pred . getValue ( ) > rl . predicateSet . get ( f ) . getValue ( ) ) { rl . predicateSet . remove ( f ) ; initializeRuleStatistics ( rl , pred , inst ) ; } } } if ( countIqualPred == 0 ) { initializeRuleStatistics ( rl , pred , inst ) ; } } else { int countIqualPred = 0 ; for ( int f = 0 ; f < rl . predicateSet . size ( ) ; f ++ ) { if ( this . pred . getAttributeValue ( ) == rl . predicateSet . get ( f ) . getAttributeValue ( ) && this . pred . getSymbol ( ) == rl . predicateSet . get ( f ) . getSymbol ( ) ) { countIqualPred = countIqualPred + 1 ; if ( this . pred . getValue ( ) < rl . predicateSet . get ( f ) . getValue ( ) ) { rl . predicateSet . remove ( f ) ; initializeRuleStatistics ( rl , pred , inst ) ; } } } if ( countIqualPred == 0 ) { initializeRuleStatistics ( rl , pred , inst ) ; } } } } } } }
This function This expands the rule