Make-Believe (R14): Initial Netica .dne support

For a little while, I’ve been wanting to add support for Netica .dne files, and I’ve managed to finally land something. The support is very crude (even cruder than for GeNIe .xdsl files) and probably very flaky. There’s only support for basic networks with discrete chance nodes — no support at all for deterministic nodes, equations, decision nodes, utility nodes or dynamic nodes (as there is for GeNIe files).

I included another one of my side-projects in order to get this support, namely a parser. I ought to write a separate post about the parser at some point, but in short, it’s meant to be a very quick way to use a grammar (with embedded regular expression support) to transform an input source into not just a syntax tree, but something that more closely represents the final desired object model. It’s not quite there yet, but it’s certainly good enough to do the parsing work needed here.

Anyway, here’s the 14th release of Make-Believe:

Changes:

  • Initial Netica .dne support for basic networks (discrete chance nodes only!)
  • Update beliefs immediately on BN loaded from query string

Make-Believe (R13): Working Workers

I finally have workers performing inference as quickly as on the main thread. This means workers now actually speed up the inference, with some substantial speed improvements as you move up to 4-8 cores. In fact, updating speed is no longer simply comparable to GeNIe, but can run quite a bit faster — OK, you should take that with a large grain of salt, because it’s BN-dependent, I’m not testing if the output variance is the same, and I’m just testing with the same number of sample iterations.

One nice side-effect of this is that I can finally unify the main-thread and worker-thread implementations. This may encourage me to clean the code organisation up a little bit. I hope.

2 workers are enabled by default for now. To change this number, go to the ‘Debug’ menu. It’s best to set the number equal to or slightly lower than the number of CPUs/cores that you have.

Changes:

  • Made worker-based belief update run as quickly as main thread update
    • (The solution was to recreate BNs on the worker side, rather than pass in via structured clone. I’m unaware as to why this is needed, since the structures (TypedArrays, etc.) were identical as far as I could tell. This was the case on both Firefox and Chrome, so it’s obviously something I missed.)
  • Enabled worker-based belief updating by default
  • Added a ‘Debug’ menu
    • (Mostly just performance-testing options.)
  • Performance tweaks to continuous variables

Make-Believe (R12): Continuous Improvement

Ack! The previous version I posted had broken the ability to enter evidence, and due to an extended period of busyness, I didn’t notice until now. (No regression tests yet — I do this for fun.) Oh well, thankfully no-one is paying attention.

Given the long period since the last update, I thought I’d try adding something a bit more interesting this time — initial support for continuous nodes. The support I’m providing will match what GeNIe supports as closely as possible. This release includes support for Uniform, Bernoulli, and Normal. It also supports arithmetic operators (e.g. +, *, etc.) as well as the ternary operator (i.e. <if-cond> ? <then> : <else>).  To be clear, that’s just because I’m handing things over to JavaScript. 🙂 I’ll continue to do that because it’s probably the approach with the best performance, but I’ll validate inputs in future. (Just in case people do start loading .xdsl files from suspicious locations.)

It’s also worth pointing out how limited the overall support is at the moment. You can’t enter evidence into a net with continuous nodes. You can’t use the continuous nodes with worker threads. The Normal sampling is very crude. The distributions that are displayed are just histograms up to a maximum of 10 bins. I also haven’t thought about performance yet. As I’ve noted, I do this because I enjoy it, so I’m not rushing things — there’s no need to scoff down the whole dessert at once.

From now on, I’ll put each release in its own folder, so that there’s at least a working version to go back to if I break things again! Here’s Release 12:

Changes:

  • Fixed entering of evidence
  • Improved robustness of saving a bit (note: can’t save continuous nodes at all yet, and probably many other types of node)
  • Initial support for continuous nodes

Make-Believe (R11)

I’ve added a very crude view of node CPTs — just double-click a node. (No support for deterministic nodes yet.) I expect I’ll be improving this in the next iteration. Also, moving nodes around is no longer quite so awful, with arrows updating as you move.

Changes:

  • Arrows update continuously as you move nodes
  • Added viewing of a CPT by double-clicking node

Make-Believe (R9)

Another small update, this time adding a control in the toolbar for the number of iterations that the likelihood weighting algorithm performs. At some point I’m going to need to clean up the toolbar.

Changes:

  • Control to allow changes to the number of iterations of the inference algorithm

Make-Believe and a Late R8

I missed the R8 release from two weeks ago — partly because I forgot, and partly because I was busy — so here it is now. Sadly, there isn’t too much to excite in this release. The main change is the ability to do automatic layout using the dagre.js library. I haven’t tweaked the defaults at all, so the layouts it creates right now aren’t ideal.

Changes:

  • Auto layout using the dagre.js library

Make-Believe R7

The work on R6 allowed me to add an experimental worker thread implementation in this release. Unfortunately, I’m seeing absolutely no performance gain at this stage from it on a multi-core system, so it’s off by default. No other changes in this release.

Changes:

  • Added experimental worker threads (currently worse perf)

Make-Believe R6

For this version, I focused on making some improvements to the backend, disentangling the .xdsl format from the internal BN representation. I also added a crude and experimental save to .xdsl function — expect it to work for basic networks only, and even then less often than not. Here it is:

I’ve also finally put the code on GitHub.

Changes

  • Backend rewrite to remove dependencies on .xdsl format for BN representation and display
  • Extremely experimental .xdsl saving (basic networks only)