PNL high crashes with two nets?

  • Gunnar Vagotis
    Gunnar Vagotis

    Hi all, new to PNL but *really* want this to work for a project I am working on.

    So, the scenario is simple. I need multiple copies of the same basic network, each of which will get its own evidence as it is used for analyses of different situations in my system. PNL breaks when a second network is created using the same spec as a first and SetPTabular is called.

    I have compiled it using
    g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
    Which builds the libs though it does not pass all tests.

    I can replicate my problem with an extremely simple test case:

    void wetgrass(BayesNet& net) {
      net.AddNode("discrete^Cloudy", "true false");
      net.AddNode("discrete^Sprin.Kler", "true false");
      net.AddNode("discrete^Rain", "true false");
      net.AddNode("discrete^WetGrass", "true false");
      net.AddArc("Cloudy", "Sprin.Kler Rain");
      net.AddArc("Sprin.Kler Rain", "WetGrass");
      net.SetPTabular("Cloudy^true Cloudy^false", "0.6 0.4");
      net.SetPTabular("Sprin.Kler^true Sprin.Kler^false", "0.1 0.9", "Cloudy^true");
      net.SetPTabular("Sprin.Kler^true Sprin.Kler^false", "0.5 0.5", "Cloudy^false");
      net.SetPTabular("WetGrass^true WetGrass^false", "0.99 0.01", "Rain^true Sprin.Kler^true ");
      net.SetPTabular("WetGrass^true WetGrass^false", "0.9 0.1", "Sprin.Kler^true Rain^false");
      net.SetPTabular("WetGrass^true WetGrass^false", "0.9 0.1", "Sprin.Kler^false Rain^true");
      net.SetPTabular("WetGrass^true WetGrass^false", "0.0 1.0", "Sprin.Kler^false Rain^false");

    int main(int argc,char* argv[]) {
      BayesNet wgNet;

      BayesNet wgNet2;

    The program breaks when the second network is initialized. Here is gdb backtrace:

    #0  0xffffe410 in __kernel_vsyscall ()
    #1  0xb7970df0 in raise () from /lib/tls/i686/cmov/
    #2  0xb7972641 in abort () from /lib/tls/i686/cmov/
    #3  0xb7b73270 in __gnu_cxx::__verbose_terminate_handler ()
       from /usr/lib/
    #4  0xb7b70ca5 in ?? () from /usr/lib/
    #5  0xb7b70ce2 in std::terminate () from /usr/lib/
    #6  0xb7b70e1a in __cxa_throw () from /usr/lib/
    #7  0xb7c0bc89 in pnlw::Tok::Node (this=0x0, i=0, context=0x0)
        at Tokens.cpp:1032
    #8  0xb7c0bd12 in pnlw::Tok::Node (this=0x0, context=0x0) at Tokens.cpp:1023
    #9  0xb7c03396 in pnlw::WDistribFun::FillData (this=0x80ae5c0, matrixId=0,
        value=@0xbffe07ac, probability=@0xbffe0780, parentValue=@0xbffe0754)
        at WDistribFun.cpp:392
    #10 0xb7bf9422 in pnlw::WDistributions::FillData (this=0x80a3e10,
        value=@0xbffe0b20, probability=@0xbffe0af4, parentValue=@0xbffe0ac8,
        matType=pnl::matTable) at pnlWDistributions.cpp:514
    #11 0xb7c2afe5 in pnlw::BayesNet::SetPTabular (this=0x0, value=@0x0,
        prob=@0x0, parentValue=@0x0) at BNet.cpp:130
    #12 0x08091aa1 in wetgrass ()
    #13 0x080921c3 in main ()

    As you can see, the SetPTabular call is getting all null values for its args. Is this a known behavior? Is there something painfully stupid that I've done? Is it possible the compiler I am using screwed it up? Does PNL High pretend like BayesNets refer to different structures but they really don't?

    I appreciate any help greatly. And I apologize if what I have done is somehow painfully stupid.

    •         Hi Gunnar,
          You did nothing wrong. It's a bug in the code. I hit the same problem and had to fix it (it took me a while). I submitted two bug reports and fixes for this problem (1601418 and 1601439). Unfortunately they are not integrated in the current release, but you can look at the bug reports and correct the bugs yourself (or just use the corrected files I submitted). If I remember correctly only small fixes are required.
          I did make it work for me, so if the two bug fixes don't correct the problem please let me know. There might be other corrections that I omitted to submit.
          One word of caution! PNLHigh is great if you have small amounts of data (evidences). If you have a lots of data (over 5000-10000 examples), you are better off using just the core pnl functionality because the PNLHigh does not scale very well. Just loading the data and transforming it into tokens takes a LOT of cpu.

    • Gunnar Vagotis
      Gunnar Vagotis

      Alex, THANKS!! If I can get your patches going it is going to save me some serious stress.

      We will be using the nets on small amounts of data, but thanks for the warning, too. I figured the token code was heavyweight but we should be able to spare the cycles to make it work.

    • Gunnar Vagotis
      Gunnar Vagotis

      Your fixes seem to have done the trick for me as well. Hopefully someone incorporates them (along with the g++ 4.x fixes) into a new release. THANKS!