Julia standard library for interval type

Ah I see, this would indeed require a slightly new function which does not forget the endpoint intervals.

1 Like

Exactly! :slight_smile: IntervalOptimisation.minimise does already much more than solving this problem would require, but there is an interface-level issue that makes it unsolvable, and the issue arises precisely from using a..b instead of (a, b) to specify a domain.

Iā€™m not saying this to point out a flaw (IntervalOptimisation does what it promises, and I find it a great piece of work), but I am using it as an example in this discussion about different ways to use intervals and building a unified interface.


Yes, intervals are generally useful concepts, but that does not mean that a single one generalizes well in Julia. They come in many forms, and what one would encode in the type (for type stable dispatch) matters on the application.

Eg for a plotting library, a pair of finite numbers suffices. But for a constrained optimization package, which end is open/closed can matter. For a package that maps intervals to some other interval, whether the interval is finite is important.

For these reasons, there are lot of implementations, and I am not sure a single one will emerge as the best solution.

Also, I would only wrap things in a struct if I want to treat it as a single unit (eg for the purposes of arithmetic or transformations). Specifically for plotting, this is not a common use case, and frequently you even want to specify just the lower- or upper limit and leave the other one to be determined by the data.