ConstraintDomains

ConstraintDomains.AbstractDomainType
AbstractDomain

An abstract super type for any domain type. A domain type D <: AbstractDomain must implement the following methods to properly interface AbstractDomain.

  • Base.∈(val, ::D)
  • Base.rand(::D)
  • Base.length(::D) that is the number of elements in a discrete domain, and the distance between bounds or similar for a continuous domain

Addtionally, if the domain is used in a dynamic context, it can extend

  • add!(::D, args)
  • delete!(::D, args)

where args depends on D's structure

source
ConstraintDomains.IntervalsType
Intervals{T <: Real} <: ContinuousDomain{T}

An encapsuler to store a vector of PatternFolds.Interval. Dynamic changes to Intervals are not handled yet.

source
Base.delete!Method
Base.delete!(d::SetDomain, value)(d::SetDomain, value)

Delete value from the list of points in d.

source
Base.inMethod
Base.in(x, itv::Intervals)

Return true if x ∈ I for any 'I ∈ itv, false otherwise.x ∈ I` is equivalent to

  • a < x < b if I = (a, b)
  • a < x ≤ b if I = (a, b]
  • a ≤ x < b if I = [a, b)
  • a ≤ x ≤ b if I = [a, b]
source
Base.inMethod
Base.in(value, d <: AbstractDomain)

Fallback method for value ∈ d that returns false.

source
Base.inMethod
Base.in(value, d::D) where D <: DiscreteDomain

Return true if value is a point of d.

source
Base.isemptyMethod
Base.isempty(d <: AbstractDomain)

Fallback method for isempty(d) that return length(d) == 0 which default to 0.

source
Base.lengthMethod
Base.rand(d <: AbstractDomain)

Fallback method for length(d) that return 0.

source
Base.lengthMethod
Base.length(d::D) where D <: DiscreteDomain

Return the number of points in d.

source
Base.lengthMethod
Base.length(itv::Intervals)

Return the sum of the length of each interval in itv.

source
Base.randMethod
Base.rand(d::D) where D <: DiscreteDomain

Draw randomly a point in d.

source
Base.randMethod
Base.rand(itv::Intervals)
Base.rand(itv::Intervals, i)

Return a random value from itv, specifically from the ith interval if i is specified.

source
ConstraintDomains.domainMethod
domain(values)
domain(range::R) where {T <: Real, R <: AbstractRange{T}}

Construct either a SetDomain or a RangeDomain.

d1 = domain(1:5)
d2 = domain([53.69, 89.2, 0.12])
d3 = domain([2//3, 89//123])
d4 = domain(4.3)
source
ConstraintDomains.domainMethod
domain(a::Tuple{T, Bool}, b::Tuple{T, Bool}) where {T <: Real}
domain(intervals::Vector{Tuple{Tuple{T, Bool},Tuple{T, Bool}}}) where {T <: Real}

Construct a domain of continuous interval(s). ```julia d1 = domain((0., true), (1., false)) # d1 = [0, 1) d2 = domain([ # d2 = 0, 1) ∪ (3.5, 42, (1., false), (3.5, false), (42., true), ])

source