I am attempting to use jSMILE To create a network with a noisy max node. I am getting a "bad allocation" error when I call setNodeDefinition() on my noisy max node. After some testing I found that even if I set the node definition to the same array I get from calling getNodeDefinition() immediately after adding all of the nodes and arcs to the network I still get the "bad allocation" error.
For example, the following should give you this error:
Code: Select all
import smile.Network;
import smile.Network.NodeType;
public class SmileTest {
public static void main(String[] args) {
Network net = new Network();
int n = 6;
net.addNode(NodeType.NoisyMax,"noisy_max");
net.setOutcomeId("noisy_max", 0, "outcome"+n);
net.setOutcomeId("noisy_max", 1, "outcome"+(n-1));
for (int i = 2; i < n; i++) {
net.addOutcome("noisy_max", "outcome"+(n-i));
}
int nparents = 8;
int nvalues = 10;
for (int i = 0; i < nparents; i++) {
net.addNode(NodeType.Cpt,"parent"+i);
net.addArc("parent"+i,"noisy_max");
net.setOutcomeId("parent"+i, 0, "value"+nvalues);
net.setOutcomeId("parent"+i, 1, "value"+(nvalues-1));
for (int v = 2; v < nvalues; v++) {
net.addOutcome("parent"+i, "bin"+(nvalues-v));
}
}
double[] defn = net.getNodeDefinition("noisy_max");
net.setNodeDefinition("noisy_max", defn);
}
}
Thank you