diff --git a/src/CP/constraints/sumlessthan.jl b/src/CP/constraints/sumlessthan.jl index 0d14755e1..29b3624e7 100644 --- a/src/CP/constraints/sumlessthan.jl +++ b/src/CP/constraints/sumlessthan.jl @@ -10,7 +10,7 @@ struct SumLessThan <: Constraint numberOfFreeVars ::StateObject{Int} sumOfFixedVars ::StateObject{Int} freeIds ::Array{Int} - function SumLessThan(x::Array{<:AbstractIntVar}, upper::Int, trailer) + function SumLessThan(x::Array{<:AbstractIntVar}, upper::Int, trailer) @assert !isempty(x) freeIds = zeros(length(x)) diff --git a/src/CP/variables/IntDomain.jl b/src/CP/variables/IntDomain.jl index 668ab01a2..43d029f8d 100644 --- a/src/CP/variables/IntDomain.jl +++ b/src/CP/variables/IntDomain.jl @@ -170,6 +170,26 @@ function removeBelow!(dom::IntDomain, value::Int) return pruned end +""" + removeBetween!(dom::IntDomain, min::Int, max::Int) + +Remove every integer of `dom` that is *strictly* between `min` and `max`. Return the pruned values. +""" +function removeBetween!(dom::IntDomain, min::Int, max::Int) + if dom.max.value < max && dom.min.value > min + return removeAll!(dom) + end + + pruned = Int[] + for i in min+1:(max-1) + if i in dom + remove!(dom, i) + push!(pruned, i) + end + end + return pruned +end + """ assign!(dom::IntDomain, value::Int)