torchquad icon indicating copy to clipboard operation
torchquad copied to clipboard

Example/documentation for parametric domain of integration?

Open mawright opened this issue 9 months ago • 9 comments

Hi,

I found issue https://github.com/esa/torchquad/issues/170 asking about the case where both the integrand and the domain of integration are functions of parameters, and it looks like @ilan-gold implemented this feature in pull request https://github.com/esa/torchquad/pull/173. I'd like to use this feature and wanted to ask if there are any examples or documentation showing how to use it.

Thanks!

mawright avatar Sep 28 '23 18:09 mawright

Hey @mawright !

Thanks for your interest! This should be documented here in the readthedocs, I think? :)

In case it is what you are looking for, feel free to suggest any potential changes that can help make it easier to find. 🙏

Edit: Ah, actually that is only for the same domain, I think 🤔 Maybe @ilan-gold can chime in if it's possible?

gomezzz avatar Sep 28 '23 18:09 gomezzz

Hi @mawright - to clarify, what I did is make it so that you could implement this by tweaking a few things in the API. There's no feature at the moment for it. You would have to override a few functions to handle however you want to handle the new domain.

ilan-gold avatar Sep 28 '23 18:09 ilan-gold

I can perhaps write something up explaining which methods to override - how does that sound @gomezzz ? Perhaps an example if it's not too crazy?

ilan-gold avatar Sep 28 '23 18:09 ilan-gold

I can perhaps write something up explaining which methods to override - how does that sound @gomezzz ? Perhaps an example if it's not too crazy?

That would be fantastic! :)

gomezzz avatar Sep 28 '23 18:09 gomezzz

Thanks! Looking forward to it!

mawright avatar Sep 28 '23 18:09 mawright

I wrote something that works for my problem. It's here: https://github.com/mawright/torchstable/blob/main/torchstable/integrator.py.

mawright avatar Oct 11 '23 19:10 mawright

@mawright I am sorry for not doing this yet. I'm finishing my thesis at the moment so have been a bit busy. You got it right, though, it seems. My code looks quite similar

ilan-gold avatar Oct 12 '23 12:10 ilan-gold

No problem. One thing I was thinking is that it might be easier to work with batch integration if there was an additional batch dimension. The hacked-together thing I wrote breaks a lot of the code's assumptions as to the meaning of the tensor dimensions, e.g. that the polynomial roots and the number of rows of integration_domain have the same dimension, the splitting up of the N gridpoints over a multidimensional space, etc. Not sure how much work that would be for you though.

mawright avatar Oct 13 '23 19:10 mawright

No problem. One thing I was thinking is that it might be easier to work with batch integration if there was an additional batch dimension. The hacked-together thing I wrote breaks a lot of the code's assumptions as to the meaning of the tensor dimensions, e.g. that the polynomial roots and the number of rows of integration_domain have the same dimension, the splitting up of the N gridpoints over a multidimensional space, etc. Not sure how much work that would be for you though.

Alternatively, to make the feature more accessible, maybe as a start you could add your example and a few explanatory words in the docs? This might already help as this feature interests many, I think? :)

gomezzz avatar Oct 18 '23 07:10 gomezzz