1:- module(test_pita,
2 [test_pita/0]). 3:- use_module(library(plunit)). 4
5test_pita:-
6 run_tests([coin,
7 coinmsw,
8 coinmsw_memo,
9 coin_mpe,
10 dice,
11 epidemic,
12 earthquake,
13 sneezing,
14 trigger,
15 light,
16 threesideddice,
17 bloodtype,
18 mendel,
19 coin2,
20 simpson,
21 viral,
22 uwcse,
23 path,
24 pathdb,
25 multiple_paths_simple,
26 multiple_paths,
27 abd1,
28 abd2,
29 abd3,
30 abd1cons1,
31 abd1cons2,
32 bag_game_mpe,
33 bag_pb_mpe,
34 bag_simple,
35 bag_mpe,
36 eruption_mpe,
37 bag_1,
38 bag_2,
39 hmm_mpe,
40 meta,
41 pcfg,
42 pcfglrdb,
43 var_objdb,
44 card,
45 dt_umbrella,
46 dt_winning,
47 dt_weather,
48 dt_viral,
49 tabling_probs,
50 event_calculus
51 ]).
52
53:-use_module(library(cplint_test/cplint_test)). 54
55
56:- begin_tests(event_calculus, []). 57:- ensure_loaded(library(examples/event_calculus)). 58test(garden2):-
59 run((prob(holdsAt(locatedIn(bob,garden),2),P),close_to(P,1))).
60test(garden4):-
61 run((prob(holdsAt(locatedIn(bob,garden),4),P),close_to(P,0.34))).
62test(kitchen4):-
63 run((prob(holdsAt(locatedIn(bob,kitchen),4),P),close_to(P,0.66))).
64test(garage6):-
65 run((prob(holdsAt(locatedIn(bob,garage),6),P),close_to(P,0.66))).
66:- end_tests(event_calculus). 67
68
69:- begin_tests(dt_winning, []). 70:- ensure_loaded(library(examples/dt_winning)). 71test(best_st_wnning):-
72 run((dt_solve(Strategy,ExpValue),close_to(ExpValue,17.25),perm(Strategy,[[play1]]))).
73:- end_tests(dt_winning). 74
75:- begin_tests(dt_umbrella, []). 76:- ensure_loaded(library(examples/dt_umbrella)). 77test(best_st_umbrella):-
78 run((dt_solve(Strategy,ExpValue),close_to(ExpValue,43),perm(Strategy,[[umbrella]]))).
79:- end_tests(dt_umbrella). 80
81:- begin_tests(dt_weather, []). 82:- ensure_loaded(library(examples/dt_weather)). 83test(best_st_weather):-
84 run((dt_solve(Strategy,ExpValue),close_to(ExpValue,77),perm(Strategy,[[decide_u(rainy)]]))).
85:- end_tests(dt_weather). 86
87:- begin_tests(dt_viral, []). 88:- ensure_loaded(library(examples/dt_viral)). 89test(best_st_viral):-
90 ansi_format([bold,fg(cyan)], '~nThis test takes some time.~n',[]),
91 92 run((dt_solve(Strategy,ExpValue),close_to(ExpValue,3.21),perm(Strategy,[[marketed(theo)],[marketed(martijn)],[marketed(ingo)],[marketed(guy)]]))).
93:- end_tests(dt_viral). 94
95:- begin_tests(tabling_probs, []). 96:- ensure_loaded(library(examples/dt_viral_probs)). 97test(correct_probs):-
98 run((compute_probs(PB,PI,PT,PA,PG,PM,PL,PK),close_to(PB,0.420),close_to(PI,0.480),close_to(PT,0.486),close_to(PA,0.384),close_to(PG,0.480),close_to(PM,0.486),close_to(PL,0.490),close_to(PK,0.291))).
99:- end_tests(tabling_probs). 100
101:- begin_tests(coin, []). 102
103:-ensure_loaded(library(examples/coin)). 104
105test(h_c):-
106 run((prob(heads(coin),P),close_to(P,0.51))).
107test(h_c_b):-
108 run(((prob(heads(coin),P),bar(P,C)),close_to(P,0.51),is_dict(C))).
109test(h_c_b2):-
110 run(((prob(heads(coin),P),bar1(P,C)),close_to(P,0.51),is_dict(C))).
111test(h_c_b_c):-
112 run((prob((heads(coin),biased(coin)),P),close_to(P,0.06))).
113test(t_c):-
114 run((prob(tails(coin),P),close_to(P,0.49))).
115test(h_c_g_b_c):-
116 run((prob(heads(coin),biased(coin),P),close_to(P,0.6))).
117test(h_c_n_b_c):-
118 run((prob((heads(coin),\+ biased(coin)),P),close_to(P,0.45))).
119test(n_h_c):-
120 run((prob(\+ heads(coin),P),close_to(P,0.49))).
121
122:- end_tests(coin). 123
124:- begin_tests(coin_mpe, []). 125
126:-ensure_loaded(library(examples/coin_mpe)). 127
128test(h_c):-
129 run((map(heads(coin),Prob,Exp),close_to(Prob,0.27),
130 perm(Exp, [rule(2,fair(coin),[fair(coin):0.9,biased(coin):0.1],true),
131 rule(0,heads(coin),[heads(coin):0.5,tails(coin):0.5],(toss(coin),\+biased(coin))),
132 rule(1,heads(coin),[heads(coin):0.6,tails(coin):0.4],(toss(coin),biased(coin)))]
133 ))).
134:- end_tests(coin_mpe). 135
136:- begin_tests(coinmsw, []). 137
138:-ensure_loaded(library(examples/coinmsw)). 139
140test(r_c_h):-
141 run((prob(res(coin,heads),P),close_to(P,0.51))).
142test(r_c_t):-
143 run((prob(res(coin,tails),P),close_to(P,0.49))).
144
145:- end_tests(coinmsw). 146
147:- begin_tests(coinmsw_memo, []). 148
149:-ensure_loaded(library(examples/coinmsw_memo)). 150
151test(r_c_h):-
152 run((prob(res(coin,heads),fairness(coin,fair),P),close_to(P,0.5))).
153test(r_c_t):-
154 run((prob(res(coin,tails),fairness(coin,fair),P),close_to(P,0.5))).
155
156:- end_tests(coinmsw_memo). 157
158:- begin_tests(dice, []). 159
160:-ensure_loaded(library(examples/dice)). 161
162test(on_0_1):-
163 run((prob(on(0,1),P),close_to(P,0.16666666666666666))).
164test(on_1_1):-
165 run((prob(on(1,1),P),close_to(P,0.13888888888888887))).
166test(on_2_1):-
167 run((prob(on(2,1),P),close_to(P,0.11574074074074071))).
168test(on_2_1_0_1):-
169 run((prob(on(2,1),on(0,1),P),close_to(P,0.13888888888888887))).
170test(on_2_1_ev):-
171 run((prob(on(2,1),evidence,P),close_to(P,0.16666666666666666))).
172
173:- end_tests(dice). 174
175:- begin_tests(epidemic, []). 176
177:-ensure_loaded(library(examples/epidemic)). 178
179test(ep):-
180 run((prob(epidemic,P),close_to(P,0.588))).
181test(pan):-
182 run((prob(pandemic,P),close_to(P,0.357))).
183
184:- end_tests(epidemic). 185
186:- begin_tests(earthquake, []). 187
188:-ensure_loaded(library(examples/earthquake)). 189
190test(s_s):-
191 run((prob(earthquake(stromboli,strong),P),close_to(P,0.43999999999999995))).
192test(s_m):-
193 run((prob(earthquake(stromboli,moderate),P),close_to(P,0.7999999999999998))).
194test(e_s):-
195 run((prob(earthquake(eyjafjallajkull,strong),P),close_to(P,0.2))).
196test(e_m):-
197 run((prob(earthquake(eyjafjallajkull,moderate),P),close_to(P,0.6))).
198:- end_tests(earthquake). 199
200
201:- begin_tests(sneezing, []). 202
203:-ensure_loaded(library(examples/sneezing)). 204
205test(s_s):-
206 run((prob(strong_sneezing(bob),P),close_to(P,0.43999999999999995))).
207test(m_s):-
208 run((prob(moderate_sneezing(bob),P),close_to(P,0.7999999999999998))).
209
210:- end_tests(sneezing). 211
212:- begin_tests(trigger, []). 213
214:-ensure_loaded(library(examples/trigger)). 215
216test(death):-
217 run((prob(death,P),close_to(P,0.305555555555556))).
218
219:- end_tests(trigger). 220
221
222:- begin_tests(light, []). 223
224:-ensure_loaded(library(examples/light)). 225
226test(light):-
227 run((prob(light,P),close_to(P,0.4))).
228test(replace):-
229 run((prob(replace,P),close_to(P,0.6))).
230
231:- end_tests(light). 232
233:- begin_tests(threesideddice, []). 234
235:-ensure_loaded(library(examples/threesideddice)). 236
237test(on_0_1):-
238 run((prob(on(0,1),P),close_to(P,0.333333333333333))).
239test(on_1_1):-
240 run((prob(on(1,1),P),close_to(P,0.222222222222222))).
241test(on_2_1):-
242 run((prob(on(2,1),P),close_to(P,0.148148147703704))).
243
244test(on_2_1_0_1):-
245 run((prob(on(2,1),on(0,1),P),close_to(P,0.222222222222222))).
246test(on_2_1_1_1):-
247 run((prob(on(2,1),on(1,1),P),close_to(P,0.333333333333333))).
248
249:- end_tests(threesideddice). 250
251:- begin_tests(bloodtype, []). 252
253:-ensure_loaded(library(examples/bloodtype)). 254
255test(pc_p_f_a):-
256 run((prob(pchrom(p_f,a),Prob),
257 close_to(Prob, 0.318))).
258
259test(p_f_a):-
260 run((prob(pchrom(p_f,a),Prob),
261 close_to(Prob, 0.3))).
262
263test(p_a):-
264 run((prob(bloodtype(p,a),Prob),
265 close_to(Prob, 0.3186942939999999))).
266
267test(p_b):-
268 run((prob(bloodtype(p,b),Prob),
269 close_to(Prob, 0.2239874943000002))).
270
271test(p_aa):-
272 run((prob(bloodtype(p,ab),Prob),
273 close_to(Prob, 0.19329257700000035))).
274
275test(p_null):-
276 run((prob(bloodtype(p,null),Prob),
277 close_to(Prob, 0.16751706690000012))).
278
279:- end_tests(bloodtype). 280
281:- begin_tests(mendel, []). 282
283:-ensure_loaded(library(examples/mendel)). 284
285
286test(s_1_p):-
287 run((prob(cg(s,1,p),P),close_to(P,0.5))).
288test(s_1_w):-
289 run((prob(cg(s,1,w),P),close_to(P,0.5))).
290test(s_2_p):-
291 run((prob(cg(s,2,p),P),close_to(P,0.5))).
292test(s_2_w):-
293 run((prob(cg(s,2,w),P),close_to(P,0.5))).
294
295:- end_tests(mendel). 296
297:- begin_tests(mendel_mpe, []). 298
299:-ensure_loaded(library(examples/mendel_mpe)). 300
301test(s_p):-
302 run((map(color(s,purple),Prob,Exp),close_to(Prob,0.5),
303 perm(Exp, [rule(0, cg(s, 1, p), [cg(s, 1, p):0.5, cg(s, 1, w):0.5],
304 [mother(m, s), cg(m, 1, p), cg(m, 2, w)])]))).
305
306
307test(s_w):-
308 run((map(color(s,white),Prob,Exp),close_to(Prob,0.25),
309 perm(Exp, [rule(0, cg(s, 1, w), [cg(s, 1, p):0.5, cg(s, 1, w):0.5],
310 [mother(m, s), cg(m, 1, p), cg(m, 2, w)]),
311 rule(1, cg(s, 2, w), [cg(s, 2, w):0.5, cg(s, 2, p):0.5],
312 [father(f, s), cg(f, 1, w), cg(f, 2, p)])]))).
313
314:- end_tests(mendel_mpe). 315
316:- begin_tests(coin2, []). 317
318:-ensure_loaded(library(examples/coin2)). 319
320test(h_coin1):-
321 run((prob(heads(coin1),P),close_to(P,0.51))).
322test(h_coin2):-
323 run((prob(heads(coin2),P),close_to(P,0.51))).
324
325test(t_coin1):-
326 run((prob(tails(coin1),P),close_to(P,0.49))).
327test(t_coin2):-
328 run((prob(tails(coin2),P),close_to(P,0.49))).
329
330:- end_tests(coin2). 331
332:- begin_tests(simpson, []). 333
334:-ensure_loaded(library(examples/simpson)). 335
336test(r_d):-
337 run((prob(recovery,drug,P),close_to(P,0.5))).
338test(r_n_d):-
339 run((prob(recovery,\+ drug,P),close_to(P,0.4))).
340test(d_f):-
341 run((prob(recovery,(drug,female),P),close_to(P,0.2))).
342test(n_d_f):-
343 run((prob(recovery,(\+drug,female),P),close_to(P,0.3))).
344test(d_n_m):-
345 run((prob(recovery,(drug,\+female),P),close_to(P,0.6))).
346test(n_d_m):-
347 run((prob(recovery,(\+ drug,\+female),P),close_to(P,0.7))).
348test(d_d):-
349 run((prob(recovery,do(drug),P),close_to(P,0.4))).
350test(d_n_d):-
351 run((prob(recovery,do(\+ drug),P),close_to(P,0.5))).
352test(d_d_f):-
353 run((prob(recovery,(do(drug),female),P),close_to(P,0.2))).
354test(d_n_d_f):-
355 run((prob(recovery,(do(\+drug),female),P),close_to(P,0.3))).
356test(d_d_m):-
357 run((prob(recovery,(do(drug),\+ female),P),close_to(P,0.6))).
358test(d_n_d_m):-
359 run((prob(recovery,(do(\+ drug),\+ female),P),close_to(P,0.7))).
360
361:- end_tests(simpson). 362
363
364:- begin_tests(viral, []). 365
366:-ensure_loaded(library(examples/viral)). 367
368test(h_2_3):-
369 run((prob(has(2),has(3),P),close_to(P,0.4065135474609725))).
370test(h_2_d_3):-
371 run((prob(has(2),do(has(3)),P),close_to(P,0.136))).
372
373:- end_tests(viral). 374
375:- begin_tests(uwcse, []). 376
377:-ensure_loaded(library(examples/uwcse_inf)). 378
379test(t_c1_p1):-
380 run((prob(taught_by(c1,p1),P),close_to(P,0.0926040439925477))).
381
382:- end_tests(uwcse). 383
384:- begin_tests(path, []). 385
386:-ensure_loaded(library(examples/path)). 387
388test(p_a_e):-
389 run((prob(path(a,e),P),close_to(P,0.22888))).
390
391:- end_tests(path). 392
393:- begin_tests(pathdb, []). 394
395:-ensure_loaded(library(examples/pathdb)). 396
397test(p_a_e):-
398 run((prob(path(a,e),P),close_to(P,0.22888))).
399
400:- end_tests(pathdb). 401
402:- begin_tests(multiple_paths_simple, []). 403
404:-ensure_loaded(library(examples/multiple_paths_simple)). 405
406test(p):-
407 run((prob(p,P),close_to(P,0.54))).
408
409:- end_tests(multiple_paths_simple). 410
411:- begin_tests(multiple_paths, []). 412
413:-ensure_loaded(library(examples/multiple_paths)). 414
415test(p):-
416 run((prob(p,P),close_to(P,0.0636))).
417
418:- end_tests(multiple_paths). 419
420:- begin_tests(abd1, []). 421
422:-ensure_loaded(library(examples/abd1)). 423
424test(a):-
425 run((abd_prob(a,P,Exp),close_to(P,0.72),perm_map(Exp,[[e,c]]))).
426test(bdd_a):-
427 run((abd_bdd_dot_string(a,_BDD,_Var,_VarA,P,Exp),close_to(P,0.72),perm_map(Exp,[[e,c]]))).
428
429:- end_tests(abd1). 430
431:- begin_tests(abd1cons1, []). 432
433:-ensure_loaded(library(examples/abd1cons1)). 434
435test(a):-
436 run((abd_prob(a,P,Delta),Delta=[[e]],close_to(P,0.6))).
437
438:- end_tests(abd1cons1). 439
440:- begin_tests(abd1cons2, []). 441
442:-ensure_loaded(library(examples/abd1cons2)). 443
444test(a):-
445 run((abd_prob(a,P,Exp),close_to(P,0.648),perm_map(Exp,[[c,e]]))).
446
447:- end_tests(abd1cons2). 448
449:- begin_tests(abd2, []). 450
451:-ensure_loaded(library(examples/abd2)). 452
453test(a):-
454 run((abd_prob(a,P,Exp),close_to(P,0.72),perm_map(Exp,[[f,c,d]]))).
455test(bdd_a):-
456 run((abd_bdd_dot_string(a,_BDD,_Var,_VarA,P,Exp),close_to(P,0.72), perm_map(Exp,[[f,c,d]]))).
457
458:- end_tests(abd2). 459
460:- begin_tests(abd3, []). 461
462:-ensure_loaded(library(examples/abd3)). 463
464test(a):-
465 run((abd_prob(a,P,Exp),close_to(P,0.72),perm_map(Exp,[[c,d,f]]))).
466test(bdd_a):-
467 run((abd_bdd_dot_string(a,_BDD,_Var,_VarA,P,Exp),close_to(P,0.72),
468 perm_map(Exp,[[c,d,f]]))).
469
470:- end_tests(abd3). 471
472:- begin_tests(bag_game_mpe, []). 473
474:-ensure_loaded(library(examples/bag_game_mpe)). 475
476test(winb):-
477 run((map_bdd_dot_string(win,_BDD,_Var,_VarA,P,Exp),close_to(P,0.162),
478 perm(Exp,[
479 rule(0, '', [red:0.4, '':0.6], true),
480 rule(2, blue, [blue:0.5, '':0.5], true),
481 rule(3, yellow, [yellow:0.6, '':0.4], true),
482 rule(1, green, [green:0.9, '':0.09999999999999998], true)
483 ]))).
484
485test(win):-
486 run((map(win,P,Exp),close_to(P,0.162),
487 perm(Exp,[
488 rule(0, '', [red:0.4, '':0.6], true),
489 rule(2, blue, [blue:0.5, '':0.5], true),
490 rule(3, yellow, [yellow:0.6, '':0.4], true),
491 rule(1, green, [green:0.9, '':0.09999999999999998], true)
492 ]))).
493:- end_tests(bag_game_mpe). 494
495:- begin_tests(bag_pb_mpe, []). 496
497:-ensure_loaded(library(examples/bag_pb_mpe)). 498
499test(ev):-
500 run((map(ev,P,Exp),close_to(P,0.27),
501 perm(Exp,[
502 rule(2,pf(2,1),[pf(2,1):0.6,'':0.4],true),
503 rule(1,pf(1,2),[pf(1,2):0.75,'':0.25],true),
504 rule(0,pf(1,1),[pf(1,1):0.6,'':0.4],true)
505 ]))).
506
507test(evb):-
508 run((map_bdd_dot_string(ev,_BDD,_Var,_VarA,P,Exp),close_to(P,0.27),
509 perm(Exp,[
510 rule(2,pf(2,1),[pf(2,1):0.6,'':0.4],true),
511 rule(1,pf(1,2),[pf(1,2):0.75,'':0.25],true),
512 rule(0,pf(1,1),[pf(1,1):0.6,'':0.4],true)
513 ]))).
514
515:- end_tests(bag_pb_mpe). 516
517:- begin_tests(bag_simple, []). 518
519:-ensure_loaded(library(examples/bag_simple)). 520
521test(evb):-
522 run((map_bdd_dot_string(ev,_BDD,_Var,_VarA,P,Exp),close_to(P,0.6),
523 perm(Exp,[
524 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
525 ]))).
526test(ev):-
527 run((map(ev,P,Exp),close_to(P,0.6),
528 perm(Exp,[
529 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
530 ]))).
531:- end_tests(bag_simple). 532
533:- begin_tests(bag_mpe, []). 534
535:-ensure_loaded(library(examples/bag_mpe)). 536
537test(evb):-
538 run((map_bdd_dot_string(ev,_BDD,_Var,_VarA,P,Exp),close_to(P,0.36),
539 perm(Exp,[
540 rule(1, pick(b1), [pick(b1):0.6, no_pick(b1):0.4], true),
541 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
542 ]))).
543test(ev):-
544 run((map(ev,P,Exp),close_to(P,0.36),
545 perm(Exp,[
546 rule(1, pick(b1), [pick(b1):0.6, no_pick(b1):0.4], true),
547 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
548 ]))).
549:- end_tests(bag_mpe). 550
551:- begin_tests(eruption_mpe, []). 552
553:-ensure_loaded(library(examples/eruption_mpe)). 554
555test(eruption):-
556 run((map(eruption,P,Exp),close_to(P,0.08316),
557 perm(Exp,[rule(1,sudden_energy_release,[sudden_energy_release:0.7,'':0.30000000000000004],true),
558 rule(2,fault_rupture(southwest_northeast),[fault_rupture(southwest_northeast):0.6,'':0.4],true),
559 rule(3,fault_rupture(east_west),[fault_rupture(east_west):0.55,'':0.44999999999999996],true),
560 rule(0,eruption,[eruption:0.6,earthquake:0.3,'':0.10000000000000003],(sudden_energy_release,fault_rupture(southwest_northeast))),
561 rule(0,eruption,[eruption:0.6,earthquake:0.3,'':0.10000000000000003],(sudden_energy_release,fault_rupture(east_west)))
562 ]))).
563:- end_tests(eruption_mpe). 564
565:- begin_tests(bag_1, []). 566
567:-ensure_loaded(library(examples/bag_1)). 568
569test(evb):-
570 run((map_bdd_dot_string(ev,_BDD,_Var,_VarA,P,Exp),close_to(P,0.54),
571 perm(Exp,[
572 rule(1, pick(b1), [pick(b1):0.6, no_pick(b1):0.4], true)
573 ]))).
574test(ev):-
575 run((map(ev,P,Exp),close_to(P,0.54),
576 perm(Exp,[
577 rule(1, pick(b1), [pick(b1):0.6, no_pick(b1):0.4], true)
578 ]))).
579:- end_tests(bag_1). 580
581:- begin_tests(bag_2, []). 582
583:-ensure_loaded(library(examples/bag_2)). 584test(evb):-
585 run((map_bdd_dot_string(ev,_BDD,_Var,_VarA,P,Exp),close_to(P,0.6),
586 perm(Exp,[
587 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
588 ]))).
589test(ev):-
590 run((map(ev,P,Exp),close_to(P,0.6),
591 perm(Exp,[
592 rule(0, red(b1), [red(b1):0.6, green(b1):0.3, blue(b1):0.1], pick(b1))
593 ]))).
594:- end_tests(bag_2). 595
596
597:- begin_tests(hmm_mpe, []). 598
599:-ensure_loaded(library(examples/hmm_mpe)). 600
601test(hmm_a_g):-
602
603 run((map(hmm([a,g]),P,Exp),close_to(P,0.00054),
604 perm(Exp,
605 [rule(0,next_state(q1,q2,[]),[next_state(q1,q1,[]):0.5,next_state(q1,q2,[]):0.45,next_state(q1,end,[]):0.05],true),
606 rule(2,letter(q1,a,[]),[letter(q1,a,[]):0.4,letter(q1,c,[]):0.3,letter(q1,g,[]):0.2,letter(q1,t,[]):0.1],true),
607 rule(0,next_state(q1,q1,[q1]),[next_state(q1,q1,[q1]):0.5,next_state(q1,q2,[q1]):0.45,next_state(q1,end,[q1]):0.05],true),
608 rule(2,letter(q1,a,[q1]),[letter(q1,a,[q1]):0.4,letter(q1,c,[q1]):0.3,letter(q1,g,[q1]):0.2,letter(q1,t,[q1]):0.1],true),
609 rule(1,next_state(q2,end,[q1]),[next_state(q2,q1,[q1]):0.45,next_state(q2,q2,[q1]):0.5,next_state(q2,end,[q1]):0.05],true),
610 rule(3,letter(q2,g,[q1]),[letter(q2,a,[q1]):0.1,letter(q2,c,[q1]):0.2,letter(q2,g,[q1]):0.3,letter(q2,t,[q1]):0.4],true)]
611 ))).
612
613:- end_tests(hmm_mpe). 614
615:- begin_tests(meta, []). 616
617:-ensure_loaded(library(examples/meta)). 618
619test(meta):-
620 run((prob(a,Prob),close_to(Prob,0.2)
621 )).
622
623:- end_tests(meta). 624
625
626:- begin_tests(var_objdb, []). 627
628:-ensure_loaded(library(examples/var_objdb)). 629
630test(obj):-
631 run((prob(obj(2),Prob),close_to(Prob, 0.08190000000000008)
632 )).
633
634test(nobj):-
635 run((prob(numObj(0,2),Prob),close_to(Prob,0.06300000000000006)
636 )).
637
638:- end_tests(var_objdb). 639
640
641:- begin_tests(pcfg, []). 642
643:-ensure_loaded(library(examples/pcfg)). 644
645test(pcfg):-
646 run((prob(pcfg([a,b,a,a]),Prob),close_to(Prob,0.0024,0.0001)
647 )).
648
649:- end_tests(pcfg). 650
651
652:- begin_tests(pcfglrdb, []). 653
654:-ensure_loaded(library(examples/pcfglrdb)). 655
656test(pcfglrdb):-
657 run((prob(pcfg([a]),Prob),close_to(Prob,0.3)
658 )).
659
660:- end_tests(pcfglrdb). 661
662:- begin_tests(card, []). 663
664:-ensure_loaded(library(examples/card)). 665
666test(card):-
667 run((prob(pair,Prob),close_to(Prob,0.07692307692307693))).
668
669:- end_tests(card). 670
671:- begin_tests(card_body, []). 672
673:-ensure_loaded(library(examples/card_body)). 674
675test(card_body):-
676 run((prob(pair,Prob),close_to(Prob,0.07692307692307693))).
677
678:- end_tests(card_body). 679
680:- begin_tests(card_disc, []). 681
682:-ensure_loaded(library(examples/card_disc)). 683
684test(card_disc):-
685 run((prob(pair,Prob),close_to(Prob,0.07692307692307693))).
686
687:- end_tests(card_disc). 688
689:- begin_tests(card_disc_body, []). 690
691:-ensure_loaded(library(examples/card_disc_body)). 692
693test(card_disc_body):-
694 run((prob(pair,Prob),close_to(Prob,0.07692307692307693))).
695
696:- end_tests(card_disc_body).