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

Plot loops as plate notations #69

Open
yebai opened this issue Aug 21, 2023 · 6 comments
Open

Plot loops as plate notations #69

yebai opened this issue Aug 21, 2023 · 6 comments

Comments

@yebai
Copy link
Member

yebai commented Aug 21, 2023

The current plotting extensions will "unroll" all loops, resulting in a rather cluttered graph. It would be good to investigate whether it is possible to plot loops as plate notations, as in the original BUGS software.

@sunxd3
Copy link
Member

sunxd3 commented Aug 22, 2023

Plate notation maybe available via Tikz and bayesnet.
But in general this is difficult, because sometimes the BUGS program is not regular as the original graph interface of BUGS, because programmer can create indices more freely.

A possible approach is to do some graph analysis and put nodes with common parents and/or children in the same class and plot the classes.

@sunxd3
Copy link
Member

sunxd3 commented Aug 29, 2023

daft looks like a good candidate for the work.

@yebai
Copy link
Member Author

yebai commented Jan 9, 2024

But in general this is difficult, because sometimes the BUGS program is not regular as the original graph interface of BUGS, because programmer can create indices more freely.

Not sure I understand your point fully. But maybe one can check whether all LHS indices are loop variables (instead of the derivative of loop variables), and only plot in plate notations when this constraint is satisfied.

@sunxd3
Copy link
Member

sunxd3 commented Jan 9, 2024

But maybe one can check whether all LHS indices are loop variables (instead of the derivative of loop variables), and only plot in plate notations when this constraint is satisfied.

This can be done, and actually align with my recent thinking. A lot of BUGS programs fits this constraint, I would love to support the plate notation for these models.

@sunxd3
Copy link
Member

sunxd3 commented Feb 27, 2024

Drawing plate with respect to nodes seems to be a hard job, I think both bayenet(tikz) and Daft requires some level of manual maneuver. Maybe we can use color to say "these nodes are in the same plate" and have a legend explain the plate variable.

@sunxd3
Copy link
Member

sunxd3 commented Feb 27, 2024

Also, a good starting point now is to define a subset of BUGS that's easy to draw.
For instance, one variable should only appear once on the LHS, i.e.

x[1] = ...
for i in 2:3
    x[i] = ...
end

is not allowed.

The indices can only contain loop variable and constant.

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