/******************************************************************************** A Bayesian network for fault diagnosis in a power supply network modelled in PRISM pp: a power plant wi: wires ni: connecting nodes vi: villages ~~~~~~ || __ ######## w1 w2 w3 w4 /||\ ## pp ##---------(n1)---------(n2)---------(n3)---------[v3] ######## | | | ######## | w5 | w6 | w7 | | | | __ __ (n4) /||\ /||\ / \ [v1] [v2] w8 / \ w9 / \ __ __ /||\ /||\ [v4] [v5] Each entity may be *up* or *down* meaning: - for pp, whether it is working or not - for ni and vi, whether electric current is present - for wi, whether it is able to port electric current or not (read up/down literally) The villages are observables, meaning that information about whether each village has electricity or not can be observed. The state of the other entities are 'hidden' in the sense that from observations we will try to figure out the most probably states of other components. This is useful in order to decide where it is best to send out a repair team to check entities and possibly repair them. Whether the power plant or a given wire is up or down is independent of anything else. Whether any other given entity ni or vi is up or down depends on the previous ni-or-vi-or-pp and the wire supposed to connect them. In the probabilities below, we assume a very high reliability of any component, and we assume also a small small probability that electricity is observed at a given place even if the there is no electricity in the previous node or connecting cable is down - this may be due to disturbed information or the unlikely event that the villagers has set up some a small motor driven electricity generator. As we will se below, the high prior probability that wires and other entities are up has unexpected consequences. (C) Henning Christiansen, 2007 *********************************************************************/ values(pp, [ppup,ppdown]). values(w1, [w1up,w1down]). values(w2, [w2up,w2down]). values(w3, [w3up,w3down]). values(w4, [w4up,w4down]). values(w5, [w5up,w5down]). values(w6, [w6up,w6down]). values(w7, [w7up,w7down]). values(w8, [w8up,w8down]). values(w9, [w9up,w9down]). values(n1(_,_), [n1up,n1down]). %n(ppState,w1state) values(n2(_,_), [n2up,n2down]). %n(n1State,w2state) values(n3(_,_), [n3up,n3down]). %n(n2State,w3state) values(n4(_,_), [n4up,n4down]). %n(n1State,w5state) values(v1(_,_), [v1up,v1down]). %n(n2State,w6state) values(v2(_,_), [v2up,v2down]). %n(n3State,w7state) values(v3(_,_), [v3up,v3down]). %n(n3State,w4state) values(v4(_,_), [v4up,v4down]). %n(n4State,w8state) values(v5(_,_), [v5up,v5down]). %n(n4State,w9state) target(observable_world,5). observable_world(V1,V2,V3,V4,V5):- world(PP,W1,W2,W3,W4,W5,W6,W7,W8,W9, N1,N2,N3,N4, V1,V2,V3,V4,V5). world(PP,W1,W2,W3,W4,W5,W6,W7,W8,W9, N1,N2,N3,N4, V1,V2,V3,V4,V5):- msw(pp,PP), msw(w1,W1), msw(w2,W2), msw(w3,W3), msw(w4,W4), msw(w5,W5), msw(w6,W6), msw(w7,W7), msw(w8,W8), msw(w9,W9), msw(n1(PP,W1),N1), msw(n2(N1,W2),N2), msw(n3(N2,W3),N3), msw(n4(N1,W5),N4), msw(v1(N2,W6),V1), msw(v2(N3,W7),V2), msw(v3(N3,W4),V3), msw(v4(N4,W8),V4), msw(v5(N4,W9),V5). set_params:- set_sw(pp, [0.999,0.001]), set_sw(w1, [0.999,0.001]), set_sw(w2, [0.999,0.001]), set_sw(w3, [0.999,0.001]), set_sw(w4, [0.999,0.001]), set_sw(w5, [0.999,0.001]), set_sw(w6, [0.999,0.001]), set_sw(w7, [0.999,0.001]), set_sw(w8, [0.999,0.001]), set_sw(w9, [0.999,0.001]), set_sw(n1(ppup,w1up), [0.999,0.001]), set_sw(n1(ppup,w1down), [0.001, 0.999]), set_sw(n1(ppdown,w1up), [0.001, 0.999]), set_sw(n1(ppdown,w1down), [0.001, 0.999]), set_sw(n2(n1up,w2up), [0.999,0.001]), set_sw(n2(n1up,w2down), [0.001, 0.999]), set_sw(n2(n1down,w2up), [0.001, 0.999]), set_sw(n2(n1down,w2down), [0.001, 0.999]), set_sw(n3(n2up,w3up), [0.999,0.001]), set_sw(n3(n2up,w3down), [0.001, 0.999]), set_sw(n3(n2down,w3up), [0.001, 0.999]), set_sw(n3(n2down,w3down), [0.001, 0.999]), set_sw(n4(n1up,w5up), [0.999,0.001]), set_sw(n4(n1up,w5down), [0.001, 0.999]), set_sw(n4(n1down,w5up), [0.001, 0.999]), set_sw(n4(n1down,w5down), [0.001, 0.999]), set_sw(v1(n2up,w6up), [0.999,0.001]), set_sw(v1(n2up,w6down), [0.001, 0.999]), set_sw(v1(n2down,w6up), [0.001, 0.999]), set_sw(v1(n2down,w6down), [0.001, 0.999]), set_sw(v2(n3up,w7up), [0.999,0.001]), set_sw(v2(n3up,w7down), [0.001, 0.999]), set_sw(v2(n3down,w7up), [0.001, 0.999]), set_sw(v2(n3down,w7down), [0.001, 0.999]), set_sw(v3(n3up,w4up), [0.999,0.001]), set_sw(v3(n3up,w4down), [0.001, 0.999]), set_sw(v3(n3down,w4up), [0.001, 0.999]), set_sw(v3(n3down,w4down), [0.001, 0.999]), set_sw(v4(n4up,w8up), [0.999,0.001]), set_sw(v4(n4up,w8down), [0.001, 0.999]), set_sw(v4(n4down,w8up), [0.001, 0.999]), set_sw(v4(n4down,w8down), [0.001, 0.999]), set_sw(v5(n4up,w9up), [0.999,0.001]), set_sw(v5(n4up,w9down), [0.001, 0.999]), set_sw(v5(n4down,w9up), [0.001, 0.999]), set_sw(v5(n4down,w9down), [0.001, 0.999]). :- set_params. w1:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,query,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)). w2:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,query,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)). w3:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,query,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)). w4:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,query,_,_,_,_,_,_,_,_,_,_,_,_,_,_)). w5:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,_,query,_,_,_,_,_,_,_,_,_,_,_,_,_)). w6:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,_,_,query,_,_,_,_,_,_,_,_,_,_,_,_)). w7:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,_,_,_,query,_,_,_,_,_,_,_,_,_,_,_)). w8:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,_,_,_,_,query,_,_,_,_,_,_,_,_,_,_)). w9:- chindsight_agg(observable_world(v1up,v2down,v3up,v4down,v5down), world(_,_,_,_,_,_,_,_,_,query,_,_,_,_,_,_,_,_,_)). ww:- w1,w2,w3,w4,w5,w6,w7,w8,w9. /******************* | ?- w7. conditional hindsight probabilities: world(*,*,*,*,*,*,*,w7up,*,*,*,*,*,*,*,*,*,*,*): 0.500875149097325 world(*,*,*,*,*,*,*,w7down,*,*,*,*,*,*,*,*,*,*,*): 0.499124850902673 DISCUSSION: This seems counterintuitive. When v2 has no electricity, we should believe that there is a high probability that w7 is down: As electricity reaches v1 and all parts are generally reliable, there is high probability that n3 is up, so - intuitively - w7 must be down. However, w7 has a very high prior probability for being up - which means therefore that the possibility that electricity shows up somewhere against the facts that there is seemingly no electricity going into the place is given a chance so to speak. ******************/