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

Max-sum value assignment Error #5

Open
Saad-Mahmud opened this issue Jan 23, 2019 · 1 comment
Open

Max-sum value assignment Error #5

Saad-Mahmud opened this issue Jan 23, 2019 · 1 comment

Comments

@Saad-Mahmud
Copy link

Saad-Mahmud commented Jan 23, 2019


fg = graphs.FactorGraph()

x1 = nodes.VNode("x1", rv.Discrete)
x2 = nodes.VNode("x2", rv.Discrete)
x3 = nodes.VNode("x3", rv.Discrete)
x4 = nodes.VNode("x4", rv.Discrete)
x5 = nodes.VNode("x5", rv.Discrete)

dist_fa = [
    [
        [0.1, 0.2],
        [0.1, 0.1]
    ],
    [
        [0.2, 0.05],
        [0.2, 0.05]
    ]
           ]
fa = nodes.FNode("fa", rv.Discrete(dist_fa, x1, x2,x3))

dist_fb = [[0.1, 0.4],
           [0.2, 0.3]]
fb = nodes.FNode("fb", rv.Discrete(dist_fb, x3, x4))

dist_fc = [[0.5, 0.1],
           [0.2, 0.2]]
fc = nodes.FNode("fc", rv.Discrete(dist_fc, x3, x5))

fg.set_nodes([x1, x2, x3, x4, x5])
fg.set_nodes([fa,fb,fc])

fg.set_edge(x1, fa)
fg.set_edge(x2, fa)
fg.set_edge(fa, x3)
fg.set_edge(x4, fb)
fg.set_edge(fb, x3)
fg.set_edge(x3, fc)
fg.set_edge(fc, x5)
fg.set_edge(x2, fb)
fg.set_edge(fb, x3)
fg.set_edge(x2, fc)
fg.set_edge(fc, x4)

belief = inference.max_sum(fg,x5)`

for this problem I get Value assignment
x5 0
x3 1
x1 3
x2 1
x4 0
but all of the variables are binary. SO x1 = 3 does not looks right

@danbar
Copy link
Owner

danbar commented Jan 26, 2019

Thx for the feedback.
Yes, there seems to be something wrong. I will have a look.

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

No branches or pull requests

2 participants