Skip to content

Support for non-static dimensionality? #53

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

Closed
oschulz opened this issue Feb 4, 2020 · 8 comments
Closed

Support for non-static dimensionality? #53

oschulz opened this issue Feb 4, 2020 · 8 comments

Comments

@oschulz
Copy link

oschulz commented Feb 4, 2020

For higher-dimensional problems it would be great to have support for non-static dimensionality and argument types like Vector in addition to SVector. E.g. a ProductDomain based on AbstractVector{IntervalSet} should allow for in(x::AbstractVector, d::ProductDomain). N-dimensional hyper-spheres with N not fixed at compile time would also come on very handy.

@daanhb
Copy link
Member

daanhb commented Feb 4, 2020

That sounds doable. Currently the spheres are hardcoded to be EuclideanDomain, but ProductDomain already mostly works more generically. If you comment out the two checks in the inner constructor here, then you get this behaviour:

julia> using DomainSets

julia> b = 0..1.0
0.0..1.0

julia> domains = [b for i in 1:10]
10-element Array{Interval{:closed,:closed,Float64},1}:
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0
 0.0..1.0

julia> p = DomainSets.ProductDomain{typeof(domains),Vector{Float64},Vector{Float64}}(domains)
0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0 x 0.0..1.0

julia> rand(10)  p
true

julia> 2*rand(10)  p
false

(The final test will succeed with some probability.)
I've invoked the constructor explicitly here. It would be a matter of modifying the computation of the element types, plus finding a nicer way of invoking the constructor. Perhaps when invoked with an array of domains, a ProductDomain could use array's as type. When invoked with an argument list of domains, it could be a tuple.

It is similar with the spheres: there could be an AbstractHyperSphere{T} <: Domain{T} and an AbstractEuclideanHyperSphere{N,T} <: AbstractHyperSphere{SVector{N,T}}. And some syntax for constructing them. Care to look at it?

@oschulz
Copy link
Author

oschulz commented Feb 4, 2020

Maybe, yes. I have something similar in BAT.jl, for boundaries for likelihoods and priors and I was looking for a solution that's more generic. DomainSets may be a great fit.

@daanhb
Copy link
Member

daanhb commented Feb 5, 2020

Cool, I hope using DomainSets works out. You suggested an interesting generalization that fits well in the package, because the whole aim is to be general and avoid repetition in other packages. I will try to get to this particular issue soon, and update here.

@oschulz
Copy link
Author

oschulz commented Feb 5, 2020

Great, thanks! I think this could be a valuable building block for statistics/fitting/optimization/etc. applications, to avoid redundant functionality across packages.

@daanhb
Copy link
Member

daanhb commented Feb 11, 2020

Working on it in #55. It motivated working on some other issues as well, and #55 will perhaps take some time and additional effort before we can merge it I'm afraid.

@oschulz
Copy link
Author

oschulz commented Feb 11, 2020

Thanks, @daanhb! I'l try to pitch in at some point, I'll try to get a clearer idea on requirements - and how to represent them more cleanly than I do at the moment - first, for such applications (statistics/fitting/optimization/...).

@daanhb
Copy link
Member

daanhb commented Apr 21, 2020

The changes have been merged into version 0.3. The README is updated with a few examples of basic usage. Issues are to be expected - please report! :-)

@daanhb daanhb closed this as completed Apr 21, 2020
@oschulz
Copy link
Author

oschulz commented Apr 21, 2020

Thanks a lot - will do!

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

No branches or pull requests

2 participants