[jboss-svn-commits] JBL Code SVN: r26913 - in labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees: factory and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 10 20:49:09 EDT 2009


Author: dsotty
Date: 2009-06-10 20:49:09 -0400 (Wed, 10 Jun 2009)
New Revision: 26913

Added:
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeAnd.java
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianLogicAnd.java
Removed:
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAnd.java
Modified:
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/ProbabilityDistributionDegree.java
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/factory/BayesianDegreeFactory.java
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeOr.java
   labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianModusPonensOperator.java
Log:


Modified: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/ProbabilityDistributionDegree.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/ProbabilityDistributionDegree.java	2009-06-11 00:48:49 UTC (rev 26912)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/ProbabilityDistributionDegree.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -30,8 +30,8 @@
 		setN(domain.getN());
 		setDistribution(new Matrix(getN(), 1, 1.0/getN()));
 		
-		if (getDistribution().getRowDimension() != N && getDistribution().getColumnDimension() != 1)
-			throw new RuntimeException("X-ED ");
+//		if (getDistribution().getRowDimension() != N && getDistribution().getColumnDimension() != 1)
+//			throw new RuntimeException("X-ED ");
 	}
 	
 	public ProbabilityDistributionDegree(IDomain domain, Matrix distribution) {
@@ -46,8 +46,8 @@
 		
 		setDistribution(mat);
 		
-		if (getDistribution().getRowDimension() != N && getDistribution().getColumnDimension() != 1)
-			throw new RuntimeException("X-ED 2");
+//		if (getDistribution().getRowDimension() != N && getDistribution().getColumnDimension() != 1)
+//			throw new RuntimeException("X-ED 2");
 	}
 	
 	
@@ -167,6 +167,11 @@
 		if (m1.getColumnDimension() == m2.getColumnDimension()
 			&& m2.getRowDimension() == m1.getRowDimension()) {
 			ans = m1.arrayTimes(m2);
+			
+		} else if (isUnity(m1)) {
+			ans = m2;
+		} else if (isUnity(m2)) {
+			ans = m1;
 		} else if (m2.getRowDimension() == m1.getRowDimension()
 				   && m2.getColumnDimension() != m1.getColumnDimension()) {
 				
@@ -199,6 +204,11 @@
 	}
 	
 	
+	private boolean isUnity(Matrix m1) {
+		return m1.getColumnDimension() == 1 && m1.getRowDimension() == 1;
+	}
+
+
 	private void normalize(Matrix mat) {
 		double[][] data = mat.getArray();
 		int C = mat.getColumnDimension();

Modified: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/factory/BayesianDegreeFactory.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/factory/BayesianDegreeFactory.java	2009-06-11 00:48:49 UTC (rev 26912)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/factory/BayesianDegreeFactory.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -10,8 +10,9 @@
 import org.drools.degrees.operators.IDiscountStrategy;
 import org.drools.degrees.operators.IMergeStrategy;
 import org.drools.degrees.operators.INullHandlingStrategy;
+import org.drools.degrees.operators.bayesian.BayesianAlternativeAnd;
 import org.drools.degrees.operators.bayesian.BayesianAlternativeOr;
-import org.drools.degrees.operators.bayesian.BayesianAnd;
+import org.drools.degrees.operators.bayesian.BayesianLogicAnd;
 import org.drools.degrees.operators.bayesian.BayesianDiscounter;
 import org.drools.degrees.operators.bayesian.BayesianMergeStrategy;
 import org.drools.degrees.operators.bayesian.BayesianModusPonensOperator;
@@ -41,7 +42,8 @@
 	}
 
 	public IDegree Unknown() {
-		return new ProbabilityDistributionDegree(new double[] {0.5,0.5});		
+		//return new ProbabilityDistributionDegree(new double[] {0.5,0.5});		
+		return new ProbabilityDistributionDegree(new BooleanDomain(), new Matrix(1,1,1.0));
 	}
 
 	
@@ -95,11 +97,18 @@
 	}
 
 	public IDegreeCombiner getAndOperator() {
-		return new BayesianAnd();
+		return new BayesianLogicAnd();
 	}
 
 	public IDegreeCombiner getAndOperator(String params) {
-		return new BayesianAnd();
+		StringTokenizer tok = new StringTokenizer(params,",");
+			
+			int ix = params.indexOf("kind:et");
+			if (ix >= 0)
+				return new BayesianAlternativeAnd(params.substring(0,ix)+params.substring(ix+7));
+
+					
+		return new BayesianLogicAnd();
 	}
 
 	public IFilterStrategy getDefaultStrategy() {
@@ -190,12 +199,11 @@
 	}
 
 	public IDegreeCombiner getModusPonensOp() {
-		// TODO Auto-generated method stub
-		return null;
+		return new BayesianModusPonensOperator();
 	}
 
 	public IDegreeCombiner getModusPonensOperator(String params) {
-		return new BayesianModusPonensOperator();
+		return new BayesianModusPonensOperator(params);
 	}
 
 	public IDegreeCombiner getNegationOperator() {

Added: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeAnd.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeAnd.java	                        (rev 0)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeAnd.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -0,0 +1,142 @@
+package org.drools.degrees.operators.bayesian;
+
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.drools.degrees.IDegree;
+import org.drools.degrees.ProbabilityDistributionDegree;
+import org.drools.degrees.factory.IDegreeFactory;
+import org.drools.degrees.operators.AbstractOperator;
+import org.drools.degrees.operators.IDegreeCombiner;
+import org.drools.reteoo.CompositeEvaluation;
+import org.drools.reteoo.Evaluation;
+
+public class BayesianAlternativeAnd extends AbstractOperator implements
+		IDegreeCombiner {
+
+	
+	private String linkSource;
+
+	public BayesianAlternativeAnd(String params) {
+		StringTokenizer tok = new StringTokenizer(params,",");
+		while (tok.hasMoreTokens()) {			
+			String param = tok.nextToken().trim();
+			if (param.startsWith("args:")) {
+				
+				param = param.substring(5);
+				
+				StringTokenizer subTok = new StringTokenizer(param,";");
+				while (subTok.hasMoreElements()) {
+					String subP = subTok.nextToken().trim();
+					
+					if (subP.startsWith("lambda")) {
+						setLinkSource(revert(param));
+					}
+					
+				}
+			}
+			
+			
+		}
+	}
+
+	
+	
+	public IDegree eval(IDegree[] args, IDegreeFactory factory) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public String getName() {
+		return "B_et";
+	}
+
+	
+	public IDegree eval(Evaluation evaluation, IDegreeFactory factory) {
+		CompositeEvaluation combo = (CompositeEvaluation) evaluation;
+		
+		Iterator<Evaluation> iter = combo.getOperands().iterator();
+		Evaluation left = iter.next();	//this is the "child"
+		Evaluation right = iter.next();	//this is the all-but-one "parents"
+		
+		Evaluation sub = lookForBit(left,getLinkSource());
+		if (sub != null) {
+			left = sub;
+		
+		
+			IDegree[] bits = new IDegree[left.getDegreeBitSources().size()-1];
+			int k = 0;
+			for (String source : left.getDegreeBitSources()) {
+				if (! matches(source,(getLinkSource())))
+					bits[k++] = left.getDegreeBit(source);
+			}
+			ProbabilityDistributionDegree msg = (ProbabilityDistributionDegree) factory.getMergeStrategy().eval(bits, factory);
+			
+			return msg;
+			
+		} else {
+			
+			return left.getDegree();
+		}
+				
+	}
+	
+	
+	
+	private String revert(String ruleId) {
+		int idx = ruleId.indexOf(':');
+		String type = ruleId.substring(0,idx);
+		
+		String rule = ruleId.substring(idx+1);
+			int idx2 = rule.lastIndexOf('_');
+			if (type.equals("lambda") && idx2 >= 0)
+				rule = rule.substring(0,idx2);
+		
+		String ntype = type.equals("lambda") ? "pi" : "lambda"; 
+		
+		return ntype + ":" + rule; 
+		 
+	}
+	
+	
+	private boolean matches(String bit, String key) {
+		int ix1 = bit.lastIndexOf('_');
+		int ix2 = key.lastIndexOf('_');
+		
+		String test1 = (ix1 >= 0 && bit.startsWith("lambda")) ? bit.substring(0,ix1) : bit;
+		String test2 = (ix2 >= 0 && key.startsWith("lambda")) ? key.substring(0,ix2) : key;
+		return (test1.equals(test2)); 					
+	}
+
+	
+	
+	public boolean isTruthFunctional() {
+		return false;
+	}
+	
+	
+	private Evaluation lookForBit(Evaluation operand, String key) {
+		for (String bit : operand.getDegreeBitSources())
+			if (matches(bit,key))
+				return operand;
+		if (operand instanceof CompositeEvaluation) {
+			CompositeEvaluation combo = (CompositeEvaluation) operand;
+			for (Evaluation eval : combo.getOperands()) {
+				Evaluation ans = lookForBit(eval,key);
+				if (ans != null) 
+					return ans;
+			}				
+		}
+		return null;
+	}
+
+	
+	public void setLinkSource(String linkSource) {
+		this.linkSource = linkSource;
+	}
+
+	public String getLinkSource() {
+		return linkSource;
+	}
+
+}

Modified: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeOr.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeOr.java	2009-06-11 00:48:49 UTC (rev 26912)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAlternativeOr.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -28,20 +28,26 @@
 	public BayesianAlternativeOr(String params) {
 		StringTokenizer tok = new StringTokenizer(params,",");
 		while (tok.hasMoreTokens()) {			
-			String param = tok.nextToken();
+			String param = tok.nextToken().trim();
 			if (param.startsWith("args:")) {
 				
 				param = param.substring(5);
-				if (param.startsWith("lambda"))
-					setLambda(true);
 				
-				if (param.startsWith("lambda") || param.startsWith("pi")) {
-					setLinkSource(revert(param));;
+				StringTokenizer subTok = new StringTokenizer(param,";");
+				while (subTok.hasMoreElements()) {
+					String subP = subTok.nextToken().trim();
+					if (subP.startsWith("lambda"))
+						setLambda(true);
+					
+					if (subP.startsWith("lambda") || subP.startsWith("pi")) {
+						setLinkSource(revert(param));
+					}
+					
+					if (subP.startsWith("index:")) {					
+						if (isLambda())
+							setSkip(Integer.parseInt(subP.substring(6).trim()));		
+					}
 				}
-				
-				int ix = param.lastIndexOf('_');
-				if (isLambda() && ix >= 0)
-					setSkip(Integer.parseInt(param.substring(ix+1).trim()));
 			}
 			
 			
@@ -53,26 +59,49 @@
 
 
 	public IDegree eval(IDegree[] args, IDegreeFactory factory) {
+		
 		if (args.length == 0)
 			return factory.Unknown();
+		if (args.length == 1) {
+			ProbabilityDistributionDegree p = (ProbabilityDistributionDegree) args[0];
+			if (p.getDistribution().getColumnDimension() == 1 && p.getDistribution().getRowDimension() == 1)
+				return p;
+		}
 		
-		int n = args.length;
-		int N = (int) Math.pow(2,args.length);
+		
+		if (getSkip() >= 0)
+			System.out.println();
+		
+		int n = getSkip() >= 0 ? args.length+1 : args.length;
+		int nargs = args.length; 
+		int N = (int) Math.pow(2,n);
 		int M = getSkip() >= 0 ? 2 : 1;
-		double[][] core = new double[N/M][M];
-	
+		double[][] core = new double[N][M];
 		
+		
+		
 		for (int j = 0; j < N; j++) {
 			double x = 1;
 			
-			for (int k = 0; k < n; k++) {
+			for (int k = 0; k < nargs; k++) {
 				int pow = (int) Math.pow(2,k);
 				int bit = (j & pow) > 0 ? 1 : 0;
 				
-				x *= ((ProbabilityDistributionDegree) args[k]).getDistribution().get(bit,0);
+				Matrix m = ((ProbabilityDistributionDegree) args[k]).getDistribution();
+				
+				if (m.getRowDimension()+m.getColumnDimension() > 2)
+					x *= ((ProbabilityDistributionDegree) args[k]).getDistribution().get(bit,0);
 			}
 			
-			core[j][0] = x;
+			if (getSkip() >= 0) {
+				int pow = (int) Math.pow(2,getSkip()-1);
+				int col = (j & pow) > 0 ? 1 : 0;
+				core[j][col] = x;
+			} else {
+				core[j][0] = x;
+			}
+			
+			
 		}
 		
 		System.out.println();

Deleted: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAnd.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAnd.java	2009-06-11 00:48:49 UTC (rev 26912)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAnd.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -1,59 +0,0 @@
-package org.drools.degrees.operators.bayesian;
-
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Iterator;
-
-
-import org.drools.degrees.IDegree;
-import org.drools.degrees.ProbabilityDistributionDegree;
-import org.drools.degrees.factory.IDegreeFactory;
-import org.drools.degrees.operators.AbstractOperator;
-import org.drools.degrees.operators.IDegreeCombiner;
-import org.drools.util.ArrayUtils;
-
-import Jama.Matrix;
-
-public class BayesianAnd extends AbstractOperator implements IDegreeCombiner {
-
-	public IDegree eval(IDegree[] args, IDegreeFactory factory) {
-		if (args.length == 0)
-			return factory.Unknown();
-	
-				
-		ProbabilityDistributionDegree p0 = (ProbabilityDistributionDegree) args[0]; 
-		double[][] core = p0.getDistribution().getArrayCopy();
-		
-		for (int j = 1 ; j < args.length; j++) {
-			double[][] more = ((ProbabilityDistributionDegree) args[j]).getDistribution().getArray();
-			core[1][0] = core[1][0]*more[1][0];
-			core[0][0] = 1-core[1][0];
-		}
-		
-		return new ProbabilityDistributionDegree(p0.getDomain(),new Matrix(core));
-	
-	}
-
-	public IDegree eval(Collection<? extends IDegree> args,
-			IDegreeFactory factory) {
-		if (args.size() == 0)
-			return factory.Unknown();
-		
-		Iterator<? extends IDegree> iter = args.iterator();
-		ProbabilityDistributionDegree p0 = (ProbabilityDistributionDegree) iter.next(); 
-		double[][] core = p0.getDistribution().getArrayCopy();
-		
-		while (iter.hasNext()) {			
-				double[][] more = ((ProbabilityDistributionDegree) iter.next()).getDistribution().getArray();
-				core[1][0] = core[1][0]*more[1][0];
-				core[0][0] = 1-core[1][0];
-			}
-			
-		return new ProbabilityDistributionDegree(p0.getDomain(),new Matrix(core));		
-	}
-
-	public String getName() {
-		return "B_and";
-	}
-
-}

Copied: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianLogicAnd.java (from rev 26894, labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianAnd.java)
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianLogicAnd.java	                        (rev 0)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianLogicAnd.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -0,0 +1,59 @@
+package org.drools.degrees.operators.bayesian;
+
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Iterator;
+
+
+import org.drools.degrees.IDegree;
+import org.drools.degrees.ProbabilityDistributionDegree;
+import org.drools.degrees.factory.IDegreeFactory;
+import org.drools.degrees.operators.AbstractOperator;
+import org.drools.degrees.operators.IDegreeCombiner;
+import org.drools.util.ArrayUtils;
+
+import Jama.Matrix;
+
+public class BayesianLogicAnd extends AbstractOperator implements IDegreeCombiner {
+
+	public IDegree eval(IDegree[] args, IDegreeFactory factory) {
+		if (args.length == 0)
+			return factory.Unknown();
+	
+				
+		ProbabilityDistributionDegree p0 = (ProbabilityDistributionDegree) args[0]; 
+		double[][] core = p0.getDistribution().getArrayCopy();
+		
+		for (int j = 1 ; j < args.length; j++) {
+			double[][] more = ((ProbabilityDistributionDegree) args[j]).getDistribution().getArray();
+			core[1][0] = core[1][0]*more[1][0];
+			core[0][0] = 1-core[1][0];
+		}
+		
+		return new ProbabilityDistributionDegree(p0.getDomain(),new Matrix(core));
+	
+	}
+
+	public IDegree eval(Collection<? extends IDegree> args,
+			IDegreeFactory factory) {
+		if (args.size() == 0)
+			return factory.Unknown();
+		
+		Iterator<? extends IDegree> iter = args.iterator();
+		ProbabilityDistributionDegree p0 = (ProbabilityDistributionDegree) iter.next(); 
+		double[][] core = p0.getDistribution().getArrayCopy();
+		
+		while (iter.hasNext()) {			
+				double[][] more = ((ProbabilityDistributionDegree) iter.next()).getDistribution().getArray();
+				core[1][0] = core[1][0]*more[1][0];
+				core[0][0] = 1-core[1][0];
+			}
+			
+		return new ProbabilityDistributionDegree(p0.getDomain(),new Matrix(core));		
+	}
+
+	public String getName() {
+		return "B_and";
+	}
+
+}

Modified: labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianModusPonensOperator.java
===================================================================
--- labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianModusPonensOperator.java	2009-06-11 00:48:49 UTC (rev 26912)
+++ labs/jbossrules/branches/DroolsChance/drools-core/src/main/java/org/drools/degrees/operators/bayesian/BayesianModusPonensOperator.java	2009-06-11 00:49:09 UTC (rev 26913)
@@ -2,7 +2,9 @@
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.StringTokenizer;
 
+import org.drools.bayesian.BooleanDomain;
 import org.drools.degrees.IDegree;
 import org.drools.degrees.ProbabilityDistributionDegree;
 import org.drools.degrees.factory.IDegreeFactory;
@@ -16,6 +18,29 @@
 
 public class BayesianModusPonensOperator extends AbstractOperator  implements IDegreeCombiner {
 
+	private boolean isFullLambda = false;
+	
+	
+	public BayesianModusPonensOperator() {
+		setFullLambda(false);
+	}
+	
+	public BayesianModusPonensOperator(String params) {
+		StringTokenizer tok = new StringTokenizer(params,",");
+		while (tok.hasMoreTokens()) {
+			String param = tok.nextToken();
+			if (param.startsWith("kind:")) {
+				String val = param.substring(5);
+					setFullLambda(val.equals("complex"));
+			}
+		}
+	}
+
+
+
+
+
+
 	public IDegree eval(IDegree[] args, IDegreeFactory factory) {
 //		if (args.length < 2)
 //			return factory.Unknown();
@@ -35,44 +60,66 @@
 	
 	
 	public IDegree eval(Evaluation evaluation, IDegreeFactory factory) {
-		boolean exclude = false;
 		
-				
+		if (isFullLambda)
+			return evalComplex(evaluation, factory);
+		else 
+			return evalSimple(evaluation, factory);
+	}
+
+		
+	
+	public IDegree evalComplex(Evaluation evaluation, IDegreeFactory factory) {
 		EvalRecord record = (EvalRecord) evaluation;
 		if (record.getOperands().size() < 2)
 			return factory.Unknown();
 		
 		Iterator<Evaluation> iter = record.getOperands().iterator();
+				
+		CompositeEvaluation andRoot = (CompositeEvaluation) iter.next();		//remove the outermost rule-And wrapper
+		andRoot = (CompositeEvaluation) andRoot.getOperands().iterator().next();
+				
+		ProbabilityDistributionDegree cleanEt = (ProbabilityDistributionDegree) andRoot.getDegree();
+			if (cleanEt.getDistribution().getColumnDimension() == 1 && cleanEt.getDistribution().getRowDimension() == 1)
+				return cleanEt;
 		
+		Iterator<Evaluation> iter2 = andRoot.getOperands().iterator();
+		iter2.next();		// ignore dirty first premise
+		ProbabilityDistributionDegree cleanVel = (ProbabilityDistributionDegree) iter2.next().getDegree();
+		
+		
+		ProbabilityDistributionDegree implDegree = (ProbabilityDistributionDegree) iter.next().getDegree();
+
+		
+		Matrix l = cleanEt.getDistribution();
+		Matrix cond = implDegree.getDistribution();
+		Matrix m = cleanVel.getDistribution(); 
+		
+		
+		Matrix mat = (l.transpose().times(cond)).times(m).transpose();
+		ProbabilityDistributionDegree ans = new ProbabilityDistributionDegree(new BooleanDomain(),mat);
+		return ans;
+	}
+	
+	
+	
+	public IDegree evalSimple(Evaluation evaluation, IDegreeFactory factory) {
+		
+		EvalRecord record = (EvalRecord) evaluation;
+		if (record.getOperands().size() < 2 )
+			return factory.Unknown();
+		
+		Iterator<Evaluation> iter = record.getOperands().iterator();
+		
 		String ruleId = record.getRuleId();
-//		
-//		
-//		
-//			String target = revertLinkId(ruleId);
-//			
+
 		Evaluation premise = iter.next();
 		ProbabilityDistributionDegree premDistr = (ProbabilityDistributionDegree) premise.getDegree(); 
 		Matrix belief = premDistr.getDistribution();
-//		
-//		Evaluation combo = (ruleId.indexOf("->") > -1) ? lookForBit(premise,target) : null;
-//			if (combo != null) {
-//				exclude = true;
-//				premise = combo;
-//				
-//				IDegree[] args = new IDegree[premise.getDegreeBitSources().size()-1];
-//				int j = 0;
-//				for (String source : premise.getDegreeBitSources()) {
-//					if (! source.equals(target))
-//						args[j++] = premise.getDegreeBit(source);
-//				}
-//				
-//				ProbabilityDistributionDegree msg = (ProbabilityDistributionDegree) factory.getMergeStrategy().eval(args, factory);
-//				belief = msg.getDistribution();
-//			
-//			}
-//					
 		
 		ProbabilityDistributionDegree condTable = (ProbabilityDistributionDegree) iter.next().getDegree();
+		if (belief.getRowDimension() == 1 && belief.getColumnDimension() == 1)
+			return new ProbabilityDistributionDegree(premDistr.getDomain(), belief );
 		
 		Matrix conclDistr = null;
 		if (isLambda(ruleId)) {
@@ -164,5 +211,23 @@
 		return "B_m|p";
 	}
 
+
+
+
+
+
+	public void setFullLambda(boolean isFullLambda) {
+		this.isFullLambda = isFullLambda;
+	}
+
+
+
+
+
+
+	public boolean isFullLambda() {
+		return isFullLambda;
+	}
+
 		
 }




More information about the jboss-svn-commits mailing list