torchquad
torchquad copied to clipboard
Example/documentation for parametric domain of integration?
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!
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?
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.
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?
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! :)
Thanks! Looking forward to it!
I wrote something that works for my problem. It's here: https://github.com/mawright/torchstable/blob/main/torchstable/integrator.py.
@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
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.
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 theN
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? :)