[jboss-svn-commits] JBL Code SVN: r21494 - in labs/jbossrules/branches/uncDrools5x: Essence and 41 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 12 18:50:52 EDT 2008
Author: dsotty
Date: 2008-08-12 18:50:52 -0400 (Tue, 12 Aug 2008)
New Revision: 21494
Added:
labs/jbossrules/branches/uncDrools5x/Essence/
labs/jbossrules/branches/uncDrools5x/Essence/.classpath
labs/jbossrules/branches/uncDrools5x/Essence/.project
labs/jbossrules/branches/uncDrools5x/Essence/.settings/
labs/jbossrules/branches/uncDrools5x/Essence/.settings/org.eclipse.jdt.ui.prefs
labs/jbossrules/branches/uncDrools5x/Essence/Essence.jar
labs/jbossrules/branches/uncDrools5x/Essence/SOM.jpg
labs/jbossrules/branches/uncDrools5x/Essence/SOM.net
labs/jbossrules/branches/uncDrools5x/Essence/SOM.txt
labs/jbossrules/branches/uncDrools5x/Essence/SOMlog.txt
labs/jbossrules/branches/uncDrools5x/Essence/bin/
labs/jbossrules/branches/uncDrools5x/Essence/lib/
labs/jbossrules/branches/uncDrools5x/Essence/lib/gluegen-rt.jar
labs/jbossrules/branches/uncDrools5x/Essence/lib/jogl.jar
labs/jbossrules/branches/uncDrools5x/Essence/lib/libgluegen-rt.so
labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl.so
labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_awt.so
labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_cg.so
labs/jbossrules/branches/uncDrools5x/Essence/pom.xml
labs/jbossrules/branches/uncDrools5x/Essence/src/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/Main.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/DiscreteDomain.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IContDomain.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDiscDomain.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDomain.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/EssenceDegreeFactory.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/IDegreeFactory.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/SimpleDegreeFactory.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IDegreeEvalFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IMeasureFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ConcreteImpDist.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IBeliefFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IMassFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IPlausibilityFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ImpreciseDistribution.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/INecessityFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/IPossibilityFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IBayesianMassFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IProbabilityFunction.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/ImpreciseProbability.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IAssignmentStrategy.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IUncAssignmentStrat.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauPignisticStrategy.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauProjectionStrategy.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLOperator.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLPredicate.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IArg.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainOperator.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainPredicate.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Degree.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/DegreeInterval.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Essence.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDegree.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDistribution.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainInterval.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/AggregationStrat.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/BRPLOp.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/IUncDegCombiner.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/DotAnd.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/Equiv.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasAnd.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasImply.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasNeg.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasOr.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MaxOr.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MinAnd.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/ModusPonensOp.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/NegOp.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TCoNormOp.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TNormOp.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleDotAnd.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMaxOr.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMinAnd.java
labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/util/
labs/jbossrules/branches/uncDrools5x/Essence/src/main/resources/
labs/jbossrules/branches/uncDrools5x/Essence/src/test/
labs/jbossrules/branches/uncDrools5x/Essence/src/test/java/
labs/jbossrules/branches/uncDrools5x/Essence/src/test/resources/
labs/jbossrules/branches/uncDrools5x/Essence/target/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main$1.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/DiscreteDomain.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IContDomain.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDiscDomain.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDomain.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/EssenceDegreeFactory.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/IDegreeFactory.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/SimpleDegreeFactory.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IDegreeEvalFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IMeasureFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ConcreteImpDist.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IBeliefFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IMassFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IPlausibilityFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ImpreciseDistribution.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/INecessityFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/IPossibilityFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IBayesianMassFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IProbabilityFunction.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/ImpreciseProbability.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IAssignmentStrategy.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IUncAssignmentStrat.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauPignisticStrategy.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauProjectionStrategy.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLOperator.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLPredicate.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IArg.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainOperator.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainPredicate.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Degree.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/DegreeInterval.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Essence.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDegree.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDistribution.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainInterval.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/AggregationStrat.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/BRPLOp.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/IUncDegCombiner.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/DotAnd.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/Equiv.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasAnd.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasImply.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasNeg.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasOr.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MaxOr.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MinAnd.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/ModusPonensOp.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/NegOp.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TCoNormOp.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TNormOp.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/aggregators/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleDotAnd.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMaxOr.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMinAnd.class
labs/jbossrules/branches/uncDrools5x/Essence/target/classes/util/
labs/jbossrules/branches/uncDrools5x/Essence/target/test-classes/
labs/jbossrules/branches/uncDrools5x/Test/
labs/jbossrules/branches/uncDrools5x/Test/.classpath
labs/jbossrules/branches/uncDrools5x/Test/.project
labs/jbossrules/branches/uncDrools5x/Test/bin/
labs/jbossrules/branches/uncDrools5x/Test/bin/prova.drl
labs/jbossrules/branches/uncDrools5x/Test/bin/test/
labs/jbossrules/branches/uncDrools5x/Test/bin/test/Person.class
labs/jbossrules/branches/uncDrools5x/Test/bin/test/TestDrools.class
labs/jbossrules/branches/uncDrools5x/Test/log.log
labs/jbossrules/branches/uncDrools5x/Test/src/
labs/jbossrules/branches/uncDrools5x/Test/src/prova.drl
labs/jbossrules/branches/uncDrools5x/Test/src/test/
labs/jbossrules/branches/uncDrools5x/Test/src/test/Person.java
labs/jbossrules/branches/uncDrools5x/Test/src/test/TestDrools.java
Log:
New branch for uncertainty support in 5.x
Added: labs/jbossrules/branches/uncDrools5x/Essence/.classpath
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/.classpath (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/.classpath 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/gluegen-rt.jar"/>
+ <classpathentry kind="lib" path="lib/jogl.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/.classpath
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/.project
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/.project (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/.project 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Essence</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/.project
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/.settings/org.eclipse.jdt.ui.prefs 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,3 @@
+#Tue Sep 18 17:05:13 CEST 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/.settings/org.eclipse.jdt.ui.prefs
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/Essence.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/Essence.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/SOM.jpg
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/SOM.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/SOM.net
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/SOM.net (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/SOM.net 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1 @@
+?Ã?Ö?½÷cxÿe?Ë\+ÅÎ?ÊÆäi`?ÑÌ7·?ÑA["À?ÖÐÅuÒaå?Õ¾Ñ+}?ÜK§\JÖ½?Ü+ê7r=?áyÿ^@ù7?á ?äÄ£w
?ä?Äí¾=?æ8×ȸ?æ¡ãº¡?è{§P[¤?èBX)¿.?ê®aæ`Z?ëF*«Y
\ No newline at end of file
Added: labs/jbossrules/branches/uncDrools5x/Essence/SOM.txt
===================================================================
Added: labs/jbossrules/branches/uncDrools5x/Essence/SOMlog.txt
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/SOMlog.txt (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/SOMlog.txt 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,10 @@
+1.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 | conf = 1.0
+0.221 0.325 0.454 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 | conf = 1.0
+0.083 0.115 0.147 0.172 0.219 0.264 -0.000 -0.000 -0.000 -0.000 | conf = 1.0
+0.009 0.086 0.166 0.118 0.128 0.124 0.134 0.236 -0.000 -0.000 | conf = 1.0
+0.000 0.000 0.022 0.168 0.268 0.273 0.238 0.030 0.000 0.000 | conf = 1.0
+-0.000 0.000 0.022 0.168 0.268 0.273 0.238 0.030 0.000 0.000 | conf = 1.0
+-0.000 -0.000 -0.000 0.132 0.143 0.138 0.150 0.255 0.164 0.018 | conf = 1.0
+-0.000 -0.000 -0.000 -0.000 -0.000 0.353 0.214 0.183 0.142 0.108 | conf = 1.0
+-0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 0.528 0.297 0.175 | conf = 1.0
+-0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 -0.000 1.000 | conf = 1.0
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/gluegen-rt.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/gluegen-rt.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/jogl.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/jogl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/libgluegen-rt.so
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/libgluegen-rt.so
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl.so
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl.so
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_awt.so
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_awt.so
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_cg.so
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/lib/libjogl_cg.so
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/pom.xml
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/pom.xml (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/pom.xml 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>Essence</groupId>
+ <artifactId>Essence</artifactId>
+ <version>0.0.1</version>
+</project>
+
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/pom.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/Main.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/Main.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/Main.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,452 @@
+
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import uncertainty.measures.belief.ConcreteImpDist;
+import uncertainty.measures.belief.ImpreciseDistribution;
+import uncertainty.measures.probability.conversion.TauPignisticStrategy;
+import uncertainty.predicates.BRPLOperator;
+import uncertainty.predicates.BRPLPredicate;
+import uncertainty.predicates.IArg;
+import uncertainty.predicates.IUncertainPredicate;
+import uncertainty.truthvals.DegreeInterval;
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.operators.BRPLOp;
+import uncertainty.truthvals.operators.ModusPonensOp;
+import uncertainty.truthvals.operators.TNormOp;
+import uncertainty.truthvals.operators.Lukas.LukasAnd;
+import uncertainty.truthvals.operators.Lukas.LukasImply;
+import uncertainty.truthvals.operators.Lukas.LukasNeg;
+import uncertainty.truthvals.operators.aggregators.DempsterShaferAggStrat;
+
+
+
+/*
+ * Created on 04/giu/07
+ *
+ */
+
+public class Main extends JFrame {
+
+ private static final long serialVersionUID = 1L;
+
+
+
+
+
+ double[] prior1 = new double[] { 00.0 , 000.0 , 0.0 , 0.6 , 0.4 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posterior1 = new double[] { 00.0 , 000.0 , 0.0 , 000.0 , 000.0 , 90000.0 , 0000.0 , 0000.0 , 0.0 , 0};
+ double delta1 = 0.0;
+ double w = 1;
+
+ double[] prior2 = new double[] { 00.0 , 000.0 , 0.0 , 0.6 , 0.4 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posterior2 = new double[] { 00.0 , 000.0 , 0.0 , 000.0 , 000.0 , 0.0 , 000.0 , 90000.0 , 0000.0 , 000.0 };
+ double delta2 = 0.0;
+
+ double[] prior3 = new double[] { 00.0 , 000.0 , 0.0 , 0.6 , 0.4 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posterior3 = new double[] { 00.0 , 000.0 , 0000.0 , 000.0 , 000.0 , 0.0 , 000.0 , 10000.0 ,0 , 0000.0 };
+ double delta3 = 0.00;
+
+
+
+
+ double[] priorRich = new double[] { 00.0 , 000.0 , 0.0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorRich = new double[] { 00.0 , 000.0 , 0000.0 , 000.0 , 000.0 , 0.0 , 45000.0 , 45000.0 ,0 , 0000.0 };
+ double deltaRich = 0.00;
+
+ double[] priorHeal = new double[] { 00.0 , 000.0 , 0.0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorHeal = new double[] { 00.0 , 000.0 , 0000.0 , 000.0 , 000.0 , 0.0 , 0000.0 , 00.0 ,0 , 89000.0 };
+ double deltaHeal = 0.00;
+
+ double[] priorHappy = new double[] { 00.0 , 000.0 , 0.0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorHappy = new double[] { 2500.0 , 2500.0 , 5000.0 , 10000.0 , 25000.0 , 25000.0 , 10000.0 , 5000.0 , 2500 , 2500.0 };
+ double[] posteriorHappyb = new double[] { 25.0 , 25.0 , 50.0 , 100.0 , 250.0 ,250.0 , 100.0 , 50.0 , 25 , 25.0 };
+ double deltaHappy = 0.00;
+
+ double[] priorH2H = new double[] { 00.0 , 000.0 , 0.0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorH2H = new double[] { 00.0 , 00.0 , 00.0 , 000.0 , 00.0 , 15000.0 , 35000.0 , 15000.0 , 00 , 20000.0 };
+ //double[] posteriorH2H = new double[] { 00.0 , 00.0 , 00.0 , 000.0 , 00.0 , 0 , 90000.0 , 00.0 , 00 , 00.0 };
+ double deltaH2H = 0.00;
+
+ double[] priorR2H = new double[] { 00.0 , 000.0 , 0.0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorR2H = new double[] { 30000.0 , 00.0 , 00.0 , 000.0 , 00.0 ,000.0 , 000.0 , 000.0 , 00 , 30000.0 };
+ double deltaR2H = 0.00;
+
+
+
+
+ double[] priorKN = new double[] { 0 , 0 , 0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorKN = new double[] { 9000 , 9000 , 9000 , 9000 , 9000 , 9000 , 9000 , 9000 ,9000 , 9000 };
+ double deltaKN = 0.00;
+
+ double[] priorNK = new double[] { 0 , 0 , 0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorNK = new double[] { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,1 , 1 };
+ double deltaNK = 0.00;
+
+ double[] priorHT = new double[] { 0 , 0 , 0 , 0 , 0 , 0.0 , 0 , 0000.0 , 0.0 , 00.0 };
+ double[] posteriorHT = new double[] { 45000 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,0 , 45000 };
+ double deltaHT = 0.00;
+
+
+ static Essence rich;
+ static Essence heal;
+ static Essence happy;
+ static Essence r2h;
+ static Essence h2h;
+
+ static Essence h0;
+ static Essence h1;
+ static Essence h2;
+ static Essence happyBob;
+
+ static Essence e1;
+ static Essence e2;
+ static Essence e3;
+ static Essence e;
+
+ static Essence knowNot;
+ static Essence notKnow;
+ static Essence headorTail;
+
+
+ public static void main(String[] args) {
+ Main m = new Main();
+ m.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) { System.exit(0); }
+ });
+
+
+ JPanel pan = new JPanel(true);
+ m.setContentPane(pan);
+
+ m.display();
+ }
+
+
+ private Essence buildEx() {
+//
+//
+// for (int j = 0; j < Essence.DEF_N; j++) {
+// prior[j] = 1.0/Essence.DEF_N;
+// posterior[j] = w*posterior[j];
+// }
+
+ return new Essence(delta1,prior1,posterior1,Double.POSITIVE_INFINITY,Essence.L200_DOMAIN);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Main() {
+ super("Test");
+ //e = buildEx();
+ e1 = new Essence(delta1,prior1,posterior1,Double.POSITIVE_INFINITY,Essence.L200_DOMAIN);
+ e2 = new Essence(delta2,prior2,posterior2,Double.POSITIVE_INFINITY,Essence.L200_DOMAIN);
+ //e3 = new Essence(delta3,prior3,posterior3,Double.POSITIVE_INFINITY,Essence.L200_DOMAIN);
+ e3 = new Essence(200);
+
+
+ happy = new Essence(deltaHappy,priorHappy,posteriorHappy,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ heal = new Essence(deltaHeal,priorHeal,posteriorHeal,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ rich = new Essence(deltaRich,priorRich,posteriorRich,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+
+ h2h = new Essence(deltaH2H,priorH2H,posteriorH2H,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ r2h = new Essence(deltaR2H,priorR2H,posteriorR2H,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+
+ h0 = new Essence(deltaHappy,priorHappy,posteriorHappyb,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ h1 = new Essence(0);
+ h2 = new Essence(0);
+ happyBob = new Essence(0);
+
+ knowNot = new Essence(deltaKN,priorKN,posteriorKN,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ notKnow = new Essence(deltaNK,priorNK,posteriorNK,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+ headorTail = new Essence(deltaHT,priorHT,posteriorHT,Double.POSITIVE_INFINITY,Essence.L0_BASIC);
+
+
+// double[][] p = new double[][] { {0 , 0.1 , 0.2 , 0.1 , 0.1 , 0.4 , 0 , 0 , 0 , 0} ,
+// {0 , 0.1 , 0.2 , 0.1 , 0.1 , 0.4 , 0 , 0 , 0 , 0} ,
+// {0 , 0.3 , 0.6 , 0.5 , 0.9 , 0.6 , 0.2 , 0.2 , 0 , 0} };
+ double[][] p = new double[][] { {0.05 , 0.1 , 0.1 , 0.15 , 0.2 , 0.25 , 0.1 , 0.05 } ,
+ {0.05 , 0.1 , 0.1 , 0.15 , 0.2 , 0.25 , 0.1 , 0.05 } ,
+ {0.1 , 0.2 , 0.25 , 0.25 , 0.3 , 0.35 , 0.2 , 0.05 } };
+ ImpreciseDistribution id = new ConcreteImpDist(p);
+ //System.out.println(id);
+ //id.normalize();
+ //System.out.println(id);
+
+ //id.discount(0.5, -1);
+ //System.out.println(id);
+
+ //DegreeInterval iv = (DegreeInterval) id.getBelief(null);
+ //System.out.println(""+iv.getInf() + "\t" + iv.getSup());
+ ImpreciseDistribution[] mass = new ImpreciseDistribution[2];
+ double[][] m0 = new double[][] {
+ {0, 0.1, 0.4, 0.3, 0, 0, 0, 0},
+ {0, 0.2, 0.5, 0.3, 0, 0, 0, 0},
+ {1, 0.3, 0.6, 0.5, 1, 1, 1, 1}
+ };
+ mass[0] = new ImpreciseDistribution(m0);
+ double[][] m1 = new double[][] {
+ {0, 0.6, 0.0, 0.2, 0, 0, 0, 0},
+ {0, 0.7, 0.1, 0.2, 0, 0, 0, 0},
+ {1, 0.8, 0.2, 0.4, 1, 1, 1, 1}
+ };
+ mass[1] = new ImpreciseDistribution(m1);
+
+// int[] out = new int[8];
+// mass[0].orderPerm(m1[1], out);
+// for (int i = 0; i < 8; i++) System.out.print(out[i]+" ");
+
+
+ HashSet<List<Integer>>[] hashSets = new HashSet[8];
+ Set<List<Integer>>[] map = hashSets;
+ for (int j = 0; j < 8; j++) {
+ map[j] = new HashSet<List<Integer>>();
+ }
+ for (int j = 0; j < 3; j++) {
+ for (int k = 0; k < 3; k++) {
+ List<Integer> list = new ArrayList<Integer>(2);
+ list.add(j+1);
+ list.add(k+1);
+ if (j == k) map[j+1].add(list);
+ else map[0].add(list);
+ }
+ }
+ //e.fitCopy(5).fitCopy(10);
+
+ //ImpreciseDistribution demp = new ImpreciseDistribution(mass,map);
+// double[] testS = mass[0].minimizeLC(m0[0], m0[2], new double[] {0.2, 0.1, 0, 0, 0.3, 0.2, 0.1, 0},
+// new int[] {2,3,7,1,6,0,5,4});
+//
+// System.out.print("Test : ");
+// for (int z = 0; z < 8; z++)
+// System.out.print(testS[z]+" ");
+// System.out.println();
+
+ //System.out.println(demp);
+// demp.normalize();
+// System.out.println(demp);
+
+ //BRPLOp op = new LukasImply();
+// e = (Essence)
+// op.eval(new Essence[] { e, e});
+
+ IArg[] args = new IArg[2];
+ IUncertainPredicate prem = new BRPLPredicate("premise",null,e1);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ IUncertainPredicate conc = new BRPLPredicate("conclus",null,e3);
+ args[0] = prem;
+ args[1] = conc;
+ BRPLOperator implic = new BRPLOperator("testMP",args,e2);
+ ModusPonensOp mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+
+ mop.updateConclusion();
+
+ e = (Essence) conc.getDegree();
+
+
+
+
+
+
+
+ args = new IArg[2];
+ prem = new BRPLPredicate("premise",null,heal);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ conc = new BRPLPredicate("conclus",null,h2);
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,h2h);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+
+ mop.updateConclusion();
+
+ h2 = (Essence) conc.getDegree();
+
+
+ args = new IArg[2];
+ prem = new BRPLPredicate("premise",null,rich);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ conc = new BRPLPredicate("conclus",null,h1);
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,r2h);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+
+ mop.updateConclusion();
+
+ h1 = (Essence) conc.getDegree();
+
+
+ args = new IArg[2];
+ prem = new BRPLPredicate("premise",null,rich);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ conc = new BRPLPredicate("conclus",null,e);
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,r2h);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+ mop.updateConclusion();
+
+ prem = new BRPLPredicate("premise",null,heal);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,h2h);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+ mop.updateConclusion();
+
+ happyBob = (Essence) conc.getDegree();
+
+
+
+
+
+
+
+
+
+
+ LukasNeg non = new LukasNeg();
+
+ args = new IArg[2];
+ Essence ne1 = (Essence) non.eval(new Essence[] {e1});
+ prem = new BRPLPredicate("premise",null,ne1);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ conc = new BRPLPredicate("conclus",null,e);
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,e2);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+
+ mop.updateConclusion();
+
+ e = (Essence) non.eval(new Essence[] {(Essence) conc.getDegree()});
+
+
+ args = new IArg[2];
+
+ prem = new BRPLPredicate("premise",null,e1);
+ //IUncertainPredicate conc = new BRPLPredicate("conclus",null,new Essence(Essence.L200_DOMAIN));
+ conc = new BRPLPredicate("conclus",null,e);
+ args[0] = prem;
+ args[1] = conc;
+ implic = new BRPLOperator("testMP",args,e2);
+ mop = new ModusPonensOp(implic,new TauPignisticStrategy(),new DempsterShaferAggStrat());
+
+ mop.updateConclusion();
+
+ e = (Essence) conc.getDegree();
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+ public void display() {
+ setSize(820,450);
+ setVisible(true);
+
+ }
+
+ public void paint(Graphics g) {
+ super.paint(g);
+ Essence z = new Essence(200);
+ //e.render(this.getContentPane().getBounds(),this.getContentPane().getGraphics());
+
+// g.setFont(new Font(Font.MONOSPACED,Font.PLAIN,12));
+// happy.renderCompact(new Rectangle(100,0,75,75), this.getContentPane().getGraphics());
+// g.drawString("Happy(X)", 115, 120);
+//
+// rich.renderCompact(new Rectangle(0,100,75,75), this.getContentPane().getGraphics());
+// g.drawString("Rich(guy)", 15, 220);
+// heal.renderCompact(new Rectangle(0,200,75,75), this.getContentPane().getGraphics());
+// g.drawString("Healthy(guy)", 5, 320);
+//
+// r2h.renderCompact(new Rectangle(100,100,75,75), this.getContentPane().getGraphics());
+// g.drawString("R(X)->Hap(X)", 100, 220);
+// h2h.renderCompact(new Rectangle(100,200,75,75), this.getContentPane().getGraphics());
+// g.drawString("H(X)->Hap(X)", 100, 320);
+//
+// h0.renderCompact(new Rectangle(225,0,75,75), this.getContentPane().getGraphics());
+// g.drawString("Happy(guy)|0", 225, 120);
+// h1.renderCompact(new Rectangle(225,100,75,75), this.getContentPane().getGraphics());
+// g.drawString("Happy(guy)|R", 225, 220);
+// h2.renderCompact(new Rectangle(225,200,75,75), this.getContentPane().getGraphics());
+// g.drawString("Happy(guy)|H", 225, 320);
+// happyBob.renderCompact(new Rectangle(225,320,75,75), this.getContentPane().getGraphics());
+// g.drawString("Happy(guy)", 235, 440);
+//
+//
+// g.drawLine(225,335,305,335);
+// g.drawString("*", 88, 175);
+// g.drawString("*", 88, 275);
+// g.drawString("/", 200, 75);
+// g.drawString("=>", 200, 175);
+// g.drawString("=>", 200, 275);
+
+
+
+// g.setFont(new Font(Font.MONOSPACED,Font.PLAIN,12));
+// e1.renderCompact(new Rectangle(00,0,75,75), this.getContentPane().getGraphics());
+// g.drawString("P(X)", 30, 120);
+//
+// e2.renderCompact(new Rectangle(100,00,75,75), this.getContentPane().getGraphics());
+// g.drawString("P(X) <-> C(Y)", 95, 120);
+//
+// e.renderCompact(new Rectangle(225,0,75,75), this.getContentPane().getGraphics());
+// g.drawString("C(Y)", 255, 120);
+//
+//
+// g.drawLine(225,335,305,335);
+// g.drawString("*", 88, 75);
+// g.drawString("=>", 200, 75);
+
+ Essence tr = Essence.True(0);
+ tr.renderCompact(new Rectangle(0,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("True", 30, 120);
+
+ Essence fa = Essence.spike(0,0);
+ fa.renderCompact(new Rectangle(100,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("False", 125, 120);
+
+ Essence av = Essence.spike(5,0);
+ av.renderCompact(new Rectangle(200,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("T and F", 220, 120);
+
+ knowNot.renderCompact(new Rectangle(300,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("Know Not", 315, 120);
+
+ notKnow.renderCompact(new Rectangle(400,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("Not Know", 415, 120);
+
+ headorTail.renderCompact(new Rectangle(500,0,75,75), this.getContentPane().getGraphics());
+ g.drawString("Head/Tail", 515, 120);
+
+
+ }
+
+
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/Main.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/DiscreteDomain.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/DiscreteDomain.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/DiscreteDomain.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,78 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.domains;
+
+import java.util.BitSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+ at SuppressWarnings("unchecked")
+
+/**
+ * @
+ */
+public class DiscreteDomain<T>
+ extends HashSet<T>
+ implements IDiscDomain<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ public DiscreteDomain() { super(); }
+
+ /**
+ * @deprecated
+ */
+ public Set<T> getSubset(int j) {
+ Set<T> ans = new HashSet<T>();
+ Iterator<T> it = this.iterator();
+ for (int k = 0; k < j; k++) it.next();
+
+ ans.add(it.next());
+ return ans;
+ }
+
+ /**
+ * @deprecated
+ */
+ public BitSet getCharacteristic(Set<?> s) {
+ BitSet ans = new BitSet(Long.SIZE);
+ for (Object obj : s) {
+ int j = -1;
+ Iterator it = this.iterator();
+ while (! it.next().equals(obj)) j++;
+
+ if (j < 0 || j > Long.SIZE) return null;
+ ans.set(j);
+ }
+ return ans;
+ }
+
+ public Set<T> getComplement(Set<?> s) {
+ Set<T> ans = new HashSet<T>();
+ ans.addAll(this);
+ ans.removeAll(s);
+ return ans;
+ }
+
+ public BitSet getCharByIdx(int j) {
+ BitSet bs = new BitSet();
+ for (int i= 0; i < 32; i++)
+ if ((j&(1<<i)) != 0) bs.set(i);
+ return bs;
+ }
+
+
+ public int getIdx(BitSet bs) {
+ int k = 1;
+ int ans = 0;
+ for (int j = 0; j < bs.length(); j++) {
+ if (bs.get(j)) ans += k;
+ k = k >> 1;
+ }
+ return ans;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/DiscreteDomain.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IContDomain.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IContDomain.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IContDomain.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,17 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.domains;
+
+/**
+ * Continuous domain
+ *
+ * @author Sotty
+ *
+ */
+public interface IContDomain<T> extends IDomain<T> {
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IContDomain.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDiscDomain.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDiscDomain.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDiscDomain.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,15 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.domains;
+
+/**
+ * Discrete domain
+ *
+ * @author Sotty
+ *
+ */
+public interface IDiscDomain<T> extends IDomain<T> {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDiscDomain.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDomain.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDomain.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDomain.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,30 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.domains;
+
+import java.util.BitSet;
+import java.util.Set;
+
+/**
+ * Domain
+ * In fact, a constrained set which acts as a Range for
+ * some measure function
+ *
+ * @author Sotty
+ *
+ */
+public interface IDomain<T> extends Set<T> {
+
+ public Set<T> getSubset(int j);
+
+ public BitSet getCharacteristic(Set<?> s);
+
+ public BitSet getCharByIdx(int j);
+
+ public int getIdx(BitSet bs);
+
+ public Set<T> getComplement(Set<?> s);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/domains/IDomain.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/EssenceDegreeFactory.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/EssenceDegreeFactory.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/EssenceDegreeFactory.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,82 @@
+package uncertainty.factory;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+import uncertainty.truthvals.operators.ModusPonensOp;
+import uncertainty.truthvals.operators.Lukas.LukasAnd;
+import uncertainty.truthvals.operators.Lukas.LukasOr;
+import uncertainty.truthvals.operators.aggregators.DempsterShaferAggStrat;
+
+//TODO : To be specified in much greater detail...
+public class EssenceDegreeFactory implements IDegreeFactory {
+
+
+ private int level = Essence.L20_BOUNDS;
+ private int N = Essence.DEF_N;
+
+
+ @Override
+ public IUncertainDegree False() {
+ Essence ans = Essence.spike(0, level);
+// System.out.println("Factory.False" + ans);
+ return ans;
+ }
+
+ @Override
+ public IUncertainDegree True() {
+ Essence ans = Essence.True(level);
+// System.out.println("Factory.True"+ans);
+ return ans;
+ }
+
+ @Override
+ public IUncertainDegree buildDegree(double val) {
+ if (val == 1) return True();
+
+ Essence ans = new Essence(val,1,level);
+// System.out.println("Factory.degree" + ans);
+ return ans;
+
+ }
+
+ @Override
+ public IUncertainDegree fromBoolean(boolean b) {
+ return b ? True() : False();
+ }
+
+ @Override
+ public IUncDegCombiner getAggregator() {
+ return new DempsterShaferAggStrat();
+ }
+
+ @Override
+ public IUncDegCombiner getAndOperator() {
+ return new LukasAnd();
+ }
+
+ @Override
+ public IUncDegCombiner getOrOperator() {
+ return new LukasOr();
+ }
+
+ @Override
+ public IUncertainDegree Unknown() {
+ return new Essence(level);
+ }
+
+ @Override
+ public IUncDegCombiner getModusPonensOp() {
+ return new ModusPonensOp();
+ }
+
+ /* (non-Javadoc)
+ * @see uncertainty.factory.IDegreeFactory#mergeIntersect(uncertainty.truthvals.IUncertainDegree, uncertainty.truthvals.IUncertainDegree)
+ */
+ @Override
+ public IUncertainDegree mergeIntersect(IUncertainDegree d1,
+ IUncertainDegree d2) {
+ return getAggregator().eval(new IUncertainDegree[] {d1,d2});
+ }
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/IDegreeFactory.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/IDegreeFactory.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/IDegreeFactory.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,36 @@
+package uncertainty.factory;
+
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+
+public interface IDegreeFactory {
+
+
+ public IUncertainDegree buildDegree(double val);
+
+
+ public IUncertainDegree True();
+
+ public IUncertainDegree False();
+
+ public IUncertainDegree Unknown();
+
+ public IUncertainDegree fromBoolean(boolean b);
+
+ public IUncDegCombiner getAndOperator();
+
+ public IUncDegCombiner getOrOperator();
+
+ public IUncDegCombiner getAggregator();
+
+
+ public IUncDegCombiner getModusPonensOp();
+
+
+ public IUncertainDegree mergeIntersect(IUncertainDegree d1, IUncertainDegree d2);
+
+
+
+
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/SimpleDegreeFactory.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/SimpleDegreeFactory.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/factory/SimpleDegreeFactory.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,66 @@
+package uncertainty.factory;
+
+import uncertainty.truthvals.Degree;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+import uncertainty.truthvals.operators.simple.SimpleDotAnd;
+import uncertainty.truthvals.operators.simple.SimpleMaxOr;
+import uncertainty.truthvals.operators.simple.SimpleMinAnd;
+
+public class SimpleDegreeFactory implements IDegreeFactory {
+
+ @Override
+ public IUncertainDegree buildDegree(double val) {
+ return new Degree(val);
+ }
+
+ @Override
+ public IUncertainDegree False() {
+ return new Degree(0);
+ }
+
+ @Override
+ public IUncertainDegree True() {
+ return new Degree(1);
+ }
+
+ @Override
+ public IUncertainDegree fromBoolean(boolean b) {
+ return b ? new Degree(1) : new Degree(0);
+ }
+
+ @Override
+ public IUncDegCombiner getAndOperator() {
+ return new SimpleDotAnd();
+ }
+
+ @Override
+ public IUncDegCombiner getOrOperator() {
+ return new SimpleMaxOr();
+ }
+
+ @Override
+ public IUncDegCombiner getAggregator() {
+ return new SimpleMaxOr();
+ }
+
+ @Override
+ public IUncertainDegree Unknown() {
+ return False();
+ }
+
+ @Override
+ public IUncDegCombiner getModusPonensOp() {
+ return new SimpleMinAnd();
+ }
+
+ /* (non-Javadoc)
+ * @see uncertainty.factory.IDegreeFactory#mergeIntersect(uncertainty.truthvals.IUncertainDegree, uncertainty.truthvals.IUncertainDegree)
+ */
+ @Override
+ public IUncertainDegree mergeIntersect(IUncertainDegree d1,
+ IUncertainDegree d2) {
+ return getAggregator().eval(new IUncertainDegree[] {d1,d2});
+ }
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IDegreeEvalFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IDegreeEvalFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IDegreeEvalFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,27 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures;
+
+import java.util.Set;
+
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * Objects implementing this interface must be able
+ * to take a set of objects belonging to some universe
+ * domain and evaluate some sort of property these
+ * objects can have (as a set) in some degree.
+ *
+ * @author Sotty
+ */
+public interface IDegreeEvalFunction {
+
+ /**
+ * Evaluation function
+ * @param s The objects to be evaluated
+ * @return The Degree of the evaluation
+ */
+ public IUncertainDegree eval(Set<Object> s);
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IDegreeEvalFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IMeasureFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IMeasureFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IMeasureFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,23 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures;
+
+/**
+ * This function evaluates a proper measure on the set of objects
+ * i.e.
+ * given an universe X
+ * m(0) = 0
+ * m(X) = 1
+ * S1 in S2 => m(S1) <= m(S2)
+ * plus, it must be continuous
+ *
+ * @author Sotty
+ *
+ */
+public interface IMeasureFunction extends IDegreeEvalFunction {
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/IMeasureFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ConcreteImpDist.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ConcreteImpDist.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ConcreteImpDist.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,58 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.measures.belief;
+
+import java.util.Set;
+
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.IUncertainInterval;
+
+public class ConcreteImpDist extends ImpreciseDistribution {
+
+
+ @Override
+ public IUncertainInterval getMetaDegreeBounds(Set<Object> s) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+ public boolean isBayesian() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isCategorical() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isContradictory() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isDogmatic() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isVacuous() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public ConcreteImpDist(double[][] p) { super(p); }
+
+
+
+ @Override
+ public IUncertainDegree getPlausibility(Set<?> s) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ConcreteImpDist.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IBeliefFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IBeliefFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IBeliefFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,31 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.belief;
+
+import uncertainty.measures.IMeasureFunction;
+
+/**
+ * Belief measure function
+ *
+ * @see IMassFunction
+ * @author Sotty
+ */
+public interface IBeliefFunction extends IMeasureFunction {
+
+ /**
+ * Applying Moebius' theorem, belief measures can be inverted
+ * to return the basic mass assignment that originated them.
+ * @return a mass function evaluator
+ */
+ public IMassFunction invertToMass();
+
+ /**
+ * Pl(A) = 1-Bel(A')
+ * Hence, plausibility and belief are strongly correlated
+ * @return 1-Bel(A')
+ */
+ public IPlausibilityFunction mirrorToPlausibility();
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IBeliefFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IMassFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IMassFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IMassFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,93 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.belief;
+
+import java.util.Set;
+
+import uncertainty.measures.IMeasureFunction;
+import uncertainty.measures.probability.IBayesianMassFunction;
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * This measure is a proper mass assignment on a universe X
+ * Being P(X) the set of subsets of X, 2^X:
+ *
+ * m : P(X) -> [0,1]
+ * forall Aj in P(X)
+ * m(Aj) >= 0
+ * Sum(m(Aj)) = 1
+ *
+ * @author Sotty
+ *
+ */
+public interface IMassFunction extends IMeasureFunction {
+
+ /**
+ * Basic Mass assignment allows belief computation
+ * Bel S = Sum(m(Aj)), Aj <= S, Aj != 0
+ * @param s
+ * @return Bel(s)
+ */
+ public IUncertainDegree getBelief(Set<?> s);
+
+ /**
+ * Basic Mass assignment allows plausibility computation
+ * Pl S = Sum(m(Aj)), Aj ^ S != 0
+ * @param s
+ * @return Pl(s)
+ */
+ public IUncertainDegree getPlausibility(Set<?> s);
+
+ /**
+ * Converts this mass assignment into a bayesian one
+ * @return
+ */
+ public IBayesianMassFunction toBayesianMassFunction();
+
+ /**
+ * The focal elements are all the subsets of the universe
+ * X for which m(S) > 0.
+ * @return
+ */
+ public Set<Set<?>> getFocalElements();
+
+ /**
+ * A categorical mass function has m(A*) = 1
+ * @return true if categorical
+ */
+ public boolean isCategorical();
+
+ /**
+ * A vacuous mass function has m(X) = 1
+ * @return true if vacuous
+ */
+ public boolean isVacuous();
+
+ /**
+ * A contradictory mass function has m(0) = 1
+ * @return true if contradictory
+ */
+ public boolean isContradictory();
+
+ /**
+ * A normalized mass function has m(0) = 0
+ * @return true if normalized
+ */
+ public boolean isNormalized();
+
+ /**
+ * A dogmatic mass function has m(X) = 0
+ * @return true if dogmatic
+ */
+ public boolean isDogmatic();
+
+ /**
+ * A bayesian mass function has m(Aj) > 0 iff |Aj| == 1
+ * (i.e. it gives credit to singletons only)
+ * @return true if bayesian
+ */
+ public boolean isBayesian();
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IMassFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IPlausibilityFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IPlausibilityFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IPlausibilityFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,31 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.belief;
+
+import uncertainty.measures.IMeasureFunction;
+
+/**
+ * Plausibility measure function
+ *
+ * @see IMassFunction
+ * @author Sotty
+ */
+public interface IPlausibilityFunction extends IMeasureFunction {
+
+ /**
+ * Applying Moebius' theorem, plausibility measures can be inverted
+ * to return the basic mass assignment that originated them.
+ * @return a mass function evaluator
+ */
+ public IMassFunction invertToMass();
+
+ /**
+ * Bel(A) = 1-Pl(A')
+ * Hence, plausibility and belief are strongly correlated
+ * @return 1-Pl(A')
+ */
+ public IBeliefFunction mirrorToBelief();
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/IPlausibilityFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ImpreciseDistribution.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ImpreciseDistribution.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ImpreciseDistribution.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,1058 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.belief;
+
+import java.util.BitSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Observable;
+import java.util.Set;
+
+import uncertainty.domains.DiscreteDomain;
+import uncertainty.domains.IDiscDomain;
+import uncertainty.measures.probability.IBayesianMassFunction;
+import uncertainty.measures.probability.conversion.IAssignmentStrategy;
+import uncertainty.measures.probability.conversion.IUncAssignmentStrat;
+import uncertainty.truthvals.DegreeInterval;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.IUncertainInterval;
+
+/**
+ * An imprecise mass assignment has bounds: lj <= pj <= mj
+ * Sum(lj) <= 1
+ * Sum(mj) >= 1
+ *
+ * @author Sotty
+ *
+ */
+public class ImpreciseDistribution
+ extends Observable
+ implements IMassFunction {
+
+ public static final double ZERO = 1e-10;
+
+ /**
+ * Holder for universe U
+ */
+ protected IDiscDomain<? extends Object> universe;
+
+
+ /**
+ * Vector of masses
+ * given |U| = N, j in {0,...,2^N-1}
+ *
+ * p[j] is the mass of the subset of U whose
+ * characteristical function is encoded by j
+ *
+ * Most likely, p is sparse, so mapping functions should be used
+ */
+ protected double[] p;
+ public double getMass(int j) { return p[j]; }
+ public double[] getMass() { return p; }
+
+ /**
+ * Vector of upper mass bounds
+ */
+ protected double[] pU;
+ public double getMassU(int j) { return pU[j]; }
+ public double[] getMassU() { return pU; }
+ /**
+ * Vector of lower mass bounds
+ */
+ protected double[] pL;
+ public double getMassL(int j) { return pL[j]; }
+ public double[] getMassL() { return pL; }
+
+ /**
+ * Getter
+ * @return The number of elements
+ */
+ public int getSize() { return p.length; }
+
+
+
+ /**
+ * Bayesian projection strategy
+ * Turns this Distribution into a probabilistic one, focused on singletons
+ */
+ IAssignmentStrategy caster;
+
+ /**
+ * Sets the projection strategy
+ * @param strat The desired conversion algorithm
+ */
+ public void setAssignmentStrategy(IAssignmentStrategy strat) {
+ caster = strat;
+ }
+
+
+
+
+ /**
+ * An assignment is normal iff
+ *
+ * pLj + Sum{pUk, k != j} >= 1
+ * pUj + Sum{pLk, k != j} <= 1
+ */
+ private boolean normalized = false;
+
+
+ /**
+ * Bound accessor / evaluator
+ * @param s set whose imprecise mass assignment. is sought
+ * @return the interval [l(s),m(s)]
+ */
+ public IUncertainInterval getMetaDegreeBounds(Set<Object> s) {
+ int j = universe.getIdx(universe.getCharacteristic(s));
+ return new DegreeInterval(pL[j],pU[j]);
+ }
+
+
+ /**
+ * Property
+ * @return true if the bounds have been normalized
+ * @see uncertainty.measures.belief.IMassFunctionr#isNormalized()
+ */
+ public boolean isNormalized() { return normalized; }
+
+ /**
+ * Normalizes the unnormalized bounds, remembering that:
+ *
+ * lj* = max{lj, 1-Sum{mk, k != j}}
+ * mj* = min{mj, 1-Sum{lk, k != j}}
+ * Should set the flag <code>normal</code> to true.
+ *
+ */
+ public void normalize() {
+ /*
+ int n = p.length;
+ double[] tempL = new double[n];
+
+ double[] tempU = new double[n];
+
+ for (int j = 0; j < n; j++) {
+ tempL[j] = 1;
+ tempU[j] = 1;
+ for (int k = 0; k < n; k++) {
+ if (k != j) {
+ tempL[j] -= pU[k];
+ tempU[j] -= pL[k];
+ }
+ }
+ }
+ for (int j = 0; j < n; j++) {
+ pL[j] = Math.max(pL[j],tempL[j]);
+ pU[j] = Math.min(pU[j],tempU[j]);
+ }
+ */
+ double[][] ni = normalizeIntvals(1,pL,1,pU);
+ pL = ni[0];
+ pU = ni[1];
+ }
+
+
+ protected double[][] normalizeIntvals(double L, double[] low, double U, double[] upp) {
+ int n = low.length;
+ double[][] ans = new double[2][];
+ double[] tempL = new double[n];
+ double[] tempU = new double[n];
+
+ for (int j = 0; j < n; j++) {
+ tempL[j] = L;
+ tempU[j] = U;
+ for (int k = 0; k < n; k++) {
+ if (k != j) {
+ tempL[j] -= upp[k];
+ tempU[j] -= low[k];
+ }
+ }
+ }
+ for (int j = 0; j < n; j++) {
+ tempL[j] = Math.max(low[j],tempL[j]);
+ tempU[j] = Math.min(upp[j],tempU[j]);
+ }
+ ans[0] = tempL;
+ ans[1] = tempU;
+ return ans;
+ }
+
+
+ /**
+ * Sets the "normal" flag to true
+ */
+ public void setNormal() { normalized = true; }
+
+
+ /**
+ * Imprecise belief can be computed from imprecise masses:
+ * Given bounds lambda and mu for a set's mass:
+ * l <= p <= m
+ *
+ * Knowing that bel(X) = Sum{bel(Y) | Y subset_eq X , Y != 0}
+ * one has:
+ * lambda(bel(X)) = max{ Sum{l(Y)} , 1 - Sum{m(Z)} - m(0)}
+ * with Y subset_eq X, Y != 0
+ * Z not subset_eq X
+ * mu(bel(X)) = min{ Sum{m(Y)} , 1 - Sum{l(Z)} - l(0)}
+ * with Y subset_eq X, Y != 0
+ * Z not subset_eq X
+ *
+ *
+ * Test implementation: bitsets are to be removed
+ * TODO : Domain rep should be more concrete
+ *
+ * @deprecated
+ * @see uncertainty.measures.belief.IMassFunctionr#getBelief(Set<Object> s)
+ */
+ public IUncertainDegree getBelief(Set<?> s) {
+ int n = p.length;
+ BitSet ref = universe.getCharacteristic(s);
+ //BitSet ref = new BitSet(3);
+ //ref.set(1);
+ //ref.set(2);
+ double l1 = 0;
+ double l2 = 1;
+ double m1 = 0;
+ double m2 = 1;
+
+ for (int j = 0; j < n; j++) {
+
+ BitSet bs = universe.getCharByIdx(j);
+
+ System.out.println(bs);
+ bs.andNot(ref);
+ boolean sub = (j != 0) && (bs.cardinality() == 0);
+ if (sub) {
+ l1 += pL[j];
+ m1 += pU[j];
+ } else {
+ l2 -= pU[j];
+ m2 -= pL[j];
+ }
+ }
+ return new DegreeInterval(Math.max(l1,l2),Math.min(m1,m2));
+ }
+
+
+
+ /**
+ * Focal elements are subsets of the Set-Part 2^U
+ * that have mass greater than 0.
+ *
+ * @see uncertainty.measures.belief.IMassFunctionr#getFocalElements()
+ */
+ public Set<Set<?>> getFocalElements() {
+ Set<Set<?>> ans = new HashSet<Set<?>>();
+ for (int j = 0; j < p.length; j++)
+ if (p[j] != 0) {
+ Set<?> s = universe.getSubset(j);
+ ans.add(s);
+ }
+ return ans;
+ }
+
+ /**
+ * Plausibility depends on belief
+ * lambda(pl(X)) = 1 - mu(bel(X'))
+ * mu(pl(X)) = 1 - lambda(bel(X'))
+ *
+ * @deprecated
+ * @see uncertainty.measures.belief.IMassFunctionr#getPlausibility(Set<Object> s)
+ */
+ public IUncertainDegree getPlausibility(Set<?> s) {
+ IUncertainInterval iv = (IUncertainInterval) this.getBelief(universe.getComplement(s));
+ return new DegreeInterval(1-iv.getSup().getValue(),1-iv.getInf().getValue());
+ }
+
+
+ /**
+ * Bayesian projection
+ * Relies on the strategy the object has been provided with
+ */
+ public IBayesianMassFunction toBayesianMassFunction() {
+ return this.caster.massToBayesianMass(this);
+ }
+
+ /**
+ * Uncertain Bayesian projection
+ * Relies on the strategy the object has been provided with
+ */
+ public IBayesianMassFunction toBayesianMassFunction(boolean withBounds) {
+ if (caster instanceof IUncAssignmentStrat)
+ return ((IUncAssignmentStrat) caster).massToBayesianMass(this,withBounds);
+ return this.caster.massToBayesianMass(this);
+ }
+
+
+ /**
+ * Evaluation returns the distribution bounds for the given set
+ */
+ public IUncertainDegree eval(Set<Object> s) {
+ return getMetaDegreeBounds(s);
+ }
+
+
+ /**
+ * Discount operation
+ * Decreases belief in non-full sets and assigns
+ * the discounted mass to the full set
+ * p[j] = alfa*p[j] , j != U
+ * pL[j] = alfa*pL[j] , j != U
+ * pU[j] = alfa*pU[j] , j != U
+ * p[U] += 1-alfa;
+ *
+ * When U < 0, the universal mass is pignistically
+ * (uniformly) distributed among ALL the masses:
+ * pL[j] += 0;
+ * p[j] += (1-alfa)/N
+ * pU[j] += 1-alfa
+ * (normalization status does not change)
+ *
+ * @param alfa discount factor
+ * @param univIdx index of the universal mass
+ * @return the universal set mass
+ */
+ public double discount(double alfa, int univIdx) {
+ int n = p.length;
+ if (univIdx >= 0) {
+ for (int j = 0; j < n; j++) {
+ if (j != univIdx) {
+ pL[j] *= alfa;
+ p[j] *= alfa;
+ pU[j] *= alfa;
+ }
+ }
+ } else {
+ for (int j = 0; j < n; j++) {
+ pL[j] = pL[j]*alfa;
+ p[j] = p[j]*alfa + (1.0-alfa)/n;
+ pU[j] = pU[j]*alfa + (1.0-alfa);
+ }
+ }
+ // cui prodest?
+ return (1.0-alfa);
+ }
+
+
+
+
+
+ /**
+ * Constrained linear programming algorithm:
+ *
+ * Minimize c'm (i.e. find m*)
+ * s.t.
+ * 0 <= a <= m <= b <= 1
+ * n = m.length
+ * |m*| (L1-norm) == 1
+ * c is increasing
+ * i.e. c(j) <= c(k) iff j <= k
+ *
+ * @param a lower bound vector
+ * @param b upper bound vector
+ * @param c increasingly ordered coefficients vector
+ * @return ans[0..n-1] is the admissible solution m*
+ * ans[n] is the min value c'm*
+ */
+ public double[] minimizeLC(double[] a, double[] b, double[] c, int[] prm ) {
+ int n = a.length;
+ double[] ans = new double[n+1];
+ ans[n] = Double.MIN_VALUE;
+ int idx = -1;
+ double tempMin = 0;
+
+ for (int k = 0; k < n; k++) {
+ double u = 0;
+ double l = 0;
+ double r = 0;
+ double s = 0;
+ double p = 0;
+ int ki = prm[k];
+
+ for (int t = 0; t < k; t++) {
+// idx = t;
+ idx = prm[t];
+ u += c[idx]*b[idx];
+ r += b[idx];
+ }
+ for (int t = k+1; t < n; t++) {
+ //idx = t;
+ idx = prm[t];
+ l += c[idx]*a[idx];
+ s += a[idx];
+ }
+ p = 1-r-s;
+ tempMin = u + l + c[ki]*p;
+// System.out.println("K as "+ki+" gives max="+tempMin+"with p "+p);
+
+ if (tempMin > ans[n] && (p >= a[ki]-ZERO) && (p <= b[ki]+ZERO)) {
+// System.out.println("Up for "+k);
+ ans[n] = tempMin;
+ ans[ki] = p;
+ for (int t = 0; t < k; t++) {
+ idx = prm[t];
+ ans[idx] = b[idx];
+ }
+ for (int t = k+1; t < n; t++) {
+ idx = prm[t];
+ ans[idx] = a[idx];
+ }
+ }
+ }
+
+ return ans;
+ }
+
+
+
+ /**
+ * Constrained linear programming algorithm:
+ *
+ * Maximize c'm
+ * s.t.
+ * 0 <= a <= m <= b <= 1
+ * n = m. length
+ * |m| = 1 (L1 norm)
+ * c is increasingly ordered
+ * i.e. c(j) <= c(k) iff j <= k
+ *
+ * @param a lower bound vector
+ * @param b upper bound vector
+ * @param c increasingly ordered coefficients vector
+ * @return ans[0..n-1] is the admissible solution m*
+ * ans[n] is the min value c'm*
+ */
+ public double[] maximizeLC(double[] a, double[] b, double[] c, int[] prm) {
+// System.out.println("maxLc with perm");
+// for (int j = 0; j < prm.length; j++) System.out.print(prm[j]+" ");
+
+ int n = a.length;
+ double[] ans = new double[n+1];
+ ans[n] = Double.MAX_VALUE;
+ int idx = -1;
+ double tempMax = 0;
+
+
+ for (int k = 0; k < n; k++) {
+ double u = 0;
+ double l = 0;
+ double s = 0;
+ double r = 0;
+ double p = 0;
+ int ki = prm[k];
+
+ for (int t = 0; t < k; t++) {
+ //idx = t;
+ idx = prm[t];
+ u += c[idx]*a[idx];
+ r += a[idx];
+ }
+ for (int t = k+1; t < n; t++) {
+ //idx = t;
+ idx = prm[t];
+ l += c[idx]*b[idx];
+ s += b[idx];
+ }
+ p = 1-r-s;
+ tempMax = u + l + c[ki]*(p);
+// System.out.println("K as "+ki+" gives max="+tempMax + "with p being "+p + "should be in "+a[ki]+" "+b[ki]);
+
+
+ if (tempMax < ans[n] && (p >= a[ki]-ZERO) && (p<=b[ki]+ZERO)) {
+ //System.out.println("Found better at ki "+ki+", aka k="+k);
+ ans[n] = tempMax;
+ ans[ki] = p;
+ for (int t = 0; t < k; t++) {
+ idx = prm[t];
+ ans[idx] = a[idx];
+ }
+ for (int t = k+1; t < n; t++) {
+ idx = prm[t];
+ ans[idx] = b[idx];
+ }
+ }
+ }
+
+ return ans;
+ }
+
+
+ /**
+ * Generalized Dempster-Shafer Imprecise distribution combination
+ * Given:
+ * N imprecise source distributions: Mj:1..X,n:1..N
+ * an operator op
+ *
+ * all the possible product chains m(1)j1,n1*m(2)j2,n2*...*m(N)jN,nN
+ * are summed into the various slots of the distribution Opj
+ *
+ * @param mass
+ * @param map
+ * @param withBounds
+ */
+ public ImpreciseDistribution(ImpreciseDistribution[] mass, Set<List<Integer>>[] map, boolean withBounds, int N) {
+ p = combine(mass,map,N);
+ if (withBounds) {
+ double[][] bnds = combineBounds(mass,map,N);
+ pL = bnds[0];
+ pU = bnds[1];
+ }
+ }
+
+ public ImpreciseDistribution(ImpreciseDistribution[] mass, Set<List<Integer>>[] map, boolean withBounds) {
+ p = combine(mass,map,mass[0].getSize());
+ if (withBounds) {
+ double[][] bnds = combineBounds(mass,map,mass[0].getSize());
+ pL = bnds[0];
+ pU = bnds[1];
+ }
+ }
+
+
+ protected double[] combine(ImpreciseDistribution[] mass, Set<List<Integer>>[] map, int N) {
+ double[] ans = new double[N];
+ for (int j = 0; j < map.length; j++) {
+ Set<List<Integer>> chains = map[j];
+ for (List<Integer> chain : chains) {
+ double acc = 1;
+ for (int i = 0; i < chain.size(); i++)
+ acc *= mass[i].p[chain.get(i)];
+ ans[j] += acc;
+ }
+ }
+ return ans;
+ }
+
+ /**
+ * Alternating directions research for bound-combinations
+ * Experimental and under revision
+ * See Deneux
+ *
+ * In searching min (max) for a given combination of m1 and m2,
+ * the minimizing (maximizing) solution is optimized using, alternatively, the bounds of m1 and m2
+ * to obtain a solution that is valid for both.
+ *
+ * Interface is provided for n-ary operations,
+ * but is implemented for binary only
+ *
+ * TODO: generalize to n-ary
+ *
+ * @param mass
+ * @param map
+ * @return
+ */
+ protected double[][] combineBounds(ImpreciseDistribution[] mass, Set<List<Integer>>[] map, int N) {
+ int n = mass[0].p.length;
+ double[] lambda = new double[N];
+ double[] mu = new double[N];
+
+ //TODO 0 is N !!!
+ for (int j = 0; j < N; j++) {
+ boolean flag = true;
+ double[] temp = new double[n+1];
+ double[] temp2 = new double[n+1];
+ double[] acc = new double[n];
+ int[] perm = new int[n];
+ mu[j] = 1;
+ lambda[j] = 0;
+ double[] m1low = mass[0].getLowBoundVec();
+ double[] m1upp = mass[0].getUppBoundVec();
+ double[] m2low = mass[1].getLowBoundVec();
+ double[] m2upp = mass[1].getUppBoundVec();
+ Set<List<Integer>> chains = map[j];
+
+
+ if (chains.size() == 1) {
+ List<Integer> list = chains.iterator().next();
+ int j1 = list.get(0);
+ int j2 = list.get(1);
+ mu[j] = m1upp[j1]*m2upp[j2];
+ lambda[j] = m1low[j1]*m2low[j2];
+ continue;
+ }
+
+ // solution initialization
+ for (int i = 0; i < n; i++) {
+ //temp[i] = (p != null) ? p[i] : (m2low[i]+m2upp[i])*0.5;
+ temp[i] = (m2low[i]+m2upp[i])*0.5;
+ }
+ temp[n] = 1;
+// System.out.println("Initialization mass:");
+// for (int z = 0; z < N; z++)
+// System.out.print(" "+temp[z]);
+// System.out.println();
+//
+
+
+ while (flag) {
+// System.out.println(".-...-.-.--.-..-.-.-.-");
+ /* max m1, with m2 const */
+
+ // the coeffs
+ for (int i = 0; i < n; i++)
+ acc[i] = 0;
+
+ for (List<Integer> chain : chains) {
+ //if (j == 4) System.out.println("Merging into "+j+" couples " + chain.get(0) + " and " + chain.get(1));
+ Integer idx1 = chain.get(1);
+ acc[idx1] += temp[chain.get(0)];
+ }
+ // acc must be sorted and the perm provided
+ this.orderPerm(acc,perm);
+// System.out.println("Coeffs I:");
+// for (int z = 0; z < N; z++) System.out.print(""+acc[z]+ " ");
+// System.out.println("");
+
+
+ // actual maximization
+
+ temp2 = maximizeLC(m1low,m1upp,acc,perm);
+// System.out.print("Partsol I ");
+// for (int z = 0; z <= N; z++) System.out.print(""+temp2[z]+ " ");
+// System.out.println();
+
+
+ // if better, mu
+// if (true || temp2[N] <= temp[N]) {
+// System.out.println("update");
+ for (int i = 0; i <= n; i++)
+ temp[i] = temp2[i];
+// }
+
+ /* Now the same, m1 const and max m2 */
+
+ // the coeffs
+ for (int i = 0; i < n; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx2 = chain.get(0);
+ acc[idx2] += temp[chain.get(1)];
+ }
+// System.out.println("Coeffs II:");
+// for (int z = 0; z < N; z++) System.out.print(""+acc[z]+ " ");
+// System.out.println("");
+ // acc must be sorted and the perm provided
+ this.orderPerm(acc,perm);
+
+ // actual maximization
+ temp2 = maximizeLC(m2low,m2upp,acc,perm);
+
+// System.out.print("Partsol II ");
+// for (int z = 0; z <= N; z++) System.out.print(""+temp2[z]+ " ");
+// System.out.println();
+
+
+ // if better, mu
+// if (true || temp2[N] <= temp[N]) {
+// System.out.println("update");
+ for (int i = 0; i <= n; i++)
+ temp[i] = temp2[i];
+// }
+
+
+ if (Math.abs(mu[j]-temp[n]) < ZERO) flag = false;
+ mu[j] = temp[n];
+ }
+
+
+
+// System.out.println("Now updating the lower bounds!!");
+
+ flag = true;
+ for (int i = 0; i < n; i++) {
+ temp[i] = (p == null) ? p[i] : (m2low[i]+m2upp[i])*0.5;
+ }
+ temp[n] = 0;
+// System.out.println("Initialization mass:");
+// for (int z = 0; z < N; z++)
+// System.out.print(" "+temp[z]);
+// System.out.println();
+
+ while (flag) {
+ // min m1, with m2 const /
+
+ // the coeffs
+ for (int i = 0; i < n; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ // System.out.println("Merging into "+j+" couples " + chain.get(0) + " and " + chain.get(1));
+ Integer idx1 = chain.get(1);
+ acc[idx1] += temp[chain.get(0)];
+ }
+ // acc must be sorted and the perm provided
+ this.orderPerm(acc,perm);
+// System.out.println("Coeffs III:");
+// for (int z = 0; z < N; z++) System.out.print(""+acc[z]+ " ");
+// System.out.println("");
+
+ // actual maximization
+ temp2 = minimizeLC(m1low,m1upp,acc,perm);
+// System.out.print("Partsol III ");
+// for (int z = 0; z <= N; z++) System.out.print(""+temp2[z]+ " ");
+// System.out.println();
+
+ // if better, mu
+// if (true || temp2[N] <= temp[N]) {
+ for (int i = 0; i <= n; i++)
+ temp[i] = temp2[i];
+// }
+
+ // Now the same, m1 const and max m2
+
+ // the coeffs
+ for (int i = 0; i < n; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx2 = chain.get(0);
+ acc[idx2] += temp[chain.get(1)];
+ }
+ // acc must be sorted and the perm provided
+ this.orderPerm(acc,perm);
+// System.out.println("Coeffs IV:");
+// for (int z = 0; z < N; z++) System.out.print(""+acc[z]+ " ");
+// System.out.println("");
+
+ // actual maximization
+ temp2 = minimizeLC(m2low,m2upp,acc,perm);
+// System.out.print("Partsol IV ");
+// for (int z = 0; z <= N; z++) System.out.print(""+temp2[z]+ " ");
+// System.out.println();
+
+ // if better, mu
+// if (true || temp2[N] <= temp[N]) {
+ for (int i = 0; i <= n; i++)
+ temp[i] = temp2[i];
+// }
+
+ if (Math.abs(lambda[j]-temp[n]) < ZERO) flag = false;
+ lambda[j] = temp[n];
+ }
+
+ }
+
+ double[][] ans = new double[2][];
+ ans[0] = lambda;
+ ans[1] = mu;
+ return ans;
+ }
+
+
+
+
+
+ protected double[] getUppBoundVec() {
+ return pU;
+ }
+
+
+ protected double[] getLowBoundVec() {
+ return pL;
+ }
+
+
+ /**
+ * Version II
+ * Alternating directions research for bound-combinations
+ * Experimental and under revision
+ * Deneux's implementation does not convice, esp when compared to his theory. Thus, I'll try another
+ *
+ * @param mass
+ * @param map
+ * @return
+ */
+ protected double[][] combineBounds2(ImpreciseDistribution[] mass, Set<List<Integer>>[] map) {
+ int N = mass[0].p.length;
+ double[] lambda = new double[N];
+ double[] mu = new double[N];
+
+ //TODO 0 is N !!!
+ for (int j = 0; j < N; j++) {
+ boolean flag1 = true;
+ boolean flag2 = true;
+ double[] tempSol = new double[N+1];
+ double[] temp1 = new double[N+1];
+ double[] temp2 = new double[N+1];
+ double[] acc = new double[N];
+ int[] perm = new int[N];
+ mu[j] = 0;
+ lambda[j] = 0;
+ double[] m1low = mass[0].pL;
+ double[] m1upp = mass[0].pU;
+ double[] m2low = mass[1].pL;
+ double[] m2upp = mass[1].pU;
+ Set<List<Integer>> chains = map[j];
+
+ if (chains.size() == 1) {
+ List<Integer> list = chains.iterator().next();
+ int j1 = list.get(0);
+ int j2 = list.get(1);
+ mu[j] = m1upp[j1]*m2upp[j2];
+ lambda[j] = m1low[j1]*m2low[j2];
+ continue;
+ }
+
+ // solution initialization
+ for (int i = 0; i < N; i++) {
+ temp2[i] = (p != null) ? p[i] : (m2low[i]+m2upp[i])*0.5;
+ }
+ temp1[N] = 0;
+ temp2[N] = 0;
+// System.out.println("Initialization mass:");
+// for (int z = 0; z < N; z++)
+// System.out.print(" "+temp[z]);
+// System.out.println();
+//
+
+
+ while (flag1 || flag2) {
+
+ for (int i = 0; i < N; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx1 = chain.get(0);
+ acc[idx1] += temp2[chain.get(1)];
+ }
+ this.orderPerm(acc,perm);
+ tempSol = maximizeLC(m1low,m1upp,acc,perm);
+
+ if (tempSol[N] > temp1[N]) {
+ for (int i = 0; i <= N; i++)
+ temp1[i] = tempSol[i];
+ }
+ if (tempSol[N] > mu[j]) {
+ flag1 = true;
+ mu[j] = tempSol[N];
+ } else flag1 = false;
+
+ for (int i = 0; i < N; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx2 = chain.get(1);
+ acc[idx2] += temp1[chain.get(0)];
+ }
+ this.orderPerm(acc,perm);
+ tempSol = maximizeLC(m2low,m2upp,acc,perm);
+
+ if (tempSol[N] > temp2[N]) {
+ for (int i = 0; i <= N; i++)
+ temp2[i] = tempSol[i];
+ }
+ if (tempSol[N] > mu[j]) {
+ flag2 = true;
+ mu[j] = tempSol[N];
+ } else flag2 = false;
+
+ }
+
+
+
+ for (int i = 0; i < N; i++) {
+ temp2[i] = (p != null) ? p[i] : (m2low[i]+m2upp[i])*0.5;
+ }
+ temp1[N] = 1;
+ temp2[N] = 1;
+
+
+
+ flag1 = true;
+ flag2 = true;
+ while (flag1 || flag2) {
+
+ for (int i = 0; i < N; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx1 = chain.get(0);
+ acc[idx1] += temp2[chain.get(1)];
+ }
+ this.orderPerm(acc,perm);
+ tempSol = minimizeLC(m1low,m1upp,acc,perm);
+
+ if (tempSol[N] < temp1[N]) {
+ for (int i = 0; i <= N; i++)
+ temp1[i] = tempSol[i];
+ }
+
+ if (tempSol[N] > lambda[j]) {
+ flag1 = true;
+ lambda[j] = tempSol[N];
+ } else flag1 = false;
+
+
+ for (int i = 0; i < N; i++)
+ acc[i] = 0;
+ for (List<Integer> chain : chains) {
+ Integer idx2 = chain.get(1);
+ acc[idx2] += temp1[chain.get(0)];
+ }
+ this.orderPerm(acc,perm);
+ tempSol = minimizeLC(m2low,m2upp,acc,perm);
+
+ if (tempSol[N] < temp2[N]) {
+ for (int i = 0; i <= N; i++)
+ temp2[i] = tempSol[i];
+ }
+
+ if (tempSol[N] > lambda[j]) {
+ flag2 = true;
+ lambda[j] = tempSol[N];
+ } else flag2 = false;
+
+ }
+
+ }
+
+ double[][] ans = new double[2][];
+ ans[0] = lambda;
+ ans[1] = mu;
+ return ans;
+ }
+
+
+
+
+
+ /**
+ * Very inefficient (N^3) ordering algorithm, should be substituted ASAP
+ *
+ * Outputs the permutation needed to order the vec ascending.
+ * @param vec
+ * @param outPerm
+ * @deprecated
+ */
+ public void orderPerm(double[] vec, int[] outPerm) {
+ int N = outPerm.length;
+// System.out.println("Permuting a vec");
+// for (int j = 0; j < vec.length; j++)
+// System.out.print(vec[j] + " ");
+
+ for (int i = 0; i < N; i++)
+ outPerm[i] = -1;
+
+ for (int i = 0; i < N; i++) {
+ double min = Double.POSITIVE_INFINITY;
+
+ int minIdx = -1;
+
+ for (int k = 0; k < N; k++) {
+ boolean unset = true;
+ for (int z = 0; z <=i; z++)
+ if (outPerm[z] == k) unset = false;
+ if (vec[k] < min && unset) {
+ min = vec[k];
+ minIdx = k;
+ }
+ }
+
+ outPerm[i] = minIdx;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+ /**
+ * Default constructor can't be used
+ */
+ protected ImpreciseDistribution() { }
+
+ /**
+ * Test Constructor
+ * m[0] holds lower bounds
+ * m[1] holds masses
+ * m[2] holds upper bounds
+ *
+ * @param m intervals distribution
+ * @deprecated
+ */
+ public ImpreciseDistribution(double[][] m) {
+ universe = new DiscreteDomain<Object>();
+ int n = m[0].length;
+ p = new double[n];
+ pL = new double[n];
+ pU = new double[n];
+ for (int j = 0; j < n; j++) {
+ pL[j] = m[0][j];
+ p[j] = m[1][j];
+ pU[j] = m[2][j];
+ }
+ }
+
+
+ public String toString() {
+ StringBuilder s = new StringBuilder("");
+ int n = p.length;
+
+ if (pL != null)
+ for (int j = 0; j < n; j++)
+ s.append(formatt(pL[j],3)).append(" ");
+ s.append("\n");
+ for (int j = 0; j < n; j++)
+ s.append(formatt(p[j],3)).append(" ");
+ s.append("\n");
+ if (pU != null)
+ for (int j = 0; j < n; j++)
+ s.append(formatt(pU[j],3)).append(" ");
+ s.append("\n");
+ return s.toString();
+ }
+
+
+ protected String formatt(double d, int n) {
+ return String.format("%."+n+"f", new Object[] {d});
+ }
+
+
+
+
+
+ //TODO : test methods are not safe
+
+ /**
+ * @deprecated
+ */
+ public boolean isBayesian() {
+ int n = (int) Math.round(Math.log(p.length)/Math.log(2));
+ double acc = 0;
+ for (int j = 1; j <= n; j++) {
+ acc += p[j];
+ }
+ return (acc == 1);
+ }
+
+ /**
+ * @deprecated
+ */
+ public boolean isCategorical() {
+ for (double m : p) {
+ if (m == 1) return true;
+ }
+ return false;
+ }
+
+
+ public boolean isContradictory() {
+ return (p[0] == 1);
+ }
+
+
+ public boolean isDogmatic() {
+ return (p[p.length-1] == 0);
+ }
+
+
+ public boolean isVacuous() {
+ return (p[p.length-1] == 1);
+ }
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/belief/ImpreciseDistribution.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/INecessityFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/INecessityFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/INecessityFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,16 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.possibility;
+
+import uncertainty.measures.IMeasureFunction;
+
+/**
+ * Much to do
+ * @author Sotty
+ *
+ */
+public interface INecessityFunction extends IMeasureFunction {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/INecessityFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/IPossibilityFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/IPossibilityFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/IPossibilityFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,16 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.possibility;
+
+import uncertainty.measures.IMeasureFunction;
+
+/**
+ * Much to do
+ * @author Sotty
+ *
+ */
+public interface IPossibilityFunction extends IMeasureFunction {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/possibility/IPossibilityFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IBayesianMassFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IBayesianMassFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IBayesianMassFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,20 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.probability;
+
+import uncertainty.measures.belief.IMassFunction;
+
+/**
+ * A bayesian mass assignment is a mass measure with
+ * only singletons as focal elements
+ * I.e. it is a probability distribution
+ *
+ * @author Sotty
+ *
+ */
+public interface IBayesianMassFunction
+ extends IMassFunction {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IBayesianMassFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IProbabilityFunction.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IProbabilityFunction.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IProbabilityFunction.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,14 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.measures.probability;
+
+/**
+ * Sounds like an alias
+ * @author Sotty
+ *
+ */
+public interface IProbabilityFunction extends IBayesianMassFunction {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/IProbabilityFunction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/ImpreciseProbability.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/ImpreciseProbability.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/ImpreciseProbability.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,23 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.measures.probability;
+
+import uncertainty.measures.belief.ImpreciseDistribution;
+
+/**
+ * @author Sotty
+ *
+ */
+public class ImpreciseProbability extends ImpreciseDistribution
+ implements IProbabilityFunction {
+
+ protected ImpreciseProbability() { }
+
+ public ImpreciseProbability(double[][] p) {
+ super(p);
+ }
+
+ public boolean isBayesian() { return true; }
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/ImpreciseProbability.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IAssignmentStrategy.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IAssignmentStrategy.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IAssignmentStrategy.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,28 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.measures.probability.conversion;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.measures.probability.IBayesianMassFunction;
+
+/**
+ * Mass function conversion strategy
+ *
+ * Turns a mass assignment into a bayesian one
+ * A mass assignment is a map 2^X --> [0,1] assigning
+ * masses to subsets of X
+ * A bayesian mass assignment assigns masses > 0 to singletons only.
+ *
+ * Thus, masses assigned to sets with |S| > 1 must be
+ * divided between the singleton elements
+ *
+ * @author Sotty
+ *
+ */
+public interface IAssignmentStrategy {
+
+ public IBayesianMassFunction massToBayesianMass(IMassFunction source);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IAssignmentStrategy.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IUncAssignmentStrat.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IUncAssignmentStrat.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IUncAssignmentStrat.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,18 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.measures.probability.conversion;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.measures.probability.IBayesianMassFunction;
+
+/**
+ * @author Sotty
+ *
+ */
+public interface IUncAssignmentStrat extends IAssignmentStrategy {
+
+ public IBayesianMassFunction massToBayesianMass(IMassFunction source, boolean withBounds);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/IUncAssignmentStrat.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauPignisticStrategy.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauPignisticStrategy.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauPignisticStrategy.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,88 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.measures.probability.conversion;
+
+import java.util.Arrays;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.measures.belief.ImpreciseDistribution;
+import uncertainty.measures.probability.IBayesianMassFunction;
+import uncertainty.measures.probability.ImpreciseProbability;
+
+/**
+ *
+ * Mass-to-Probabilistic conversion
+ *
+ * This strategy assumes:
+ * - The universe is discrete and ordered
+ * i.e. foreach 0 <= j,k < N : xj <= xk iff j <= k
+ * - The mass function targets continuous sets {xi,..,xN-1}
+ * for various 0 <= i < N
+ *
+ * Thus, pignization becomes:
+ *
+ * p(xj) = Sum(k <= j) {mj*cj}
+ * cj = 1 / (N-j)
+ *
+ * @author Sotty
+ *
+ */
+public class TauPignisticStrategy implements IUncAssignmentStrat {
+
+
+ public IBayesianMassFunction massToBayesianMass(IMassFunction source) {
+ return massToBayesianMass(source,false);
+ }
+
+
+ public IBayesianMassFunction massToBayesianMass(IMassFunction source, boolean withBounds) {
+ ImpreciseDistribution dist = (ImpreciseDistribution) source;
+ int N = dist.getSize();
+
+ double[][] prob = new double[3][];
+
+ double[] p = new double[N];
+ Arrays.fill(p,0);
+ double[] pL = null;
+ double[] pU = null;
+ if (withBounds) {
+ pL = new double[N];
+ Arrays.fill(pL,0);
+ pU = new double[N];
+ Arrays.fill(pU,0);
+ }
+ double[] temp;
+
+ double[] a = dist.getMassL();
+ double[] b = dist.getMassU();
+
+ for (int k = 0; k < N; k++) {
+ double[] cj = new double[N];
+ for (int j = 0; j < N; j++)
+ cj[j] = (j <= k) ? 1.0/(N-j) : 0;
+
+ for (int j = 0; j <= k; j++) {
+ p[k] += dist.getMass(j)*cj[j];
+ }
+ if (withBounds) {
+ int[] prm = new int[N];
+ for (int j = 0; j < N; j++)
+ prm[j] = (j+k+1 < N) ? j+k+1 : j+k+1-N ;
+
+ temp = dist.maximizeLC(a, b, cj, prm);
+ pU[k] = temp[N];
+ temp = dist.minimizeLC(a, b, cj, prm);
+ pL[k] = temp[N];
+ }
+
+ }
+ prob[1] = p;
+ prob[0] = withBounds ? pL : p;
+ prob[2] = withBounds ? pU : p;
+
+ return new ImpreciseProbability(prob);
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauPignisticStrategy.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauProjectionStrategy.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauProjectionStrategy.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauProjectionStrategy.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,24 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.measures.probability.conversion;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.measures.probability.IBayesianMassFunction;
+
+/**
+ * @author Sotty
+ *
+ */
+public class TauProjectionStrategy implements IAssignmentStrategy {
+
+ /* (non-Javadoc)
+ * @see uncertainty.measures.probability.conversion.IAssignmentStrategy#massToBayesianMass(uncertainty.measures.belief.IMassFunction)
+ */
+ public IBayesianMassFunction massToBayesianMass(IMassFunction source) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/measures/probability/conversion/TauProjectionStrategy.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLOperator.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLOperator.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLOperator.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,56 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.predicates;
+
+import java.util.Observable;
+
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.BRPLOp;
+
+/**
+ * Operator node
+ * In time, these will be undone to be merged with drools
+ *
+ * @author Sotty
+ * @deprecated
+ */
+public class BRPLOperator extends BRPLPredicate
+ implements IUncertainOperator {
+
+
+ protected BRPLOp evaluator;
+
+
+
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * @param args
+ * @param tval
+ */
+ public BRPLOperator(String name, IArg[] args, IUncertainDegree tval) {
+ super(name, args, tval);
+ }
+
+
+
+ public IUncertainDegree eval() {
+ IUncertainDegree[] tvals = new IUncertainDegree[this.getArity()];
+ for (int j = 0; j < this.getArity(); j++)
+ tvals[j] = ((IUncertainPredicate) this.getArg(j)).getDegree();
+ return evaluator.eval(tvals);
+ }
+
+ public IUncertainPredicate getOperand(int j) {
+ return (IUncertainPredicate) this.getArg(j);
+ }
+
+ public void update(Observable o, Object arg) {
+ eval();
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLOperator.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLPredicate.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLPredicate.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLPredicate.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,127 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.predicates;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * Predicate with an Essence as a truth value
+ *
+ * Args should not change in time, but truth values can
+ * Hence, predicates are not observable themselves, but
+ * allow observers to attach (detach) from their truth
+ * values.
+ *
+ * @author Sotty
+ * @deprecated
+ *
+ */
+public class BRPLPredicate
+ //extends Observable
+ implements IUncertainPredicate {
+
+ /**
+ * Name
+ */
+ protected String name;
+
+ /**
+ * Arguments
+ * (arity is args.length)
+ */
+ protected IArg[] args;
+
+ /**
+ * Truth value
+ */
+ protected IUncertainDegree tval;
+
+ /**
+ * Getter
+ * 0 <= j <= arity
+ * @return Args[j] (or null if j is not valid)
+ */
+ public IArg getArg(int j) {
+ if (j < 0 || j >= args.length) return null;
+ return args[j];
+ }
+
+ /**
+ * Getter
+ * @return arity
+ */
+ public int getArity() {
+ return args.length;
+ }
+
+ /**
+ * Getter
+ * @return uncertain truth value
+ */
+ public IUncertainDegree getDegree() {
+ return tval;
+ }
+
+ /**
+ * Getter
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Constructor for pred(Args)<t>
+ * @param name name, e.g. "pred"
+ * @param args args, whatever they are
+ * (input array is assigned, not copied)
+ * @param tval truth value t
+ */
+ public BRPLPredicate(String name, IArg[] args, IUncertainDegree tval) {
+ this.name = name;
+ this.args = args;
+ this.tval = tval;
+ }
+
+ /**
+ * Allows an external Observer to be notified of changes in
+ * the truth value (iff the tval is observable)
+ * @param watcher The observer
+ * @return <code>true</code> iff the truth value is observable
+ * and thus the operation succeeds
+ */
+ public boolean addTvalObserver(Observer watcher) {
+ // Try and cast...
+ Observable obs = (Observable) tval;
+ if (obs != null)
+ obs.addObserver(watcher);
+ return (obs != null);
+ }
+
+ /**
+ * Detaches an external Observer from
+ * the truth value (iff the tval is observable)
+ * @param watcher The observer
+ * @return <code>true</code> iff the truth value is observable
+ * and thus the operation succeeds
+ */
+ public boolean detachTvalObserver(Observer watcher) {
+ Observable obs = (Observable) tval;
+ if (obs != null)
+ obs.deleteObserver(watcher);
+ return (obs != null);
+ }
+
+ /**
+ * Setter
+ * @param deg The new truth value
+ */
+ public void setDegree(IUncertainDegree deg) {
+ this.tval = deg;
+ }
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/BRPLPredicate.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IArg.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IArg.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IArg.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,16 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.predicates;
+
+
+/**
+ * ....
+ * Predicate argument, whatever it will be...
+ *
+ * @author Sotty
+ */
+public interface IArg {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IArg.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainOperator.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainOperator.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainOperator.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,48 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.predicates;
+
+import java.util.Observer;
+
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * Operators are predicates whose args are particular compound terms, predicates
+ * Uncertain Operators should, but need not necessarily, be truth-functional
+ *
+ * Truth functionality: the operator's (uncertain) truth value should be computed only from
+ * the operands' truth values : t(op) = f({t(arg)})
+ *
+ * Actual evaluation is delegated to an instance of a strategy class IUncDegCombiner
+ * Due to truth functionality, glitches may arise
+ * (glitch : spurious output due to unstable, or changing, inputs)
+ * so, evaluation should be called explicitly when inputs are stable
+ * Alternatively, IOps can and should Observe their operands.
+ *
+ * @author Sotty
+ */
+public interface IUncertainOperator
+ extends IUncertainPredicate, Observer {
+
+ /**
+ * Specialized getter, allows typed access to the operands
+ * @param j index
+ * @return Args[j], an uncertain predicate
+ */
+ public IUncertainPredicate getOperand(int j);
+
+ /**
+ * Forces the evaluation of the operand's truth value, which is returned
+ * and becomes available for later reading.
+ *
+ * Evaluation is not automatically triggered by changes in operands' t-vals
+ * to avoid glitches.
+ * @return
+ */
+ public IUncertainDegree eval();
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainOperator.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainPredicate.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainPredicate.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainPredicate.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,48 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.predicates;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * @author Sotty
+ *
+ * Implementing classes extend the concept of predicate
+ * pred(Args) by adding an uncertain truth value: pred(Args)<t>
+ *
+ */
+public interface IUncertainPredicate extends IArg {
+
+ /**
+ * Getter
+ * @return The predicate's Name (e.g. "pred")
+ */
+ public String getName();
+
+ /**
+ * Getter
+ * @return The predicate's "arity" (i.e. |Args|)
+ */
+ public int getArity();
+
+ /**
+ * Getter
+ * @return Args[j]
+ */
+ public IArg getArg(int j);
+
+ /**
+ * Getter
+ * @return The predicate's truth value (i.e. t)
+ */
+ public IUncertainDegree getDegree();
+
+ /**
+ * Setter
+ * @param deg The new predicate's truth value
+ */
+ public void setDegree(IUncertainDegree deg);
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/predicates/IUncertainPredicate.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Degree.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Degree.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Degree.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,98 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+/**
+ * Very basic class.
+ * Wraps the concept of "degree", ranging
+ * from null (zero) to full (one).
+ *
+ * Can be used in modeling vagueness, uncertainty,
+ * probability, belief, percentages, ...
+ * @author Sotty
+ *
+ */
+public class Degree implements IUncertainDegree {
+
+ /**
+ * Actual value, must be 0 <= val <= 1
+ */
+ private double value = 0.0;
+
+ /**
+ * Default constructor
+ * value is set to default
+ */
+ public Degree() {}
+
+ /**
+ * Constructor
+ * @param val initial value
+ */
+ public Degree(double val) {
+ if (val >= 0 && val <= 1)
+ value = val;
+ else val = 0;
+ }
+
+
+ /**
+ * Getter
+ * @return The degree
+ */
+ public double getValue() { return value; }
+
+ /**
+ * Setter.
+ *
+ * @param deg The new degree, which must be in [0,1].
+ */
+ public void setValue(double deg) { if (deg >= 0.0 && deg <= 1.0) value = deg; }
+
+ /**
+ * Viewer
+ * @return The degree as a percentage 0 <= x <= 100
+ */
+ public int getPercentage() { return (int) Math.round(100*value); }
+
+ public String toString() {
+ return getPercentage()+"%";
+ }
+
+ /**
+ * A Degree is a Degree
+ * @return this
+ */
+ public Degree getDegree() {
+ return this;
+ }
+
+
+ /**
+ * Equality is by value, not by identity
+ */
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (! (other instanceof Degree)) return false;
+ Degree o = (Degree) other;
+ return this.value == o.value;
+ }
+
+
+
+ public static Degree fromBoolean(boolean bool) {
+ return bool ? new Degree(1) : new Degree(0);
+ }
+
+ /**
+ * @return true if value >= 0.5
+ */
+ @Override
+ public boolean toBoolean() {
+ return this.value >= 0.5;
+ }
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Degree.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/DegreeInterval.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/DegreeInterval.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/DegreeInterval.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,77 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+import java.util.Set;
+
+/**
+ * @author Sotty
+ *
+ */
+public class DegreeInterval implements IUncertainInterval {
+
+ /**
+ * Lower bound
+ */
+ private Degree inf;
+
+ /**
+ * Upper bound
+ */
+ private Degree sup;
+
+ /**
+ * @return interval lower bound
+ * @see uncertainty.truthvals.IUncertainInterval#getInf()
+ */
+ public Degree getInf() { return inf; }
+
+ /**
+ * @return interval upper bound
+ * @see uncertainty.truthvals.IUncertainInterval#getSup()
+ */
+ public Degree getSup() { return sup; }
+
+ /**
+ * return average degree (inf+sup)/2
+ * @see uncertainty.truthvals.IUncertainDegree#getDegree()
+ */
+ public Degree getDegree() {
+ return new Degree((inf.getValue()+sup.getValue())/2);
+ }
+
+ /**
+ * @return this
+ * @see uncertainty.measures.IDegreeEvalFunction#eval(java.util.Set)
+ */
+ public IUncertainDegree eval(Set<Object> s) {
+ return this;
+ }
+
+ /**
+ * Constructor
+ * @param inf lower bound
+ * @param sup upper bound
+ */
+ public DegreeInterval(double inf, double sup) {
+ this.inf = new Degree(inf);
+ this.sup = new Degree(sup);
+ }
+
+ /**
+ * @return
+ * @deprecated
+ * @TODO There is something better than the average
+ */
+ @Override
+ public boolean toBoolean() {
+ return ((this.sup.getValue() + this.inf.getValue()) >= 1);
+ // return inf >= 0.5;
+ // ...
+ }
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/DegreeInterval.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Essence.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Essence.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Essence.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,2222 @@
+/*
+ * Created on 04/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.media.opengl.GL;
+
+import com.sun.opengl.util.GLUT;
+
+import uncertainty.domains.DiscreteDomain;
+import uncertainty.domains.IDiscDomain;
+import uncertainty.domains.IDomain;
+import uncertainty.measures.belief.ImpreciseDistribution;
+import uncertainty.measures.probability.ImpreciseProbability;
+
+/**
+ * @author Sotty
+ *
+ * Essence is an imprecise Bayesian belief distribution over the
+ * discretized event space [0,1], where an event E means "X is true
+ * to a degree of E".
+ *
+ * Probabilities and their bounds are defined using an imprecise
+ * multinomial distribution (i.e. a Dirichlet distribution
+ * with parameters beta[j]).
+ * B := Sum{beta[j]}
+ * p[j] = beta[j]/B
+ * maximum likelihood distribution
+ * Sum{p[j]} = 1
+ * lambda[j] <= p[j] <= mu[j]
+ * lower and upper bounds for the max lkd (aka DISTRIBUTION BIAS)
+ * mu[j*] + Sum{lambda[j]} - lambda[j*] = 1
+ * intervals are normalized
+ * 1/B is connected to DISTRIBUTION VARIANCE sigma^2 (see comments or external doc)
+ * hence p-[j] = lambda[j] - k*sigma
+ * p+[j] = mu[j] + k*sigma
+ * 1/Bref makes variance drop below a given threshold
+ * B/Bref is a measure of confidence
+ *
+ * Bref = delta*Bdog + (1-delta)*Boss
+ * beta[j] = boss[j] + d[j]*Bdog
+ * Sum{d[j]} = 1
+ * d[j] is PRIOR probability distribution, due to "hidden" or prior observations
+ * delta, is "dogmatism factor", stating how much
+ * observations can shift POSTERIORS beta[j] from PRIORS d[j]
+ * Usually, lambda[j] and mu[j] are determined by Boss and thus may be considered "empiric bounds"
+ *
+ *
+ * TODO: specLevel-dependant getters should be revised
+ */
+public class Essence
+ extends ImpreciseProbability
+ implements IUncertainDistribution {
+
+
+
+ /**
+ * Number of bins the interval [0,1] is divided into
+ * May only be initialized at construction
+ * Default is N = 10;
+ */
+ public static int DEF_N = 10;
+ protected int N = DEF_N;
+ /**
+ * Getter
+ * @return parameter N, number of bins used to cover the interval [0,1]
+ */
+ public int getN() { return N; }
+
+
+
+
+
+ /**
+ * Target # of observations, if achieved maked variance drop under
+ * a certain threshold and thus can be considered null.
+ * Under null variance, modal (max likelihood) probabilities is "certain" (bias apart)
+ *
+ */
+ protected double Btgt;
+ /**
+ * Getter
+ * @return The target # of observations to achieve full confidence
+ */
+ public double getBtgt() { return Btgt; }
+ /**
+ * Estimator of the target # of observations to achieve full confidence
+ * a Dirichlet distribution has maximum global variance when it is uniform (p[j] = 1/N)
+ * S = Sum{sigma[j]^2} = N*(N-1) / (N*N*(Btot+N+1))
+ * Setting S = thold and extracting Btot gives Btot(thold) := Btgt
+ * Default thold sets Btgt around 10^5
+ * @param thold
+ * @param N
+ * @return The target # of observations to drop total variance below the given thold
+ */
+ public static double assessBTgt(double thold, int N) {
+ return N*(N-1)/(thold*N*N) - (N+1);
+ }
+
+ /**
+ * "Dogmatism" or PRIOR CONFIDENCE.
+ * Given a prior d[j] distribution, which is normally 1/N reflecting a state of ignorance,
+ * we initialize beta[j] = 0 + d[j]*delta*Btgt
+ *
+ * Delta must be chosen carefully, since we want a p[j] for which the posterior is 0
+ * (no chance to be observed) to drop below a zero treshold when enough observations are made:
+ * (boss[j] == 0 + d[j]*delta*Btgt) / (Btot) + k*sigma < epsilon
+ *
+ * For large Btot the first term behaves like delta, the second like 1/sqrt(N*B)
+ * Thus, delta should also behave like 1/sqrt(N*Btgt)
+ *
+ * So, 1/(N*N*N) = 10^-3 seems a reasonable choice for its initial value
+ */
+ protected double delta = 1.0/(DEF_N*DEF_N*DEF_N);
+ /**
+ * Getter
+ * @return delta, dogmatism degree
+ */
+ public double getDelta() { return delta; }
+ /**
+ * Utility
+ * Sets delta to its default value 1/N*N*N
+ * To be used in case N != Ndefault
+ */
+ protected void initDelta() { delta = 1/(N*N*N); }
+
+ /**
+ * Current number of observations.
+ * Btot = B*(1-delta) + delta*Btgt
+ */
+ protected double Btot;
+ /**
+ * Getter
+ * @return The current number of observations
+ */
+ public double getBtot() { return Btot; }
+
+ /**
+ * Prior observation count.
+ * Bdog = delta*Bref
+ */
+ protected double Bdog;
+ /**
+ * Getter
+ * @return The number of prior observations delta*Bref
+ */
+ public double getBdog() { return Bdog; }
+
+ /**
+ * Max posterior observation count
+ * Boss = (1-delta)*Bref
+ */
+ protected double Boss;
+ /**
+ * Getter
+ * @return The max number of posterior observations (1-delta)*Bref
+ */
+ public double getBoss() { return Boss; }
+
+ /**
+ * Real number of expected observations
+ * Up to expCard. observations must add up to Boss, so an unitary observation
+ * is scaled by Boss/expCardinality.
+ * If expCard. == +inf,
+ * B(t+1) = B(t) + Boss(B(t)/Boss + W/Boss - W/Boss^2)
+ * ensuring B(+inf) = Boss
+ * W accounts for "multiple" or "heavy" observations
+ *
+ * Remark: when expCard. == +inf, choose W > 1-exp(ln(eps)/n) to have convergence |B-Boss| < eps
+ * in n observations of weight W.
+ */
+ protected double expCardinality = Double.POSITIVE_INFINITY;
+ /**
+ * Getter
+ * @return The expected max number of observations
+ */
+ public double getExpCardinality() { return expCardinality; }
+ /**
+ * Returns the impact factor of W observations on the overall empirical confidence
+ * (Key idea: up to expCardinality observations on set X can be made. They must
+ * add up to Boss in order to grant max. confidence Bref along with Bdog.
+ *
+ * @param W Weight for multiple observations
+ * @return The amount B should be increased by after W observations
+ */
+ protected double getImpact(double W) {
+ if (expCardinality == Double.POSITIVE_INFINITY)
+ return Boss*(B/Boss+W/Boss-(B*W)/Boss);
+ else return W*Boss/expCardinality;
+ }
+ /*
+ * Temporary : a set may be used in many, more general, supersets. A scalar is inadequate
+
+ /*
+ * "Weight" or generalization confidence
+ * E.g. observations on p(X,X) may be used to increase confidence in p(X,Y), but only
+ * to some extent, since |X,Y| > |X,X|.
+ * Hence, full confidence (Btot(X,X) = Bref) will induce confidence belF(X,X)*Boss(X,Y)
+ * in the superset. (More generally, belF(X,X)*(Btot(X,X)/Bref)*Boss(X,Y))
+ * Remark: W observations in (X,X) weight belFract(X,X)*W in (X,Y)
+ *
+ protected double belFract = 1;
+ public double getBelFract() { return belFract; }
+ */
+
+
+ /**
+ * Actual posterior observation count
+ * B = Sum{b[j]}
+ */
+ protected double B;
+ /**
+ * Getter
+ * @return The number of actual posterior observations
+ */
+ public double getB() { return B; }
+
+ /**
+ * The variance sigma^2[j] of an uniform Dirichlet distribution (equal for all components)
+ * (N-1) / (N*N*(Btot+N+1))
+ * Default values have sigma^2[j] around 10^-6 and sigma[j] around 10^-3
+ */
+ protected double maxUnifVar;
+ /**
+ * Updates the value of the max uniform variance for a new Btot
+ */
+ protected void updateMaxUnifVar() { maxUnifVar = (N-1) / (N*N*(getBtot()+N+1)); }
+ /**
+ * Getter
+ * @return the actual value of the max uniform variance
+ */
+ public double getMaxUnifVar() { return maxUnifVar; }
+
+ /**
+ * Upper bound on the sum of of variances sigma[j]^2. Equals N times the max variance
+ * of an uniform distribution, which is equal for all components
+ * Equals N*(N-1) / (N*N*(Btot+N+1))
+ * When Btot >> N >> 1 (as is usually the case) this value can be approximated by 1/Btot
+ * When Btot=Btgt and defaults are used, this becomes (obviously!) about 10^-5
+ */
+ protected double varSumUB;
+ /**
+ * Getter
+ * @return The upper bound on the sum of variances: N*(N-1) / (N*N*(Btot+N+1))
+ */
+ public double getVarSumUB() { return varSumUB; }
+ /**
+ * Updates the value of the sum-of-vars upper bound for a new Btot
+ */
+ protected void updateVarSumUB() { varSumUB = N*(N-1) / (N*N*(getBtot()+N+1)); }
+ /**
+ * Utility *
+ * This is an upper bound on the sum of vars for another distribution with the same B
+ * The ub for a single component is obtained dividing this number by N.
+ * @param B
+ * @return The sum of the variances of an uniform Dirichlet for a given B.
+ */
+ public double computeVarSumUB(double B) { return N*(N-1) / (N*N*(B+N+1)); }
+
+
+
+ public static final double DEF_V_THOLD = 0.00001; //10^-5
+ /**
+ * Sum-of-variances threshold
+ * Its default value sets Btgt around 10000
+ * and thresholds sigma[j] around 0.001
+ */
+ protected double varSumThold = DEF_V_THOLD;
+ public double getVarSumThreshold() { return varSumThold; }
+
+ public static final double DEF_Z_THOLD = 0.01; //10^-2
+ /**
+ * Null threshold. p[j] is considered null if inferior to this value
+ * Must allow Bdog/Btot + k*sigma[j] < ZeroTHold , k around 3
+ * Since both terms behave like 10^-3 as Btot nears Bref, 10^-2 is more than adequate
+ */
+ protected double zeroTHold = DEF_Z_THOLD;
+ /**
+ * Getter
+ * @return The value of the zero-threshold
+ */
+ public double getZeroTHold() { return zeroTHold; }
+ /**
+ * Setter
+ * @param th A new zero threshold. Order of magnitude Should be N^-2
+ */
+ protected void setZeroTHold(double th) { if (th > 0) zeroTHold = th; }
+
+
+ /**
+ * Confidence is inversely proportional to Dirichlet's variance.
+ * Btot is the actual number of observations, whereas Btgt is the number of observations
+ * necessary to make variance drop below an almost-zero threshold.
+ * Hence, Btot/Btgt reasonably measures confidence.
+ * @return confidence factor in the accuracy of the p[j] estimate
+ */
+ public double getConfidenceFactor() { return getBtot() / getBtgt(); }
+
+ /**
+ * Empiric confidence. Computed as the number of observations / max number of observations.
+ * @return B/Boss
+ */
+ public double getEmpiricConfidence() { return getB() / getBoss(); }
+
+
+
+
+ /**
+ * Vector of observation #s
+ * beta[j] = boss[j] + d[j]*delta*Btgt
+ */
+ protected double[] beta;
+ /**
+ * Vector of lower empiric bounds
+ * betaL[j] = boss[j];
+ */
+ protected double[] betaL;
+ /**
+ * Vector of upper empiric bounds
+ * betaU[j] = boss[j] + delta*Btgt;
+ */
+ protected double[] betaU;
+ /**
+ * Vector of prior distribution
+ */
+ protected double[] d;
+ /*
+ * Vector of posterior distribution
+ * p[j] = beta[j] / Btot
+ * Inherited structure
+ */
+ //protected double[] p = new double[N];
+
+ /**
+ * Vector of by-component variances
+ * p[j] = beta[j] / Btot
+ */
+ protected double[] v;
+
+ /*
+ * Vector of upper distribution bounds
+ */
+ //protected double[] diricU = new double[N];
+ /*
+ * Vector of lower distribution bounds
+ */
+ //protected double[] diricL = new double[N];
+
+
+ /**
+ * Getter
+ * @param j index
+ * @return beta[j] = boss[j] + d[j]*delta*Btgt
+ * @throws IndexOutOfBoundsException
+ */
+ public double getBeta(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return beta[j];
+ }
+ /**
+ * Getter
+ * @param j index
+ * @return betaL[j] = boss[j]
+ * @throws IndexOutOfBoundsException
+ */
+ public double getBetaL(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return betaL[j];
+ }
+ /**
+ * Getter
+ * @param j index
+ * @return betaU[j] = boss[j] + delta*Btgt
+ * @throws IndexOutOfBoundsException
+ */
+ public double getBetaU(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return betaU[j];
+ }
+
+ /**
+ * Getter
+ * @return Upper bound vector (non-scaled)
+ */
+ protected double[] getUppBoundVec() {
+ double[] ans = new double[getN()];
+ for (int j = 0; j < getN(); j++)
+ ans[j] = betaU[j] / getBtot();
+
+ return ans;
+ }
+
+ /**
+ * Getter
+ * @return Lower bound vector (non-scaled)
+ */
+ protected double[] getLowBoundVec() {
+ double[] ans = new double[getN()];
+ for (int j = 0; j < getN(); j++)
+ ans[j] = betaL[j] / getBtot();
+
+ return ans;
+ }
+
+ /**
+ * Max likelihood posterior probabilities
+ * @param j index
+ * @return p[j] = beta[j] / Btot
+ * @throws IndexOutOfBoundsException
+ */
+ public double getP(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return p[j];
+ }
+
+ /**
+ * Average posterior probabilities
+ * @param j index
+ * @return avg[j] = (beta[j]+1) / (Btot+N)
+ * @throws IndexOutOfBoundsException
+ */
+ public double getAvgP(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return (beta[j]+1)/(getBtot()+N);
+ }
+
+ /**
+ * prior probabilities ("dogmatic")
+ * @param j index
+ * @return d[j]
+ * @throws IndexOutOfBoundsException
+ */
+ public double getD(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return d[j];
+ }
+
+ /**
+ * Variances
+ * @param j index
+ * @return var[j] = (beta[j]+1) * (Btot+N - (beta[j]+1)) / ((Btot+N)*(Btot+N)*(Btot+N+1));
+ * @throws IndexOutOfBoundsException
+ */
+ public double getVar(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return v[j];
+ }
+
+ /**
+ * Empiric lower bound
+ * @param j index
+ * @return lambda[j] = betaL[j] / Btot
+ * @throws IndexOutOfBoundsException
+ */
+ public double getLambda(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return betaL[j] / getBtot();
+ }
+
+ /**
+ * Empiric upper bound
+ * @param j index
+ * @return mu[j] = betaU[j] / Btot
+ * @throws IndexOutOfBoundsException
+ */
+ public double getMu(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return betaU[j] / getBtot();
+ }
+
+ /**
+ * Confidence upper bound
+ * @param j index
+ * @return min(mu[j] + 3*sqrt(var[j]),1)
+ * @throws IndexOutOfBoundsException
+ */
+ public double getUB(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return Math.min(getMu(j)+3*Math.sqrt(getVar(j)),1);
+ }
+
+ /**
+ * Confidence lower bound
+ * @param j index
+ * @return max(lambda[j] - 3*sqrt(var[j]),0)
+ * @throws IndexOutOfBoundsException
+ */
+ public double getLB(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return Math.max(getLambda(j)-3*Math.sqrt(getVar(j)),0);
+ }
+
+ /**
+ * Dirichlet lower bound
+ * @param j index
+ * @return the lower bound computed on the dirichlet
+ * @throws IndexOutOfBoundsException
+ */
+ public double getDiricLB(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return pL[j];
+ }
+
+ /**
+ * Dirichlet upper bound
+ * @param j index
+ * @return the lower bound computed on the dirichlet
+ * @throws IndexOutOfBoundsException
+ */
+ public double getDiricUB(int j) throws IndexOutOfBoundsException {
+ if (j < 0 || j >= N) throw new IndexOutOfBoundsException("Invalid bin!");
+ return pU[j];
+ }
+
+ /**
+ * Essence lower bound. Points to the first index such that ALL previous slots are almost zero
+ * tau = max{j | p[k] < zeroThold forall k < j}
+ */
+ protected int tau = 0;
+ /**
+ * Getter
+ * @return Lower bound index
+ */
+ public int getTauIdx() { return tau; }
+ /**
+ * Getter
+ * @return tau, truth degree lower bound (slot index)
+ */
+ public Degree getTau() { return new Degree(tau); }
+ /**
+ * @return the truth degree lower bound
+ */
+ public Degree getInf() { return new Degree(1.0*tau / N); }
+
+ /**
+ * Essence upper bound. Points to the first index such that ALL following slots are almost zero
+ * tau = min{j | p[k] < zeroThold forall k > j}
+ */
+ protected int fi = 0;
+ /**
+ * Getter
+ * @return Upper bound index
+ */
+ public int getFiIdx() { return fi; }
+ /**
+ * Getter
+ * @return tau, truth degree upper bound (slot index)
+ */
+ public Degree getFi() { return new Degree(fi); }
+ /**
+ * @return the truth degree upper bound
+ */
+ public Degree getSup() { return new Degree(1.0*fi / N); }
+
+ /**
+ * Parameter: certainty
+ * An essence is certain if tau = fi, i.e. (almost) all observations fall into exactly one slot.
+ * Notice that certainty and confidence are very different concepts
+ * @return (fi-tau) / N-1
+ */
+ public double getCertainty() { return 1.0*(tau+N-fi) / (N-1); }
+
+
+
+
+ /**
+ * Entropy of the max lkhd probabilities
+ * H(p) = Sum{p[j]*ln(1/p[j])}
+ */
+ protected double entropy;
+ /**
+ * Getter
+ * The max lkhd entropy = Sum{p[j]*ln(1/p[j])} is max for p[j] = 1/N and equals ln(N)
+ * @return entropy/ln(N)
+ */
+ public Double getRelativeEntropy() { return getBtot() == 0 ? 1 : entropy/Math.log(N); }
+
+
+ /**
+ * Dirichlet distribution
+ * Given params beta[j], the Dirichlet distribution estimates the posterior likelihood
+ * a probability distribution q[j] supposed to have generated the observations beta[j].
+ * lk(beta,q) = K * Prod{q[j]^beta[j]}
+ * K = Gamma(Btot+N)/Prod{beta[j]+1}
+ *
+ * ln(lk) = lnG(Btot+N) - Sum{lnG(beta[j]+1)} + Sum{beta[j]*q[j]}
+ * Hence define:
+ * A := lnG(Btot+N) - Sum{lnG(beta[j]+1)}
+ * Aj:= lnG(beta[j]+1)
+ */
+ protected double A;
+ /**
+ * Dirichlet distribution
+ * Given params beta[j], the Dirichlet distribution estimates the posterior likelihood
+ * a probability distribution q[j] supposed to have generated the observations beta[j].
+ * D(beta,q) = K * Prod{q[j]^beta[j]}
+ * K = Gamma(Btot+N)/Prod{beta[j]+1}
+ *
+ * ln(lk) = lnG(Btot+N) - Sum{lnG(beta[j]+1)} + Sum{beta[j]*ln(q[j])}
+ * Hence define:
+ * A := lnG(Btot+N)
+ * Aj:= lnG(beta[j]+1)
+ */
+ protected double[] Aj;
+ /**
+ * Global Entropy of a Dirichlet distribution
+ * H(D) = (lnG(Btot+N) - Sum{lnG(beta[j]+1)}) + Sum{beta[j]*(diG(beta[j]+1)-diG(B+N))}
+ * The first term is "A", while diG() is the digamma function
+ */
+ protected double diricEntropy;
+
+ /**
+ * Evaluate the Dirichlet function at its peak p[j]
+ * @return Dirichlet function for p[j]
+ */
+ public double evalLkhd() {
+ double lk = A;
+ for (int j = 0; j < N; j++) {
+ if (beta[j] > 0)
+ lk += beta[j]*Math.log(p[j]);
+ }
+ return Math.exp(lk);
+ }
+ /**
+ * Evaluate the Dirichlet function for a given prob. distribution q[j]
+ * @param q Test distribution
+ * @return Dirichlet function for q[j], -1 if q.lenght != N
+ */
+ public double evalLkhd(double[] q) {
+ if (q.length != N) return -1;
+ double lk = A;
+ for (int j = 0; j < N; j++) {
+ if (beta[j] > 0)
+ lk += beta[j]*Math.log(q[j]);
+ }
+ return Math.exp(lk);
+ }
+
+
+
+ /**
+ * Factory method
+ * @param level
+ * @return The full-confident true Essence
+ */
+ public static Essence True(int level) {
+ return Essence.spike(DEF_N-1,level);
+ }
+
+ public static Essence True(int N, int level) {
+ return Essence.spike(N-1,N,level);
+ }
+
+ public static Essence Unknown(int N, int level) {
+ return new Essence(N,level);
+ }
+
+
+ /**
+ * Factory method
+ * @param k The specified truth degree
+ * @param level
+ * @return An Essence with full confidence in a given truth degree
+ */
+ public static Essence spike(int k, int level) {
+// if (k >= Essence.DEF_N) k = Essence.DEF_N-1;
+// double pWgt = 1.0;
+// double[] prior = new double[Essence.DEF_N];
+// double[] obser = new double[Essence.DEF_N];
+// double card = Essence.assessBTgt(Essence.DEF_V_THOLD, Essence.DEF_N);
+// prior[k] = 1.0;
+// return new Essence(pWgt,prior,obser,card,level);
+ return Essence.spike(k, Essence.DEF_N, level);
+ }
+
+
+
+ public static Essence spike(int k, int N, int level) {
+ if (k >= N || k < 0) k = N-1;
+ double pWgt = 1.0;
+ double[] prior = new double[N];
+ double[] obser = new double[N];
+ double card = Essence.assessBTgt(Essence.DEF_V_THOLD, N);
+ prior[k] = 1.0;
+ return new Essence(pWgt,prior,obser,card,level);
+ }
+
+
+ /**
+ * Void constructor
+ * @return a non-initialized structure
+ */
+ protected Essence() {}
+
+ /**
+ * Default constructor
+ * Minimal initialization of a minimal-confidence uniform distribution *
+ * @param level Specification level
+ */
+ public Essence(int level) {
+ this(DEF_N,level);
+ }
+
+ public Essence(int N, int level) {
+ this.N = N;
+ specLevel = level;
+ expCardinality = Double.POSITIVE_INFINITY;
+ beta = new double[N];
+ betaL = new double[N];
+ betaU = new double[N];
+ p = new double[N];
+ //pU = new double[N];
+ //pL = new double[N];
+ d = new double[N];
+ p = new double[N];
+ if (level >= Essence.L20_BOUNDS) {
+ this.v = new double[N];
+ }
+ if (level >= Essence.L99_DIRIC_BOUNDS) {
+ this.Aj = new double[N];
+ this.pU = new double[N];
+ this.pL = new double[N];
+ }
+ Btgt = assessBTgt(getVarSumThreshold(), getN());
+ Bdog = getDelta()*getBtgt();
+ Boss = getBtgt()-getBdog();
+
+ for (int j = 0; j < getN(); j++)
+ d[j] = 1.0/N;
+
+ B = 0;
+ for (int j = 0; j < getN(); j++) {
+ beta[j] = d[j]*Bdog;
+ betaL[j] = d[j]*Bdog; //0
+ betaU[j] = d[j]*Bdog; //Bdog
+ }
+ Btot = Bdog;
+
+ updateInnerStructs(level);
+ }
+
+
+ /**
+ * General default constructor
+ * Does not check d and obs
+ *
+ *
+ */
+ public Essence(double priorWgt, double[] prior, double obs[], double expCard, int level) {
+
+ specLevel = level;
+ delta = priorWgt;
+ expCardinality = expCard;
+
+ N = obs.length;
+ this.beta = new double[N];
+ this.betaL = new double[N];
+ this.betaU = new double[N];
+ this.d = new double[N];
+ this.p = new double[N];
+
+ if (level >= Essence.L20_BOUNDS) {
+ this.v = new double[N];
+// this.pU = new double[N];
+// this.pL = new double[N];
+ }
+
+ if (level >= Essence.L40_DIRICHLET) {
+ this.Aj = new double[N];
+ }
+
+ if (level >= Essence.L99_DIRIC_BOUNDS) {
+ this.pU = new double[N];
+ this.pL = new double[N];
+ }
+
+
+ Btgt = assessBTgt(getVarSumThreshold(), getN());
+ Bdog = getDelta()*getBtgt();
+ Boss = getBtgt()-getBdog();
+
+ for (int j = 0; j < getN(); j++)
+ d[j] = prior[j];
+
+ B = 0;
+ for (int j = 0; j < getN(); j++) {
+ double x = (1-getDelta())*obs[j];
+ B+= x;
+ beta[j] = x + d[j]*getBdog();
+ betaL[j] = x;
+ betaU[j] = x + getBdog();
+ }
+ Btot = B + getBdog();
+
+ updateInnerStructs(level);
+ }
+
+ /**
+ * Operator constructor
+ * Essence is built from the combination of different essences
+ *
+ * Usecase: intersection
+ *
+ * operator combination !!!!!
+ *
+ * modus ponens
+ *
+ * Specification
+ * N essences have been fitted to the same N
+ * specLevel = min{lev_j} the simpler dictates
+ * delta = 0, no priors in combinations
+ *
+ * Btgt = Prod{Btgt_j} product confidence
+ * Bdog = 0 see above
+ * Boss = Btgt see above
+ * B = Prod{B_j} product confidence
+ * Btot = B see above
+ * expCard = Prod{Card_j}
+ *
+ * d = {0} no priors
+ *
+ * beta = product combination
+ * betaL,U = imprecise bound combination
+ *
+ * @param mass
+ * @param map
+ */
+ public Essence(Essence[] mass, Set<List<Integer>>[] map) {
+ int minLevel = Essence.L200_DOMAIN;
+ for (Essence e : mass) {
+ if (e.getSpecLevel() < minLevel)
+ minLevel = e.getSpecLevel();
+ }
+
+ specLevel = minLevel;
+ delta = 0;
+ N = mass[0].getN();
+ //System.out.println("Building "+mass.length+" masses of size"+N);
+
+ Btgt = mass[0].getBtgt();
+ B = Btgt;
+ expCardinality = 1;
+ for (int j = 0; j < mass.length; j++) {
+ B *= mass[j].getConfidenceFactor();
+ expCardinality *= mass[j].getExpCardinality();
+ }
+
+ Bdog = 0;
+ Boss = Btgt;
+ Btot = B;
+
+
+ this.d = new double[N];
+ Arrays.fill(d,0);
+
+ this.beta = new double[N];
+ this.betaL = new double[N];
+ this.betaU = new double[N];
+ this.p = new double[N];
+
+
+
+ if (specLevel >= Essence.L20_BOUNDS) {
+ this.v = new double[N];
+ }
+
+ if (specLevel >= Essence.L99_DIRIC_BOUNDS) {
+ this.pU = new double[N];
+ this.pL = new double[N];
+ }
+
+ if (specLevel >= Essence.L40_DIRICHLET) {
+ this.Aj = new double[N];
+ }
+
+ this.beta = super.combine(mass, map,this.getN());
+ for (int j = 0; j < getN(); j++)
+ beta[j] *= B;
+
+ if (specLevel >= Essence.L20_BOUNDS) {
+ double[][] bounds = super.combineBounds(mass, map, getN());
+ betaL = bounds[0];
+ betaU = bounds[1];
+ for (int j = 0; j < getN(); j++) {
+ betaL[j] *= B;
+ betaU[j] *= B;
+ }
+
+ } else {
+ betaL = Arrays.copyOf(beta,beta.length);
+ betaU = Arrays.copyOf(beta,beta.length);
+ }
+
+ updateInnerStructs(specLevel);
+
+ }
+
+
+
+
+
+
+ /**
+ * Constructor, from Interval.
+ * Allocates the default mass to the [start, end] truth interval, uniformly.
+ * @param start
+ * @param end
+ */
+ public Essence(double start, double end, int level) {
+ this(start,end,Essence.DEF_N,level);
+ }
+
+ public Essence(double start, double end, int N, int level) {
+ this.N = N;
+ specLevel = level;
+ expCardinality = Double.POSITIVE_INFINITY;
+ beta = new double[N];
+ betaL = new double[N];
+ betaU = new double[N];
+ p = new double[N];
+ //pU = new double[N];
+ //pL = new double[N];
+ d = new double[N];
+ p = new double[N];
+ if (level >= Essence.L20_BOUNDS) {
+ this.v = new double[N];
+ }
+ if (level >= Essence.L99_DIRIC_BOUNDS) {
+ this.Aj = new double[N];
+ this.pU = new double[N];
+ this.pL = new double[N];
+ }
+ Btgt = assessBTgt(getVarSumThreshold(), getN());
+ //Bdog = getDelta()*getBtgt();
+ Bdog = getBtgt();
+ //Boss = getBtgt()-getBdog();
+ Boss = 0;
+
+
+
+ int startIx = (int) Math.floor(N*start);
+ if (startIx >= N)
+ startIx = N-1;
+ int endIx = (int) Math.floor(N*end);
+ if (endIx >= N)
+ endIx = N-1;
+
+
+ for (int j = startIx; j <= endIx; j++)
+ d[j] = 1.0/(endIx-startIx+1);
+
+ B = 0;
+ for (int j = 0; j < getN(); j++) {
+ beta[j] = d[j]*Bdog;
+ betaL[j] = d[j]*Bdog; //0
+ betaU[j] = d[j]*Bdog; //Bdog
+ }
+ Btot = Bdog;
+
+ updateInnerStructs(level);
+ }
+
+
+ /**
+ * Specializes a generic ImpreciseDistribution
+ * @param dist
+ */
+ public Essence(ImpreciseDistribution dist, double conf, int level) {
+ specLevel = level;
+ delta = 0;
+ N = dist.getSize();
+
+ Btgt = assessBTgt(DEF_V_THOLD, N);
+ B = Btgt*conf;
+ expCardinality = Double.POSITIVE_INFINITY;
+
+ Bdog = 0;
+ Boss = Btgt;
+ Btot = B;
+
+ this.d = new double[N];
+ Arrays.fill(d,0);
+
+ this.beta = new double[N];
+ this.betaL = new double[N];
+ this.betaU = new double[N];
+ this.p = new double[N];
+
+ if (specLevel >= Essence.L20_BOUNDS) {
+ this.v = new double[N];
+ }
+
+ if (specLevel >= Essence.L40_DIRICHLET) {
+ this.Aj = new double[N];
+ }
+
+ if (level >= Essence.L99_DIRIC_BOUNDS) {
+ this.pU = new double[N];
+ this.pL = new double[N];
+ }
+
+ for (int j = 0; j < getN(); j++)
+ beta[j] = B*dist.getMass(j);
+
+ if (specLevel >= Essence.L20_BOUNDS) {
+ for (int j = 0; j < getN(); j++) {
+ betaL[j] = B*dist.getMassL(j);
+ betaU[j] = B*dist.getMassU(j);
+ }
+ } else {
+ betaL = Arrays.copyOf(beta,beta.length);
+ betaU = Arrays.copyOf(beta,beta.length);
+ }
+
+ updateInnerStructs(specLevel);
+ //System.out.println();
+ }
+ /**
+ * Cloning method
+ * Deep array copy, can't share arrays !
+ */
+ public Object clone() {
+ Essence ans = new Essence();
+ ans.N = N;
+
+ ans.A = this.A;
+
+ if (this.Aj != null) {
+ ans.Aj = new double[N];
+ for (int j = 0; j < N; j++)
+ ans.Aj[j] = Aj[j];
+ }
+
+ ans.B = B;
+ ans.Bdog = Bdog;
+ ans.Boss = Boss;
+ ans.Btgt = Btgt;
+ ans.Btot = Btot;
+ ans.delta = delta;
+ ans.diricEntropy = diricEntropy;
+ ans.entropy = entropy;
+ ans.expCardinality = expCardinality;
+ ans.fi = fi;
+ ans.maxUnifVar = maxUnifVar;
+ ans.specLevel = specLevel;
+ ans.tau = tau;
+ ans.varSumThold = varSumThold;
+ ans.varSumUB = varSumUB;
+ ans.zeroTHold = zeroTHold;
+
+ ans.beta = new double[N];
+ ans.betaL = new double[N];
+ ans.betaU = new double[N];
+ ans.d = new double[N];
+ ans.p = new double[N];
+ for (int j = 0; j < N; j++) {
+ ans.p[j] = p[j];
+ ans.beta[j] = beta[j];
+ ans.betaL[j] = betaL[j];
+ ans.betaU[j] = betaU[j];
+ ans.d[j] = d[j];
+ }
+ if (v != null) {
+ ans.v = new double[N];
+ for (int j = 0; j < N; j++)
+ ans.v[j] = v[j];
+ }
+ if (pL != null) {
+ ans.pL = new double[N];
+ ans.pU = new double[N];
+ for (int j = 0; j < N; j++) {
+ ans.pL[j] = pL[j];
+ ans.pU[j] = pU[j];
+ }
+ }
+
+ return ans;
+ }
+
+ /**
+ * Creates a copy of this Essence with reversed inner
+ * structures.
+ * Used in negation and more
+ * @return
+ */
+ public Essence reverse() {
+ Essence ans = new Essence();
+ ans.N = N;
+ int N1 = N-1;
+ ans.A = this.A;
+
+ if (this.Aj != null) {
+ ans.Aj = new double[N];
+ for (int j = 0; j < N; j++)
+ ans.Aj[j] = Aj[N1-j];
+ }
+
+ ans.B = B;
+ ans.Bdog = Bdog;
+ ans.Boss = Boss;
+ ans.Btgt = Btgt;
+ ans.Btot = Btot;
+ ans.delta = delta;
+ ans.diricEntropy = diricEntropy;
+ ans.entropy = entropy;
+ ans.expCardinality = expCardinality;
+ ans.fi = N-tau;
+ ans.maxUnifVar = maxUnifVar;
+ ans.specLevel = specLevel;
+ ans.tau = N-fi;
+ ans.varSumThold = varSumThold;
+ ans.varSumUB = varSumUB;
+ ans.zeroTHold = zeroTHold;
+
+ ans.beta = new double[N];
+ ans.betaL = new double[N];
+ ans.betaU = new double[N];
+ ans.d = new double[N];
+ ans.p = new double[N];
+ for (int j = 0; j < N; j++) {
+ ans.p[j] = p[N1-j];
+ ans.beta[j] = beta[N1-j];
+ ans.betaL[j] = betaL[N1-j];
+ ans.betaU[j] = betaU[N1-j];
+ ans.d[j] = d[N1-j];
+ }
+ if (v != null) {
+ ans.v = new double[N];
+ for (int j = 0; j < N; j++)
+ ans.v[j] = v[N1-j];
+ }
+ if (pL != null) {
+ ans.pL = new double[N];
+ ans.pU = new double[N];
+ for (int j = 0; j < N; j++) {
+ ans.pL[j] = pL[N1-j];
+ ans.pU[j] = pU[N1-j];
+ }
+ }
+
+ return ans;
+ }
+
+ /**
+ * Converts an N-slotted essence into a newN-slotted distribution
+ *
+ * @param newN
+ * @return
+ */
+ public Essence fitCopy(int newN) {
+
+// System.out.println("Fit ");
+// for (int j = 0; j < getN(); j++) System.out.print(getP(j)+" ");
+// System.out.println();
+
+ double[] pr = new double[newN];
+ double[] pt = new double[newN];
+ Arrays.fill(pr,0);
+ Arrays.fill(pt,0);
+
+ if (this.getN() == newN) return this;
+ else if (this.getN() < newN) {
+ //enlarge!
+ int j = 0; //0..N-1
+ int k = 0; //0..M-1
+ double frac = 1.0*getN()/newN;
+ double jd = 1.0;
+ double kd = 1.0/frac;
+
+ while (k < newN) {
+ if (kd >= 1) {
+ kd -= 1.0;
+ pt[k] += this.beta[j]*frac;
+ pr[k] += this.d[j]*frac;
+ k++;
+ } else {
+ pt[k] += this.beta[j]*kd*frac;
+ pr[k] += this.d[j]*kd*frac;
+ j++;
+
+ jd = 1.0 - kd;
+
+ pt[k] += this.beta[j]*jd*frac;
+ pr[k] += this.d[j]*jd*frac;
+
+ k++;
+ kd = (1.0/frac)-jd;
+ }
+ }
+
+
+
+
+ } else {
+ //shrink!
+ int j = 0; //0..N-1
+ int k = 0; //0..M-1
+ double inc = 1.0*getN()/newN;
+ double jd = 1.0;
+ double kd = inc;
+
+ while (j < N) {
+ if (kd >= 1.0) {
+ kd -= 1.0;
+ pt[k] += this.beta[j];
+ pr[k] += this.d[j];
+ j++;
+ } else {
+ pt[k] += this.beta[j]*kd;
+ pr[k] += this.d[j]*kd;
+ k++;
+ jd = 1.0 - kd;
+ pt[k] += this.beta[j]*jd;
+ pr[k] += this.d[j]*jd;
+ j++;
+ kd = inc-jd;
+ }
+ }
+ }
+
+ Essence ans = new Essence(this.getDelta(),pr,pt,this.getExpCardinality(),this.getSpecLevel());
+
+// for (int j = 0; j < ans.getN(); j++) System.out.print(ans.getP(j)+" ");
+// System.out.println();
+
+ return ans;
+ }
+
+
+
+
+ /**
+ * Adds a new observation of weight W. Computes its impact over the empiric and overall confidences
+ * and updates beta, betaL and betaU accordingly.
+ * Update
+ * @param j Index of the bin the new obs falls in
+ * @param W Weight of (usually 1, or equal to the # of observations falling in the bin)
+ * If +inf observations can be made, choose W > 1-exp(ln(eps)/n)
+ * to make confidence converge below eps in n steps.
+ * @param update If false, inner structures are not updated (useful when making updates in serie
+ * before actually using the results)
+ * @param level @see updateInnerStructs
+ */
+ public void updatePreciseObs(int j, double W, boolean update, int level) {
+ double b = getImpact(W);
+
+ beta[j] += b;
+ betaL[j] += b;
+ betaU[j] += b;
+ B += b;
+ Btot += b;
+
+ if (update) updateInnerStructs(level);
+ }
+
+
+
+ /**
+ * Adds a new imprecise observation of weight W. The data falls within one of the bins whose index
+ * is contained in set J, but exactly which one is not.
+ * Conceptually similar to updatePreciseObs, but empiric updates are as following:
+ * beta[J] += b*1/|J| (pignistic distribution among the bins in J)
+ * betaL[J] += |J| == 1 ? b : 0 (worst case: chosen a bin in J, the data is elsewhere)
+ * betaU[J] += b (worst case: chose a bin in J, the whole data falls therein)
+ * Notice that when |J| = 1 updatePreciseObs() may be used
+ * @param J Set of bin indexes
+ * @param W Observation weight
+ * @param update Set to True to update inner structures
+ * @param level @see updateInnerStructs
+ */
+ public void updateObs(Set<Integer> J, double W, boolean update, int level) {
+ if (J.size() == 0) return;
+ if (J.size() == 1) { updatePreciseObs(J.iterator().next(),W,update,level); return; }
+
+ double b = getImpact(W);
+ Iterator<Integer> jit = J.iterator();
+
+ while (jit.hasNext()) {
+ int j = jit.next();
+ //betaL[j] += 0;
+ beta[j] += b/J.size();
+ betaU[j] += b;
+ }
+ B += b;
+ Btot += b;
+
+ if (update) updateInnerStructs(level);
+ }
+
+ /**
+ * Use: max lkhd probabilities, tau, fi
+ */
+ public static final int L0_BASIC = 0;
+ /**
+ * Use: variances, entropy
+ */
+ public static final int L20_BOUNDS = 20;
+ /**
+ * Use: varSumUB, maxUnifVar
+ */
+ public static final int L30_GLOBAL_BOUNDS = 30;
+ /**
+ * Use: Dirichlet distribution
+ */
+ public static final int L40_DIRICHLET = 40;
+ /**
+ * Use: diricL, diricU, diricEntropy
+ */
+ public static final int L99_DIRIC_BOUNDS = 99;
+
+ /**
+ * Use: domain specification
+ */
+ public static final int L200_DOMAIN = 200;
+
+ /**
+ * Specification level
+ * The higher, the more information on the distribution has been computed
+ */
+ protected int specLevel = L0_BASIC;
+
+ /**
+ * Getter
+ * @return The current specification level
+ */
+ public int getSpecLevel() { return specLevel; }
+
+ /**
+ * After updating observation vector B, all parameters must be updated
+ * Normalization is ensured.
+ *
+ * Since some of them may be unnecessary (esp. if compared to the computational cost) a "level" L
+ * is assigned to each param according to the following table:
+ * A param p is actually computed iff level >= L(p)
+ */
+ protected void updateInnerStructs(int level) {
+ setNormal();
+ specLevel = level;
+
+ //System.out.println("Init level 0 ");
+ if (level >= L0_BASIC) {
+ for (int j = 0; j < getN(); j++)
+ p[j] = beta[j] / getBtot();
+
+ tau = 0;
+ while (tau < N && p[tau] < getZeroTHold()) tau++;
+ if (tau >= N) tau = 0;
+ fi = N;
+ while (fi > 0 && p[fi-1] < getZeroTHold()) fi--;
+ if (fi <= 0) fi = N;
+ }
+ //System.out.println("Done level 0");
+
+ //System.out.println("Init level 20");
+ if (level >= L20_BOUNDS) {
+ entropy = 0;
+ double Bx = Btot+N;
+ double Bden = 1.0/(Bx*Bx*(Bx+1));
+ for (int j = 0; j < getN(); j++) {
+ entropy += (p[j] <= zeroTHold) ? 0 : -p[j]*Math.log(p[j]);
+ v[j] = (beta[j]+1) * (Bx - (beta[j]+1)) * Bden;
+ }
+ }
+ //System.out.println("Done level 20");
+
+ //System.out.println("Init level 30");
+ if (level >= L30_GLOBAL_BOUNDS) {
+ updateMaxUnifVar();
+ updateVarSumUB();
+ }
+ //System.out.println("Done level 3");
+
+ if (level >= L40_DIRICHLET) {
+ A = lnGamma(Btot+N);
+ for (int j = 0; j < N; j++) {
+ Aj[j] = (beta[j] == 0) ? 0 : lnGamma(beta[j]+1);
+ A -= Aj[j];
+ }
+ }
+ //System.out.println("Done level 40");
+
+ //System.out.println("Init level 99");
+ if (level >= L99_DIRIC_BOUNDS) {
+ double STEP = 0.001;
+ /*
+ * Start at empiric lambda[j] (resp. mu[j]) and choose each j=j*
+ * Consider the binomial with parms {beta[j*],Btot-beta[j*]}
+ * Increase or decrease p[j] by successive steps and eval the binomial until log-likelihood(p) < log(thold)
+ */
+ double Bp0 = lnGamma(Btot+N);
+ double th = Math.log(getZeroTHold());
+ for (int j = 0; j < N; j++) {
+
+ double s = getMu(j);
+ double lk;
+ double Bp = Bp0 - (beta[j] == 0 ? 0 : lnGamma(beta[j]+1)) - lnGamma(Btot + N - beta[j] - 1);
+ do {
+ s += STEP;
+ lk = Bp + beta[j]*Math.log(s) + (Btot - beta[j])*Math.log(1-s);
+ } while (lk > th && s < 1);
+ pU[j] = Math.min(s,1);
+
+ s = getLambda(j);
+ do {
+ s -= STEP;
+ lk = Bp + beta[j]*Math.log(s) + (Btot - beta[j])*Math.log(1-s);
+ } while (lk > th && s > 0);
+ pL[j] = Math.max(s,0);
+ }
+
+
+ this.diricEntropy = A;
+ double dig0 = diGamma(A+N);
+ for (int j = 0; j < N; j++) {
+ diricEntropy += (beta[j] == 0) ? 0 : beta[j]*(diGamma(beta[j]+1)-dig0);
+ }
+ }
+ //System.out.println("Done level 99");
+
+ if (level >= L200_DOMAIN) {
+ IDiscDomain<Degree> d = new DiscreteDomain<Degree>();
+ for (int j = 0; j < N; j++)
+ d.add(new Degree(1.0*j/N));
+ this.universe = d;
+ }
+ }
+
+
+ @Override
+ /**
+ * Set s must contain a singleton object o
+ * Object o must be a Degree itself
+ * return [getLB(),getUB()]
+ */
+ public IUncertainInterval getMetaDegreeBounds(Set<Object> s) {
+ if (s.size() != 1) return null;
+ Object o = s.iterator().next();
+ Degree deg = (Degree) o;
+ if (o == null) return new DegreeInterval(0,0);
+ int j = (int) Math.floor(deg.getValue()*N);
+ return new DegreeInterval(getLB(j),getUB(j));
+ }
+
+
+ @Override
+ /**
+ * Betas are normalized by construction.
+ * Hence, no further action is required
+ */
+ public void normalize() {
+ setNormal();
+ }
+
+
+ /**
+ * Returns max likelihood p(epsilon = deg).
+ * Selects p[j*], with j* being the bin deg falls into
+ */
+ public IUncertainDegree getMetaDegree(Degree deg) {
+ int j;
+ if (deg.getValue() == 1) j = N-1;
+ else j = (int) Math.floor(deg.getValue());
+ return new Degree(p[j]);
+ }
+
+ /**
+ * Property
+ * @return The most likely degree (ties broken by choosing lower)
+ */
+ public Degree getDegree() {
+ double pmax = p[0];
+ int jmax = 0;
+ for (int j = 1; j < N; j++)
+ if (p[j] > pmax) jmax = j;
+ return new Degree(1.0*jmax/N);
+ }
+
+ /**
+ * Property
+ * @return degree lower bound tau
+ */
+ public Degree getSafeDegree() {
+ return getTau();
+ }
+
+ /**
+ * Property
+ * @return The expected (in a probabilistic sense) truth degree,
+ * according to the mass assignment.
+ */
+ public Degree getAverageDegree() {
+ double ans = 0;
+ for (int j = 0; j < N; j++) {
+ ans += (1.0/N)*(j)*p[j];
+ }
+ return new Degree(ans);
+ }
+
+
+ /**
+ * Property
+ * @return The expected (in a probabilistic sense) truth degree,
+ * according to the mass assignment.
+ */
+ public Degree getMostlikelyDegree() {
+ int ansIdx = 0;
+ double b = 0;
+ for (int j = 0; j < N; j++) {
+ if (this.getBeta(j) > b) {
+ b = this.getBeta(j);
+ ansIdx = j;
+ }
+ }
+ return new Degree(1.0*ansIdx/N);
+ }
+
+ /**
+ * Here, the domain is truth values
+ * Hence, s should contain 1 object of type Degree
+ * @return getMetaDegree(deg), 0 if arg is not valid
+ */
+ public IUncertainDegree eval(Set<Object> s) {
+ Degree deg = (s != null) ? (Degree) s.iterator().next() : null;
+ if (deg == null) return new Degree(0);
+ return getMetaDegree(deg);
+ }
+
+
+ @Override
+ /**
+ * Focal elements are singletons for which p[j] is > thold
+ * @return Set of focal elements
+ */
+ public Set<Set<? extends Object>> getFocalElements() {
+ Set<Set<? extends Object>> ans = new HashSet<Set<? extends Object>>();
+ for (int j = 0; j < N; j++) {
+ if (p[j] > this.zeroTHold) {
+ Set<Object> s = new HashSet<Object>();
+ s.add(new Degree(1.0*j/N));
+ ans.add(s);
+ }
+ }
+ return ans;
+ }
+
+
+
+
+ /**
+ * Gives the belief in a set of alternatives
+ * The "set" is a set of Degrees J : jk in [0,1] for each k
+ *
+ * This method returns the max lkhd degree only
+ * For probabilities, belief and plausibility coincide
+ * @return Sum(j in J){p(j)}
+ *
+ * TODO: getBoundedBelief()
+ */
+ public IUncertainDegree getBelief(Set<? extends Object> s) {
+ double sum = 0;
+ Iterator<? extends Object> it = s.iterator();
+ while (it.hasNext()) {
+ Degree d = (Degree) it.next();
+ if (d != null)
+ sum += ((Degree) getMetaDegree(d)).getValue();
+ }
+ return new Degree(sum);
+ }
+
+ /**
+ * Computes the belief bounds
+ * Calls ImpreciseDistribution.getBelief
+ * @param s
+ * @return
+ */
+ public IUncertainDegree getBeliefBounds(Set<? extends Object> s) {
+ return super.getBelief(s);
+ }
+
+ @Override
+ /**
+ * Gives the plausibility in a set of alternatives
+ * The "set" is a set of Degrees J : jk in [0,1] for each k
+ *
+ * This method returns the max lkhd degree only
+ * For probabilities, belief and plausibility coincide
+ * @return Sum(j in J){p(j)}
+ *
+ */
+ public IUncertainDegree getPlausibility(Set<? extends Object> s) {
+ return getBelief(s);
+ }
+
+
+ /**
+ * Computes the plausibility bounds
+ * Calls ImpreciseDistribution.getPlausibility
+ * @param s
+ * @return
+ */
+ public IUncertainDegree getPlausibilityBounds(Set<? extends Object> s) {
+ return super.getPlausibility(s);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /**
+ * TRUE as per definition
+ * @see uncertainty.measures.belief.IMassFunctionr#isBayesian()
+ */
+ public boolean isBayesian() { return true; }
+
+ /**
+ * Property
+ * It is equivalent to certainty = 1
+ * @see uncertainty.measures.belief.IMassFunctionr#isCategorical()
+ */
+ public boolean isCategorical() { return (getCertainty() >= (1.0 - this.zeroTHold)); }
+
+ /**
+ * FALSE as per definition. Whole mass is on singletons
+ * @see uncertainty.measures.belief.IMassFunctionr#isContradictory()
+ */
+ public boolean isContradictory() { return false; }
+
+ /**
+ * TRUE as per definition
+ * @see uncertainty.measures.belief.IMassFunctionr#isDogmatic()
+ */
+ public boolean isDogmatic() { return true; }
+
+ /**
+ * FALSE as per definition. No mass in on the universe as a whole
+ * @see uncertainty.measures.belief.IMassFunctionr#isVacuous()
+ */
+ public boolean isVacuous() { return false; }
+
+
+
+ public String toString() {
+ StringBuilder s = new StringBuilder("");
+ int n = p.length;
+
+ if (pL != null) {
+ for (int j = 0; j < n; j++)
+ s.append(formatt(pL[j],3)).append(" ");
+ s.append("\n");
+ }
+ for (int j = 0; j < n; j++)
+ s.append(formatt(p[j],3)).append(" ");
+ s.append("\t | conf = "+this.getConfidenceFactor());
+ if (pU != null) {
+ s.append("\n");
+ for (int j = 0; j < n; j++)
+ s.append(formatt(pU[j],3)).append(" ");
+ s.append("\n");
+ }
+ return s.toString();
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /* ********************************************************** */
+
+ /* ********************************************************** */
+
+ /**
+ * Uses Lanczos' approx to compute logGamma(x)
+ * @param x
+ * @return lnGamma(x)
+ */
+ protected static double lnGamma(double x) {
+ double tmp = (x - 0.5) * Math.log(x + 4.5) - (x + 4.5);
+ double ser = 1.0 + 76.18009173 / (x + 0) - 86.50532033 / (x + 1)
+ + 24.01409822 / (x + 2) - 1.231739516 / (x + 3)
+ + 0.00120858003 / (x + 4) - 0.00000536382 / (x + 5);
+ return tmp + Math.log(ser * Math.sqrt(2 * Math.PI));
+ }
+ /**
+ * Uses Lanczos' approx to compute Gamma(x)
+ * @param x
+ * @return Gamma(x)
+ */
+ static double gamma(double x) { return Math.exp(lnGamma(x)); }
+
+ protected static double GAMMA = 0.5772156649015328606065120900824024;
+ protected static double LN2 = Math.log(2);
+ protected static double Kncoe[] = { .30459198558715155634315638246624251,
+ .72037977439182833573548891941219706, -.12454959243861367729528855995001087,
+ .27769457331927827002810119567456810e-1, -.67762371439822456447373550186163070e-2,
+ .17238755142247705209823876688592170e-2, -.44817699064252933515310345718960928e-3,
+ .11793660000155572716272710617753373e-3, -.31253894280980134452125172274246963e-4,
+ .83173997012173283398932708991137488e-5, -.22191427643780045431149221890172210e-5,
+ .59302266729329346291029599913617915e-6, -.15863051191470655433559920279603632e-6,
+ .42459203983193603241777510648681429e-7, -.11369129616951114238848106591780146e-7,
+ .304502217295931698401459168423403510e-8, -.81568455080753152802915013641723686e-9,
+ .21852324749975455125936715817306383e-9, -.58546491441689515680751900276454407e-10,
+ .15686348450871204869813586459513648e-10, -.42029496273143231373796179302482033e-11,
+ .11261435719264907097227520956710754e-11, -.30174353636860279765375177200637590e-12,
+ .80850955256389526647406571868193768e-13, -.21663779809421233144009565199997351e-13,
+ .58047634271339391495076374966835526e-14, -.15553767189204733561108869588173845e-14,
+ .41676108598040807753707828039353330e-15, -.11167065064221317094734023242188463e-15 } ;
+
+ /**
+ * Digamma function approximation (unverified)
+ * Source:
+ * http://arXiv.org/abs/math.CA/0403344
+ * http://www.strw.leidenuniv.nl/~mathar/progs/digamma.c
+ * @param x
+ * @return diGamma(x)
+ */
+ double diGamma(double x)
+ {
+ /* force into the interval 1..3 */
+ if(x < 0.0)
+ return diGamma(1.0-x)+Math.PI/Math.tan(Math.PI*(1.0-x)); /* reflection formula */
+ else if(x < 1.0)
+ return diGamma(1.0+x)-1.0/x;
+ else if (x == 1.0)
+ return -GAMMA;
+ else if (x == 2.0)
+ return 1.0-GAMMA;
+ else if (x == 3.0)
+ return 1.5-GAMMA;
+ else if (x > 3.0)
+ /* duplication formula */
+ return 0.5*(diGamma(0.5*x)+diGamma(0.5*(x+1.0)))+LN2;
+ else
+ {
+
+ double Tn_1 = 1.0 ; /* T_{n-1}(x), started at n=1 */
+ double Tn = x - 2.0 ; /* T_{n}(x) , started at n=1 */
+ double resul = Kncoe[0] + Kncoe[1]*Tn ;
+
+ x -= 2.0;
+
+ for(int n = 2; n < Kncoe.length; n++)
+ {
+ double Tn1 = 2.0 * x * Tn - Tn_1 ; /* Chebyshev recursion, Eq. 22.7.4 Abramowitz-Stegun */
+ resul += Kncoe[n]*Tn1;
+ Tn_1 = Tn;
+ Tn = Tn1;
+ }
+ return resul;
+ }
+ }
+
+
+ /**
+ * Output : full graph features
+ * @param graph
+ */
+ public void render(Rectangle r, Graphics graph) {
+
+ Graphics2D g = (Graphics2D) graph;
+ int SIZ = 1500;
+ int PAD = (SIZ-1000)/2;
+ int PREC = 3;
+
+ // Init
+
+ g.setBackground(Color.WHITE);
+ g.scale(1.0*r.width/SIZ,-1.0*r.height/SIZ);
+ g.translate(PAD, -1000.0-PAD);
+ g.clearRect(-PAD, -PAD, 1000+2*PAD, 1000+2*PAD);
+ g.setFont(new Font(Font.SERIF,Font.BOLD,40));
+
+
+
+ // Truth bar
+ g.drawLine(0,0,1000,0);
+ for (int j = 0; j < N+1; j++) {
+ g.drawLine(1000*j/N,20,1000*j/N,-20);
+ }
+
+ // Tau and Fi
+ g.setColor(Color.BLUE);
+ drawArrow(g,0,-50,1000*tau/N,0,30);
+ g.setColor(Color.RED);
+ drawArrow(g,1000,-50,1000*(N-fi)/N,Math.PI,30);
+
+ // Relative Betas
+ g.setColor(new Color(0,0,0,0.1f));
+ for (int j=0; j < N; j++) {
+ int hgt = (int) Math.floor(1000*beta[j]/Btgt);
+ g.fillRect(1000*j/N, 0, 1000/N, hgt);
+ }
+
+ // pj
+ g.setColor(Color.BLACK);
+ for (int j = 0; j < N; j++) {
+ drawArrow(g,(1000*j+500)/N,0,(int) Math.floor(1000*p[j]),Math.PI/2,30);
+ }
+
+ //Lambda , Mu
+ g.setColor(Color.RED);
+ for (int j = 0; j < N; j++) {
+ int x = (1000*j+500)/N;
+ int yl = (int) Math.floor(1000*getLambda(j));
+ int yu = (int) Math.floor(1000*getMu(j));
+
+ g.drawLine(x-10,yl,x+10,yl);
+ g.drawLine(x-10,yu,x+10,yu);
+ }
+
+ //Lambda-Var , Mu+Var
+ g.setColor(Color.BLUE);
+ for (int j = 0; j < N; j++) {
+ int x = (1000*j+500)/N;
+ int yl = (int) Math.floor(1000*getLB(j));
+ int yu = (int) Math.floor(1000*getUB(j));
+
+ g.drawLine(x-15,yl,x+15,yl);
+ g.drawLine(x-15,yu,x+15,yu);
+ }
+
+ //DiricL , DiricU
+ g.setColor(Color.GREEN);
+ for (int j = 0; j < N; j++) {
+ int x = (1000*j+500)/N;
+ int yl = (int) Math.floor(1000*getDiricLB(j));
+ int yu = (int) Math.floor(1000*getDiricUB(j));
+
+ g.drawLine(x-20,yl,x+20,yl);
+ g.drawLine(x-20,yu,x+20,yu);
+ }
+
+
+ // Certainty
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-100,1000*(tau+N-fi)/N,-100);
+ // Confidence
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-150,(int) Math.floor(1000*Btot/Btgt),-150);
+ // Dogmatism
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-200,(int) Math.floor(1000*delta),-200);
+
+
+ // Strings
+ g.scale(1,-1);
+ g.setColor(Color.BLACK);
+ g.drawString("False", -150, 0);
+ g.drawString("True", 1050, 0);
+
+ g.drawString("t", -30, 70);
+ g.drawString("f", 1030, 70);
+
+ g.drawString("Certainty",-225,115);
+ g.drawString(formatt(getCertainty(),PREC),1000*(tau+N-fi)/N+25,115);
+
+ g.drawString("Confidence",-250,165);
+ g.drawString(formatt(Btot/Btgt,PREC),(int) Math.floor(1000*Btot/Btgt)+25,165);
+
+ g.drawString("Dogmatism",-250,215);
+ g.drawString(formatt(delta,PREC),(int) Math.floor(1000*delta)+25,215);
+
+ for (int j = 0; j < N; j++) {
+ //g.drawString(formatt(p[j],2), 1000*j/N +10,(int) -Math.floor(p[j]*1000)-20);
+ g.drawString(formatt(p[j],2), 1000*j/N +10,-1050);
+ }
+
+ g.setColor(Color.BLUE);
+ g.setFont(new Font(Font.SERIF,Font.BOLD,20));
+ for (int j = 0; j < N; j++) {
+ g.drawString(formatt(getLB(j),2), 1000*j/N +25,-1000);
+ g.drawString(formatt(getUB(j),2), 1000*j/N +25,-1100);
+ }
+
+ g.translate(-PAD, +1000.0+PAD);
+ g.scale(1.0/(1.0*r.width/SIZ),1.0/(-1.0*r.height/SIZ));
+
+
+ }
+
+
+
+ /**
+ * Output : full graph features
+ * @param graph
+ */
+ public void renderCompact(Rectangle r, Graphics graph) {
+
+ Graphics2D g = (Graphics2D) graph;
+ int SIZ = 1500;
+ int PAD = (SIZ-1000)/2;
+
+
+ // Init
+
+ g.setBackground(Color.WHITE);
+
+ g.translate(r.x,r.y);
+ g.scale(1.0*r.width/SIZ,-1.0*r.height/SIZ);
+ g.translate(PAD, -1000.0-PAD);
+
+ g.clearRect(-PAD, -PAD, 1000+2*PAD, 1000+2*PAD);
+
+ // Truth bar
+ g.drawLine(0,0,1000,0);
+ for (int j = 0; j < N+1; j++) {
+ g.drawLine(1000*j/N,20,1000*j/N,-20);
+ }
+
+ // Tau and Fi
+ g.setColor(Color.BLUE);
+ g.drawLine(0,-50,0+1000*tau/N,-50);
+ g.setColor(Color.RED);
+ g.drawLine(1000,-50,1000-1000*(N-fi)/N,-50);
+
+
+ // pj
+ g.setColor(Color.BLACK);
+ for (int j = 0; j < N; j++) {
+ int hgt = (int) Math.floor(1000*p[j]);
+ g.drawLine((1000*j+500)/N,0,(1000*j+500)/N,hgt);
+ }
+
+
+ // Certainty
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-100,1000*(tau+N-fi)/(N-1),-100);
+ // Confidence
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-150,(int) Math.floor(1000*Btot/Btgt),-150);
+ // Dogmatism
+ g.setColor(Color.BLACK);
+ g.drawLine(0,-200,(int) Math.floor(1000*delta),-200);
+
+ g.translate(-PAD, +1000.0+PAD);
+ g.scale(1.0/(1.0*r.width/SIZ),-1.0/(1.0*r.height/SIZ));
+ g.translate(-r.x, -r.y);
+
+
+
+ }
+
+
+
+ public void renderMinimal(Rectangle r, Graphics graph, Color c) {
+
+ Graphics2D g = (Graphics2D) graph;
+ int SIZ = 1000;
+
+
+ // Init
+
+ g.setBackground(Color.WHITE);
+
+ g.translate(r.x,r.y);
+ g.scale(1.0*r.width/SIZ,-1.0*r.height/SIZ);
+
+ g.clearRect(0, 0, 1000, 1000);
+
+ // Truth bar
+
+ for (int j = 0; j < N; j++) {
+ float alfa = (float) this.getP(j);
+ alfa = alfa < 0 ? 0 : alfa;
+ alfa = (float) Math.sqrt(alfa);
+
+ float red = alfa*(c.getRed()/260.0f);
+ float grn = alfa*(c.getGreen()/260.0f);
+ float blu = alfa*(c.getBlue()/260.0f);
+
+
+ g.setColor(new Color(red,grn,blu));
+ g.fillRect(0, j*100, 1000, 100);
+ }
+
+ // Tau and Fi
+ g.setColor(Color.BLUE);
+ g.drawLine(0,100*getTauIdx(),1000,100*getTauIdx());
+ g.setColor(Color.RED);
+ g.drawLine(0,100*getFiIdx(),1000,100*getFiIdx());
+
+
+ //g.translate(0, +1000.0);
+ g.scale(1.0/(1.0*r.width/SIZ),-1.0/(1.0*r.height/SIZ));
+ g.translate(-r.x, -r.y);
+
+ }
+
+
+
+
+
+
+
+
+ public void renderCompactOpenGL(GL gl, GLUT glut, double[] colorMask, boolean highlight) {
+ gl.glPushAttrib(GL.GL_CURRENT_BIT);
+
+
+
+ for (int j = 0; j < N; j++) {
+ double h = getP(j);
+
+ if (highlight) {
+ if (h < 1.0/10) {
+ //gl.glColor3d(0,0,0);
+ h = 0;
+ } else {
+ h = Math.sqrt(h);
+ h = 1.0 / Math.exp(10*(0.5-h));
+ }
+ }
+ //h = 0.25+h*0.75;
+
+ double[] cols = new double[3];
+ for (int idx = 0; idx < 3; idx++) {
+ cols[idx] = 1 -h*(1 -colorMask[idx]);
+ }
+
+
+ //h = 1-h;
+
+ //gl.glColor3d(h*colorMask[0],h*colorMask[1],h*colorMask[2]);
+
+ gl.glColor3d(cols[0],cols[1],cols[2]);
+ //if (j == m) gl.glColor3d(1,1,1);
+ gl.glBegin(GL.GL_POLYGON);
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*(j+1),0);
+ gl.glVertex3d(0,0.1*(j+1),0);
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glEnd();
+
+
+ }
+
+
+ gl.glColor3d(0,0,1);
+ gl.glBegin(GL.GL_POLYGON);
+ //double j = getTau().getValue();
+ int j = getTauIdx();
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*j+0.03,0);
+ gl.glVertex3d(0,0.1*j+0.03,0);
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glEnd();
+ gl.glColor3d(0,0,1);
+ gl.glBegin(GL.GL_POLYGON);
+ j = getFiIdx();
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*j,0);
+ gl.glVertex3d(0.1,0.1*j-0.03,0);
+ gl.glVertex3d(0,0.1*j-0.03,0);
+ gl.glVertex3d(0,0.1*j,0);
+ gl.glEnd();
+ gl.glPopAttrib();
+ }
+
+
+
+
+// private void drawAlfas(GL gl, GLUT glut) {
+// gl.glPushAttrib(GL.GL_CURRENT_BIT);
+// gl.glEnable(GL.GL_BLEND);
+// gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE);
+//
+//
+// gl.glPushMatrix();
+// gl.glTranslated(0,0,-0.5);
+// for (int j = 0; j < N; j++) {
+// gl.glColor4d(0.5,0.5,0.5,0.3);
+// double tal = 0.1*Math.log(ALFA[j]+1);
+//
+// gl.glRectd(j*delta+0.005,0,(j+1)*delta-0.005,tal);
+//
+// }
+// gl.glPopMatrix();
+//
+//
+//
+// gl.glBegin(GL.GL_LINES);
+// double pad = delta / 2;
+// for (int j = 0; j < N; j++) {
+// // arrow top
+// gl.glColor4d(1,1,1,1);
+// gl.glVertex2d(j*delta+0.5*delta,0);
+// gl.glVertex2d(j*delta+0.5*delta,maxP[j]);
+//
+// gl.glVertex2d(j*delta+pad,maxP[j]);
+// gl.glVertex2d(j*delta+pad+0.02,maxP[j]-0.025);
+//
+// gl.glVertex2d(j*delta+pad,maxP[j]);
+// gl.glVertex2d(j*delta+pad-0.02,maxP[j]-0.025);
+//
+//
+// // max tick
+// gl.glColor4d(0,1,0,1);
+// gl.glVertex2d(j*delta+0.05*delta,maxP[j]);
+// gl.glVertex2d(j*delta+0.95*delta,maxP[j]);
+//
+// // avg tick
+// gl.glColor4d(1,1,0,1);
+// gl.glVertex2d(j*delta+0.15*delta,avgP[j]);
+// gl.glVertex2d(j*delta+0.85*delta,avgP[j]);
+//
+//// var tick
+// gl.glColor4d(1,0,1,1);
+// gl.glVertex2d(j*delta+0.40*delta,avgP[j]+3*Math.sqrt(varP[j]));
+// gl.glVertex2d(j*delta+0.60*delta,avgP[j]+3*Math.sqrt(varP[j]));
+// gl.glVertex2d(j*delta+0.40*delta,avgP[j]-3*Math.sqrt(varP[j]));
+// gl.glVertex2d(j*delta+0.60*delta,avgP[j]-3*Math.sqrt(varP[j]));
+//
+//
+// // lb
+// gl.glColor4d(0,0,1,1);
+// gl.glVertex2d(j*delta+0.25*delta,LBP[j]);
+// gl.glVertex2d(j*delta+0.75*delta,LBP[j]);
+//
+// // ub
+// gl.glColor4d(1,0,0,1);
+// gl.glVertex2d(j*delta+0.25*delta,UBP[j]);
+// gl.glVertex2d(j*delta+0.75*delta,UBP[j]);
+//
+// // tau
+// gl.glColor4d(0,1,0,1);
+// gl.glVertex2d(0,-0.05);
+// gl.glVertex2d(tau,-0.05);
+// gl.glVertex2d(tau,-0.04);
+// gl.glVertex2d(tau,-0.06);
+//
+//
+// // fi
+// gl.glColor4d(1,0,0,1);
+// gl.glVertex2d(1,-0.05);
+// gl.glVertex2d(1-fi,-0.05);
+// gl.glVertex2d(1-fi,-0.04);
+// gl.glVertex2d(1-fi,-0.06);
+//
+// // cert
+// gl.glColor4d(1,1,1,1);
+// gl.glVertex2d(0,-0.1);
+// gl.glVertex2d(0+conf,-0.1);
+//
+// }
+// gl.glEnd();
+//
+//
+// gl.glDisable(GL.GL_BLEND);
+// gl.glPopAttrib();
+// }
+
+
+
+
+
+
+
+ private void drawArrow(Graphics2D g,int x0,int y0,int len, double angle,int arlen) {
+ g.translate(x0,y0);
+ g.rotate(angle);
+ g.drawLine(0,0,len,0);
+ g.drawLine(len,0,len-arlen,arlen/3);
+ g.drawLine(len,0,len-arlen,-arlen/3);
+ g.rotate(-angle);
+ g.translate(-x0,-y0);
+ }
+
+
+
+
+ /**
+ *
+ */
+ @Override
+ public boolean toBoolean() {
+ return this.getAverageDegree().toBoolean();
+ }
+
+
+
+
+
+
+
+
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/Essence.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDegree.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDegree.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDegree.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,28 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+/**
+ * Interface for an entity modeling and or evaluating
+ * a simple Degree.
+ *
+ * @author Sotty
+ */
+public interface IUncertainDegree {
+
+ /**
+ * Getter
+ * @return A simple Degree value
+ */
+ public Degree getDegree();
+
+ /**
+ * Converter
+ *
+ * @return The most accurate boolean representation of this truth degree
+ */
+ public boolean toBoolean();
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDegree.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDistribution.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDistribution.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDistribution.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,28 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+/**
+ * While an UncertainInterval models a degree whose exact value
+ * is uniformly distributed in [inf,sup], an UncertainDistribution
+ * models a degree that is NOT uniformly distributed therein
+ * @author Sotty
+ *
+ */
+public interface IUncertainDistribution
+ extends IUncertainInterval {
+
+ /**
+ * The degree deg in [inf,sup] describes exactly the
+ * assessed uncertain truth degree.
+ *
+ * Returns 0 if deg < getInf() || deg > getSup()
+ * @param deg
+ * @return
+ */
+ public IUncertainDegree getMetaDegree(Degree deg);
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainDistribution.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainInterval.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainInterval.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainInterval.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,28 @@
+/*
+ * Created on 07/giu/07
+ *
+ */
+package uncertainty.truthvals;
+
+import uncertainty.measures.possibility.INecessityFunction;
+import uncertainty.measures.possibility.IPossibilityFunction;
+
+/**
+ * More complex uncertainty degree, which, being uncertain itself,
+ * is modeled by an interval [inf,sup]
+ *
+ * @author Sotty
+ */
+public interface IUncertainInterval
+ extends IUncertainDegree, IPossibilityFunction, INecessityFunction {
+
+ /**
+ * @return The upper-bound Degree
+ */
+ public Degree getSup();
+
+ /**
+ * @return The lower-bound Degree
+ */
+ public Degree getInf();
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/IUncertainInterval.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/AggregationStrat.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/AggregationStrat.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/AggregationStrat.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,90 @@
+/*
+ * Created on 22/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * Strategy
+ * Defines a policy for the combination of two Belief structures
+ *
+ * @author Sotty
+ *
+ */
+public abstract class AggregationStrat implements IUncDegCombiner {
+
+ /**
+ * Property
+ * true iff X + X = X
+ * @return
+ */
+ public abstract boolean isIdempotent();
+
+
+ /**
+ * Property
+ * true iff X + Y = Y + X
+ * @return
+ */
+ public abstract boolean isCommutative();
+
+ /**
+ * Property
+ * true iff (X -> X', X + Y = Z) => (X' + Y -> Z')
+ * @return
+ */
+ public abstract boolean isContinuous();
+
+ /**
+ * Property
+ * true iff (X + Y) + Z = X + (Y + Z)
+ * @return
+ */
+ public abstract boolean isAssociative();
+
+ /**
+ * Property
+ * true iff +(X1,..,Xn) = +(Xs1,..,Xsn)
+ * where s is a permutation of 1..n
+ * @return
+ */
+ public abstract boolean isSymmetric();
+
+ /**
+ * Property
+ * true iff intersect(X1,..,Xn) in +(X1,..Xn)
+ * @return
+ */
+ public abstract boolean isIntersectionPreserving();
+
+ /**
+ * Property
+ * true iff union(X1,..,Xn) in +(X1,..Xn)
+ * @return
+ */
+ public abstract boolean isUnionPreserving();
+
+ /**
+ * Property
+ * true iff +(X1,..,Xn) in convexhull(X1,..Xn)
+ * @return
+ */
+ public abstract boolean isConvex();
+
+
+ /**
+ *
+ * @see uncertainty.truthvals.operators.IUncDegCombiner#eval(uncertainty.truthvals.IUncertainDegree[])
+ */
+ public abstract IUncertainDegree eval(IUncertainDegree[] args);
+
+ /**
+ *
+ * @see uncertainty.truthvals.operators.IUncDegCombiner#eval(uncertainty.truthvals.IUncertainDegree[])
+ */
+ public abstract IMassFunction eval(IMassFunction[] args);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/AggregationStrat.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/BRPLOp.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/BRPLOp.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/BRPLOp.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,96 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import java.util.Arrays;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * BRPL Operator
+ * Combines ImpreciseDistributions
+ *
+ * @author Sotty
+ * @see Essence
+ */
+public abstract class BRPLOp implements IUncDegCombiner {
+
+ /**
+ * Combines {@link IUncertainDegree}s that are actually ImpreciseDistributions
+ * If args are not compliant, the method returns null.
+ *
+ * @param args The arguments, which should be ImpreciseDistributions
+ *
+ * @return The evaluation, null if args are wrong type
+ * @see uncertainty.truthvals.operators.IUncDegCombiner#eval(uncertainty.truthvals.IUncertainDegree[])
+ */
+ public IUncertainDegree eval(IUncertainDegree[] args) {
+ Essence[] distArgs = new Essence[args.length];
+ for (int j = 0; j < args.length; j++) {
+ Essence arg = (Essence) args[j];
+ if (arg == null) return null;
+ else distArgs[j] = arg;
+ }
+ return eval(distArgs);
+ }
+
+ /**
+ * Concrete type evaluation
+ * Makes args comparable (same number of slots)
+ * then calls "evaluate"
+ * @param args The operands' truth distributions
+ * @return The functional evaluation
+ */
+ public IUncertainDegree eval(Essence[] args) {
+ return this.evaluate(this.equateArgs(args));
+ }
+
+ /**
+ * Actual evaluation, finally!
+ * @param args
+ * @return
+ */
+ protected abstract IUncertainDegree evaluate(Essence[] args);
+
+
+ /**
+ * Forces essence args to have all the same N slots
+ * If it is the case, as usual, the arg vector is
+ * returned unchanged
+ *
+ * Otherwise, args are conformed to the MIN N
+ * (building temporary distributions, equivalent to
+ * the given ones, for computation purposes)
+ *
+ * @param args
+ * @return
+ */
+ protected Essence[] equateArgs(Essence[] args) {
+ int minN = args[0].getN();
+ boolean equalN = true;
+ for (int j = 1; j < args.length; j++) {
+ if (args[j].getN() < minN) {
+ equalN = false;
+ minN = args[j].getN();
+ }
+ }
+ if (equalN) return args;
+
+ Essence[] ans = new Essence[args.length];
+ for (int j = 0; j < args.length; j++) {
+ if (args[j].getN() == minN) ans[j] = args[j];
+ else ans[j] = args[j].fitCopy(minN);
+ }
+ return ans;
+ }
+
+
+
+
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/BRPLOp.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/IUncDegCombiner.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/IUncDegCombiner.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/IUncDegCombiner.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,27 @@
+/*
+ * Created on 11/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * Strategy interface
+ *
+ * Generically combines generic truth values
+ *
+ * @author Sotty
+ *
+ */
+public interface IUncDegCombiner {
+
+ /**
+ * Combination
+ *
+ * @param args The truth values to be combined
+ * @return The output combination
+ */
+ public IUncertainDegree eval(IUncertainDegree[] args);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/IUncDegCombiner.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/DotAnd.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/DotAnd.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/DotAnd.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,111 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class DotAnd extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = (int) Math.floor((j*k)/(N-1));
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = (int) Math.floor((j*k)/(Essence.DEF_N-1));
+
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/DotAnd.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/Equiv.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/Equiv.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/Equiv.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,112 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class Equiv extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = N - 1 - Math.abs(j-k);
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = Essence.DEF_N - 1 - Math.abs(j-k);
+
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/Equiv.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasAnd.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasAnd.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasAnd.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,112 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class LukasAnd extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = j + k - N + 1;
+ if (z < 0) z = 0;
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = j + k - Essence.DEF_N +1;
+ if (z < 0) z = 0;
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasAnd.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasImply.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasImply.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasImply.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,101 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TCoNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class LukasImply extends TCoNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.9 -> 0.6 --> 0.7
+ *
+ * @param args
+ * @return
+ */
+ protected Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = N -1 - j + k;
+
+ if (z >= N) z = N-1;
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ protected static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = j + k - Essence.DEF_N;
+ if (z < 0) z = 0;
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasImply.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasNeg.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasNeg.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasNeg.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,21 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.NegOp;
+
+public class LukasNeg extends NegOp {
+
+ @Override
+ // TODO : Build an essence from ops
+ public IUncertainDegree evaluate(Essence[] args) {
+ Essence arg = args[0];
+
+ return arg.reverse();
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasNeg.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasOr.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasOr.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasOr.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,111 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class LukasOr extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = Math.min(N-1,j+k);
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = Math.min(Essence.DEF_N-1,j+k);
+
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/LukasOr.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MaxOr.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MaxOr.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MaxOr.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,111 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class MaxOr extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = Math.max(j,k);
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = Math.max(j,k);
+
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MaxOr.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MinAnd.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MinAnd.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MinAnd.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,113 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.Lukas;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.TNormOp;;
+
+/**
+ * @author Sotty
+ *
+ */
+public class MinAnd extends TNormOp {
+
+ @Override
+ public IUncertainDegree evaluate(Essence[] args) {
+ Set<List<Integer>>[] map = buildMapBinary(args);
+
+
+// for (int j = 0; j < map.length; j++) {
+// Set<List<Integer>> coups = map[j];
+// System.out.println("Map into "+j);
+// for (List<Integer> c : coups) {
+// System.out.print("<"+c.get(0)+","+c.get(1)+">");
+// System.out.print(" ");
+// }
+// System.out.println();
+// }
+
+ return new Essence(args,map);
+ }
+
+ /**
+ * Maps couples into operator's values
+ * e.g. 0.3x0.8 -> 0.2
+ *
+ * @param args
+ * @return
+ */
+ public Set<List<Integer>>[] buildMapBinary(Essence[] args) {
+ Essence e1 = args[0];
+ Essence e2 = args[1];
+ // By default, e1.getN() == e2.getN()
+ int N = e1.getN();
+
+ Set<List<Integer>>[] map = new Set[e1.getN()];
+
+ for (int j = 0; j < N; j++)
+ map[j] = new HashSet<List<Integer>>();
+
+
+ for (int j = e1.getTauIdx(); j < e1.getFiIdx(); j++) {
+ for (int k = e2.getTauIdx(); k < e2.getFiIdx(); k++) {
+ if (e1.getP(j) < e1.getZeroTHold() || e2.getP(k) < e2.getZeroTHold())
+ continue;
+
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+
+ int z = Math.min(j,k);
+ if (z < 0) System.out.println("ALERT");
+
+ map[z].add(pair);
+ }
+ }
+
+ return map;
+ }
+
+
+ private static Set<List<Integer>>[] map2x10 = null;
+
+ /**
+ * Global map
+ * Static, assumes 2 operands and 10 essence slots
+ * Notice that dynamic method may be faster for more certain
+ * operands, since bounds are used to speed up proceedings
+ *
+ * @param args
+ * @return
+ */
+ public static Set<List<Integer>>[] buildStandardMapBinary() {
+ if (map2x10 != null) return map2x10;
+
+ map2x10 = new Set[Essence.DEF_N];
+ for (int j = 0; j < Essence.DEF_N; j++)
+ map2x10[j] = new HashSet<List<Integer>>();
+
+ for (int j = 0; j < Essence.DEF_N; j++) {
+ for (int k = 0; k < Essence.DEF_N; k++) {
+ List<Integer> pair = new ArrayList<Integer>(2);
+ pair.add(j);
+ pair.add(k);
+ int z = Math.min(j,k);
+
+
+ map2x10[z].add(pair);
+ }
+ }
+
+
+ return map2x10;
+ }
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/Lukas/MinAnd.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/ModusPonensOp.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/ModusPonensOp.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/ModusPonensOp.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,222 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import uncertainty.measures.belief.ImpreciseDistribution;
+import uncertainty.measures.probability.ImpreciseProbability;
+import uncertainty.measures.probability.conversion.IAssignmentStrategy;
+import uncertainty.measures.probability.conversion.TauPignisticStrategy;
+import uncertainty.predicates.IUncertainOperator;
+import uncertainty.predicates.IUncertainPredicate;
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.Lukas.LukasAnd;
+import uncertainty.truthvals.operators.Lukas.LukasImply;
+import uncertainty.truthvals.operators.aggregators.DempsterShaferAggStrat;
+
+/**
+ * Modus Ponens
+ * given A/a, A->B/i, computes B/b'
+ * with b' = f(a,i)
+ *
+ * More precisely, the computation steps are:
+ * - compute tau(b) via t-norm composition a x i
+ * - project tau into a bayesian distribution
+ * - merge b' with already-known info b
+ *
+ * This Op is not to be included in an Operator, since
+ * there is no actual logical symbol for it.
+ * Rather, it is to be applied to have information
+ * flow from premises to conclusions via implications.
+ *
+ * @author Sotty
+ *
+ */
+public class ModusPonensOp extends BRPLOp {
+
+ /**
+ * Reference to the premise
+ */
+ protected IUncertainPredicate premise;
+ /**
+ * Getter
+ * @return The premise
+ */
+ public IUncertainPredicate getPremise() { return premise; }
+
+
+ /**
+ * Reference to the conclusion
+ */
+ protected IUncertainPredicate conclusion;
+ /**
+ * Getter
+ * @return The conclusion
+ */
+ public IUncertainPredicate getConclusion() { return conclusion; }
+
+
+ /**
+ * Reference to the implication operator
+ */
+ protected IUncertainOperator implication;
+ /**
+ * Getter
+ * @return The implication operator
+ */
+ protected IUncertainOperator getImplication() { return implication; }
+
+ /**
+ * Premise Truth value
+ */
+ protected Essence pTV;
+ /**
+ * Conclusion Truth value
+ */
+ protected Essence cTV;
+ /**
+ * Implication Truth value
+ */
+ protected Essence iTV;
+
+
+ protected IAssignmentStrategy asStrat;
+ protected AggregationStrat mgStrat;
+
+
+ @Override
+
+ /**
+ * Evaluation of PxI -> C (single Essence Modus Ponens)
+ * Premise truth degree is args[0]
+ * Implication truth degree is args[1]
+ *
+ */
+ protected IUncertainDegree evaluate(Essence[] args) {
+ this.pTV = args[0];
+ this.iTV = args[1];
+ return evaluate();
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /**
+ * Constructor
+ * Ghost Ops (not attached to predicates) must
+ * be built from scratch
+ * @param implic
+ */
+ public ModusPonensOp(IUncertainOperator implic, IAssignmentStrategy projStrat, AggregationStrat mergeStrat) {
+ this.implication = implic;
+ this.iTV = (Essence) implication.getDegree();
+ this.premise = implic.getOperand(0);
+ this.pTV = (Essence) premise.getDegree();
+ this.conclusion = implic.getOperand(1);
+ this.cTV = (Essence) conclusion.getDegree();
+
+ this.asStrat = projStrat;
+ this.mgStrat = mergeStrat;
+ }
+
+
+ /**
+ * Default Constructor,
+ * for evaluation only.
+ * (No predicates are attached, only truth values)
+ *
+ * Applies single Modus Ponens (using Lukas And)
+ * Projection is Pignistic
+ * Aggregation is Dempster-Shafer
+ *
+ */
+ public ModusPonensOp() {
+ this.asStrat = new TauPignisticStrategy();
+ this.mgStrat = new DempsterShaferAggStrat();
+ }
+
+
+
+
+
+
+ protected ImpreciseProbability combine() {
+
+ Essence[] mass = new Essence[2];
+ mass[0] = pTV;
+ mass[1] = iTV;
+ boolean withBounds = pTV.getSpecLevel() >= Essence.L20_BOUNDS && iTV.getSpecLevel() >= Essence.L20_BOUNDS;
+
+ ImpreciseDistribution tau = new ImpreciseDistribution(mass,new LukasAnd().buildMapBinary(mass),withBounds);
+ //System.out.println("Tau:\n" + tau);
+
+ tau.setAssignmentStrategy(this.asStrat);
+ ImpreciseProbability eps = (ImpreciseProbability) tau.toBayesianMassFunction(withBounds);
+ //System.out.println("Bayesian eps\n"+eps);
+
+ //now! discount...
+ double conf = pTV.getConfidenceFactor()*iTV.getConfidenceFactor();
+ //System.out.println("Confidence:" + conf);
+
+ eps.discount(conf,-1);
+ //System.out.println("Discounted eps\n:"+eps);
+
+ //System.out.println("Conclusion\n"+cTV);
+ return eps;
+
+ }
+
+
+ protected Essence evaluate() {
+
+ ImpreciseProbability combo = combine();
+ int level = Math.min(pTV.getSpecLevel(),iTV.getSpecLevel());
+ double conf = pTV.getConfidenceFactor()*iTV.getConfidenceFactor();
+
+ return new Essence(combo,conf,level);
+
+ }
+
+
+ /**
+ * Inference mechanism
+ * Updates conclusion from premise and implication
+ *
+ */
+ public void updateConclusion() {
+ // x prod
+
+ double conf = pTV.getConfidenceFactor()*iTV.getConfidenceFactor();
+
+ ImpreciseProbability[] mergeArgs = new ImpreciseProbability[2];
+ mergeArgs[0] = cTV;
+ mergeArgs[1] = this.combine();
+// ... and dempster-merge!
+ ImpreciseProbability jnt = (ImpreciseProbability) this.mgStrat.eval(mergeArgs);
+
+
+ // now, an Essence is built!!
+ conf = conf + cTV.getConfidenceFactor() - conf*cTV.getConfidenceFactor();
+ Essence concl = new Essence(jnt,conf,cTV.getSpecLevel());
+
+
+ conclusion.setDegree(concl);
+ //System.out.println("Answer definite\n"+ans);
+ }
+
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/ModusPonensOp.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/NegOp.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/NegOp.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/NegOp.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,15 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+
+public abstract class NegOp extends BRPLOp {
+
+ @Override
+ public abstract IUncertainDegree evaluate(Essence[] args);
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/NegOp.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TCoNormOp.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TCoNormOp.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TCoNormOp.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,9 @@
+/*
+ * Created on 21/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+public abstract class TCoNormOp extends BRPLOp {
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TCoNormOp.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TNormOp.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TNormOp.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TNormOp.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,14 @@
+/*
+ * Created on 17/giu/07
+ *
+ */
+package uncertainty.truthvals.operators;
+
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+
+public abstract class TNormOp extends BRPLOp {
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/TNormOp.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,260 @@
+/*
+ * Created on 22/giu/07
+ *
+ */
+package uncertainty.truthvals.operators.aggregators;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import uncertainty.measures.belief.IMassFunction;
+import uncertainty.measures.belief.ImpreciseDistribution;
+import uncertainty.measures.probability.ImpreciseProbability;
+import uncertainty.truthvals.Essence;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.AggregationStrat;
+
+/**
+ * Dempster-Shafer's rule of aggregation
+ * Combines two distribution masses according to the criteria:
+ *
+ * m(X) = K*Sum{A,B : A intersect B = X}m(A)m(B)
+ * K = 1-Sum{A,B : A intersect B = 0}m(A)m(B)
+ *
+ * Implementation depends on the type of masses being cobined
+ * - imprecise or not
+ * - bayesian or not
+ * - ...
+ *
+ *
+ *
+ * @author Sotty
+ *
+ */
+public class DempsterShaferAggStrat extends AggregationStrat {
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#eval(uncertainty.truthvals.IUncertainDegree[])
+ */
+ @Override
+ public IUncertainDegree eval(IUncertainDegree[] args) {
+ // TODO: what about a reflective dynamic dispatch?
+ if (args[0] instanceof Essence) {
+
+
+ Essence e1 = (Essence) args[0];
+ Essence e2 = (Essence) args[1];
+ ImpreciseProbability jnt = evalIP( new Essence[] {e1,e2});
+
+ // now, an Essence is built!!
+ double c1 = e1.getConfidenceFactor();
+ double c2 = e2.getConfidenceFactor();
+ double conf = c1 + c2 - c1*c2;
+ return new Essence(jnt,conf,e1.getSpecLevel());
+
+ } else return null;
+ }
+
+
+ @Override
+ /**
+ * TODO: Use callback, or anything
+ * BUT CHANGE THIS!!!
+ */
+ public IMassFunction eval(IMassFunction[] args) {
+ return evalIP((ImpreciseProbability[])args);
+ }
+
+ /**
+ * Combination of two imprecise bayesian distributions
+ * Custom optimized algorithm
+ *
+ * Merges distributions:
+ * A intersect B = (A == B) ? A : 0
+ *
+ * Hence, for all A:
+ * m(A) = m1(A)*m2(A);
+ * mL(A) = m1L(A)*m2L(A);
+ * mU(A) = m1U(A)*m2U(A);
+ *
+ * m0 and bounds are then computed from conflicting masses
+ * Last, masses and intervals are normalized (see Denoeux)
+ *
+ * mL*(j) = mL(j) / (1-s)
+ * s = max{mL(0), 1 - mL(j) - Sum(k != j) mU(k)}
+ *
+ * mU*(j) = mU(j) / (1-S)
+ * S = min{mU(0), 1 - mU(j) - Sum(k != j) mL(k)}
+ *
+ * @param p1 Operand: probability distribution
+ * @param p2 Operand: probability distribution
+ * @return
+ */
+ public ImpreciseProbability evalIP(ImpreciseProbability[] mass) {
+ int N = mass[0].getSize();
+ double[][] prob = new double[3][];
+ double[] p = new double[N];
+ double[] pL = new double[N];
+ double[] pU = new double[N];
+
+
+ Set<List<Integer>>[] map = new Set[N+1];
+ for (int j = 0; j < N; j++) {
+ map[j] = new HashSet<List<Integer>>();
+ List<Integer> list = new ArrayList<Integer>(2);
+ list.add(j);
+ list.add(j);
+ map[j].add(list);
+ }
+ map[N] = new HashSet<List<Integer>>();
+ for (int j = 0; j < N; j++) {
+ for (int k = 0; k < N; k++) {
+ if (j !=k) {
+ List<Integer> list = new ArrayList<Integer>(2);
+ list.add(j);
+ list.add(k);
+ map[N].add(list);
+ }
+ }
+ }
+ ImpreciseDistribution temp = new ImpreciseDistribution(mass,map,true,N+1);
+ //System.out.println("Temp:\n"+temp);
+ double norm = 0;
+ for (int j = 0; j < N; j++)
+ norm += temp.getMass(j);
+
+ for (int j = 0; j < N; j++) {
+ //p[j] = temp.getMass(j)/(1-temp.getMass(N));
+ p[j] = temp.getMass(j)/norm;
+
+ double s = 1;
+ for (int k = 0; k < N; k++)
+ s -= (k == j) ? temp.getMassL(k) : temp.getMassU(k);
+ s = Math.max(s, temp.getMassL(N));
+
+ pL[j] = temp.getMassL(j)/(1.0-s);
+
+ double S = 1;
+ for (int k = 0; k < N; k++)
+ S -= (k == j) ? temp.getMassU(k) : temp.getMassL(k);
+ S = Math.min(S, temp.getMassU(N));
+
+ pU[j] = temp.getMassU(j)/(1.0-S);
+ }
+
+ prob[0] = pL;
+ prob[1] = p;
+ prob[2] = pU;
+
+ return new ImpreciseProbability(prob);
+
+ }
+
+
+ /*
+ *
+
+
+
+ double Kn = 0;
+ for (int j = 0; j < N; j++) {
+ for (int k = 0; k < N; k++) {
+ if (j != k) {
+ Kn += mass[0].getMass(j)*mass[1].getMass(k);
+ }
+ }
+ }
+ for (int j = 0; j < N; j++) {
+ p[j] = (mass[0].getMass(j)*mass[1].getMass(j)) / Kn;
+ pL[j] = (mass[0].getMassL(j)*mass[1].getMassL(j)) / Kn;
+ pU[j] = (mass[0].getMassU(j)*mass[1].getMassU(j)) / Kn;
+ }
+
+
+
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isAssociative()
+ */
+ @Override
+ public boolean isAssociative() {
+ return false;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isCommutative()
+ */
+ @Override
+ public boolean isCommutative() {
+ return true;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isContinuous()
+ */
+ @Override
+ public boolean isContinuous() {
+ return false;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isConvex()
+ */
+ @Override
+ public boolean isConvex() {
+ return true;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isIdempotent()
+ */
+ @Override
+ public boolean isIdempotent() {
+ return false;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isIntersectionPreserving()
+ */
+ @Override
+ public boolean isIntersectionPreserving() {
+ return false;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isSymmetric()
+ */
+ @Override
+ public boolean isSymmetric() {
+ return true;
+ }
+
+ /**
+ * @see uncertainty.truthvals.operators.AggregationStrat#isUnionPreserving()
+ */
+ @Override
+ public boolean isUnionPreserving() {
+ return true;
+ }
+
+
+
+}
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleDotAnd.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleDotAnd.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleDotAnd.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,20 @@
+package uncertainty.truthvals.operators.simple;
+
+import uncertainty.truthvals.Degree;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+
+public class SimpleDotAnd implements IUncDegCombiner {
+
+ @Override
+ public IUncertainDegree eval(IUncertainDegree[] args) {
+ double ans = 1;
+ for (IUncertainDegree deg : args) {
+ Degree d = deg.getDegree();
+ ans *= d.getValue();
+ }
+
+ return new Degree(ans);
+ }
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMaxOr.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMaxOr.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMaxOr.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,20 @@
+package uncertainty.truthvals.operators.simple;
+
+import uncertainty.truthvals.Degree;
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+
+public class SimpleMaxOr implements IUncDegCombiner {
+
+ @Override
+ public IUncertainDegree eval(IUncertainDegree[] args) {
+ double ans = 0;
+ for (IUncertainDegree deg : args) {
+ Degree d = deg.getDegree();
+ ans = Math.max(ans,d.getValue());
+ }
+
+ return new Degree(ans);
+ }
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMinAnd.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMinAnd.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Essence/src/main/java/uncertainty/truthvals/operators/simple/SimpleMinAnd.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,20 @@
+package uncertainty.truthvals.operators.simple;
+
+import uncertainty.truthvals.IUncertainDegree;
+import uncertainty.truthvals.operators.IUncDegCombiner;
+import uncertainty.truthvals.Degree;
+
+public class SimpleMinAnd implements IUncDegCombiner {
+
+ @Override
+ public IUncertainDegree eval(IUncertainDegree[] args) {
+ double ans = 1;
+ for (IUncertainDegree deg : args) {
+ Degree d = deg.getDegree();
+ ans = Math.min(ans,d.getValue());
+ }
+
+ return new Degree(ans);
+ }
+
+}
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main$1.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/Main.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/DiscreteDomain.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/DiscreteDomain.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IContDomain.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IContDomain.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDiscDomain.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDiscDomain.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDomain.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/domains/IDomain.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/EssenceDegreeFactory.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/EssenceDegreeFactory.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/IDegreeFactory.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/IDegreeFactory.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/SimpleDegreeFactory.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/factory/SimpleDegreeFactory.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IDegreeEvalFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IDegreeEvalFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IMeasureFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/IMeasureFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ConcreteImpDist.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ConcreteImpDist.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IBeliefFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IBeliefFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IMassFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IMassFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IPlausibilityFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/IPlausibilityFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ImpreciseDistribution.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/belief/ImpreciseDistribution.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/INecessityFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/INecessityFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/IPossibilityFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/possibility/IPossibilityFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IBayesianMassFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IBayesianMassFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IProbabilityFunction.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/IProbabilityFunction.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/ImpreciseProbability.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/ImpreciseProbability.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IAssignmentStrategy.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IAssignmentStrategy.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IUncAssignmentStrat.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/IUncAssignmentStrat.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauPignisticStrategy.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauPignisticStrategy.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauProjectionStrategy.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/measures/probability/conversion/TauProjectionStrategy.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLOperator.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLOperator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLPredicate.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/BRPLPredicate.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IArg.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IArg.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainOperator.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainOperator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainPredicate.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/predicates/IUncertainPredicate.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Degree.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Degree.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/DegreeInterval.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/DegreeInterval.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Essence.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/Essence.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDegree.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDegree.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDistribution.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainDistribution.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainInterval.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/IUncertainInterval.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/AggregationStrat.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/AggregationStrat.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/BRPLOp.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/BRPLOp.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/IUncDegCombiner.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/IUncDegCombiner.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/DotAnd.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/DotAnd.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/Equiv.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/Equiv.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasAnd.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasAnd.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasImply.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasImply.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasNeg.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasNeg.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasOr.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/LukasOr.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MaxOr.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MaxOr.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MinAnd.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/Lukas/MinAnd.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/ModusPonensOp.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/ModusPonensOp.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/NegOp.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/NegOp.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TCoNormOp.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TCoNormOp.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TNormOp.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/TNormOp.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/aggregators/DempsterShaferAggStrat.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleDotAnd.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleDotAnd.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMaxOr.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMaxOr.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMinAnd.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Essence/target/classes/uncertainty/truthvals/operators/simple/SimpleMinAnd.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Test/.classpath
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/.classpath (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/.classpath 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/drools-compiler"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/drools-core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/Essence"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: labs/jbossrules/branches/uncDrools5x/Test/.project
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/.project (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/.project 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.drools.eclipse.droolsbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: labs/jbossrules/branches/uncDrools5x/Test/bin/prova.drl
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/bin/prova.drl (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/bin/prova.drl 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,100 @@
+#created on: 01-Aug-2008
+package test
+
+#list any import classes here.
+
+import java.util.Hashtable;
+import uncertainty.truthvals.IUncertainDegree;
+import org.drools.rule.ConstraintSignature
+
+
+#declare any global variables here
+
+global uncertainty.factory.IDegreeFactory factory;
+global org.drools.base.evaluators.EvaluatorRegistry registry;
+
+
+
+
+rule "One more rule II"
+
+ when
+ $p : Person ( weight ` nearly[30] height )
+ then
+ System.out.println("This is a square person in a degree "+drools.getActivationDegree());
+
+end
+
+
+
+
+
+/*
+rule "Your First Rule"
+
+ when
+ $p : Person( name == "davide", age ` young[1,27] 1 )
+ then
+ System.out.println("R0 : " + $p.getName() + " at " + $p.getAge() + " is Young " + drools.getActivationDegree());
+end
+*/
+
+
+/*
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ $p : Person( weight ` heavy[100,150] 1 , age ` young[5,18] 1 , name == "davide")
+ $q : Person( weight == 142.5 , name == $p.name)
+
+ then
+ #actions
+ System.out.println("Rule II is active at "+drools.getActivationDegree());
+end
+*/
+
+
+
+/*
+
+rule "Prem1"
+
+ when
+ $s : String( $s.toString == "Premise1" )
+
+ then
+ System.out.println("Rule 1");
+
+ Person p = new Person(1);
+ p.setName("davide");
+ Hashtable<ConstraintSignature,IUncertainDegree> priors = new Hashtable<ConstraintSignature, IUncertainDegree>();
+ priors.put(new ConstraintSignature("age","young","1"), factory.buildDegree(0.25));
+
+ insertLogical(p,priors);
+
+end
+
+
+
+
+rule "Prem2"
+
+ when
+ $s : String( $s.toString == "Premise2" )
+ then
+ System.out.println("Rule P2: Another rule has fired!! ");
+
+ Person p = new Person(1);
+ p.setName("davide");
+ p.setAge(4);
+ Hashtable<ConstraintSignature,IUncertainDegree> priors = new Hashtable<ConstraintSignature, IUncertainDegree>();
+ priors.put(new ConstraintSignature("age","young","1"),
+ factory.buildDegree(drools.getActivationDegree().getDegree().getValue()));
+
+
+ insertLogical(p,priors);
+end
+
+*/
+
+
Added: labs/jbossrules/branches/uncDrools5x/Test/bin/test/Person.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Test/bin/test/Person.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Test/bin/test/TestDrools.class
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/branches/uncDrools5x/Test/bin/test/TestDrools.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/branches/uncDrools5x/Test/log.log
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/log.log (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/log.log 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,24 @@
+<object-stream>
+<org.drools.audit.event.ActivationLogEvent>
+ <activationId>One more rule II [1]</activationId>
+ <rule>One more rule II</rule>
+ <declarations>$p=test.Person at 30(1)</declarations>
+ <type>4</type>
+</org.drools.audit.event.ActivationLogEvent>
+<org.drools.audit.event.ObjectLogEvent>
+ <factId>1</factId>
+ <objectToString>test.Person at 30</objectToString>
+ <type>1</type>
+</org.drools.audit.event.ObjectLogEvent>
+<org.drools.audit.event.ActivationLogEvent>
+ <activationId>One more rule II [1]</activationId>
+ <rule>One more rule II</rule>
+ <declarations>$p=test.Person at 30(1)</declarations>
+ <type>6</type>
+</org.drools.audit.event.ActivationLogEvent>
+<org.drools.audit.event.ActivationLogEvent>
+ <activationId>One more rule II [1]</activationId>
+ <rule>One more rule II</rule>
+ <declarations>$p=test.Person at 30(1)</declarations>
+ <type>7</type>
+</org.drools.audit.event.ActivationLogEvent>
Added: labs/jbossrules/branches/uncDrools5x/Test/src/prova.drl
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/src/prova.drl (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/src/prova.drl 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,100 @@
+#created on: 01-Aug-2008
+package test
+
+#list any import classes here.
+
+import java.util.Hashtable;
+import uncertainty.truthvals.IUncertainDegree;
+import org.drools.rule.ConstraintSignature
+
+
+#declare any global variables here
+
+global uncertainty.factory.IDegreeFactory factory;
+global org.drools.base.evaluators.EvaluatorRegistry registry;
+
+
+
+
+rule "One more rule II"
+
+ when
+ $p : Person ( weight ` nearly[30] height )
+ then
+ System.out.println("This is a square person in a degree "+drools.getActivationDegree());
+
+end
+
+
+
+
+
+/*
+rule "Your First Rule"
+
+ when
+ $p : Person( name == "davide", age ` young[1,27] 1 )
+ then
+ System.out.println("R0 : " + $p.getName() + " at " + $p.getAge() + " is Young " + drools.getActivationDegree());
+end
+*/
+
+
+/*
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ $p : Person( weight ` heavy[100,150] 1 , age ` young[5,18] 1 , name == "davide")
+ $q : Person( weight == 142.5 , name == $p.name)
+
+ then
+ #actions
+ System.out.println("Rule II is active at "+drools.getActivationDegree());
+end
+*/
+
+
+
+/*
+
+rule "Prem1"
+
+ when
+ $s : String( $s.toString == "Premise1" )
+
+ then
+ System.out.println("Rule 1");
+
+ Person p = new Person(1);
+ p.setName("davide");
+ Hashtable<ConstraintSignature,IUncertainDegree> priors = new Hashtable<ConstraintSignature, IUncertainDegree>();
+ priors.put(new ConstraintSignature("age","young","1"), factory.buildDegree(0.25));
+
+ insertLogical(p,priors);
+
+end
+
+
+
+
+rule "Prem2"
+
+ when
+ $s : String( $s.toString == "Premise2" )
+ then
+ System.out.println("Rule P2: Another rule has fired!! ");
+
+ Person p = new Person(1);
+ p.setName("davide");
+ p.setAge(4);
+ Hashtable<ConstraintSignature,IUncertainDegree> priors = new Hashtable<ConstraintSignature, IUncertainDegree>();
+ priors.put(new ConstraintSignature("age","young","1"),
+ factory.buildDegree(drools.getActivationDegree().getDegree().getValue()));
+
+
+ insertLogical(p,priors);
+end
+
+*/
+
+
Added: labs/jbossrules/branches/uncDrools5x/Test/src/test/Person.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/src/test/Person.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/src/test/Person.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,83 @@
+package test;
+
+public class Person {
+
+ private Integer id;
+ public Integer getId() { return id; }
+
+
+ private Integer age;
+ public Integer getAge() { return age; }
+ public void setAge(Integer newAge) { this.age = newAge; }
+
+
+ private String name;
+ public String getName() { return name; }
+ public void setName(String newName) { this.name = newName; }
+
+
+ private Double weight;
+ public void setWeight(Double weight) {
+ this.weight = weight;
+ }
+ public Double getWeight() {
+ return weight;
+ }
+
+
+ private Double height;
+ public void setHeight(Double height) {
+ this.height = height;
+ }
+ public Double getHeight() {
+ return height;
+ }
+
+
+
+ public Person(int id, String name, int age) {
+ this.id = id;
+ setName(name);
+ setAge(age);
+ }
+
+ public Person(int id) {
+ this.id = id;
+ age = null;
+ name = null;
+ weight = null;
+ }
+
+
+ public int hashCode() {
+ int result = 53;
+
+ result = result ^ id.hashCode();
+ //if (name != null) result ^= name.hashCode();
+ //if (age != null) result ^= age.hashCode();
+ //if (weight != null) result ^= weight.hashCode();
+
+ return result;
+ }
+
+
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (! (other instanceof Person)) return false;
+ Person o2 = (Person) other;
+
+ if (this.id == null || o2.id == null) return false;
+
+ if (name != null && o2.name != null && ! name.equals(o2.name)) return false;
+ if (age != null && o2.age != null && this.age != o2.age) return false;
+ if (weight != null && o2.weight != null && this.weight != o2.weight) return false;
+ if (height != null && o2.height != null && this.height != o2.height) return false;
+ if (this.id != null && o2.id != null && this.id != o2.id) return false;
+
+
+ return true;
+
+
+
+ }
+}
Added: labs/jbossrules/branches/uncDrools5x/Test/src/test/TestDrools.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/Test/src/test/TestDrools.java (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/Test/src/test/TestDrools.java 2008-08-12 22:50:52 UTC (rev 21494)
@@ -0,0 +1,123 @@
+package test;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.drools.IUncertainRuleBase;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.WorkingMemory;
+import org.drools.audit.WorkingMemoryFileLogger;
+import org.drools.base.ClassFieldReader;
+import org.drools.base.ValueType;
+import org.drools.base.evaluators.EvaluatorRegistry;
+import org.drools.base.evaluators.Operator;
+import org.drools.base.evaluators.YoungEvaluatorDefinition;
+import org.drools.base.evaluators.YoungEvaluatorDefinition.YoungEvaluator;
+import org.drools.base.field.LongFieldImpl;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.event.DebugAgendaEventListener;
+import org.drools.event.DebugWorkingMemoryEventListener;
+import org.drools.rule.ClassConstraint;
+import org.drools.rule.ConstraintSignature;
+import org.drools.rule.LiteralConstraint;
+import org.drools.rule.Package;
+import org.drools.spi.Constraint;
+
+import uncertainty.factory.IDegreeFactory;
+import uncertainty.truthvals.IUncertainDegree;
+
+
+public class TestDrools {
+
+ /**
+ * @param args
+ * @throws IOException
+ * @throws DroolsParserException
+ */
+ public static void main(String[] args) throws DroolsParserException, IOException {
+
+ Reader source = null;
+ System.out.println(new File(".").getAbsolutePath());
+ source = new InputStreamReader(
+ //HelloWorldExample.class.getResourceAsStream( "HelloWorld.drl" )
+ new FileInputStream("src/prova.drl")
+ );
+
+
+
+ final PackageBuilder builder = new PackageBuilder();
+ EvaluatorRegistry registry = builder.getPackageBuilderConfiguration().getEvaluatorRegistry();
+
+ //this will parse and compile in one step
+ builder.addPackageFromDrl( source );
+
+ // Check the builder for errors
+ if ( builder.hasErrors() ) {
+ System.out.println( builder.getErrors().toString() );
+ throw new RuntimeException( "Unable to compile \"prova.drl\".");
+ }
+
+ //get the compiled package (which is serializable)
+ final Package pkg = builder.getPackage();
+
+ //add the package to a rulebase (deploy the rule package).
+ final RuleBase ruleBase = RuleBaseFactory.newRuleBase(IUncertainRuleBase.RETEOO_UNCERTAIN);
+ IDegreeFactory factory = ((IUncertainRuleBase) ruleBase).getTruthFactory();
+ ruleBase.addPackage( pkg );
+
+ final StatefulSession session = ruleBase.newStatefulSession();
+
+
+ session.addEventListener( new DebugAgendaEventListener() );
+ session.addEventListener( new DebugWorkingMemoryEventListener() );
+
+ session.setGlobal("registry", registry);
+ session.setGlobal("factory", factory);
+
+ final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( session );
+ logger.setFileName( "log" );
+
+
+
+ Person p = new Person(5);
+ p.setAge(12);
+ p.setName("davide");
+ p.setWeight(142.5);
+ p.setHeight(175.0);
+
+ Hashtable<ConstraintSignature, IUncertainDegree> priors = new Hashtable<ConstraintSignature,IUncertainDegree>();
+
+ priors.put(ClassConstraint.buildSignature(p.getClass()),factory.buildDegree(0.85));
+ priors.put(LiteralConstraint.buildSignature("age", "young",""+1), factory.buildDegree(0.65));
+ priors.put(new ConstraintSignature("weight", "nearly","height"), factory.buildDegree(0.99));
+
+
+
+
+
+
+// session.insert(new String("Premise1"),new Hashtable<ConstraintSignature, IUncertainDegree>());
+// session.insert(new String("Premise2"),new Hashtable<ConstraintSignature, IUncertainDegree>());
+
+ session.insert(p, priors);
+
+ session.fireAllRules();
+
+
+
+ logger.writeToDisk();
+
+ session.dispose();
+
+
+
+ }
+
+}
More information about the jboss-svn-commits
mailing list