Stan used in co-simulations?

Hi there,

I work with a group which does HPC with co-simulations to integrate distinct models of subsystems.

I did a google for “co-sim” and Stan, and came up blank. Do any users of Stan here apply this in co-simulation contexts? If so, can you describe any difficulties you have experienced?

Hmm, what do you mean by a co-simulation here? I’m not familiar.

This case study I think outlines the basic thing Stan does (make it easy to fit Bayesian models and iterate on them): https://mc-stan.org/users/documentation/case-studies/golf.html

Keep in mind in principle Stan can function as long as it’s fed with likelihood components & its gradient w.r.t. the parameters. So it’s less of a problem of Stan then of the solvers involved in co-sim. Off the top of my head, challenges involve

  • Gradient calculation. I imagine your HPC solvers are optimized toward specific model but may not be able to do sensitivity analysis. If that’s the case, 1st step would be find way to do SA. Stan does provide ODE solvers but they’re not designed for large systems.
  • Data sharing. Depends on how subsystems in co-sim communicate, you’ll need to coordinate it with Stan. Stan provides both multi-core & distributed support, but only within Stan lang itself. Interface to multi-core(TBB) & distributed(MPI) must be accessed and modified at C++ level.
  • Stability. Again this is the problem of co-sim but it could affect posterior accuracy. Depend on communication & parallel patterns, you may want to improve the algorithm stability, which usually implies more expensive computing. The reason is while many co-sim is designed to solve the model efficiently, they may not designed to solve it robustly. So a sample from Stan may send the co-sim to haywire and result in erratic results(need more accuracy) or unnecessarily stressed solution(need detection and early termination).

The above items are based on my past experience on co-sim(computational physics where co-sim involves solid + fluid, fluid + fluid, solid + fluid + fluid, with optimization on top). I haven’t done any co-sim + Stan but I believe the same are applicable here.

2 Likes