Skip to content
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

Typo in sets #1024

Merged
merged 7 commits into from
Feb 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 119 additions & 1 deletion src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,123 @@ end

dimension(set::Complements) = 2 * set.dimension

"""
AllDifferent(dimension::Int)

The set corresponding to an all-different constraint.

All expressions of a vector-valued function are enforced to take distinct
values in the solution: for all pairs of expressions, their values must
differ. This constraint is only defined for integer-valued expressions.
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved

This constraint is sometimes called `distinct`.
"""
struct AllDifferent <: AbstractVectorSet
dimension::Int
end

"""
Domain{T <: Int}(values::Set{T})

The set corresponding to an enumeration of constant values.

The value of a scalar function is enforced to take a value from this set of
values.

This constraint is sometimes called `in`.
"""
struct Domain{T <: Int} <: AbstractScalarSet
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved
values::Set{T}
end

function Base.copy(set::Domain{T <: Int})
return Domain(copy(set.values))
end

"""
Membership(values::Set{AbstractScalarFunction})

The set corresponding to an enumeration of values, given by expressions.

The value of a scalar function is enforced to take a value from this set of
values. These values are given by expressions potentially depending on other
variables for the problem.

This constraint is sometimes called `in_set`.
"""
struct Membership <: AbstractScalarSet
values::Set{AbstractScalarFunction}
end
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved

function Base.copy(set::Membership)
return Domain(copy(set.values))
end

"""
DifferentFrom(value::AbstractScalarFunction)

The set excluding the single point ``x \\in \\mathbb{R}`` where ``x`` is given by `value`.
All other values in the domain of ``x`` are allowed. `value` is a generic scalar function.
"""
struct DifferentFrom <: AbstractScalarSet
value::AbstractScalarFunction
end
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved

function Base.copy(set::DifferentFrom)
return DifferentFrom(copy(set.value))
end

"""
Count{T <: Real}(values::Set{AbstractScalarFunction}, value::T)

The set including the single point ``x \\in \\mathbb{N}`` where ``x`` is the number of `values`
equal to `value`: ``|\\{x \\in values | x = value \\}|``.
"""
struct Count{T <: Real} <: AbstractScalarSet
values::Set{AbstractScalarFunction}
value::T
end

function Base.copy(set::Count)
return Count(copy(set.value), value)
end

"""
StrictlyGreaterThan{T <: Real}(lower::T)

The set ``(lower,\\infty) \\subseteq \\mathbb{R}``. It is mostly useful if `lower` is an integer.
"""
struct StrictlyGreaterThan{T <: Real} <: AbstractScalarSet
lower::T
end
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved

"""
StrictlyLessThan{T <: Real}(upper::T)

The set ``(-\\infty,upper) \\subseteq \\mathbb{R}``. It is mostly useful if `upper` is an integer.
"""
struct StrictlyLessThan{T <: Real} <: AbstractScalarSet
upper::T
end

"""
ReificationSet{S <: AbstractScalarSet}(set::S)

``\\{y \\in \\{0, 1\\} | y = 1 \\iff x \\in set, y = 0 otherwise\\}``.

`S` has to be a sub-type of `AbstractScalarSet`.

This set serves to find out whether a given constraint is satisfied. The only possible values are
0 and 1.
"""
struct ReificationSet{S <: AbstractScalarSet} <: AbstractScalarSet
set::S
end

function Base.copy(set::ReificationSet{S <: AbstractScalarSet}{S}) where S
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved
return ReificationSet(copy(set.set))
end

# isbits types, nothing to copy
function Base.copy(
set::Union{
Expand All @@ -818,7 +935,8 @@ function Base.copy(
PositiveSemidefiniteConeTriangle, PositiveSemidefiniteConeSquare,
LogDetConeTriangle, LogDetConeSquare, RootDetConeTriangle,
RootDetConeSquare, Complements, Integer, ZeroOne, Semicontinuous,
Semiinteger
Semiinteger, AllDifferent, DifferentFrom, StrictlyGreaterThan,
StrictlyLessThan
}
)
return set
Expand Down