Wednesday, July 27, 2005

Well, after becoming increasingly unsatisfied with the cleanliness of my code. I decided to drastically change my representation of graphs. For a graph is just a list of nodes. A DAG is just a topologically sorted list of nodes.

A "node" has a list of neighbors. a "directednode" has a list of parents. It took very little actually to make these changes. Mostly it changed the way i create a network. The changes had minimal effects on the rest of my inference code because i maintained all of the same functions in the BayesNet class but redefined them to work with the new structure. It does mean that now that style is probably not ideal in terms of efficiency. Because the inference code was designed to work on a graph centric view of the way to do things. Meaning that if you wanted the parents of a node you would say bnet.parents(node), which you can still do, but now in order to do that, the graph has to find the node in its node list and then returns node.parents. Which means it takes linear time to do it, when it should be a constant time operation.

I plan to go back and redesign the code to work more properly with this new representation.

These changes greatly cleaned up my JunctionTree inference code and got me back on track there. hopefully meaning i will finish it sometime tonight and let me move on to MCMC and EM.



Post a Comment

<< Home