Skip to content

Refactor overapproximate: two-stage dispatch #2588

@schillic

Description

@schillic

I suggest to let overapproximate only dispatch on the second argument (the target type). In each method we can call helper methods that then dispatch on the first argument. This unifies the interface and avoids many disambiguation methods.

function overapproximate(X::LazySet, ::Type{<:Interval})
    return overapproximate_interval(X)
end

function overapproximate(X::LazySet{N}, ::Type{<:HPolygon}) where {N<:Real}
    return overapproximate_hpolygon(X, N(1e-3))
end

function overapproximate(X::LazySet{N}, ::Type{<:HPolygon}, ε::Real) where {N<:Real}
    return overapproximate_hpolygon(X, ε)
end

...

function overapproximate_interval(X::LazySet)
    ... # default implementation with two support-function queries
end

function overapproximate_interval(X::S)
    ... # specific implementation for set type S
end

...

function overapproximate_hpolygon(X::LazySet{N}, ε::N) where {N<:Real}
    ... # epsilon-close approximation
end

...

Originally posted by @schillic in #1353 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions