[jboss-svn-commits] JBL Code SVN: r21961 - in labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools: common and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Aug 28 12:55:53 EDT 2008


Author: dsotty
Date: 2008-08-28 12:55:53 -0400 (Thu, 28 Aug 2008)
New Revision: 21961

Modified:
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainLeftTuple.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainReteooRuleBase.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainRightTuple.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/AndConstraint.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/ConstraintSignature.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/Forall.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/OrConstraint.java
Log:
New branch for uncertainty support in 5.x

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 JBoss Inc
+compo * Copyright 2007 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -1066,7 +1066,7 @@
     		final Activation activation,
     		Hashtable<ConstraintSignature, IUncertainDegree> priors) throws FactException {
 
-    	System.out.println("AbstractWorkingMemory : Uncertain  State / Justify Ordeal");
+//    	System.out.println("AbstractWorkingMemory : Uncertain  State / Justify Ordeal");
 
     	if ( object == null ) {
 //  		you cannot assert a null object
@@ -1080,7 +1080,7 @@
 
     	//TODO : Not really supported yet...
     	if ( isSequential() ) {
-    		System.out.println("AWM :Sequential mode, buggy. TODO");
+//    		System.out.println("AWM :Sequential mode, buggy. TODO");
     		handle = this.handleFactory.newUncertainFactHandle( object,
     				priors,
     				typeConf,    				
@@ -1127,14 +1127,14 @@
     					key.setStatus( EqualityKey.STATED );   
     					//Restate with true overrides following evaluations.
     					//Starting again from zero, evaluators must contribute 
-    					System.out.println("AWM : State existing-by-ID statement, which is overridden");
+//    					System.out.println("AWM : State existing-by-ID statement, which is overridden");
     					return this.reAssert(entryPoint, handle, rule, activation, typeConf, priors, false, false);    					
     					
     				} else {
     					// This is a JUSTIFY.     					
     					if  (key.getStatus() == EqualityKey.STATED) {
     						//If the object is stated, the justification is ignored
-    						System.out.println("AWM : Justify existing-by-ID statement, ignored");
+//    						System.out.println("AWM : Justify existing-by-ID statement, ignored");
     						return handle;
     					} else {
     						//TODO: Priors should enter the dependency, so to be undone
@@ -1146,7 +1146,7 @@
     						}
     						//Restate with false merges info...
     						// Evaluators contrib already in, so they must be inhibited
-    						System.out.println("AWM : Justify existing-by-ID justify, merge but not reeval");
+//    						System.out.println("AWM : Justify existing-by-ID justify, merge but not reeval");
     						return this.reAssert(entryPoint, handle, rule, activation, typeConf,priors, true, true);
     					}
     				}
@@ -1168,12 +1168,12 @@
         								activation.getPropagationContext(),
         								rule );
         						//Merge new info, but inhibit evaluators
-        						System.out.println("AWM : Justify existing-by-EQ justify, merge but not reeval");
+//        						System.out.println("AWM : Justify existing-by-EQ justify, merge but not reeval");
         						return reAssert(entryPoint, key.getFactHandle(), rule, activation,typeConf, priors,true,true);
         						//return key.getFactHandle();
         					} else {
         						// Can't justify a stated obj, do nothing
-        						System.out.println("AWM : Justify existing-by-EQ statement, do nothing");
+//        						System.out.println("AWM : Justify existing-by-EQ statement, do nothing");
         						return key.getFactHandle();
         					}
     						
@@ -1184,7 +1184,7 @@
     						if ( key.getStatus() == EqualityKey.STATED ) {
     							// The obj was already stated, so reset that other object.
     							// THIS IS A DIFFERENCE WITH THE USUAL SEMANTICS 
-    							System.out.println("AWM : State existing-by-EQ statement, override with values and new eval");
+//    							System.out.println("AWM : State existing-by-EQ statement, override with values and new eval");
     							return reAssert(entryPoint, key.getFactHandle(), rule, activation,typeConf, priors,false,false);
     						} else {
     							// Stating an existing equal obj, which is only justified.
@@ -1194,7 +1194,7 @@
     	    					key.setStatus( EqualityKey.STATED );   
     	    					//Restate with true overrides following evaluations.
     	    					//Starting again from zero, evaluators must contribute 
-    	    					System.out.println("AWM : State existing-by-EQ justify, cleanup and override");
+//    	    					System.out.println("AWM : State existing-by-EQ justify, cleanup and override");
     	    					return this.reAssert(entryPoint, key.getFactHandle(), rule, activation, typeConf,priors, false, false);  
     						}
     					
@@ -1216,7 +1216,7 @@
         				this.tms.put( key );
         				if ( !logical ) {
         					key.setStatus( EqualityKey.STATED );
-        					System.out.println("AWM : Brand new statement, eval everything");
+//        					System.out.println("AWM : Brand new statement, eval everything");
         					return reAssert(entryPoint, handle, rule, activation,typeConf, priors,false,false);
         				} else {
         					key.setStatus( EqualityKey.JUSTIFIED );
@@ -1225,7 +1225,7 @@
         							activation,
         							activation.getPropagationContext(),
         							rule );
-        					System.out.println("AWM : Brand new justification, eval everything");
+//        					System.out.println("AWM : Brand new justification, eval everything");
         					return reAssert(entryPoint, handle, rule, activation ,typeConf,priors,false,false);
         				}
     					
@@ -1239,14 +1239,14 @@
     			// OK, here no TMS:
     			// Logical insertions are ignored, statement exists already.
     			if (logical) {
-    				System.out.println("AWM : No TMS, logical insertion ignored");
+//    				System.out.println("AWM : No TMS, logical insertion ignored");
     				return null;
     			}
     			
     			if ( handle != null ) {
     				// Object exists, priors are updated just later
     				//TODO: Check: Obj should be retracted before being inserted again??
-    				System.out.println("AWM : No TMS, stated existing object, nothing done");
+//    				System.out.println("AWM : No TMS, stated existing object, nothing done");
     				return handle;
     			} else {
     			// No object exists, so we just create. Priors will be set just later
@@ -1256,7 +1256,7 @@
     					this );
     				this.objectStore.addHandle( handle, object );
     				//Nothing to merge with, let the evaluators play
-    				System.out.println("AWM : No TMS, new insertion is evaluated");
+//    				System.out.println("AWM : No TMS, new insertion is evaluated");
     				return reAssert(entryPoint, handle, rule, activation,typeConf,priors,false,false);
     			}
 
@@ -1329,8 +1329,8 @@
     			entryPoint );
     	
     	
-    	System.out.println("AbstractWorkingMemory : Wrapped a to-be-inserted obj with a handle");
-    	System.out.println("AbstractWorkingMemory : New insert method uses uncValues");
+//    	System.out.println("AbstractWorkingMemory : Wrapped a to-be-inserted obj with a handle");
+//    	System.out.println("AbstractWorkingMemory : New insert method uses uncValues");
 
         this.entryPointNode.assertObject( handle,
                                           propagationContext,

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -321,7 +321,7 @@
     			InternalWorkingMemory workingMemory) {
     		    	                    
             IUncertainDegree constrDeg = this.constraint.matches( factHandle, workingMemory, this.contextEntry );                            
-            	System.out.println("UNCERTAIN AlphaNode.ObjectSinkUpdateAdapter : Passed object "+factHandle.getObject()+ " with degree "+constrDeg);
+//            	System.out.println("UNCERTAIN AlphaNode.ObjectSinkUpdateAdapter : Passed object "+factHandle.getObject()+ " with degree "+constrDeg);
                                                                
                     this.sink.assertObject( factHandle,
                     			   		    truthVal,
@@ -359,7 +359,7 @@
 		final AlphaMemory memory = (AlphaMemory) workingMemory.getNodeMemory( this );
                 	
         IUncertainDegree constrDeg = this.constraint.matches( factHandle, workingMemory, memory.context );                            
-        	System.out.println("UNCERTAIN AlphaNode : Passed object "+factHandle.getObject()+ " with degree "+constrDeg);
+//        	System.out.println("UNCERTAIN AlphaNode : Passed object "+factHandle.getObject()+ " with degree "+constrDeg);
          
         truthVal.addLast(constrDeg);
                 	

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -181,7 +181,7 @@
         		Deque<IUncertainDegree> truthVal = (tVal != null) ? tVal : new LinkedList<IUncertainDegree>();  
         			        		
         			truthVal.addLast(cachedNodes.get(node));
-        		System.out.println("EntryPointNode : Dispatching "+handle.getObject() + " to node "+node + "with tval "+cachedNodes.get(node));
+//        		System.out.println("EntryPointNode : Dispatching "+handle.getObject() + " to node "+node + "with tval "+cachedNodes.get(node));
         		node.assertObject(handle, truthVal, context, workingMemory);
         	}        	
 	        

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -22,14 +22,18 @@
 
 import org.drools.IUncertainRuleBase;
 import org.drools.RuntimeDroolsException;
+import org.drools.WorkingMemory;
 import org.drools.common.BetaConstraints;
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
 import org.drools.reteoo.builder.BuildContext;
 import org.drools.rule.Behavior;
 import org.drools.spi.PropagationContext;
+import org.drools.spi.Tuple;
 
 import uncertainty.factory.IDegreeFactory;
+import uncertainty.predicates.IInducible;
+import uncertainty.predicates.IInductor;
 import uncertainty.truthvals.IUncertainDegree;
 
 /**
@@ -154,6 +158,8 @@
     private void assertUncertainLeftTuple(LeftTuple leftTuple,
 			PropagationContext context, InternalWorkingMemory workingMemory) {
     	
+    	boolean found = false;
+    	
     	IDegreeFactory factory = ((IUncertainRuleBase) workingMemory.getRuleBase()).getTruthFactory();
     	
     	final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
@@ -163,26 +169,112 @@
                                           leftTuple );
         
         
+        //TODO : THIS is what the node should do, more or less
         
-        Vector<IUncertainDegree> degrees = new Vector<IUncertainDegree>();
-        for ( RightTuple rightTuple = memory.getRightTupleMemory().getLast( leftTuple ); rightTuple != null; rightTuple = (RightTuple) rightTuple.getPrevious() ) {        	
-            IUncertainDegree mDeg = this.constraints.matchesCachedLeft(memory.getContext(), rightTuple.getFactHandle(), factory);
-                    	
-        	//TODO : Creare una sorta di "resetTupleDegree"
-        	((UncertainRightTuple) rightTuple).setDegree(mDeg);
+        
+        IUncertainDegree existDegree = null;
+        
+        //boolean rightInducible = (memory.getRightTupleMemory().getLast( leftTuple ).getFactHandle().getObject() instanceof IInducible);
+        boolean leftInductor = leftTuple.getLastHandle().getObject() instanceof IInductor;
+        
+        //if ( ! (leftTuple.getLastHandle().getObject()  instanceof IInducible)) {
+        //if ( ! (rightInducible && leftInductor)) {
+        if ( ! leftInductor) {
+        
+		        Vector<IUncertainDegree> degrees = new Vector<IUncertainDegree>();
+		        for ( RightTuple rightTuple = memory.getRightTupleMemory().getLast( leftTuple ); rightTuple != null; rightTuple = (RightTuple) rightTuple.getPrevious() ) {        	
+		            IUncertainDegree mDeg = this.constraints.matchesCachedLeft(memory.getContext(), rightTuple.getFactHandle(), factory);
+		                    	
+		        	
+		        	((UncertainRightTuple) rightTuple).setDegree(mDeg);
+		        			        	
+		        	IUncertainDegree joinVal = factory.getAndOperator().eval(((UncertainRightTuple) rightTuple).getTruthVal().toArray(new IUncertainDegree[1]));
+		        	
+		        	
+		        	
+//		        	if (joinVal.toBoolean()) {
+		        		degrees.add(joinVal);
+//		        	}
+		        	((UncertainRightTuple) rightTuple).resetDegree();
+		        	
+		        	
+		        }
+		        IUncertainDegree[] degsArray = new IUncertainDegree[degrees.size()];
+		        
+		        if (degrees.size() > 0) {
+		        	existDegree = factory.getMaxOrOperator().eval(degrees.toArray(degsArray));
+		        	//found = existDegree.toBoolean();
+		        	found = true;
+		        } else {
+		        	existDegree = factory.False();
+		        	found = false;
+		        }
+		        
+		        
+		        
+		        
+        } else {
+        	//TODO : Remove this 
+            // This is not supposed to be here, jsut use the normal behaviour	
         	
-        	
-        	IUncertainDegree joinVal = factory.getAndOperator().eval(((UncertainRightTuple) rightTuple).getTruthVal().toArray(new IUncertainDegree[1]));
-        	degrees.add(joinVal);
-        	((UncertainRightTuple) rightTuple).resetDegree();
-        	
-        	
+        	Vector<IUncertainDegree> degrees = new Vector<IUncertainDegree>();
+        	Vector<IUncertainDegree> weights = new Vector<IUncertainDegree>();
+	        for ( RightTuple rightTuple = memory.getRightTupleMemory().getLast( leftTuple ); rightTuple != null; rightTuple = (RightTuple) rightTuple.getPrevious() ) {        	
+	            
+	        	IUncertainDegree mDeg = this.constraints.matchesCachedLeft(memory.getContext(), rightTuple.getFactHandle(), factory);	        	
+	        		//if (! mDeg.toBoolean()) continue;
+	        	
+	        	//((UncertainRightTuple) rightTuple).setDegree(mDeg);
+	        	//JOIN constraints are empty here... ??
+	                    	
+	            
+	        		
+	        		
+	            Deque<IUncertainDegree> tVal = ((UncertainRightTuple) rightTuple).getTruthVal();
+	            	IUncertainDegree integrand = tVal.getLast();
+	            	IUncertainDegree constraint = tVal.getFirst();	            	
+	            	IUncertainDegree weight = ((IInducible) rightTuple.getFactHandle().getObject()).getWeight();
+	            
+	            //tVal should have two vals. The last is the integrand, the first the weight. ??
+	            //IUncertainDegree inductVal = factory.getEquivModusPonensOp().eval(new IUncertainDegree[] {integrand, weight});
+	            
+	            	
+	            
+	            
+//	        	if (weight.toBoolean()) {
+	        		degrees.add(integrand);
+	        		degrees.add(constraint);
+	        		degrees.add(weight);
+//	        	}
+	        	//((UncertainRightTuple) rightTuple).resetDegree();
+	        	
+	        	//TODO : This is a trick , heresy
+
+	        }
+	        
+	        if (degrees.size() > 0) {
+	        	IUncertainDegree[] degsArray = new IUncertainDegree[degrees.size()];
+	        	
+	        
+	        	existDegree = factory.getInductionOperator().eval(degrees.toArray(degsArray));
+	        	found = true;
+	        } else {
+	        	found = false;
+	        	existDegree = factory.Unknown();
+	        }
+	        
         }
-        IUncertainDegree[] degsArray = new IUncertainDegree[degrees.size()];
-        IUncertainDegree existDegree = factory.getOrOperator().eval(degrees.toArray(degsArray));
         
         
-    	if ( existDegree.toBoolean() ) {
+        
+        
+        
+        
+        
+        
+        
+        
+    	if ( found ) {
     		RightTuple rightTuple = memory.getRightTupleMemory().getLast(leftTuple);
     		leftTuple.setBlocker( rightTuple );
     		rightTuple.setBlocked( leftTuple );
@@ -194,9 +286,9 @@
 
         if ( leftTuple.getBlocker() != null ) {
             // tuple is not blocked to propagate
-        	Deque<IUncertainDegree> degList = new LinkedList<IUncertainDegree>();
-        		degList.add(existDegree);
-        	RightTuple exisTuple = new UncertainRightTuple(leftTuple.getBlocker().getFactHandle(),degList,this); 
+        	
+        	RightTuple exisTuple = new UncertainRightTuple(leftTuple.getBlocker().getFactHandle(),
+        													existDegree,this); 
             this.sink.propagateAssertLeftTuple( leftTuple,
             									exisTuple,
                                                 context,
@@ -218,10 +310,15 @@
             final InternalWorkingMemory workingMemory) {    
 		
 		
+		
+		
+		
 		IDegreeFactory factory = ((IUncertainRuleBase) workingMemory.getRuleBase()).getTruthFactory();
         final RightTuple rightTuple = new UncertainRightTuple( factHandle,
         												tVal,
         												this );
+        
+                
 
         final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
         if ( !behavior.assertRightTuple( memory.getBehaviorContext(),
@@ -239,6 +336,8 @@
             return;
         }
 
+        
+        
         this.constraints.updateFromFactHandle( memory.getContext(),
                                                workingMemory,
                                                factHandle );
@@ -251,40 +350,51 @@
             // preserve next now, in case we remove this leftTuple 
             LeftTuple temp = (LeftTuple) leftTuple.getNext();
 
-           
             
+                       
             Vector<IUncertainDegree> degrees = new Vector<IUncertainDegree>();
             for ( RightTuple right = memory.getRightTupleMemory().getLast( leftTuple ); right != null; right = (RightTuple) right.getPrevious() ) {        	
                 
             	IUncertainDegree mDeg = this.constraints.matchesCachedLeft(memory.getContext(), right.getFactHandle(), factory);
             	
-            	//TODO : Creare una sorta di "resetTupleDegree"
             	((UncertainRightTuple) right).setDegree(mDeg);
             	
             	
             	IUncertainDegree joinVal = factory.getAndOperator().eval(((UncertainRightTuple) right).getTruthVal().toArray(new IUncertainDegree[1]));
-            	degrees.add(joinVal);
-            	((UncertainRightTuple) rightTuple).resetDegree();
+            	//if (joinVal.toBoolean())
+            		degrees.add(joinVal);
             	
+            	((UncertainRightTuple) right).resetDegree();
+            	
             }
             IUncertainDegree[] degsArray = new IUncertainDegree[degrees.size()];
-            IUncertainDegree existDegree = factory.getOrOperator().eval(degrees.toArray(degsArray));
+            IUncertainDegree existDegree = factory.getMaxOrOperator().eval(degrees.toArray(degsArray));
             
             
-        	if ( existDegree.toBoolean() ) {        		
+            
+            
+            
+            
+            
+//        	if ( existDegree.toBoolean() ) {        		
         		leftTuple.setBlocker( rightTuple );
         		rightTuple.setBlocked( leftTuple );
-        	}
+//        	}
             
-                       
+                
+        	
+        	
+        	
+        	
                 if ( this.tupleMemoryEnabled ) {
                     // this is now blocked so remove it from memory
                     memory.getLeftTupleMemory().remove( leftTuple );
                 }
                 
-                Deque<IUncertainDegree> degList = new LinkedList<IUncertainDegree>();
-        			degList.add(existDegree);
-        			RightTuple exisTuple = new UncertainRightTuple(rightTuple.getFactHandle(),degList,this); 
+        
+                
+                                                                                                               
+        			RightTuple exisTuple = new UncertainRightTuple(rightTuple.getFactHandle(),existDegree,this); 
                 this.sink.propagateAssertLeftTuple( leftTuple,
                 									exisTuple,
                                                     context,
@@ -307,6 +417,8 @@
         this.constraints.resetFactHandle( memory.getContext() );
 		
 				
+  
+    
     }
     
     /**

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/JoinNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/JoinNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -318,7 +318,7 @@
 		
 		IDegreeFactory factory = ((IUncertainRuleBase) workingMemory.getRuleBase()).getTruthFactory();
 		
-		System.out.println("Beta JOIN Node : Added Object with uncertainty");
+//		System.out.println("Beta JOIN Node : Added Object with uncertainty");
 		
 		final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
 
@@ -353,7 +353,7 @@
         	IUncertainDegree deg = this.constraints.matchesCachedRight(memory.getContext(), leftTuple, factory);
         	rightTuple.setDegree(deg);
         	
-        	System.out.println("Join Node : Newly created Right Tuple Updated :"+ rightTuple);
+//        	System.out.println("Join Node : Newly created Right Tuple Updated :"+ rightTuple);
         	
                 this.sink.propagateAssertLeftTuple( leftTuple,
                                                     rightTuple,

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -248,13 +248,13 @@
 		IUncertainDegree classPrior = truthVal.removeLast();
 		IUncertainDegree posterior = null;
 		
-		System.out.println("ObjectTypeNode : Trying to filter "+object);
-		System.out.println("\t ObjectTypeNode : Object.Class vs class match "+classPrior);
+//		System.out.println("ObjectTypeNode : Trying to filter "+object);
+//		System.out.println("\t ObjectTypeNode : Object.Class vs class match "+classPrior);
 		
 			if (objectPrior == null) {
 				// No external priors, combine class and object compatibility, then set it
 				IUncertainDegree objPost = isAn(object, factory);
-				System.out.println("\t ObjectTypeNode : Object vs class match "+objPost);
+//				System.out.println("\t ObjectTypeNode : Object vs class match "+objPost);
 				/*
 				 * TODO: see below
 				 *	posterior = factory.mergeIntersect(objPost, classPrior); 
@@ -262,14 +262,14 @@
 				posterior = factory.getAndOperator().eval(new IUncertainDegree[] {objPost,classPrior});
 			} else {
 				if (uncHandle.isOverruling()) {
-					System.out.println("\t ObjectTypeNode : Keep priors from table");
+//					System.out.println("\t ObjectTypeNode : Keep priors from table");
 					// Do not change the priors
 		      		posterior = objectPrior;
 		      	} else {
 		      		// Combine everything
-		      		System.out.println("\t ObjectTypeNode : Prior info "+objectPrior);
+//		      		System.out.println("\t ObjectTypeNode : Prior info "+objectPrior);
 		      		IUncertainDegree objPost = isAn(object, factory);
-		      		System.out.println("\t ObjectTypeNode : Object vs class match "+objPost);
+//		      		System.out.println("\t ObjectTypeNode : Object vs class match "+objPost);
 		      		/*
 		      		 * TODO : debate if and-merge or intersect!!!
 		      		 * posterior = factory.mergeIntersect(objPost, classPrior);
@@ -282,7 +282,7 @@
 			
 			uncHandle.setPrior(cs, posterior);
 			truthVal.addLast(posterior);
-			System.out.println("\t ObjectTypeNode : Global result "+posterior);
+//			System.out.println("\t ObjectTypeNode : Global result "+posterior);
 			
 			if (posterior.getDegree().getValue() > 0) {
 						

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -43,6 +43,7 @@
 import org.drools.util.Iterator;
 import org.drools.util.LeftTupleList;
 
+
 import uncertainty.factory.IDegreeFactory;
 import uncertainty.truthvals.IUncertainDegree;
 import uncertainty.truthvals.operators.IUncDegCombiner;
@@ -213,11 +214,14 @@
         
         if (cloned instanceof UncertainLeftTuple) {
         	
+        	
+        	
         	IUncertainDegree degree = combine((UncertainLeftTuple) cloned, ((IUncertainRuleBase) workingMemory.getRuleBase()).getTruthFactory() );
-        		if (degree.getDegree().getValue() == 0) return;
         	
         	final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
-    		
+
+        	
+        	
             final AgendaItem item = new UncertainAgendaItem( context.getPropagationNumber(),
             												 cloned,
             												 rule.getSalience().getValue( tuple, workingMemory ),
@@ -556,8 +560,10 @@
     
     protected IUncertainDegree combine(UncertainLeftTuple leftTuple, IDegreeFactory factory) {
     	
+    	
+    	
     	IUncDegCombiner and = factory.getAndOperator();
-    	
+    	    	    	    
     	UncertainLeftTuple tuple = leftTuple;
     	
     	Vector<IUncertainDegree> argsV = new Vector<IUncertainDegree>(); 
@@ -580,6 +586,13 @@
     		return factory.True();
     	
     	IUncertainDegree[] args = new IUncertainDegree[argsV.size()];
+    	
+    	
+    	//TODO : REmove this!!
+    	if (rule.getSalience().getValue(leftTuple, null) == 111)
+    		return factory.getEquivOperator().eval(argsV.toArray(args));
+    		
+    	
     	return factory.getAndOperator().eval(argsV.toArray(args));
     	    	    	   
     }

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainLeftTuple.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainLeftTuple.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainLeftTuple.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -42,11 +42,11 @@
 		
 		this.tVal = truthVal;
 		
-		System.out.println("UncertainLeftTuple : U.Left Tuple has been created");
-			for (IUncertainDegree deg : tVal) {
-				System.out.print("\t"+deg+" ");
-			}
-			System.out.println();
+//		System.out.println("UncertainLeftTuple : U.Left Tuple has been created");
+//			for (IUncertainDegree deg : tVal) {
+//				System.out.print("\t"+deg+" ");
+//			}
+//			System.out.println();
 	}
 
 	/**

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainReteooRuleBase.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainReteooRuleBase.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainReteooRuleBase.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -4,6 +4,8 @@
 package org.drools.reteoo;
 
 import org.drools.reteoo.ReteooRuleBase;
+
+import uncertainty.factory.EssenceDegreeFactory;
 import uncertainty.factory.SimpleDegreeFactory;
 
 import org.drools.IUncertainRuleBase;
@@ -36,6 +38,7 @@
 		super(string, config);		
 		
 		//TODO : Instantiate the factory from the config
+//		this.setTruthFactory(new EssenceDegreeFactory());
 		this.setTruthFactory(new SimpleDegreeFactory());
 	}
 	
@@ -58,7 +61,7 @@
      * TODO : better not to mess like this...
      * @deprecated
      */   
-    protected void setTruthFactory(IDegreeFactory factory) {
+    public void setTruthFactory(IDegreeFactory factory) {
     	truthFactory = factory;
     }
 	

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainRightTuple.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainRightTuple.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainRightTuple.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -4,6 +4,7 @@
 package org.drools.reteoo;
 
 import java.util.Deque;
+import java.util.LinkedList;
 
 import org.drools.common.InternalFactHandle;
 
@@ -28,11 +29,23 @@
 		
 		this.tVal = truthVal;
 		
-		System.out.println("UncertainRightTuple : U.Right Tuple has been created");
-		System.out.println(this);
+//		System.out.println("UncertainRightTuple : U.Right Tuple has been created");
+//		System.out.println(this);
 	}
 	
+	public UncertainRightTuple(InternalFactHandle handle,
+			IUncertainDegree truthVal,
+            RightTupleSink sink) {
+		super(handle,sink);
+		
+		this.tVal = new LinkedList<IUncertainDegree>();
+			tVal.add(truthVal);
+		
+//		System.out.println("UncertainRightTuple : U.Right Tuple has been created");
+//		System.out.println(this);
+	}
 	
+	
 	public void setDegree(IUncertainDegree deg) {
 		tVal.addLast(deg);
 	}

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/AndConstraint.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/AndConstraint.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/AndConstraint.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -163,7 +163,7 @@
     		IUncDegCombiner and = factory.getAndOperator();
     		IUncertainDegree ans = and.eval(degs); 
     		
-    		System.out.println("AndConstraint : Combination yields "+ans);
+//    		System.out.println("AndConstraint : Combination yields "+ans);
     		return ans;
     		    		
     	} else return factory.True();

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/ConstraintSignature.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/ConstraintSignature.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/ConstraintSignature.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -24,7 +24,7 @@
 		
 		
 		this.sign = sb.toString();
-		System.out.println("ConstraintSignature Built a ConstrSignature :  "+sign);
+//		System.out.println("ConstraintSignature Built a ConstrSignature :  "+sign);
 	}
 
 	public boolean equals(Object o) {

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/Forall.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/Forall.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/Forall.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -146,4 +146,4 @@
         return true;
     }
 
-}
+}
\ No newline at end of file

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/LiteralConstraint.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -68,7 +68,7 @@
     
     public static ConstraintSignature buildSignature(String fieldName, String op, String value) {
     	ConstraintSignature cs = new ConstraintSignature(fieldName,op, value);
-    	System.out.println("LiteralConstraint : Static signature build  "+cs);
+//    	System.out.println("LiteralConstraint : Static signature build  "+cs);
     	return cs;
     }
     
@@ -79,7 +79,7 @@
     									this.restriction.getEvaluator().getOperator().getOperatorString(),
     									this.restriction.getField().toString());
     	
-    	System.out.println("LiteralConstraint : transformed to signature "+cs);
+//    	System.out.println("LiteralConstraint : transformed to signature "+cs);
     	return cs;
     }
     
@@ -195,10 +195,10 @@
 			InternalWorkingMemory workingMemory, ContextEntry context) {
 
 
-		System.out.println("LiteralConstraint :: Trying to evaluate an Alpha-Constraint over Object ..."+handle.getObject().toString());
-    	System.out.println("Using extractor of type "+this.extractor.getClass());
+//		System.out.println("LiteralConstraint :: Trying to evaluate an Alpha-Constraint over Object ..."+handle.getObject().toString());
+//    	System.out.println("Using extractor of type "+this.extractor.getClass());
     	    	
-    	System.out.println("The value to be matched against is "+this.restriction.getField());    	
+//    	System.out.println("The value to be matched against is "+this.restriction.getField());    	
     	
     	UncertainFactHandle uHandle = (UncertainFactHandle) handle;  
     	Hashtable<ConstraintSignature, IUncertainDegree> priors = uHandle.getPriors();

Modified: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/OrConstraint.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/OrConstraint.java	2008-08-28 15:52:27 UTC (rev 21960)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/rule/OrConstraint.java	2008-08-28 16:55:53 UTC (rev 21961)
@@ -178,7 +178,7 @@
     		IUncDegCombiner or = factory.getOrOperator();
     		IUncertainDegree ans = or.eval(degs); 
     		
-    		System.out.println("OrConstraint : Combination of "+this.alphaConstraints.length+" constraints yields "+ans);
+//    		System.out.println("OrConstraint : Combination of "+this.alphaConstraints.length+" constraints yields "+ans);
     		return ans;
     		    		
     	} else return factory.True();




More information about the jboss-svn-commits mailing list