EMMA Coverage Report (generated Tue Aug 23 05:57:12 CDT 2011)
[all classes][felix.test]

COVERAGE SUMMARY FOR SOURCE FILE [DDTest.java]

nameclass, %method, %block, %line, %
DDTest.java100% (1/1)100% (4/4)93%  (249/267)87%  (39.3/45)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DDTest100% (1/1)100% (4/4)93%  (249/267)87%  (39.3/45)
testDDMarginal (): void 100% (1/1)91%  (135/148)88%  (20.3/23)
testDDMAP (): void 100% (1/1)95%  (104/109)84%  (16/19)
<static initializer> 100% (1/1)100% (7/7)100% (3/3)
DDTest (): void 100% (1/1)100% (3/3)100% (1/1)

1package felix.test;
2 
3import static org.junit.Assert.*;
4 
5import java.io.BufferedReader;
6import java.io.FileReader;
7import java.util.ArrayList;
8import java.util.HashMap;
9import java.util.HashSet;
10import java.util.regex.Matcher;
11import java.util.regex.Pattern;
12 
13import org.junit.BeforeClass;
14import org.junit.Test;
15 
16import tuffy.util.UIMan;
17 
18import felix.main.Felix;
19import felix.parser.FelixCommandOptions;
20import felix.util.FelixConfig;
21import felix.util.FelixUIMan;
22 
23 
24/**
25 * Test LR operator's quality.
26 * @author Ce Zhang
27 *
28 */
29public class DDTest{
30        
31        public static ArrayList<Double> planCosts = new ArrayList<Double>();
32        public static String exeTime = "";
33        
34 
35        /**
36         * Test Marginal inference results of LR on a test case with manually-built ground truth.
37         */
38        @Test
39        public final void testDDMarginal() {
40                try{
41                        String[] args = {"-e", "test/felix/DDTest/evidence.db", "-i", "test/felix/DDTest/prog.mln",
42                                         "-o", "test/testOutput.txt", "-q", "op1", "-marginal", "-dd", "-nDD", "5"
43                                         , "-mcsatSamples", "1000"};
44                        
45                        
46                        FelixConfig.overrideID();
47                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
48                        
49                        
50                        new Felix().run(options);
51                        
52                        String outfile = "test/testOutput.txt";
53 
54                
55                        BufferedReader br = new BufferedReader(new FileReader("test/testOutput.txt"));
56                        
57                        Pattern p1 = Pattern.compile("(.*?)\top1\\(\"K2\", \"L2\"\\)");
58                        Pattern p2 = Pattern.compile("(.*?)\top1\\(\"K1\", \"L1\"\\)");        
59                        
60                        String line;
61                        while( (line = br.readLine()) != null){
62                                int ct = 0;
63                                
64                                Matcher m = p1.matcher(line);
65                                if(m.find() && Double.valueOf(m.group(1)) > 0.6){
66                                        ct++;
67                                }
68                                
69                                m = p2.matcher(line);
70                                if(m.find() && Double.valueOf(m.group(1)) < 0.3){
71                                        ct++;
72                                }
73                                
74                                
75                                UIMan.warn(""+ct);
76                                assertTrue(ct == 1);
77                                
78                                
79                        }
80                        
81                }catch(Exception e){
82                        e.printStackTrace();
83                }
84        }
85        
86        /**
87         * Test MAP inference results of LR on a test case with manually-built ground truth.
88         */
89        @Test
90        public final void testDDMAP() {
91                try{
92                        String[] args = {"-e", "test/felix/DDTest/evidence.db", "-i", "test/felix/DDTest/prog.mln",
93                                         "-o", "test/testOutput.txt", "-q", "op1", "-dd", "-nDD", "10"
94                                         , "-maxFlips", "10000000"};
95                        
96                        
97                        FelixConfig.overrideID();
98                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
99                        
100                        
101                        new Felix().run(options);
102                        
103                        String outfile = "test/testOutput.txt";
104 
105                
106                        BufferedReader br = new BufferedReader(new FileReader("test/testOutput.txt"));
107                        
108                        Pattern p1 = Pattern.compile("top1\\(\"K1\", \"L2\"\\)");
109                        Pattern p2 = Pattern.compile("top1\\(\"K2\", \"L2\"\\)");
110                        
111                        
112                        String line;
113                        while( (line = br.readLine()) != null){
114                                int ct = 0;
115                                
116                                System.out.println(line);
117                                
118                                if(line.equals("op1(\"K2\", \"L2\")") || line.equals("op1(\"K1\", \"L2\")")){
119                                        assertTrue(true);
120                                }else{
121                                        assertTrue(false);
122                                }
123                        
124                        }
125                        
126                }catch(Exception e){
127                        e.printStackTrace();
128                }
129        }
130        
131        
132        
133}
134 
135 
136 
137 
138 
139 

[all classes][felix.test]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov