Possible bug in matrix dimensions after structure learning

The engine.
Post Reply
thom
Posts: 5
Joined: Thu Sep 24, 2009 7:39 am

Possible bug in matrix dimensions after structure learning

Post by thom »

Hi,

After learning the network structure (with PC as well as with GTT) I wanted to do something with the prob. matrix. When I do the following:

Code: Select all

DSL_Dmatrix * probMatrix = n.GetNode(n.FindNode("A"))->Definition()->GetMatrix();
DSL_intArray dimensions = probMatrix->GetDimensions();
cout << "Dimensions are";
for(int i = 0; i < dimensions.NumItems(); i++) cout << dimensions[i] << " ";
This does not output any of the dimensions. When I debug in visual studio, it seems that the array 'dimensions' does contain some items. However, NumItems() is equal to 0.

I used to following data to test this:

Code: Select all

A B C
s6 0 1
s6 0 1
s0 0 0
s0 0 0
s0 0 0
s0 1 1
s0 1 1
s0 1 1
s0 1 1
s6 0 1
s6 0 1
I'm pretty sure I can find a way around this problem. However it might be worth to take a look at it and possibly fix it.

-Thom
shooltz[BayesFusion]
Site Admin
Posts: 1423
Joined: Mon Nov 26, 2007 5:51 pm

Re: Possible bug in matrix dimensions after structure learni

Post by shooltz[BayesFusion] »

You were hit by a problem going back to the beginning of SMILE development. The author of the DSL_xxxArray classes was trying to model them on std::vector and its resize() and reserve() methods, but failed. Hence we have NumItems and GetSize. This is of course a complete mess. The rule of thumb is: always use NumItems, unless you're dealing with DSL_xxxArrays in DSL_Dmatrix - in such case GetSize is the method to call.

Sorry again for the confusion, but this stuff is basically baked into SMILE - the classes are used across large code base.
Post Reply