Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in MessagePassingAlgorithm::SetEFModel #72

Open
santoshthammana opened this issue Oct 27, 2016 · 4 comments
Open
Labels

Comments

@santoshthammana
Copy link

I'm using version 0.6.

I get a NullPointerException for the following line of MessagePassingAlgorithm::SetEFModel:
node.setParents(node.getPDist().getConditioningVariables().stream().map(this::getNodeOfVar).collect(Collectors.toList()));
It looks like the issue is with the call to map(). The getNodeOfVar() function is iterating over this.variablesToNode. But should this map() call be iterating over variablesToNode instead?

Thanks!

@rcabanasdepaz
Copy link
Contributor

Can you give us a short code-example in order to reproduce the bug?

@santoshthammana
Copy link
Author

I emailed a code example.

@rcabanasdepaz
Copy link
Contributor

Received. We will answer you as soon as possible.

@rcabanasdepaz
Copy link
Contributor

In the code you send, you create an unconnected DAG. You have to specify the links by adding nodes to the parent sets of each node. For that, use the methods DAG::getParentSet(Variable var) and ParentSet::addParent(Variable var). In the link below you have an example of DAG definition.

http://www.amidsttoolbox.com/documentation/0-6-0/examples-060/bnetworks-060/#sec:bns:models

When defining the the DAG, make sure that it has no cycles and all the nodes are connected.

Another problem that I see in your code, is that you try to build a BN over 9 nodes but you only specify 3 probability distributions. When you call the constructor new BayesianNetwork(modelDAG, modelConditionalDistributions), the list modelConditionalDistributions should contain a distribution for each node in the DAG. As you are working with discrete domains, for nodes without parents you define an object of class Multinomial. For nodes with parents, use Multinomial_MultinomialParents instead.

Let me know if fixing these problems your code works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants