diff --git a/docs/src/3-mixed-integer-optimization.jl b/docs/src/3-mixed-integer-optimization.jl index e51d569..b29d909 100644 --- a/docs/src/3-mixed-integer-optimization.jl +++ b/docs/src/3-mixed-integer-optimization.jl @@ -31,8 +31,7 @@ IntegerFromTo(1, 6) # ...and include this bound in constraints and variables: -dice_system = - C.variables(keys = [:first_dice, :second_dice], bounds = [IntegerFromTo(1, 6)]) +dice_system = C.variables(keys = [:first_dice, :second_dice], bounds = IntegerFromTo(1, 6)) # Now the main thing that is left is to be able to translate this bound to JuMP # for solving. We can slightly generalize our constraint-translation system @@ -103,7 +102,7 @@ dices_thrown = C.constraint_values( # Let's find the size of the smallest right-angled triangle with integer side # sizes (aka a Pythagorean triple). -vars = C.variables(keys = [:a, :b, :c], bounds = (IntegerFromTo(1, 100),)) +vars = C.variables(keys = [:a, :b, :c], bounds = IntegerFromTo(1, 100)) # For simpliclty, we make a shortcut for "values" in all variables: v = C.tree_map(vars, C.value, C.Value) diff --git a/src/constraint_tree.jl b/src/constraint_tree.jl index f2c627a..ff6d27d 100644 --- a/src/constraint_tree.jl +++ b/src/constraint_tree.jl @@ -194,7 +194,7 @@ maximum))`, which has the correct length. function variables(; keys::AbstractVector{Symbol}, bounds = nothing) bs = isnothing(bounds) ? Base.Iterators.cycle(tuple(nothing)) : - length(bounds) == 1 ? Base.Iterators.cycle(bounds) : + typeof(bounds) <: Bound ? Base.Iterators.cycle(tuple(bounds)) : length(bounds) == length(keys) ? bounds : error("lengths of bounds and keys differ for allocated variables") ConstraintTree(