Σχόλια 0

Το κείμενο του εγγράφου

Applying Bayesian networksin the game of MinesweeperMarta VomlelovaFaculty of Mathematics and PhysicsCharles University in Praguehttp://kti.mff.cuni.cz/~marta/Jir VomlelInstitute of Information Theory and Automation of the AS CRAcademy of Sciences of the Czech Republichttp://www.utia.cas.cz/vomlelAbstractWe use the computer game of Minesweeper to illustrate few model-ing tricks utilized when applying Bayesian network (BN) models in realapplications.Among others,we apply rank-one decomposition (ROD) toconditional probability tables (CPTs) representing addition.Typically,this transformation helps to reduce the computational complexity of prob-abilistic inference with the BN model.However,in this paper we will seethat (except for the total sum node) when ROD is applied to the wholeCPT it does not bring any savings for the BN model of Minesweeper.Actually,in order to gain from ROD we need minimal rank-one decom-positions of CPTs when the state of the dependent variable is observed.But this is not known and it is a topic for our future research.1 IntroductionThe game of Minesweeper is a one-player grid game.It is bundled with severalcomputer operating systems,e.g.,with Windows or with the KDE desktopenvironment.The game starts with a grid of n  m blank elds.During thegame the player clicks on dierent elds.If the player clicks on a eld containinga mine then the game is over.Otherwise the player gets information on howmany elds in the neighborhood of the selected eld contain a mine.The goal ofthe game is to discover all mines without clicking on any of them.In Figure 1 wepresent two screenshots from the game.For more information on Minesweepersee,e.g.,Wikipedia [12].J.Vomlel was supported by grants number 1M0572 and 2C06019 (MSMTCR),ICC/08/E010 (Eurocores LogICCC),and 201/09/1891 (GACR).2 M.VOMLELOVA,J.VOMLELFigure 1:Two screenshots from the game of Minesweeper.The screenshot onthe right hand side is taken after the player stepped on a mine.It shows theactual position of mines.Bayesian networks (BNs) [8,5,4] are probabilistic graphical models that useacyclic directed graphs (DAGs) G = (V;E) to encode conditional independencerelations among random variables associated with the nodes of the graph.Thequantitative part of a BN are conditional probability tables (CPTs) P(Xijpa(Xi));i 2 V that dene together the joint probability distribution representedby the BN as the productP(Xi;i 2 V ) =Yi2VP(Xijpa(Xi)):(1)In many real applications the CPTs have a special local structure that can befurther exploited to gain even more ecient inference.Examples of such CPTsare CPTs representing functional (i.e.deterministic) dependence or CPTs repre-senting noisy functional dependence:noisy-or,noisy-and,noisy-max,noisy-min,etc.A method that allows to use the local structure within standard inferencetechniques (such as [6,3]) is the rank-one decomposition of CPTs [2,11,10].A typical task solved by BNs is the computation of conditional probabilitiesgiven an evidence inserted in the model.In the game of Minesweeper the playeris interested in the probabilities of a mine at all elds of the grid given theobservations she has made.The reader may ask why for solving this deterministic game we use BNsinstead of the standard techniques of constraint processing.The reason is thatwe aim at more general problems that correspond to real applications.Anadvantage of BN models is that they can also represent uncertainty in the mod-Applying Bayesian networks in Minesweeper 3eled domain.This can,for example,model situations when the observations ormeasurements are noisy.In the game of Minesweeper the observations are thepresence or absence of mines.For example,we can extend the BN model ofMinesweeper so that the in uence of mines from the neighboring elds on theobserved count is noisy (i.e.non-deterministic).2 A Bayesian network model for MinesweeperAssume a game of Minesweeper on a nmgrid.The BN model of Minesweepercontains two variables for each eld (i;j) 2 f1;:::;ng  f1;:::;mg on thegame grid.The variables in the rst set X = fX1;1;:::;Xn;mg are binary andcorrespond to the (originally unknown) state of each eld of the game grid.Theyhave state 1 if there is a mine on this eld and state 0 otherwise.The variablesin the second set Y = fY1;1;:::;Yn;mg are observations made during the game.Each variables Yi;jhas as its parents1from X that are on the neighboringpositions in the grid,i.e.pa(Yi;j) =Xk;`2 X:k 2 fi 1;i;i +1g;`2 fj 1;j;j +1g;(k;l) 6= (i;j);1  k  n;1 ` m:The variables from Y provide the number of neighbors with a mine.Thereforetheir number of states is the number of their parents plus one.Their CPTs aredened by the addition function for all combinations of states x of pa(Yi;j) andstates y of Yi;jasP(Yi;j= y j pa(Yi;j) = x) =1 if y =Px2xx0 otherwise.(2)Whenever an observation of Yi;jis made the variable Xi;jcan be removedfrom the BN since its state is known.If its state is 1 the game is over,otherwiseit is 0 and the player cannot click on the same eld again.When evidence froman observation is distributed to its neighbors also the node corresponding to theobservation can be removed from the DAG.In addition,we need not include into the BN model observations Yi;jthatwere not observed yet.In order to compute a marginal probability of a variableXi;jwe sum the probability values of the joint probability distribution over allcombinations of states of remaining variables.It holds for all combinations ofstates x of pa(Yi;j) thatXyP(Yk;l= y j pa(Yi;j) = x) = 1therefore the CPT of Yi;jcan be omitted from the joint probability distributionrepresented by the BN.1Since there is a one-to-one mapping between nodes of the DAG of a BN and the variablesof BN we will use the graph notion also when speaking about random variables.4 M.VOMLELOVA,J.VOMLELThe above considerations implies that in every moment of the game wewill have at most one node for each eld (i;j) of the grid.Each node of agraph corresponding to a grid position (i;j) will be indexed by a unique numberg = j +(i 1)  m.3 A standard approach for inference in BNsIn a standard inference technique such as [6] or [3] the DAG of the BN istransformed to an undirected graph so that each subgraph of the DAG of a BNinduced by set variable Y and its parents,say fX1;:::;Xmg,is replaced by thecomplete undirected graph on fY;X1;:::;Xmg.This step is called moralization.See Figure 2.YX1X2XmX2XmYX1Figure 2:The original subgraph of the DAG induced by fY;X1;:::;Xmg andits counterpart after moralization.The second graph transformation is triangulation of the moral graph.Anundirected graph is triangulated if it does not contain an induced subgraph thatis a cycle without a chord of a length of at least four.A set of nodes C  V ofa graph G = (V;E) is a clique if it induces a complete subgraph of G and it isnot a subset of the set of nodes in any larger complete subgraph of G.An important parameter for the inference eciency is the total table sizeafter triangulation.The table size of a clique C in an undirected graph isQi2CjXij,where jXij is the number of states of a variable Xicorrespondingto a node i.The total table size (tts) of a triangulation is dened as the sumof table sizes for all cliques of the triangulated graph.Therefore,it is desirableto nd a triangulation of the original graph having the total table size as smallas possible.Since this problem is known to be NP-hard dierent heuristics areoften used.In this paper we use minweight heuristics [7] (called H1 in [1]),which,in case of binary variables,is equivalent to the minwidth heuristics [9].See Figure 3 for an example of the triangulated moral graph for the standardmethod after twenty observations in the game of Minesweeper on a 1010 grid.During the triangulation we added ve edges only.This is a typical behaviorunless we get long cycles in the moral graph.Applying Bayesian networks in Minesweeper 5123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Figure 3:An example of the triangulated moral graph of the BN after twentyobservations in the game of Minesweeper on a 10  10 grid for the standardmethod.4 Rank-one decomposition of tables represent-ing additionIn the BN model of Minesweeper the CPTs have a special local structure (theycorrespond to addition).Therefore,we can transform the CPTs using tensorrank-one decomposition (ROD) [2,11,10].A minimal ROD of CPTs repre-senting addition was proposed in [10].Assume that X1;:::;Xmare parents of Y,and CPT P(Y j X1;:::;Xm)represents addition and is dened as in formula (2).Then using Theorem 3from [10] we can writeP(Y = y j X1= x1;:::;Xm= xm) =mXb=0b(y) mYi=1'i;b(xi);(3)where for b = 0;:::;m bare real valued functions dened for states f0;1;:::;mg of Y and for i = 1;:::;m'i;bare real valued functions dened for states f0;1g ofXi.This decomposition is called rank-one decomposition (ROD) of addition.Ingraphical terms it means that each subgraph of the DAG of a BN induced by set6 M.VOMLELOVA,J.VOMLELfY;X1;:::;Xmg is replaced by an undirected graph containing one additionalvariable B that is connected by an undirected edge with all variables fromfY;X1;:::;Xmg,see Figure 4.The minimum number of states of B that allowsto write a table in the form of equation (3) is called the rank of the table.Incase of CPT for addition the rank is m+ 1,which means we cannot do thisdecomposition with less than m+1 states of B.YX1X2XmYX1X2XmBFigure 4:The original subgraph of the DAG induced by fY;X1;:::;Xmg andits counterpart after ROD.In our current approach we use only a part of table bcorresponding tothe observed state y.This implies we can eliminate node corresponding to thevariable Y from the graph,so that there is only one node in the graph (i.e,nodecorresponding to varible B) for the corresponding eld of the grid.The second graph transformation is again triangulation,but this time ap-plied to the undirected graph after ROD.See Figure 5 for an example of the graph for the model after ROD andafter twenty observations in the game of Minesweeper on a 10 10 grid.Note,that while for variables corresponding to unobserved elds of the game grid thenumber of states is two,for the variables corresponding to the observed eldsof the game grid the number of states is typically higher (up to eight states)in the model after ROD.However,there are fewer edges than in the standardapproach but during triangulation we added 73 edges,which is much more thanfor the triangulated moral graph produced by the standard approach.For thetriangulated graph of the graph from Figure 5 see Figure 6.During the computations with the model after ROD we decrease the num-ber of states of observed nodes Yi;jand of corresponding Bi;jby one for eachobserved parent and modify the CPT accordingly.At the same time we deleteedges from parents with evidence to observed nodes.The node for the total number of mines in the gameTypically,in the game of Minesweeper the total number of mines z is known inadvance.If we want to exploit this information we need to extend the modelby one auxiliary node Z that will impose this constraint.This node has theApplying Bayesian networks in Minesweeper 7123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Figure 5:An example of the graph of the BN after ROD and after the sametwenty observations as in Figure 3 in the game of Minesweeper on a 10  10grid.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Figure 6:Triangulated graph of the graph from Figure 5.8 M.VOMLELOVA,J.VOMLELnumber of states equal to the total number of elds on the game grid plus one,which is n  m+1.It has all binary nodes from the set X = fX1;1;:::;Xn;mgas its parents and we enter the evidence Z = z in the BN model.If we used the standard approach described in Section 3 for node Z we wouldget a complete graph over all nodes from X.This would make the BN model ofthe game intractable for larger values of n  m.However,since we use ROD for node Z we connect it with all nodes from Xbut we do not require nodes from X to be pairwise connected.The total tablesize of the BN with node Z after ROD is n  m larger than the total table sizeof the BN without node Z.Since this is a constant for a xed grid we do allexperiments without the auxiliary Z node.5 ExperimentsWe performed the experiments with the game of Minesweeper for two dierentgrid sizes 1010 and 2020.For simplicity we used a randomselection of eldsto be played and we assumed we never hit the mine during the game.Of course,this is an unrealistic assumption,but since we are interested in the complexityof inference in the BN models it suces to get an upper bound on the worst casecomputational complexity.For the results of experiments see Figures 7 and 8,where each value is the average over twenty dierent games.0 20 40 60 80 1001234the number of observationslog10(tts)rank one decompositionthe standard techniqueFigure 7:The development of the total table size (tts) for the RODand standardmethods during the game of Minesweeper on the 10 10 grid.From the results of experiments we can see that the ROD as it is currentlyapplied does not bring any advantages of the standard method.But,recall thatApplying Bayesian networks in Minesweeper 90 100 200 300 40002468the number of observationslog10(tts)rank one decompositionthe standard techniqueFigure 8:The development of the total table size (tts) for the RODand standardmethods during the game of Minesweeper on the 20 20 grid.ROD is very useful for the auxiliary node Z,which stands for the total numberof mines.However,the way we apply ROD in Section 4 is not the most ecient utiliza-tion of ROD.Given a state y of Y we could nd more compact factorizations ofP(Y = y j X1;:::;Xm).For example in two extreme cases,if y = mor y = 0 weknow that the state of all Xi;i = 1;:::;m is 1 or 0,respectively.Consequently,the rank of P(Y = y j X1;:::;Xm) for y = 0;m is one.However,we do notknow the rank and minimal rank-one decompositions of P(Y = y j X1;:::;Xm)for other values of y.This is a topic for our future research.We conjecturethat for most values of y the rank of P(Y = y j X1;:::;Xm) will be lower thanm+1,which will lessen the total table size for the ROD method.6 ConclusionsIn this paper we report experiments with Bayesian networks build for the gameof Minesweeper.During the construction of BN we use several modeling tricksthat allow more ecient inference in the BNs for this game.We compare thecomputational complexity of the inference in the BN model for the standardapproach and after the rank-one decomposition.We observed that there are nosignicant dierences in the computational complexity of the two approaches.Probably,the most important theoretical observation is that we miss minimalrank-one decompositions for the CPTs with a local structure when the stateof the child variable is observed.We believe this would help to reduce the10 M.VOMLELOVA,J.VOMLELcomputational complexity with the BN model after ROD.This is an issue forour future research.References[1] A.Cano and S.Moral.Heuristic algorithms for the triangulation of graphs.In B.Bouchon-Meunier,R.R.Yager,and L.A.Zadeh,editors,Advancesin Intelligent Computing { IPMU'94:Selected Papers,pages 98{107.Springer,1994.[2] F.J.Dez and S.F.Galan.An ecient factorization for the noisy MAX.International Journal of Intelligent Systems,18:165{177,2003.[3] F.V.Jensen,S.L.Lauritzen,and K.G.Olesen.Bayesian updating inrecursive graphical models by local computation.Computational StatisticsQuarterly,4:269{282,1990.[4] Finn Verner Jensen.Bayesian networks and decision graphs.Statistics forEngineering and Information Science.Springer Verlag,New York,Berlin,Heidelberg,2001.[5] S.L.Lauritzen.Graphical Models.Clarendon Press,Oxford,1996.[6] S.L.Lauritzen and D.J.Spiegelhalter.Local computations with probabil-ities on graphical structures and their application to expert systems (withdiscussion).Journal of the Royal Statistical Society,Series B,50:157{224,1988.[7] S.M.Olmsted.On representing and solving decision problems.PhD thesis,Stanford University,1983.[8] Judea Pearl.Probabilistic Reasoning in Intelligent Systems:Networks ofPlausible Inference.Morgan Kaufman,San Mateo,CA,1988.[9] D.J.Rose.A graph-theoretic study of the numerical solution of sparsepositive denite systems of linear equations.Graph Theory and Computing,pages 183{217,1972.[10] P.Savicky and J.Vomlel.Exploiting tensor rank-one decomposition inprobabilistic inference.Kybernetika,43(5):747{764,2007.[11] J.Vomlel.Exploiting functional dependence in Bayesian network inference.In Proceedings of the 18th Conference on Uncertainty in AI (UAI),pages528{535.Morgan Kaufmann Publishers,2002.[12] Wikipedia.Minesweeper (computer game).http://en.wikipedia.org/wiki/Minesweeper(computergame),2009.