-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor to allow containers to be directly used as spaces #9
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9 +/- ##
===========================================
+ Coverage 58.13% 86.90% +28.76%
===========================================
Files 1 3 +2
Lines 43 84 +41
===========================================
+ Hits 25 73 +48
+ Misses 18 11 -7
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
README.md
Outdated
Continuous spaces represent sets that have an uncountable number of elements they have a `SpaceStyle` of type `ContinuousSpaceStyle`. CommonRLSpaces does not adopt a rigorous mathematical definition of a continuous set, but, roughly, elements in the interior of a continuous space have other elements arbitrarily close to them. | ||
Continuous spaces have two additional interface functions: | ||
- `bounds(space)` returns upper and lower bounds in a tuple. For example, if `space` is a unit circle, `bounds(space)` will return `([-1.0, -1.0], [1.0, 1.0])`. This allows agents to choose policies that appropriately cover the space e.g. a normal distribution with a mean of `mean(bounds(space))` and a standard deviation of half the distance between the bounds. | ||
- [I have a few other ideas, but we can discuss later] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another more common function is clamp
|
||
julia> size(s) | ||
julia> elsize(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may also have eltype
implemented
README.md
Outdated
|
||
### Hybrid spaces | ||
|
||
[need to figure this out] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Hybrid Spaces, I think we can still use product(s1, s2)
to create a hybrid space.
To help access each sub space easily, s1
and s2
may be named spaces and the hybrid space need to support getindex
.
Ok, I have now added
|
Looking at the definition. The I mean it's more or less the same with the result of
Such information are usually environment specific. Some may want a tuple instead of array. Or others do not care about the preallocation feature. This makes me wonder that, maybe we can just define some traits to recognize some common elemental spaces. We don't need to care too much about the container type (the result type of In some extreme cases, we can still add a dedicated implementation like With the traits defiend above, I think this issue can be addressed JuliaMath/IntervalSets.jl#66 Note that we may need our customized definition of rand(x) = rand(rng, x)
rand(rng, x) = rand(rng, SpaceStyle(x), x)
rand(rng, ::DiscreteSpace, x) = Random.rand(rng, x)
rand(rng, ::ContinuousSpace, x) = ...
rand(rng, ::Any, xs) = map(x -> rand(rng, x), xs) This means |
@findmyway , thanks for the comments! This was very helpful in my thinking about Do you agree with this statement that I just added to the README:
That is my guiding principle for implementing
By the way, I was thinking that "hybrid" in |
Yes, I agree. And thanks for the explanation of |
Ok, I think this is almost ready to merge, except for a few docstrings and updating the readme. I should be able to add those tomorrow or so. I am very satisfied with how these basics turned out, so I hope everyone agrees that it is a good starting point. It is currently missing any interface for hybrid continuous-discrete spaces, but we can add that in another chunk. There are also some other issues that I will file later (the two broken tests have raised some questions). |
OK, I think this is ready to merge. @findmyway feel free to merge, or I will do it tomorrow if no one objects. I'll add issues tomorrow outlining the things that aren't done yet. |
@findmyway Here is my start to a PR related to #8 . I haven't started implementing anything yet, just wrote down my ideas in the README. Let me know what you think.
@mossr, @mykelk, @jamgochiana, feel free to chime in if you have any comments.