-
Notifications
You must be signed in to change notification settings - Fork 71
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
Should intersect_interval
(or hull
) return always trv
decoration?
#624
Comments
If I recall correctly, @Kolaru also complained about this default But if we change it, how do we preserve compliance with the standard? In particular, with the ITF1788 test suite? Cf. https://github.com/JuliaIntervals/IntervalArithmetic.jl/blob/7c46049a7455305991647115328942f0d2331239/test/ITF1788_tests/libieeep1788_set.jl#L15C1-L27C4 The setdecoration(x::Interval, d::Decoration) = _unsafe_interval(bareinterval(x), d, isguaranteed(x)) |
Well yes this As I understand it, it means that this interval does not result from the the interval extension of a well behaved function. Which is fair in that case. I think we could have the more sensible behavior as |
The |
I fully agree with @Kolaru. My proposal is having an internal helper funcion at least, say function _intersect_bareinterval_nontrv(bx::BareInterval, by::BareInterval)
bx = intersect_interval(bx, by)
d = min(decoration(bx), decoration(by))
d = min(d, felse(isinterior(bx, by), d, trv))
return bx, d
end This could allow us to avoid some code which is repeated (changing perhaps the domain) and use it elsewhere without trivializing the results of |
One could also return |
I think the following is more useful function _intersect_bareinterval_nontrv(bx::BareInterval, by::BareInterval)
bx = intersect_interval(bx, by)
d = decoration(bx)
d = min(d, felse(isinterior(bx, by), d, trv))
return _unsafe_interval(bx, d, isguaranteed(bx))
end |
Do you mean function _intersect_bareinterval_nontrv(x::Interval, domain::BareInterval)
bx = bareinterval(x)
r = intersect_interval(bx, domain)
# decoration should not inherit the domain decoration (could be [0, Inf))
# if `!issubset(bx, domain)`, then `r` is empty and `decoration(r) == trv`
d = min(decoration(x), decoration(r))
return _unsafe_interval(r, d, isguaranteed(x))
end ? I do not think we will be able to refactor code substantially with such an internal function (intersection with the domain and the determination of the decoration is decoupled to avoid intersecting twice). EDIT: in fact there is an other issue with
While I am not entirely opposed to this proposal, I find it a bit confusing to have two intersect functions. |
I'd like to open the title of this issue for discussion.
The current implementation, as stated in the docstrings, and following the standard (sect 11.7.1), returns
trv
as the decoration. (I haven't found the motivation why this is so.) Yet, there are certain cases which I think thetrv
decoration could be "higher" in the decoration order. The following are examples for which I find "trv" too restrictive.Actually, the standard (sect 11.5.2) mentions the function "setDec(x, d)" which returns the interval "x" decorated with the decoration "d". Quoting the end of that subsection: "NOTE—Careless use of the setDec function can negate the aims of the decoration system and lead to false conclusions that violate the FTDIA. It is provided for expert users, who might need it, e.g., to decorate the output of functions whose definition involves the intersection and convexHull operations." While we don't have
setdec
(and I am not proposing to have it!), I propose we should have in our implementation ofintersect_interval
andhull
a mechanism which resembles the implementation of some function, e.g.log
(orsqrt
). These functions apriori require a check if the intervalx
is inside the actual domain of this functions. Cleverly, this is not done through a naiveintersect_interval
evaluation (which otherwise would lower the decoration totrv
), but by evaluating if the bareinterval is inside the domain: it it is not, the the decoration istrv
(if it is, the decoration is evaluated as themin
from the decoration of the original interval and the resulting interval).... truly, very nice!So, what about having that same check in
intersect_interval
andhull
?The text was updated successfully, but these errors were encountered: