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.ExploreSettingsMethod
ExploreSettings(
    domains;
    complete_search_limit = 10^6,
    max_samplings = sum(domain_size, domains),
    search = :flexible,
    solutions_limit = floor(Int, sqrt(max_samplings)),
)

Settings for the exploration of a search space composed by a collection of domains.

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
ConstraintDomains.RangeDomainType
RangeDomain

A discrete domain defined by a range <: AbstractRange{Real}. As ranges are immutable in Julia, changes in RangeDomain must use set_domain!.

source
Base.convertMethod
Base.convert(::Type{Union{Intervals, RangeDomain}}, d::Union{Intervals, RangeDomain})

Extends Base.convert for domains.

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.length(itv::Intervals)

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

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.randMethod
Base.rand(d::Union{Vector{D},Set{D}, D}) where {D<:AbstractDomain}

Extends Base.rand to (a collection of) domains.

source
Base.randMethod
Base.rand(fa::FakeAutomaton)

Extends Base.rand. Currently simply returns fa.

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
Base.randMethod
Base.rand(d::D) where D <: DiscreteDomain

Draw randomly a point in d.

source
Base.stringMethod
Base.string(D::Vector{<:AbstractDomain})
Base.string(d<:AbstractDomain)

Extends the string method to (a vector of) domains.

source
ConstraintDomains._exploreMethod
_explore(args...)

Internals of the explore function. Behavior is automatically adjusted on the kind of exploration: :flexible, :complete, :partial.

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)
d5 = domain(1,42,86.9)
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).

source
ConstraintDomains.exploreMethod
explore(domains, concept, param = nothing; search_limit = 1000, solutions_limit = 100)

Search (a part of) a search space and returns a pair of vector of configurations: (solutions, non_solutions). If the search space size is over search_limit, then both solutions and non_solutions are limited to solutions_limit.

Beware that if the density of the solutions in the search space is low, solutions_limit needs to be reduced. This process will be automatic in the future (simple reinforcement learning).

Arguments:

  • domains: a collection of domains
  • concept: the concept of the targeted constraint
  • param: an optional parameter of the constraint
  • sol_number: the required number of solutions (half of the number of configurations), default to 100
source
ConstraintDomains.intersect_domains!Method
intersect_domains!(is, i, new_itvls)

Compute the intersections of a domain with an interval and store the results in new_itvls.

Arguments

  • is::IS: a collection of intervals.
  • i::I: an interval.
  • new_itvls::Vector{I}: a vector to store the results.
source