The software implementation consisted of more than 60 source files, containing approximately 20,000 lines of code. A listing of the source files and their purposes is shown in Appendix B.
During the software design process, the major tasks and processes that the software needed to implement were identified as follows: data interface, feature extraction, DBN engine, belief extraction and user interface, which interacted as shown in Figure 7.1. This chapter describes the complete software implementation in terms of these tasks.
A filter network can be thought of as a tree of `filter nodes'. Samples are entered at the root of the tree and propagate through each node, which subjects the data to some processing - determined by the node's type and configuration - and then outputs the result to its child nodes. Each software input channel (one for each sensor), has its own filter network, and has the responsibility of providing it with samples received from the datalogger through the data interface.
Using C++ inheritance techniques, many different filter nodes have been implemented to perform a number of data-processing tasks useful in extracting features such as footsteps from raw sensor signals. The configuration of each node in the filter network is specified in the comments section of the .dne network file (See Appendix A.1.3). Some filtering nodes implemented included signal rectification, quantisation, clipping and clamping, integration, differentiation, rising/falling edge triggers and a DSP variable-tap FIR filter (See A.1.3 for list of available filters).
Once evidence has been added to the DBN via one or more evidence nodes, the network is expanded by a specified number of slices7.1.
The Netica API was used to perform inference (Section 3.1.2) and store the DBN itself. Netica stores and performs inference on the DBN as if it was a static belief network; the DBN engine extends the Netica API by splitting this network into slices which are added and removed as necessary, while maintaining the proper causal links and probability distributions.
The DBN software builds a multiple-slice DBN using a 2-slice `reference network' supplied as a Netica belief network file. The names of each node in a reference network (and resulting DBN) are suffixed with a number to specify which DBN slice they belong to. The conditional probability tables supplied with the reference network specify the static and temporal probabilistic relationships between nodes both within and across slice boundaries.
The software stores each individual slice in the network as lists of nodes. This way, accessing an individual node requires a search through one slice node list, as opposed to searching the entire network. This could be very time consuming, especially during network expansion and contraction, where substantial amounts of network restructuring is commonly required.
The DBN engine maintains node lists for the DBN's current, prediction and history slices. The node lists for prediction and history slices are stored in fixed-length queues as shown in Figure 7.2. The length of these queues directly determine how many slices the network will maintain as `history slices' and `prediction slices', and is specified before processing starts. When the DBN engine is first started, prediction slices are automatically added to fill the prediction queue, but the history queue remains empty until the network is expanded.
When a new slice is added during expansion, its node list is added to the front of the prediction queue, and its nodes are connected to those of the previous newest slice while maintaining the structure specified in the reference network. Next, the slice from the rear of the prediction queue becomes the current slice, and the old current slice is added to the head of the history slice queue.
When the history queue fills, the oldest slice is removed from the end and unlinked from the network, producing a network contraction. All the remaining children of nodes in the removed slice then have their CPTs `marginalised' to account for loosing one or more parent nodes. Marginalisation works by averaging each node's probability distribution over the beliefs of its remaining parents. The method for performing this process on a node Xn with remaining parent states is shown in Equation 7.1 shows the formula used to marginalise the probability vector in a node Xn for each of the conditioning state pi of its remaining parents. If the node has all its parents removed during network contraction, its CPT was simply converted to a prior probability distribution using the node's current beliefs.
After the network has more than one slice, the software performed network expansion by effectively appending a copy of the last (newest) slice of the network onto the front of the network (and prediction queue). Network expansion uses lists of forward- and backward-linked nodes derived from the reference network to add the necessary causal links to and from the previous and newest slice. Any nodes in the previous slice which have causal links directed to previous slices (backwards links) are replaced with copies from other slices to ensure the node CPTs are correct.
The first interface required the user to specify filenames and number of reference and prediction slices on the `command-line', displayed all output in text, and was mainly intended for testing while developing under Linux.
The second interface used the Windows 32-bit API to implement the graphical user interface shown in Figure 7.3 (see Section A.3 for a brief overview of the WinDBN application). This provided a `user-friendly' interface to the otherwise complex task of configuration.
This GUI application took advantage of the Windows operating system's multi-threading environment, which enabled feedback to be provided to the operator while the DBN engine was processing
This implementation also provided file polling, which could be used to load and process data from the SiestaView program while it was being received from the datalogger.
A detailed description of the configuration method syntax is provided in Appendix A.