JuMP Optimization Help

like minimizing the largest absolute distance between two jars.

I’m attempting to do this and cannot figure it out :confounded::

# number of new marbles
N = 9
# numer of marbles currently in each of the 3 jars in group 1
m₁ = [5,3,2]
# numer of marbles currently in each of the 3 jars in group 2
m₂ = [5,10,12]

# concatenate m₁ and m₂
m = hcat(m₁, m₂)

model = Model(GLPK.Optimizer)

# a matrix instead of two different variables
@variable(model, x[1:3, 1:2], Int)

fmax(y) = maximum(y)
fmin(y) = minimum(y)

register(model, :fmax, 1, fmax, autodiff=true)
register(model, :fmin, 1, fmin, autodiff=true)

# the objective is to minimize the spread between the max and min
julia> @objective(model, Min, fmax(m + x) - fmin(m + x))
ERROR: MethodError: no method matching isless(::GenericAffExpr{Float64,VariableRef}, ::GenericAffExpr{Float64,VariableRef})
Closest candidates are:
  isless(::Missing, ::Any) at missing.jl:87
  isless(::Any, ::Missing) at missing.jl:88