# Probablistic modeling of multiagent systems?

**URL:** <https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689>\
**Category:** Probabilistic Programming\
**Created:** [March 7, 2023, 6:51pm UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689 "2023-03-07T18:51:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielV](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@DanielV](https://discourse.julialang.org/u/DanielV)\
**Post date:** [March 7, 2023, 6:51pm UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/1 "2023-03-07T18:51:02Z")

</div>

I have a simple agents.jl sim where at each step with some probability agents are added or change state or are removed. Agents are not independent, e.g., there is a finite “capacity” resource which might prevent an agent from being added.

I’d like to model this in a PPL, to enable also inference. Any examples/tips/reasons why its impossible/a bad idea?

Closest mathematical abstraction I’ve found is Resource dependent branching process [1].

Thanks,  
Daniel Vainsencher

[1] [Resource-dependent branching process - Wikipedia](https://en.wikipedia.org/wiki/Resource-dependent_branching_process)

---

<div class="post-metadata">

**Author:** ![sethaxen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sethaxen/32/35604_2.png) [@sethaxen](https://discourse.julialang.org/u/sethaxen)\
**Post date:** [March 8, 2023, 10:22am UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/2 "2023-03-08T10:22:28Z")

</div>

What specifically do you want to infer?

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [March 12, 2023, 2:03pm UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/3 "2023-03-12T14:03:59Z")

</div>

Disclaimer: I’m no expert, and as Seth writes it kind of depends on what you want to infer.

But from the rough description you provide, if you want to infer using Monte Carlo methods, you probably have to do it using [Reversible jump MCMC](https://en.wikipedia.org/wiki/Reversible-jump_Markov_chain_Monte_Carlo), which Stan, Turing etc. don’t offer afaik.  
Gen on the other hand offers ways to do this and has a [nice tutorial](https://www.gen.dev/tutorials/rj/tutorial), which might help you figure out whether this is what you’re looking for.

---

<div class="post-metadata">

**Author:** ![DanielV](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@DanielV](https://discourse.julialang.org/u/DanielV)\
**Post date:** [March 14, 2023, 2:57am UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/4 "2023-03-14T02:57:05Z")

</div>

Hi sethaxen.

I am still in exploratory mode, so I don’t really know, in principle everything.

Yet your question is usefully challenging, so thanks.

---

<div class="post-metadata">

**Author:** ![rdiaz02](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@rdiaz02](https://discourse.julialang.org/u/rdiaz02)\
**Post date:** [May 20, 2023, 9:30pm UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/5 "2023-05-20T21:30:41Z")

</div>

Not directly using PPLs, but in pp. 14 and ff. of this paper, “Being Bayesian in the 2020s: opportunities and challenges in the practice of modern applied Bayesian statistics” ([https://royalsocietypublishing.org/doi/10.1098/rsta.2022.0156](https://royalsocietypublishing.org/doi/10.1098/rsta.2022.0156)) they use as an example calibrating an ABM model using Approximate Bayesian Computation.

As for whether or not you need Reversible Jump, and how to deal with dimensionality changes with Turing, you might want to take a look at [Failure when dimension changes · Issue #1115 · TuringLang/Turing.jl · GitHub](https://github.com/TuringLang/Turing.jl/issues/1115) and [Models with dynamic dimensionality · Issue #434 · TuringLang/DynamicPPL.jl · GitHub](https://github.com/TuringLang/DynamicPPL.jl/issues/434).

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [May 21, 2023, 12:44pm UTC](https://discourse.julialang.org/t/probablistic-modeling-of-multiagent-systems/95689/6 "2023-05-21T12:44:14Z")

</div>

Another approach would be to use an invertible neural network to learn the likelihood function or posterior distribution. Here is a paper: [Estimation of agent-based models using Bayesian deep learning approach of BayesFlow](https://www.sciencedirect.com/science/article/abs/pii/S0165188921000178)
