EMMA Coverage Report (generated Sat Aug 20 11:00:51 CDT 2011)
[all classes][tuffy.mln]

COVERAGE SUMMARY FOR SOURCE FILE [Atom.java]

nameclass, %method, %block, %line, %
Atom.java100% (2/2)73%  (11/15)66%  (273/415)56%  (34.6/62)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Atom100% (1/1)73%  (8/11)60%  (208/345)55%  (32.8/60)
Atom (ArrayList, double): void 0%   (0/1)0%   (0/34)0%   (0/12)
Atom (Predicate, ArrayList, boolean): void 0%   (0/1)0%   (0/34)0%   (0/11)
Atom (Predicate, ArrayList, double): void 0%   (0/1)0%   (0/37)0%   (0/12)
isSoftEvidence (): boolean 100% (1/1)71%  (5/7)71%  (0.7/1)
club (): int 100% (1/1)75%  (12/16)67%  (4/6)
Atom (Predicate, Tuple): void 100% (1/1)76%  (32/42)97%  (11.6/12)
toString (): String 100% (1/1)81%  (47/58)83%  (5/6)
<static initializer> 100% (1/1)88%  (7/8)87%  (0.9/1)
$SWITCH_TABLE$tuffy$mln$Atom$AtomType (): int [] 100% (1/1)90%  (37/41)90%  (0.9/1)
Atom (ArrayList, boolean): void 100% (1/1)100% (31/31)100% (11/11)
groundSize (): long 100% (1/1)100% (37/37)100% (8/8)
     
class Atom$AtomType100% (1/1)75%  (3/4)93%  (65/70)88%  (1.8/2)
valueOf (String): Atom$AtomType 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (44/44)100% (1/1)
Atom$AtomType (String, int): void 100% (1/1)100% (5/5)100% (1/1)
values (): Atom$AtomType [] 100% (1/1)100% (16/16)100% (1/1)

1package tuffy.mln;
2import java.util.*;
3 
4import tuffy.util.StringMan;
5 
6 
7/**
8 * An atomic formula. It's designed as a light-weight construct, hence
9 * all fields are transparent (public).
10 */
11public class Atom {
12        
13        /**
14         * Enumerated type of Atoms. 1) NONE; 2) EVIDENCE: atom in evidence;
15         * 3) QUERY: atom in query; 4) QUEVID: atom in query as evidence.
16         */
17        public static enum AtomType {EVIDENCE, QUERY, NONE, QUEVID};
18        
19        /**
20         * The predicate of this Atom.
21         */
22        
23        public Predicate pred;
24        /**
25         * The argument list represented as a tuple of integers:
26         * constant as positive number and variable as negative number.
27         */
28        public Tuple args = null;
29        
30        public ArrayList<String> sargs = null;
31        
32        /**
33         * Truth value of this atom.
34         */
35        public Boolean truth = null;
36        
37        /**
38         * Probability of "soft evidence".
39         */
40        public Double prior = null;
41        
42        /**
43         * Type of this atom. Values are enumerated by {@link AtomType}.
44         */
45        public AtomType type = AtomType.NONE;
46 
47        /**
48         * Map the {@link AtomType} value of this atom into an integer,
49         * which is used internally by the DB.
50         */
51        public int club() {
52                switch(type) {
53                case NONE: return 0;
54                case QUERY: return 1;
55                case EVIDENCE: return 2;
56                case QUEVID: return 3; // evidence in query
57                default: return 0;
58                }
59        }
60        
61        /**
62         * Test if this atom is soft evidence.
63         */
64        public boolean isSoftEvidence(){
65                return prior != null;
66        }
67        
68        /**
69         * Return the number of grounded atoms when grounding this atom.
70         * This number equals to the multiplication of the domain size
71         * of each distinct variable appearing in this atom. That is,
72         * we assume cross product is used.
73         */
74        public long groundSize(){
75                long size = 1;
76                
77                // ASSUMPTION OF DATA STRUCTURE: $\forall$ i<j, args.get(i) > args.get(j) if
78                // args.get(i), args.get(j) < 0. (i.e., naming new variables
79                // sequentially from left to right.
80                int lastVar = 0;
81                for(int i=0; i<pred.arity(); i++){
82                        // if this is a new variable not seen before
83                        if(args.get(i) < lastVar){
84                                Type t = pred.getTypeAt(i);
85                                size *= t.size();
86                                lastVar = args.get(i);
87                        }
88                }
89                return size;
90        }
91        
92        /**
93         * Create an evidence atom.
94         * @param p the predicate
95         * @param as the arguments
96         * @param t the truth value
97         */
98        public Atom(Predicate p, ArrayList<Integer> as, boolean t){
99                pred = p;
100                args = new Tuple(as);
101                
102                truth = t;
103                type = AtomType.EVIDENCE;
104        }
105 
106        /**
107         * Create a soft evidence atom.
108         * Note that the type of 'soft evidence' atoms is NONE,
109         * as opposed to EVIDENCE.
110         * @param p the predicate
111         * @param as the arguments
112         * @param prior the prior probability
113         */
114        public Atom(Predicate p, ArrayList<Integer> as, double prior){
115                pred = p;
116                args = new Tuple(as);
117                truth = null;
118                this.prior = prior;
119                type = AtomType.NONE;
120        }
121 
122 
123        public Atom(ArrayList<String> as, double prior){
124                pred = null;
125                sargs = as;
126                truth = null;
127                this.prior = prior;
128                type = AtomType.NONE;
129        }
130 
131        public Atom(ArrayList<String> as, boolean t){
132                pred = null;
133                sargs = as;
134                truth = t;
135                type = AtomType.EVIDENCE;
136        }
137        
138        
139        
140        /**
141         * Create an atom of type NONE.
142         * The default truth value of unknown is null.
143         * 
144         * @param p the predicate
145         * @param at the arguments in the form of a tuple
146         * 
147         * @see tuffy.ground.KBMC#run()
148         */
149        public Atom(Predicate p, Tuple at){
150                assert(at.list.length == p.arity());
151                pred = p;
152                args = at;
153                truth = null;
154                type = AtomType.NONE;
155        }
156        
157        /**
158         * Returns this atom's human-friendly string representation.
159         */
160        public String toString() {
161                ArrayList<String> as = new ArrayList<String>();
162                for(int v : args.list) {
163                        if(v >= 0){
164                                as.add("C" + v);
165                        }else{
166                                as.add("v" + (-v));
167                        }
168                }
169                return pred.getName() + StringMan.commaListParen(as);
170        }
171 
172}

[all classes][tuffy.mln]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov