Constraints.jl: Streamlining Constraint Definition and Integration in Julia
Constraints on Graphs
Constraints.xcsp_circuit Function
julia
xcsp_circuit(; list, size)
Return true
if the circuit constraint is satisfied, false
otherwise. The circuit constraint is a global constraint ensuring that the values of x
form a circuit, i.e., a sequence where each value is the index of the next value in the sequence, and the sequence eventually loops back to the start.
Arguments
list::AbstractVector
: list of values to check.size::Int
: size of the circuit.
Variants
:circuit
: Global constraint ensuring that the values ofx
form a circuit, i.e., a sequence where each value is the index of the next value in the sequence, and the sequence eventually loops back to the start. Often used for routing problems.
julia
concept(:circuit, x; op, val)
concept(:circuit)(x; op, val)
Examples
julia
c = concept(:circuit)
c([1, 2, 3, 4])
c([2, 3, 4, 1])
c([2, 3, 1, 4]; op = ==, val = 3)
c([4, 3, 1, 3]; op = >, val = 0)