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

Switch to LevyArea.jl #459

Merged
merged 15 commits into from
Feb 20, 2022
Merged

Switch to LevyArea.jl #459

merged 15 commits into from
Feb 20, 2022

Conversation

frankschae
Copy link
Member

@frankschae frankschae commented Feb 7, 2022

See #458
https://github.com/stochastics-uni-luebeck/LevyArea.jl
https://arxiv.org/abs/2201.08424

To do:

test/levy_areas.jl Outdated Show resolved Hide resolved


# Wiktorssson Approximation
# Wiktorssson Approximation (for diagonal and commutative noise processes where the Levy area approximation is not required.)

Choose a reason for hiding this comment

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

A note on the terminology: Wiktorsson's algorithm is only one algorithm to approximate iterated integrals (or their associated Levy area). Another one is the one from Milstein (often attributed to Kloeden, Platen, Wright) or the newer Mrongowius-Rößler algorithm.

If the diffusion coefficient of your problem satisfies a special commutativity condition (which includes for example additive, linear and diagonal noise), then the Levy area part cancels out (because of its antisymmetry). In this case we can replace the iterated integrals by their symmetric part 1/2WW^\top and the SDE schemes get a lot easier since we don't have to approximate the Levy area anymore. But this has nothing to do with 'Wiktorsson approximation'.

Also I'm not really sure why you have different routines for diagonal and commutative noise? They should be the same, but there are some slight differences in your implementation I don't understand.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, agreed. The names go back to the first attempt where the goal was to implement Wiktorsson's algorithm (plus handling the special cases efficiently where the Levy area approximation is not required). I already updated the one that's user-facing
IIWiktorsson -> IILevyArea (open for better suggestions and suggestions for the other ones).

Also I'm not really sure why you have different routines for diagonal and commutative noise? They should be the same, but there are some slight differences in your implementation I don't understand.

This is because we represent the diffusion matrix for diagonal noise by a vector, see
https://diffeq.sciml.ai/dev/tutorials/sde_example/

Choose a reason for hiding this comment

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

This is because we represent the diffusion matrix for diagonal noise by a vector, see
diffeq.sciml.ai/dev/tutorials/sde_example

Wouldn't it be easier to just wrap the return value of g in a Diagonal? That way the intention is clearer and the solvers don't need to be special cased.
But ok, that was probably discussed when the interface was created and is set in stone now.

Copy link
Member

Choose a reason for hiding this comment

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

It comes from the methods specialized on diagonal only, which came first. We can probably cut down on code by wrapping in a Diagonal, but it doesn't make a major change to the utility of the package so no one has done the work. Someone probably should refactor that though.

@ChrisRackauckas
Copy link
Member

For strong convergence (and adaptivity) we would have to come up with a scheme so that we could easily pullback the Brownian paths. In the diagonal and commutative cases this is easy because it is done with the Brownian bridge, and the diagonal 1.5 case can be handled with a psuedo-Brownian process because the iterated integral approximation turns out to just be essentially two Brownian processes. I don't know what would have to happen with the non-commutative case though since it takes n random numbers?

@frankschae frankschae changed the title [WIP] Switch to LevyArea.jl Switch to LevyArea.jl Feb 16, 2022
@frankschae
Copy link
Member Author

The test failures (StochasticDelayDiffEq/SROCKC2) look unrelated to me.

@fkastner
Copy link

For strong convergence (and adaptivity) we would have to come up with a scheme so that we could easily pullback the Brownian paths.

What exactly do you mean by pullback here?

Re adaptivity: I'm fairly confident to say that you can't use the Levy area in an adaptive scheme that requires the rejection of steps. We thought a bit about that, but it would require some new ideas or a completely new scheme for the Levy area approximation.

@fkastner
Copy link

Is the distinction between in-place and out-of-place still necessary for the iterated integrals? Especially since LevyArea.jl currently doesn't provide that distinction either. There is no reason why the in-place-ness of the iterated integral computations has to be coupled to the in-place-ness of the problem itself, or am I missing something here?

@frankschae
Copy link
Member Author

I would say we could either remove the inplaceness completely, i.e., by removing it also from all SDE solvers

get_iterated_I!(dt, dW, W.dZ, Wik, integrator.alg.p, integrator.alg.c, alg_order(integrator.alg))

(For problems with mutating functions, the iip formulations were originally used to avoid allocations -- this doesn't work for the methods from LevyArea.jl.)
Alternatively, we can use this wrapper that offers no computational advantage but allows us to remove allocations for the other cases (IICommutative()) in principle.

@ChrisRackauckas
Copy link
Member

What the reason for not having a preallocated form in LevyArea.jl? I presume the allocation here would impact at least multithreaded performance.

@ChrisRackauckas
Copy link
Member

The SDDE test is just noisy. I need to fix that when I get back.

@ChrisRackauckas ChrisRackauckas merged commit 5bec928 into master Feb 20, 2022
@ChrisRackauckas ChrisRackauckas deleted the levy_area branch February 20, 2022 23:21
@ChrisRackauckas
Copy link
Member

Continuing the discussion on fully inplace in stochastics-uni-luebeck/LevyArea.jl#7 . While it could hit performance, for now we can probably just skip it.

@fkastner
Copy link

Alternatively, we can use this wrapper that offers no computational advantage but allows us to remove allocations for the other cases (IICommutative()) in principle.

Yes, that was my suggestion. Basically remove the out-of-place functions. It should be possible to use in-place Levy area approximations (no matter how much of it is in-place) even for out-of-place problems, shouldn't it?

@ChrisRackauckas
Copy link
Member

out of place would still be required for some forms of automatic differentiation and for use cases with immutable arrays and static arrays. So that still would have a place in the grant scheme of things.

@frankschae frankschae mentioned this pull request Jun 24, 2022
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.

4 participants