type House; type Facility; type Customer; type Neighbourhood; type Exclusivity; type Age; guaranteed Neighbourhood Good, Bad; guaranteed Exclusivity High, Low; guaranteed Age Young, Old; random Neighbourhood Neighbourhood(House); random Boolean Cheap(House); random Exclusivity Exclusivity(Facility); random Age Age(Customer); random Boolean Rich(Customer); random Boolean Wants(Customer, Facility); random Boolean Has(House, Facility); random Boolean Interested(Customer, House); random Boolean Buys(Customer,House); //p1 = 0.3 Age(c){ ~ TabularCPD[[0.3,0.7]]() }; //p2 = 0.3 Exclusivity(f){ ~ TabularCPD[[0.3,0.7]]() }; //p3 = 0.7 Neighbourhood(h){ ~ TabularCPD[[0.3,0.7]]() }; //p4 = 0.5 Wants(c,f) { ~ TabularCPD[[0.5,0.5]]() }; //p5 = 0.3 //p6 = 0.6 Rich(c) { if (Age(c) = Old) then ~ TabularCPD[[0.3,0.7]]() else ~ TabularCPD[[0.6,0.4]]() }; //p7 = 0.2 //p8 = 0.3 //p9 = 0.4 Has(h,f) { ~ TabularCPD[[0.4], [0.3], [0.2], [0.4]](Exclusivity(f), Neighbourhood(h)) }; random NaturalNum A(House); A(h) ~ Binomial[0.1](#{Facility f: Has(h,f)=true}); Cheap(h) if A(h)=0 then ~ TabularCPD[[1,0]]() else ~ TabularCPD[[0,1]](); //p11 = 0.7 //p12 = 0.4 Interested(c,h) { if (exists Facility f (Has(h,f) & Wants(c,f))) then ~ TabularCPD[[0.7,0.3]]() else ~ TabularCPD[[0.4,0.6]]() }; //p13 = 0.2 //p14 = 0.7 //p15 = 0.6 //p16 = 0.1 Buys(c,h){ if (!Interested(c,h)) then ~ TabularCPD[[0.2,0.8]]() elseif (Interested(c,h) & Rich(c) = true) then ~ TabularCPD[[0.7,0.3]]() elseif (Interested(c,h) & Rich(c) = false & Cheap(h)= true) then ~ TabularCPD[[0.6,0.4]]() else ~ TabularCPD[[0.1,0.9]]() //interested, not rich and not cheap };