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

Poly chaos #27

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open

Poly chaos #27

wants to merge 71 commits into from

Conversation

FHoltorf
Copy link
Contributor

@FHoltorf FHoltorf commented Sep 26, 2022

Hey,

I need #8 going forward and so I prepared a first draft. Specifically, this implementation addresses the generation of moment equations for polynomial models via Galerkin projection.
Extending it for non-polynomial terms is left for future work as non-polynomial terms need to be handled approximately and accordingly there are many different approaches to do that approximation. Any polynomial basis as supported by PolyChaos.jl is supported. That means that a large subset of polynomials from the Askey scheme and some additional useful ones are available (including polynomials wrt user-defined weighting/density functions). That said, it also means that currently only dense polynomial bases with equal degree in all dimensions are supported. While that wouldn't be strictly necessary and this implementation could be adjusted for more liberty in that regard, it is not natural with the way PolyChaos.jl is constructed and I think we should change PolyChaos.jl itself to accommodate sparse polynomial bases. That change would probably be less involved. The generalization would then carry over automatically.

I will add a tutorial style example to showcase potential usage soon.

Flemming

@FHoltorf
Copy link
Contributor Author

Hey, any thoughts on this @ChrisRackauckas @bowenszhu? The basic functionality of generating PCE moment equations works quite nicely and robustly for polynomial explicit ODE models (see example above). In the future, it would be good to explore the following extensions (importance vaguely in descending order):

  • Support for PDE models (integration with MethodOfLines.jl) -> PCE moment equations generated from discretized models vs. discretization of PCE moment equations for continuous model
  • Support for general nonlinearities via collocation.
  • Support for general sparse polynomial bases (perhaps better built into PolyChaos.jl, very awkward first attempt here)
  • Support for algebraic models
  • Support for stochastic optimal control problems (ControlSystems.jl)
  • Support for multi-element PCE

@bowenszhu already contacted me and would like to help with some of the PCE efforts going forward as well, so it would be nice to get a pair of eyes on this as soon as possible.

Aside: Along the way of creating this, I found that working with PolyChaos.jl is extremely cumbersome. Among many things, the type structure underpinning PolyChaos.jl makes it particularly difficult to extend. For now I decided to work around that but we may wanna consider making changes to PolyChaos itself (I can go into more detail if we have any interest in that).

Flemming

@FHoltorf FHoltorf marked this pull request as ready for review October 17, 2022 03:32
Comment on lines +206 to +211
"""
$(TYPEDSIGNATURES)

Generate moment equations of an `ODESystem` from a given `PCE`-Ansatz via Galerkin projection.
"""
function moment_equations(sys::ODESystem, pce::PCE)
Copy link
Member

@bowenszhu bowenszhu Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this interface, users can set the PCE of their own choice, which is fantastic!

I think we can make it more powerful by doing this step for our users.

My idea is as follows

  1. asking users to add the probability distributions of stochastic parameters as symbolic metadata. See ModelingToolkit.jl - Symbolic metadata - Probability distributions.
  2. we internally set the corresponding appropriate orthogonal polynomials according to the given probability distributions.

I would be happy to adapt this PR if you think this is feasible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great to me. And at least for canonical distributions it not only should be feasible but even very easy to do. That said, I am unsure how easy it would be to support more obscure distributions. With the current implementation it is very easy. So for now, I would keep this and add the interface you are proposing for canonical distributions as well. There seems to be no harm in keeping both and they both address valid use cases.

Resolve `independent_variables` deprecated warning
Remove unnecessary import in runtests.jl
Generate code of `bump_degree` for AbstractOrthoPoly subtypes
Change to use `Symbolics.variables` to create an array of symbolic vars
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

Successfully merging this pull request may close these issues.

2 participants