Hi I am having some problems with running SMILE on a Linux machine.
I have gcc version 4.0.0 20050519 (Red Hat 4.0.0-8 ) and use smile_1_1_linux_gcc_4_1_1.tar.gz. Is this a problem if the compiler versions are different?
I get different bugs depending on whether I write to .dsl or read from .xdsl.
Bug when writing to .dsl:
When a node is deterministic (DSL_TRUTHTABLE), the values written to the .dsl file is different from what I set. It works fine when I use .xdsl though. Basically writing to .dsl and .xdsl gives two different RESULTINGSTATES. Maybe the way to set the definition is different for the two file formats?
Bug when reading from .xdsl:
Because of the above bug, I want to use .xdsl. But my code will crash when reading the .xdsl file. The .xdsl file is fine because I can read it with GeNIe and the network is correct. It is when I run ReadFile() in SMILE that it crashes and the following output is produced:
*** glibc detected *** ./bar: free(): invalid pointer: 0x08cf9018 ***
======= Backtrace: =========
/lib/libc.so.6[0xc19424]
/lib/libc.so.6(__libc_free+0x77)[0xc1995f]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x2e2669]
./bar[0x81391eb]
./bar[0x8139886]
./bar[0x8094346]
./bar[0x8086908]
./bar[0x806575f]
./bar(__gxx_personality_v0+0x237)[0x804a51b]
/lib/libc.so.6(__libc_start_main+0xc6)[0xbcade6]
./bar(__gxx_personality_v0+0xcd)[0x804a3b1]
======= Memory map: ========
00222000-0022b000 r-xp 00000000 08:01 2910662 /lib/libgcc_s-4.0.0-20050520.so.1
0022b000-0022c000 rwxp 00009000 08:01 2910662 /lib/libgcc_s-4.0.0-20050520.so.1
0022e000-0030d000 r-xp 00000000 08:01 8357225 /usr/lib/libstdc++.so.6.0.4
0030d000-00312000 rwxp 000df000 08:01 8357225 /usr/lib/libstdc++.so.6.0.4
00312000-00317000 rwxp 00312000 00:00 0
004af000-004b0000 r-xp 004af000 00:00 0
00b98000-00bb2000 r-xp 00000000 08:01 2910657 /lib/ld-2.3.5.so
00bb2000-00bb3000 r-xp 00019000 08:01 2910657 /lib/ld-2.3.5.so
00bb3000-00bb4000 rwxp 0001a000 08:01 2910657 /lib/ld-2.3.5.so
00bb6000-00cda000 r-xp 00000000 08:01 2910658 /lib/libc-2.3.5.so
00cda000-00cdc000 r-xp 00124000 08:01 2910658 /lib/libc-2.3.5.so
00cdc000-00cde000 rwxp 00126000 08:01 2910658 /lib/libc-2.3.5.so
00cde000-00ce0000 rwxp 00cde000 00:00 0
00ce2000-00d04000 r-xp 00000000 08:01 2910659 /lib/libm-2.3.5.so
00d04000-00d05000 r-xp 00021000 08:01 2910659 /lib/libm-2.3.5.so
00d05000-00d06000 rwxp 00022000 08:01 2910659 /lib/libm-2.3.5.so
08048000-08197000 r-xp 00000000 08:01 1014613 /home/XXX/smile/bar
08197000-08198000 rw-p 0014f000 08:01 1014613 /home/XXX/smile/bar
08ce6000-08d07000 rw-p 08ce6000 00:00 0 [heap]
b7e00000-b7e21000 rw-p b7e00000 00:00 0
b7e21000-b7f00000 ---p b7e21000 00:00 0
b7f99000-b7f9b000 rw-p b7f99000 00:00 0
b7fb2000-b7fb3000 rw-p b7fb2000 00:00 0
bfc9d000-bfcb3000 rw-p bfc9d000 00:00 0 [stack]
Aborted
Side question: How do I set the DSL_TRUTHTABLE? The node has two outcomes. The node's single parent has four outcomes, yet when I run GetDefinition() it tells me there are eight entries in the node's definition and they are all default set to 0.5. I played around and I think if I set the odd indexes to zero it will be the first outcome and when it is one it will be the second outcome. Of course this only happens for .xdsl.
Please help thanks.
Getting different bugs with .dsl and .xdsl
-
- Site Admin
- Posts: 1457
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Getting different bugs with .dsl and .xdsl
Yes, it may be the problem. I suspect it's some subtle difference between the STL template classes. The .xdsl parser uses std::set/map/string, while old .dsl doesn't not use STL. This could explain why your program crashes during .xdsl load.gund wrote:I have gcc version 4.0.0 20050519 (Red Hat 4.0.0-8 ) and use smile_1_1_linux_gcc_4_1_1.tar.gz. Is this a problem if the compiler versions are different?
I recommend installing gcc 4.1.1 or 3.4.6 on your system (some RedHats come with two gcc versions - try running gcc34 from the console).
You can use DSL_truthTable::SetResultingState[s] methods. SetDefinition will work too, but it doesn't check if the table/matrix passed as argument is well formed (0/1 values only, single 1.0 value per each parent configuration).Side question: How do I set the DSL_TRUTHTABLE? The node has two outcomes. The node's single parent has four outcomes, yet when I run GetDefinition() it tells me there are eight entries in the node's definition and they are all default set to 0.5. I played around and I think if I set the odd indexes to zero it will be the first outcome and when it is one it will be the second outcome. Of course this only happens for .xdsl.
Thanks for the quicky reply.
My C++ is quite bad, so I'm thinking this code I wrote doesn't work because it is setting another truth table instead of the one I want.
Code:
DSL_stringArray elephant;
elephant.Add("State1");
elephant.Add("State1");
for (int i = 0; i < elephant.NumItems(); i++)
cout << elephant.Subscript(i) << endl;
DSL_truthTable(r1_handle, &theNet).SetResultingStates(elephant);
DSL_stringArray penguin;
DSL_truthTable(r1_handle, &theNet).GetResultingStates(penguin);
cout << "penguin.NumItems() = " << penguin.NumItems() << endl;
cout << "penguin.GetSize() = " << penguin.GetSize() << endl;
for (int i = 0; i < penguin.NumItems(); i++)
cout << penguin.Subscript(i) << endl;
Output:
State1
State1
penguin.NumItems() = 2
penguin.GetSize() = 10
State0
State1
Have a few questions.
1. How to properly use SetResultingStates to set the truth table for the relevant node?
2. Why is there a SetProbability method in dsl_truthTable if it's a deterministic node with probs either 1 or 0?
Thanks again for all the help. Appreciate it greatly.
My C++ is quite bad, so I'm thinking this code I wrote doesn't work because it is setting another truth table instead of the one I want.
Code:
DSL_stringArray elephant;
elephant.Add("State1");
elephant.Add("State1");
for (int i = 0; i < elephant.NumItems(); i++)
cout << elephant.Subscript(i) << endl;
DSL_truthTable(r1_handle, &theNet).SetResultingStates(elephant);
DSL_stringArray penguin;
DSL_truthTable(r1_handle, &theNet).GetResultingStates(penguin);
cout << "penguin.NumItems() = " << penguin.NumItems() << endl;
cout << "penguin.GetSize() = " << penguin.GetSize() << endl;
for (int i = 0; i < penguin.NumItems(); i++)
cout << penguin.Subscript(i) << endl;
Output:
State1
State1
penguin.NumItems() = 2
penguin.GetSize() = 10
State0
State1
Have a few questions.
1. How to properly use SetResultingStates to set the truth table for the relevant node?
2. Why is there a SetProbability method in dsl_truthTable if it's a deterministic node with probs either 1 or 0?
Thanks again for all the help. Appreciate it greatly.
-
- Site Admin
- Posts: 1457
- Joined: Mon Nov 26, 2007 5:51 pm
Your code creates temporary DSL_truthTable objects - they're destroyed immediately after SetResultingStates call, and more importantly, have no effect on node with handle specified in r1_handle variable.
You should retrieve the DSL_truthTable from existing node instead:
You should retrieve the DSL_truthTable from existing node instead:
Code: Select all
DSL_node *node = theNet.GetNode(r1_handle);
DSL_truthTable *tt =static_cast<DSL_truthTable *>(node->Definition());
tt->SetResultingStates(elephant);
DSL_truthTable derives publicly from DSL_cpt. SetProbability and SetProbabilities methods are defined by DSL_cpt.2. Why is there a SetProbability method in dsl_truthTable if it's a deterministic node with probs either 1 or 0?
Thanks man you have been great. Unfortunately it still doesn't work. Reading from the truthtable afterwards will again produce the default values.
Is there a way to set the resulting states by giving the integer index of the state instead of a string?
I guess in the end I will stick with using SetDefinition (changing matrix value) because that definitely works when looking at the .xdsl file. I just won't write to a file and read from it. It works fine if I don't do that.
I just tested on a x86-64 machine with the proper library and compiler and writing and reading from .xdsl works fine. Not with .dsl though, so probably because it's not supported and some stuff has changed.
Thanks again.
Is there a way to set the resulting states by giving the integer index of the state instead of a string?
I guess in the end I will stick with using SetDefinition (changing matrix value) because that definitely works when looking at the .xdsl file. I just won't write to a file and read from it. It works fine if I don't do that.
I just tested on a x86-64 machine with the proper library and compiler and writing and reading from .xdsl works fine. Not with .dsl though, so probably because it's not supported and some stuff has changed.
Thanks again.
-
- Site Admin
- Posts: 1457
- Joined: Mon Nov 26, 2007 5:51 pm
Yes, the SetResultingStates has an overload which accepts the integer array as an argument.gund wrote:Is there a way to set the resulting states by giving the integer index of the state instead of a string?
Note that outcome identifiers are case sensitive - maybe your string array contains the all-lowercase identifiers ('elephant'), while node's outcomes start with uppercase letter ('Elephant').
The .dsl should work 100% for truthtables. Can you post your code and network here? I would be able to determine if it's .dsl bug or the code is written incorrectly.I just tested on a x86-64 machine with the proper library and compiler and writing and reading from .xdsl works fine. Not with .dsl though, so probably because it's not supported and some stuff has changed.
Definitely an inconsistency here.shooltz wrote: The .dsl should work 100% for truthtables. Can you post your code and network here? I would be able to determine if it's .dsl bug or the code is written incorrectly.
Ok the output for writing to .dsl produces for node r1
for .xdslRESULTINGSTATES = (State0, State0);
Relevant Code (I removed all the extra stuff)<resultingstates>State0 State1</resultingstates>
#include "smile.h"
void CreateNetwork2(DSL_network &theNet) {
int r_handle = theNet.AddNode(DSL_LIST,"r");
int r1_handle = theNet.AddNode(DSL_TRUTHTABLE,"r1");
theNet.AddArc(r_handle, r1_handle);
DSL_Dmatrix *rMatrix;
theNet.GetNode(r1_handle)->Definition()->GetDefinition(&rMatrix);
rMatrix->Subscript(0) = 1;
rMatrix->Subscript(1) = 0;
rMatrix->Subscript(2) = 0;
rMatrix->Subscript(3) = 1;
theNet.WriteFile("ExampleNetwork.dsl");
theNet.WriteFile("ExampleNetwork.xdsl");
}
-
- Site Admin
- Posts: 1457
- Joined: Mon Nov 26, 2007 5:51 pm