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

Problem finding mk_sched in notebook code for "Agent-based modeling via graph rewriting" blog #41

Closed
ndo885 opened this issue Feb 7, 2024 · 3 comments

Comments

@ndo885
Copy link

ndo885 commented Feb 7, 2024

Hi,
Our CEPHIL team has been having trouble running block 17 of the following notebook code for "Agent-based modeling via graph rewriting" blog.

https://nbviewer.org/github/AlgebraicJulia/AlgebraicRewriting.jl/blob/compat_varacsets/docs/src/Dynamic%20Tracing.ipynb

Specifically, we get an error message indicating that "mk_sched" cannot be found. Here's the exact code and error message:

image

My project .toml file is attached as a txt file (so it can be attached_); is it adopted from the July7_2023 commit (reflecting the July 7 date of the associated blog post (https://blog.algebraicjulia.org/post/2023/07/graphical-schedule/#cb3-2).
Project.toml.txt

I further attach my complete .ipynb file, again as a .txt file so that it can be attached.
ACT-ABM-BlogExample-Jan-2023_With-July7_2023_Project_toml.ipynb.txt

Thanks so much for any guidance that can be offered!

@lukem12345
Copy link
Member

Hey! I’m not a developer on this package, but I have used it in the past and I can help you interpret this error message.

The Julia error that you got says that the types of the arguments that you gave to the mk_sched function are not correct, but it did find a candidate solution. The first arguments in black: mk_sched(::NamedTuple, ::NamedTuple, were matched correctly. Julia would use this definition of mk_sched if not for the remaining types, which it could not match on.

The first argument that it didn’t find (the first type in red) was something with the type ::Names. As an example on how to create a Names object, you can see this line from the tests:

N=Names(Dict("Z"=>z,""=>g1))

And where it is used here:
sched = mk_sched((o=Dot,), (i=:Z,), N, Dict(:rule=>al, :query=>q),

So, we should create our Names object here like:
N = Names(Dict("S" => S, "I" => I, "G” => G));
And pass this as the third argument to mk_sched.

For an example of a similar dynamics, check out this docs page:
https://algebraicjulia.github.io/AlgebraicRewriting.jl/dev/generated/lotka_volterra/
You can ctrl+f in this document for Names and mk_sched.

I hope this helps! ~ Luke

@kris-brown
Copy link
Collaborator

Thanks Luke! I should note that, as of an hour ago, there's a new release of AlgebraicRewriting (0.3.1) to accompany a new release of Catlab! The docs page Luke linked is important because that file gets run automatically with the tests whenever we push code (the code in the blog post does not get run, so it can become out of date).

An important difference in this latest release so the rewriting simulation can be fast via the use of in-place rewriting (rather than Catlab's normal pushout infrastructure which is a pure, non-mutating function). For this to work, there's a keyword you need to pass in when creating your ACSet data type @acset_type MyACSetType(MySchema, part_type=BitSetParts).

@kris-brown
Copy link
Collaborator

I've added a caveat to the blog post which notes the code there could be out of date. It also links to the Lotka Volterra demo, which I have also recently added a lot more exposition to. If you still have trouble getting an ABM up and running (with AlgRewriting version 0.3.2), let me know!

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

3 participants